Skip to content

Commit

Permalink
Don't do physics updates
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Sep 10, 2021
1 parent a3edde3 commit 019c678
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,14 @@ public static ItemStack harvestPlant(@Nonnull Block block) {

BlockStorage.deleteLocationInfoUnsafely(block.getLocation(), false);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.OAK_LEAVES);
block.setType(Material.AIR);
block.setType(Material.AIR, false);

plant.setType(Material.OAK_SAPLING);
plant.setType(Material.OAK_SAPLING, false);
BlockStorage.deleteLocationInfoUnsafely(plant.getLocation(), false);
BlockStorage.store(plant, getItem(berry.toBush()));
return berry.getItem().clone();
default:
block.setType(Material.OAK_SAPLING);
block.setType(Material.OAK_SAPLING, false);
BlockStorage.deleteLocationInfoUnsafely(block.getLocation(), false);
BlockStorage.store(block, getItem(berry.toBush()));
return berry.getItem().clone();
Expand All @@ -423,7 +423,7 @@ public void harvestFruit(Block fruit) {
ItemStack fruits = check.getItem().clone();
fruit.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.OAK_LEAVES);
fruit.getWorld().dropItemNaturally(loc, fruits);
fruit.setType(Material.AIR);
fruit.setType(Material.AIR, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void growStructure(StructureGrowEvent e) {
for (Tree tree : ExoticGarden.getTrees()) {
if (item.getId().equalsIgnoreCase(tree.getSapling())) {
BlockStorage.clearBlockInfo(e.getLocation());
Schematic.pasteSchematic(e.getLocation(), tree);
Schematic.pasteSchematic(e.getLocation(), tree, false);
return;
}
}
Expand All @@ -166,7 +166,7 @@ private void growStructure(StructureGrowEvent e) {
if (item.getId().equalsIgnoreCase(berry.toBush())) {
switch (berry.getType()) {
case BUSH:
e.getLocation().getBlock().setType(Material.OAK_LEAVES);
e.getLocation().getBlock().setType(Material.OAK_LEAVES, false);
break;
case ORE_PLANT:
case DOUBLE_PLANT:
Expand All @@ -186,16 +186,16 @@ private void growStructure(StructureGrowEvent e) {
}

BlockStorage.store(blockAbove, berry.getItem());
e.getLocation().getBlock().setType(Material.OAK_LEAVES);
blockAbove.setType(Material.PLAYER_HEAD);
e.getLocation().getBlock().setType(Material.OAK_LEAVES, false);
blockAbove.setType(Material.PLAYER_HEAD, false);
Rotatable rotatable = (Rotatable) blockAbove.getBlockData();
rotatable.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
blockAbove.setBlockData(rotatable);
blockAbove.setBlockData(rotatable, false);

PlayerHead.setSkin(blockAbove, PlayerSkin.fromHashCode(berry.getTexture()), true);
break;
default:
e.getLocation().getBlock().setType(Material.PLAYER_HEAD);
e.getLocation().getBlock().setType(Material.PLAYER_HEAD, false);
Rotatable s = (Rotatable) e.getLocation().getBlock().getBlockData();
s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
e.getLocation().getBlock().setBlockData(s);
Expand All @@ -217,7 +217,7 @@ private void pasteTree(ChunkPopulateEvent e, int x, int z, Tree tree) {
for (int y = e.getWorld().getMaxHeight(); y > 30; y--) {
Block current = e.getWorld().getBlockAt(x, y, z);
if (current.getType() != Material.WATER && current.getType() != Material.SEAGRASS && current.getType() != Material.TALL_SEAGRASS && !current.getType().isSolid() && !(current.getBlockData() instanceof Waterlogged && ((Waterlogged) current.getBlockData()).isWaterlogged()) && tree.isSoil(current.getRelative(0, -1, 0).getType()) && isFlat(current)) {
Schematic.pasteSchematic(e.getWorld(), x, y, z, tree);
Schematic.pasteSchematic(e.getWorld(), x, y, z, tree, false);
break;
}
}
Expand All @@ -231,47 +231,47 @@ private void growBush(ChunkPopulateEvent e, int x, int z, Berry berry, Random ra
switch (berry.getType()) {
case BUSH:
if (isPaper) {
current.setType(Material.OAK_LEAVES);
current.setType(Material.OAK_LEAVES, false);
}
else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> current.setType(Material.OAK_LEAVES));
}
break;
case FRUIT:
if (isPaper) {
current.setType(Material.PLAYER_HEAD);
current.setType(Material.PLAYER_HEAD, false);
Rotatable s = (Rotatable) current.getBlockData();
s.setRotation(faces[random.nextInt(faces.length)]);
current.setBlockData(s);
current.setBlockData(s, false);
PlayerHead.setSkin(current, PlayerSkin.fromHashCode(berry.getTexture()), true);
}
else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
current.setType(Material.PLAYER_HEAD);
Rotatable s = (Rotatable) current.getBlockData();
s.setRotation(faces[random.nextInt(faces.length)]);
current.setBlockData(s);
current.setBlockData(s, false);
PlayerHead.setSkin(current, PlayerSkin.fromHashCode(berry.getTexture()), true);
});
}
break;
case ORE_PLANT:
case DOUBLE_PLANT:
if (isPaper) {
current.setType(Material.PLAYER_HEAD);
current.setType(Material.PLAYER_HEAD, false);
Rotatable s = (Rotatable) current.getBlockData();
s.setRotation(faces[random.nextInt(faces.length)]);
current.setBlockData(s);
current.setBlockData(s, false);
PlayerHead.setSkin(current, PlayerSkin.fromHashCode(berry.getTexture()), true);
}
else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
BlockStorage.store(current.getRelative(BlockFace.UP), berry.getItem());
current.setType(Material.OAK_LEAVES);
current.getRelative(BlockFace.UP).setType(Material.PLAYER_HEAD);
current.setType(Material.OAK_LEAVES, false);
current.getRelative(BlockFace.UP).setType(Material.PLAYER_HEAD, false);
Rotatable ss = (Rotatable) current.getRelative(BlockFace.UP).getBlockData();
ss.setRotation(faces[random.nextInt(faces.length)]);
current.getRelative(BlockFace.UP).setBlockData(ss);
current.getRelative(BlockFace.UP).setBlockData(ss, false);
PlayerHead.setSkin(current.getRelative(BlockFace.UP), PlayerSkin.fromHashCode(berry.getTexture()), true);
});
}
Expand Down Expand Up @@ -348,7 +348,7 @@ public void onDecay(LeavesDecayEvent e) {

if (item != null) {
e.setCancelled(true);
e.getBlock().setType(Material.AIR);
e.getBlock().setType(Material.AIR, false);
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public short getHeight() {
return height;
}

public static void pasteSchematic(Location loc, Tree tree) {
pasteSchematic(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), tree);
public static void pasteSchematic(Location loc, Tree tree, boolean doPhysics) {
pasteSchematic(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), tree, doPhysics);
}

public static void pasteSchematic(World world, int x1, int y1, int z1, Tree tree) {
public static void pasteSchematic(World world, int x1, int y1, int z1, Tree tree, boolean doPhysics) {
Schematic schematic;

try {
Expand Down Expand Up @@ -151,7 +151,7 @@ public static void pasteSchematic(World world, int x1, int y1, int z1, Tree tree

if (material != null) {
if (blocks[index] != 0) {
block.setType(material);
block.setType(material, doPhysics);
}

if (org.bukkit.Tag.LEAVES.isTagged(material)) {
Expand All @@ -162,7 +162,7 @@ public static void pasteSchematic(World world, int x1, int y1, int z1, Tree tree
else if (material == Material.PLAYER_HEAD) {
Rotatable s = (Rotatable) block.getBlockData();
s.setRotation(BLOCK_FACES[ThreadLocalRandom.current().nextInt(BLOCK_FACES.length)]);
block.setBlockData(s);
block.setBlockData(s, doPhysics);

PlayerHead.setSkin(block, PlayerSkin.fromHashCode(tree.getTexture()), true);
BlockStorage.store(block, tree.getFruit());
Expand Down

0 comments on commit 019c678

Please sign in to comment.