Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7152043
Add SchematicLib dependency and add necessary classes
Intybyte Sep 21, 2025
21fc440
Small changes to SimpleBlock
Intybyte Sep 21, 2025
8fef6ce
Use new library
Intybyte Sep 22, 2025
48e8e39
This can be static public
Intybyte Sep 22, 2025
99a311a
Fixes
Intybyte Sep 22, 2025
5ba8591
New commands
Intybyte Sep 22, 2025
e0a0f9e
Use new max and min
Intybyte Sep 22, 2025
7d4253a
Turn SchematicWorldProcessorImpl into a singleton
Intybyte Sep 22, 2025
75c1ad6
Use new schematic system to create & check cannons
Intybyte Sep 22, 2025
7ba8440
More detailed name
Intybyte Sep 22, 2025
0f1d260
Get the block properly
Intybyte Sep 22, 2025
0ee49f2
Add method to register namespaces
Intybyte Sep 22, 2025
7584192
Update SchematicLib and add destroy to MinecraftNamespaceHandler
Intybyte Sep 22, 2025
f3cd61e
Add breakNaturally
Intybyte Sep 23, 2025
2b2af73
Use Schematic when needed
Intybyte Sep 23, 2025
f1ca317
Nuke allCannonBlocks for schematic support, the systems are now separate
Intybyte Sep 23, 2025
5441a78
Add slimefun support
Intybyte Sep 23, 2025
a004ba9
Add syntax helper for save too
Intybyte Sep 23, 2025
b6b5660
No need to load twice
Intybyte Sep 23, 2025
d4bf735
Add consistency check
Intybyte Sep 23, 2025
1bb1cad
Add utility stuff and use them
Intybyte Sep 23, 2025
4ec937f
Add ItemsAdder support
Intybyte Sep 23, 2025
8eaeb7c
Read BlockKeys instead of blockdata
Intybyte Sep 24, 2025
185d90b
Optimizations and logDebug schematic process time
Intybyte Sep 24, 2025
8ac6684
Add chat output
Intybyte Sep 24, 2025
42cf0ab
Optimizations
Intybyte Sep 24, 2025
5becf1a
Update and use new optimization
Intybyte Sep 24, 2025
24f31f2
Optimize explosion handling and BlockImpl
Intybyte Sep 25, 2025
d51c821
Optimize explosion handling
Intybyte Sep 25, 2025
244593f
Update SchematicLib version
Intybyte Sep 25, 2025
532755b
Add wand for easier schematic creation
Intybyte Sep 25, 2025
ebc0b96
Custom name for new wand
Intybyte Sep 25, 2025
9073867
Add command completions
Intybyte Sep 25, 2025
872f84a
Update FEATURES.md
Intybyte Sep 25, 2025
9786d16
Fix double select with tool
Intybyte Sep 25, 2025
bfbc769
Move dependency
Intybyte Sep 28, 2025
4de083e
Optimize getLocation/getFirstCannonBlock
Intybyte Sep 29, 2025
bd6ead8
Fix creating cannon on the fly on crafts
Intybyte Sep 30, 2025
723d99c
Optimize getBlock
Intybyte Oct 1, 2025
128f8d9
Optimize getting cannon from locations
Intybyte Oct 2, 2025
6a955b1
Get cannons on Detect and update them until release
Intybyte Oct 2, 2025
ba8f5d9
Add nexo support
Intybyte Oct 26, 2025
f062fcf
One block furnitures work too
Intybyte Oct 27, 2025
7fab949
Faster schematic implementations
Intybyte Oct 30, 2025
a6bd981
Fix and move dependencies
Intybyte Oct 30, 2025
18d11ab
Fix NexoNamespaceHandler
Intybyte Oct 30, 2025
4afaf72
I am not gonna support custom movements, but well... I added it to th…
Intybyte Nov 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ New features
- New area commands
- Mohist compatibility (kind of, you need to use particle aiming)
- Folia support
- Custom projectile definitions (Custom gravity, drag, water drag, constant acceleration, Custom model data and more)
- Custom blocks support (Slimefun & ItemsAdder so far, requires custom format)
- Command completions

