mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Strip some comments
This commit is contained in:
parent
e90ef7aaee
commit
b915ca2add
@ -53,13 +53,11 @@ public class TreeManager implements Listener {
|
|||||||
|
|
||||||
Iris.debug(this.getClass().getName() + " received a structure grow event");
|
Iris.debug(this.getClass().getName() + " received a structure grow event");
|
||||||
|
|
||||||
// Must be iris world
|
|
||||||
if (!IrisToolbelt.isIrisWorld(event.getWorld())) {
|
if (!IrisToolbelt.isIrisWorld(event.getWorld())) {
|
||||||
Iris.debug(this.getClass().getName() + " passed it off to vanilla since not an Iris world");
|
Iris.debug(this.getClass().getName() + " passed it off to vanilla since not an Iris world");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get world access
|
|
||||||
IrisAccess worldAccess = IrisToolbelt.access(event.getWorld());
|
IrisAccess worldAccess = IrisToolbelt.access(event.getWorld());
|
||||||
if (worldAccess == null) {
|
if (worldAccess == null) {
|
||||||
Iris.debug(this.getClass().getName() + " passed it off to vanilla because could not get IrisAccess for this world");
|
Iris.debug(this.getClass().getName() + " passed it off to vanilla because could not get IrisAccess for this world");
|
||||||
@ -67,38 +65,24 @@ public class TreeManager implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return null if not enabled
|
|
||||||
if (!worldAccess.getCompound().getRootDimension().getTreeSettings().isEnabled()) {
|
if (!worldAccess.getCompound().getRootDimension().getTreeSettings().isEnabled()) {
|
||||||
Iris.debug(this.getClass().getName() + " cancelled because tree overrides are disabled");
|
Iris.debug(this.getClass().getName() + " cancelled because tree overrides are disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iris.debug("Sapling grew @ " + event.getLocation() + " for " + event.getSpecies().name() + " usedBoneMeal is " + event.isFromBonemeal());
|
Iris.debug("Sapling grew @ " + event.getLocation() + " for " + event.getSpecies().name() + " usedBoneMeal is " + event.isFromBonemeal());
|
||||||
|
|
||||||
// Calculate size, type & placement
|
|
||||||
// TODO: Patch algorithm to retrieve saplings, as it's not working as intended (only ever returns 1x1)
|
|
||||||
Cuboid saplingPlane = getSaplings(event.getLocation(), blockData -> event.getLocation().getBlock().getBlockData().equals(blockData), event.getWorld());
|
Cuboid saplingPlane = getSaplings(event.getLocation(), blockData -> event.getLocation().getBlock().getBlockData().equals(blockData), event.getWorld());
|
||||||
Iris.debug("Sapling plane is: " + saplingPlane.getSizeX() + " by " + saplingPlane.getSizeZ());
|
Iris.debug("Sapling plane is: " + saplingPlane.getSizeX() + " by " + saplingPlane.getSizeZ());
|
||||||
|
|
||||||
// Find best object placement based on sizes
|
|
||||||
IrisObjectPlacement placement = getObjectPlacement(worldAccess, event.getLocation(), event.getSpecies(), new IrisTreeSize(1, 1));
|
IrisObjectPlacement placement = getObjectPlacement(worldAccess, event.getLocation(), event.getSpecies(), new IrisTreeSize(1, 1));
|
||||||
|
|
||||||
// If none were found, just exit
|
|
||||||
if (placement == null) {
|
if (placement == null) {
|
||||||
Iris.debug(this.getClass().getName() + " had options but did not manage to find objectPlacements for them");
|
Iris.debug(this.getClass().getName() + " had options but did not manage to find objectPlacements for them");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete existing saplings
|
|
||||||
saplingPlane.forEach(block -> block.setType(Material.AIR));
|
saplingPlane.forEach(block -> block.setType(Material.AIR));
|
||||||
|
|
||||||
// Get object from placer
|
|
||||||
IrisObject object = worldAccess.getData().getObjectLoader().load(placement.getPlace().getRandom(RNG.r));
|
IrisObject object = worldAccess.getData().getObjectLoader().load(placement.getPlace().getRandom(RNG.r));
|
||||||
|
|
||||||
// List of new blocks
|
|
||||||
List<BlockState> blockStateList = new KList<>();
|
List<BlockState> blockStateList = new KList<>();
|
||||||
|
|
||||||
// Create object placer
|
|
||||||
IObjectPlacer placer = new IObjectPlacer() {
|
IObjectPlacer placer = new IObjectPlacer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,11 +145,6 @@ public class TreeManager implements Listener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Prevent placing on claimed blocks (however that's defined, idk)
|
|
||||||
|
|
||||||
// TODO: Prevent placing object when overriding blocks
|
|
||||||
|
|
||||||
// Place the object with the placer
|
|
||||||
object.place(
|
object.place(
|
||||||
saplingPlane.getCenter(),
|
saplingPlane.getCenter(),
|
||||||
placer,
|
placer,
|
||||||
@ -174,19 +153,15 @@ public class TreeManager implements Listener {
|
|||||||
Objects.requireNonNull(worldAccess).getData()
|
Objects.requireNonNull(worldAccess).getData()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cancel the vanilla placement
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Queue sync task
|
|
||||||
J.s(() -> {
|
J.s(() -> {
|
||||||
|
|
||||||
// Send out a new event
|
|
||||||
StructureGrowEvent iGrow = new StructureGrowEvent(event.getLocation(), event.getSpecies(), event.isFromBonemeal(), event.getPlayer(), blockStateList);
|
StructureGrowEvent iGrow = new StructureGrowEvent(event.getLocation(), event.getSpecies(), event.isFromBonemeal(), event.getPlayer(), blockStateList);
|
||||||
block = true;
|
block = true;
|
||||||
Bukkit.getServer().getPluginManager().callEvent(iGrow);
|
Bukkit.getServer().getPluginManager().callEvent(iGrow);
|
||||||
block = false;
|
block = false;
|
||||||
|
|
||||||
// Check if blocks need to be updated
|
|
||||||
if(!iGrow.isCancelled()){
|
if(!iGrow.isCancelled()){
|
||||||
for (BlockState block : iGrow.getBlocks()) {
|
for (BlockState block : iGrow.getBlocks()) {
|
||||||
block.update(true, false);
|
block.update(true, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user