diff --git a/src/main/java/org/ultramine/mods/bukkit/EventImplProgress.java b/src/main/java/org/ultramine/mods/bukkit/EventImplProgress.java index 90df3de..108ba51 100644 --- a/src/main/java/org/ultramine/mods/bukkit/EventImplProgress.java +++ b/src/main/java/org/ultramine/mods/bukkit/EventImplProgress.java @@ -63,7 +63,7 @@ reg(true, org.bukkit.event.block.BlockExpEvent.class); reg(true, org.bukkit.event.block.BlockFadeEvent.class); reg(true, org.bukkit.event.block.BlockFormEvent.class); - reg(false, org.bukkit.event.block.BlockFromToEvent.class); + reg(true, org.bukkit.event.block.BlockFromToEvent.class); reg(false, org.bukkit.event.block.BlockGrowEvent.class); reg(false, org.bukkit.event.block.BlockIgniteEvent.class); reg(false, org.bukkit.event.block.BlockMultiPlaceEvent.class); diff --git a/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDragonEgg.java b/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDragonEgg.java new file mode 100644 index 0000000..23ac735 --- /dev/null +++ b/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDragonEgg.java @@ -0,0 +1,67 @@ +package org.ultramine.mods.bukkit.mixin.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; +import org.bukkit.event.block.BlockFromToEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.ultramine.mods.bukkit.interfaces.world.IMixinWorld; + +@Mixin(BlockDragonEgg.class) +public class MixinBlockDragonEgg extends Block +{ + protected MixinBlockDragonEgg(Material p_i45394_1_) + { + super(p_i45394_1_); + } + + /** + * @author AtomicInteger + */ + @Overwrite + private void func_150019_m(World world, int x, int y, int z) + { + if (world.getBlock(x, y, z) == this) + for (int l = 0; l < 1000; ++l) + { + int i1 = x + world.rand.nextInt(16) - world.rand.nextInt(16); + int j1 = y + world.rand.nextInt(8) - world.rand.nextInt(8); + int k1 = z + world.rand.nextInt(16) - world.rand.nextInt(16); + if (world.getBlock(i1, j1, k1).getMaterial() == Material.air) + { + org.bukkit.block.Block from = ((IMixinWorld) world).getWorld().getBlockAt(x, y, z); + org.bukkit.block.Block to = ((IMixinWorld) world).getWorld().getBlockAt(i1, j1, k1); + BlockFromToEvent event = new BlockFromToEvent(from, to); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) + return; + i1 = event.getToBlock().getX(); + j1 = event.getToBlock().getY(); + k1 = event.getToBlock().getZ(); + if (!world.isRemote) + { + world.setBlock(i1, j1, k1, this, world.getBlockMetadata(x, y, z), 2); + world.setBlockToAir(x, y, z); + } + else + { + short short1 = 128; + for (int l1 = 0; l1 < short1; ++l1) + { + double d0 = world.rand.nextDouble(); + float f = (world.rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (world.rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (world.rand.nextFloat() - 0.5F) * 0.2F; + double d1 = (double) i1 + (double) (x - i1) * d0 + (world.rand.nextDouble() - 0.5D) * 1.0D + 0.5D; + double d2 = (double) j1 + (double) (y - j1) * d0 + world.rand.nextDouble() * 1.0D - 0.5D; + double d3 = (double) k1 + (double) (z - k1) * d0 + (world.rand.nextDouble() - 0.5D) * 1.0D + 0.5D; + world.spawnParticle("portal", d1, d2, d3, (double) f, (double) f1, (double) f2); + } + } + return; + } + } + } +} diff --git a/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDynamicLiquid.java b/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDynamicLiquid.java new file mode 100644 index 0000000..3a48941 --- /dev/null +++ b/src/main/java/org/ultramine/mods/bukkit/mixin/block/MixinBlockDynamicLiquid.java @@ -0,0 +1,162 @@ +package org.ultramine.mods.bukkit.mixin.block; + +import net.minecraft.block.BlockDynamicLiquid; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.event.block.BlockFromToEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.ultramine.mods.bukkit.interfaces.world.IMixinWorld; + +import java.util.Random; + +@Mixin(BlockDynamicLiquid.class) +public abstract class MixinBlockDynamicLiquid extends BlockLiquid +{ + protected MixinBlockDynamicLiquid(Material p_i45394_1_) + { + super(p_i45394_1_); + } + + @Shadow + int field_149815_a; + + @Shadow + protected abstract void func_149813_h(World p_149813_1_, int p_149813_2_, int p_149813_3_, int p_149813_4_, int p_149813_5_); + + @Shadow + protected abstract boolean func_149809_q(World p_149809_1_, int p_149809_2_, int p_149809_3_, int p_149809_4_); + + @Shadow + protected abstract int func_149810_a(World p_149810_1_, int p_149810_2_, int p_149810_3_, int p_149810_4_, int p_149810_5_); + + @Shadow + protected abstract void func_149811_n(World p_149811_1_, int p_149811_2_, int p_149811_3_, int p_149811_4_); + + @Shadow + protected abstract boolean func_149807_p(World p_149807_1_, int p_149807_2_, int p_149807_3_, int p_149807_4_); + + @Shadow + protected abstract boolean[] func_149808_o(World p_149808_1_, int p_149808_2_, int p_149808_3_, int p_149808_4_); + + /** + * @author AtomicInteger + */ + @Overwrite + public void updateTick(World world, int x, int y, int z, Random random) + { + org.bukkit.block.Block source = ((IMixinWorld) world).getWorld() == null ? null : ((IMixinWorld) world).getWorld().getBlockAt(x, y, z); + int l = this.func_149804_e(world, x, y, z); + byte b0 = 1; + if (this.blockMaterial == Material.lava && !world.provider.isHellWorld) + b0 = 2; + boolean flag = true; + int i1 = this.tickRate(world); + int j1; + if (l > 0) + { + byte b1 = -100; + this.field_149815_a = 0; + int l1 = this.func_149810_a(world, x - 1, y, z, b1); + l1 = this.func_149810_a(world, x + 1, y, z, l1); + l1 = this.func_149810_a(world, x, y, z - 1, l1); + l1 = this.func_149810_a(world, x, y, z + 1, l1); + j1 = l1 + b0; + if (j1 >= 8 || l1 < 0) + j1 = -1; + if (this.func_149804_e(world, x, y + 1, z) >= 0) + { + int k1 = this.func_149804_e(world, x, y + 1, z); + if (k1 >= 8) + j1 = k1; + else + j1 = k1 + 8; + } + if (this.field_149815_a >= 2 && this.blockMaterial == Material.water) + { + if (world.getBlock(x, y - 1, z).getMaterial().isSolid()) + j1 = 0; + else if (world.getBlock(x, y - 1, z).getMaterial() == this.blockMaterial && world.getBlockMetadata(x, y - 1, z) == 0) + j1 = 0; + } + if (this.blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0) + i1 *= 4; + if (j1 == l) + { + if (flag) + this.func_149811_n(world, x, y, z); + } + else + { + l = j1; + if (j1 < 0) + { + world.setBlockToAir(x, y, z); + } + else + { + world.setBlockMetadataWithNotify(x, y, z, j1, 2); + world.scheduleBlockUpdate(x, y, z, this, i1); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } + } + } + else + { + this.func_149811_n(world, x, y, z); + } + + if (this.func_149809_q(world, x, y - 1, z)) + { + if (((IMixinWorld) world).getType(x, y, z).getMaterial() != this.blockMaterial) + return; + BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); + CraftServer server = ((IMixinWorld) world).getServer(); + if (server != null && source != null) + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) + { + if (this.blockMaterial == Material.lava && world.getBlock(x, y - 1, z).getMaterial() == Material.water) + { + world.setBlock(x, y - 1, z, Blocks.stone); + this.func_149799_m(world, x, y - 1, z); + return; + } + if (l >= 8) + this.func_149813_h(world, x, y - 1, z, l); + else + this.func_149813_h(world, x, y - 1, z, l + 8); + } + } + else if (l >= 0 && (l == 0 || this.func_149807_p(world, x, y - 1, z))) + { + boolean[] aboolean = this.func_149808_o(world, x, y, z); + j1 = l + b0; + if (l >= 8) + j1 = 1; + if (j1 >= 8) + return; + // CraftBukkit start - All four cardinal directions. Do not change the order! + BlockFace[] faces = new BlockFace[]{BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH}; + int index = 0; + CraftServer server = ((IMixinWorld) world).getServer(); + for (BlockFace currentFace : faces) + { + if (aboolean[index]) + { + BlockFromToEvent event = new BlockFromToEvent(source, currentFace); + if (server != null && source != null) + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) + this.func_149813_h(world, x + currentFace.getModX(), y, z + currentFace.getModZ(), j1); + } + index++; + } + } + } +} diff --git a/src/main/resources/mixin.umbukkitimpl.json b/src/main/resources/mixin.umbukkitimpl.json index 794c414..8f8718a 100644 --- a/src/main/resources/mixin.umbukkitimpl.json +++ b/src/main/resources/mixin.umbukkitimpl.json @@ -17,6 +17,8 @@ "block.MixinBlockIce", "block.MixinBlockSnow", "block.MixinBlockMycelium", + "block.MixinBlockDynamicLiquid", + "block.MixinBlockDragonEgg", "entity.MixinEntity", "entity.MixinEntityLiving", "entity.MixinEntityLivingBase",