Fixes:
---------------
Expand Down Expand Up @@ -41,6 +44,9 @@ FireTask API:
Exchange API:
- You can define your own exchanges for cannons creation requirement, example at [CannonsEXP](https://github.com/Intybyte/CannonsEXP)

Schematic Processing API:
- You can define your own custom blocks to add by defining a namespace and adding it to SchematicWorldProcessorImpl

Projectiles:
- Projectile type events now give the FlyingProjectile
- ProjectilePiercingEvent is now cancellable
Expand Down
12 changes: 12 additions & 0 deletions api-internal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.github.Intybyte</groupId>
<artifactId>SchematicLib</artifactId>
<version>f420e46a34</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
50 changes: 49 additions & 1 deletion cannons-bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>matteodev</id>
<url>https://maven.devs.beer/</url>
</repository>
<repository>
<id>nexo</id>
<url>https://repo.nexomc.com/releases</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -149,6 +157,38 @@
<scope>provided</scope>
</dependency>

<!-- Schematic handling -->
<dependency>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-37</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.lone</groupId>
<artifactId>api-itemsadder</artifactId>
<version>4.0.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.nexomc</groupId>
<artifactId>nexo</artifactId>
<version>1.12.1-dev</version>
<scope>provided</scope>
<exclusions>
<!-- can't find these so you are getting excluded, stay in a corner -->
<exclusion>
<groupId>dev.triumphteam</groupId>
<artifactId>triumph-gui</artifactId>
</exclusion>
<exclusion>
<groupId>net.byteflux</groupId>
<artifactId>libby-bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>


<!-- Testing dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -189,7 +229,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.14.1</version>
<configuration>
<source>${java.source}</source>
<target>${java.target}</target>
Expand Down Expand Up @@ -241,6 +281,14 @@
<pattern>io.papermc.lib</pattern>
<shadedPattern>at.pavlov.cannons.shaded.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>me.vaan</pattern>
<shadedPattern>at.pavlov.cannons.shaded.vaan</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>at.pavlov.cannons.shaded.google</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void onEnable() {
ProjectileManager.initialize(this);
CannonSelector.initialize(this);

DesignStorage.getInstance().loadCannonDesigns();
//DesignStorage.getInstance().loadCannonDesigns();
ProjectileStorage.getInstance().loadProjectiles();
CannonManager.getInstance().updateCannons();
UserMessages.getInstance().loadLanguage();
Expand Down
121 changes: 80 additions & 41 deletions cannons-bukkit/src/main/java/at/pavlov/cannons/cannon/Cannon.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@
import at.pavlov.cannons.interfaces.functionalities.Rotational;
import at.pavlov.cannons.projectile.Projectile;
import at.pavlov.cannons.projectile.ProjectileStorage;
import at.pavlov.cannons.schematic.world.SchematicWorldProcessorImpl;
import at.pavlov.cannons.utils.CannonsUtil;
import at.pavlov.cannons.utils.InventoryManagement;
import at.pavlov.cannons.utils.SoundUtils;
import at.pavlov.internal.Key;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.Setter;
import me.vaan.schematiclib.base.block.BlockKey;
import me.vaan.schematiclib.base.block.IBlock;
import me.vaan.schematiclib.base.schematic.OffsetSchematic;
import me.vaan.schematiclib.base.schematic.OffsetSchematicImpl;
import me.vaan.schematiclib.base.schematic.Schematic;
import me.vaan.schematiclib.file.block.FileBlock;
import me.vaan.schematiclib.file.block.FileCoord;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Effect;
Expand All @@ -45,7 +53,6 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Attachable;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -85,11 +92,12 @@ public class Cannon implements ICannon, Rotational {
//TODO make a vector util class and add this there
private final static Vector noVelocity = new Vector(0,0,0);


public Cannon(CannonDesign design, UUID world, Vector cannonOffset, BlockFace cannonDirection, UUID owner) {

this.design = design;
this.cannonPosition = new CannonPosition(cannonDirection, cannonOffset, world, false, noVelocity.clone());

Schematic schematic = design.getSchematicMap().get(cannonPosition.getCannonDirection());
boolean noFee = design.getEconomyBuildingCost() instanceof EmptyExchanger;
this.mainData = new CannonMainData( UUID.randomUUID(),null, noFee, owner, true);

Expand Down Expand Up @@ -130,7 +138,7 @@ public Cannon(CannonDesign design, UUID world, Vector cannonOffset, BlockFace ca
* @return location of the cannon
*/
public Location getLocation() {
return design.getAllCannonBlocks(this).get(0);
return getFirstCannonBlock();
}

/**
Expand All @@ -151,8 +159,10 @@ public Location getRandomBarrelBlock() {
List<Location> barrel = design.getBarrelBlocks(this);
if (!barrel.isEmpty())
return barrel.get(random.nextInt(barrel.size()));
List<Location> all = design.getAllCannonBlocks(this);
return all.get(random.nextInt(all.size()));

List<IBlock> positions = getOffsetSchematic().realBlocks().positions();
IBlock position = positions.get(random.nextInt(positions.size()));
return new Location(getWorldBukkit(), position.x(), position.y(), position.z());
}


Expand Down Expand Up @@ -737,50 +747,43 @@ public MessageEnum destroyCannon(boolean breakBlocks, boolean canExplode, BreakC
* this will force the cannon to show up at this location - all blocks will be overwritten
*/
public void show() {
for (SimpleBlock cBlock : design.getAllCannonBlocks(this.getCannonDirection())) {
Block wBlock = cBlock.toLocation(getWorldBukkit(), getOffset()).getBlock();
//todo check show
wBlock.setBlockData(cBlock.getBlockData());
//wBlock.setBlockData(cBlock);
}
SchematicWorldProcessorImpl.getProcessor().place(
getOffsetSchematic(),
cannonPosition.getWorld()
);
}

/**
* this will force the cannon blocks to become AIR
*/
public void hide() {
//remove only attachable block
for (SimpleBlock cBlock : design.getAllCannonBlocks(this.getCannonDirection())) {
Block wBlock = cBlock.toLocation(getWorldBukkit(), getOffset()).getBlock();
//if that block is not loaded

if (wBlock.getState() instanceof Attachable) {
//Cannons.logger().info("hide " + wBlock.getType());
wBlock.setType(Material.AIR);
//wBlock.setData((byte) 0, false);
}
}

//remove all
for (SimpleBlock cBlock : design.getAllCannonBlocks(this.getCannonDirection())) {
Block wBlock = cBlock.toLocation(getWorldBukkit(), getOffset()).getBlock();

if (wBlock.getType() != Material.AIR) {
wBlock.setType(Material.AIR);
// wBlock.setData((byte) 0, false);
}
}
SchematicWorldProcessorImpl.getProcessor().destroy(
getOffsetSchematic(),
cannonPosition.getWorld()
);
}


/**
* breaks all cannon blocks of the cannon
*/
private void breakAllCannonBlocks() {
List<Location> locList = design.getAllCannonBlocks(this);
for (Location loc : locList) {
loc.getBlock().breakNaturally();
}
SchematicWorldProcessorImpl.getProcessor().breakNaturally(
getOffsetSchematic(),
cannonPosition.getWorld()
);
}

public OffsetSchematic getOffsetSchematic() {
Schematic schematic = design.getSchematicMap().get(cannonPosition.getCannonDirection());
Vector off = cannonPosition.getOffset();

return new OffsetSchematicImpl(
off.getBlockX(),
off.getBlockY(),
off.getBlockZ(),
schematic
);
}


Expand All @@ -791,15 +794,45 @@ private void breakAllCannonBlocks() {
* @return - true if it is part of this cannon
*/
public boolean isCannonBlock(Block block) {
if (!getWorld().equals(block.getWorld().getUID())) {
UUID world = cannonPosition.getWorld();
if (!world.equals(block.getWorld().getUID())) {
return false;
}

for (SimpleBlock designBlock : design.getAllCannonBlocks(getCannonDirection())) {
if (designBlock.compareMaterialAndLoc(block, getOffset())) {
SchematicWorldProcessorImpl processor = SchematicWorldProcessorImpl.getProcessor();
OffsetSchematic offsetSchematic = getOffsetSchematic();
IBlock obtain = processor.registry().getBlock(block.getX(), block.getY(), block.getZ(), world);
BlockKey schemBlock = offsetSchematic.blockMap().get(
new FileCoord(
block.getX() - offsetSchematic.x(),
block.getY() - offsetSchematic.y(),
block.getZ() - offsetSchematic.z()
)
);

return obtain.key().equals(schemBlock);
}

public boolean isCannonBlock(IBlock block, UUID blockWorld) {
UUID world = cannonPosition.getWorld();
if (!world.equals(blockWorld)) {
return false;
}

Vector offset = cannonPosition.getOffset();
FileBlock offsetLessBlock = new FileBlock(
block.x() - offset.getBlockX(),
block.y() - offset.getBlockY(),
block.z() - offset.getBlockZ(),
block.key()
);

for (IBlock schemBlock : getOffsetSchematic().positions()) {
if (offsetLessBlock.matches(schemBlock)) {
return true;
}
}

return false;
}

Expand Down Expand Up @@ -976,8 +1009,14 @@ public boolean isSentryAutomatic() {
* @return - first block of the cannon
*/
public Location getFirstCannonBlock() {
return design.getAllCannonBlocks(getCannonDirection()).get(0).toLocation(getWorldBukkit(), getOffset());

Vector vec = cannonPosition.getOffset();
OffsetSchematic schematic = getOffsetSchematic();
IBlock first = schematic.positions().get(0);
return new Location(getWorldBukkit(),
first.x() + vec.getBlockX(),
first.y() + vec.getBlockY(),
first.z() + vec.getBlockZ()
);
}

/**
Expand Down
Loading
Loading