public void a(World world, int i, int j, int k, Random random) { if (!this.m(world, i, j, k) && !world.isRainingAt(i, j + 1, k)) { int l = world.getData(i, j, k); if (l > 0) { world.setData(i, j, k, l - 1, 2); } else if (!this.e(world, i, j, k)) { // CraftBukkit start org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) { return; } // CraftBukkit end world.setTypeUpdate(i, j, k, Blocks.DIRT); } } else { world.setData(i, j, k, 7, 2); } }
public void e() { this.a = Math.max(0, this.a - 1); if (this.a == 4) { int i = MathHelper.floor(this.b.locX); int j = MathHelper.floor(this.b.locY); int k = MathHelper.floor(this.b.locZ); if (this.c.getType(i, j, k) == Blocks.LONG_GRASS) { // CraftBukkit if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { this.c.setAir(i, j, k, false); } this.b.p(); } else if (this.c.getType(i, j - 1, k) == Blocks.GRASS) { // CraftBukkit if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { this.c.triggerEffect(2001, i, j - 1, k, Block.getId(Blocks.GRASS)); this.c.setTypeAndData(i, j - 1, k, Blocks.DIRT, 0, 2); } this.b.p(); } } }
public boolean a(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild) { // CraftBukkit start - Got milk? org.bukkit.Location loc = this.getBukkitEntity().getLocation(); org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.MILK_BUCKET); if (event.isCancelled()) { return false; } if (--itemstack.count <= 0) { entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack())); } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) { entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()), false); } // CraftBukkit end return true; } else { return super.a(entityhuman); } }
public void a(World world, int i, int j, int k, Random random) { if (world.isEmpty(i, j + 1, k)) { int l; for (l = 1; world.getType(i, j - l, k) == this; ++l) { ; } if (l < 3) { int i1 = world.getData(i, j, k); if (i1 == 15) { CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this, 0); // CraftBukkit world.setData(i, j, k, 0, 4); this.doPhysics(world, i, j + 1, k, this); } else { world.setData(i, j, k, i1 + 1, 4); } } } }
public void h() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; ++this.a; this.datawatcher.watch(8, Integer.valueOf(this.b)); int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locY); int k = MathHelper.floor(this.locZ); if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(i, j, k) != Blocks.FIRE) { // CraftBukkit start if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) { this.world.setTypeUpdate(i, j, k, Blocks.FIRE); } // CraftBukkit end } }
public void a(EntityLightning entitylightning) { if (!this.world.isStatic) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); // CraftBukkit start if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { return; } // CraftBukkit end entitypigzombie.setEquipment(0, new ItemStack(Items.GOLD_SWORD)); entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); // CraftBukkit - added a reason for spawning this creature this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); this.die(); } }
public void openContainer(IInventory iinventory) { if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory)); if (container == null) { iinventory.closeContainer(); return; } // CraftBukkit end this.nextContainerCounter(); this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 0, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_())); this.activeContainer = container; // CraftBukkit - Use container we passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); }
public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse)); if (container == null) { iinventory.closeContainer(); return; } // CraftBukkit end if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } this.nextContainerCounter(); this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 11, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_(), entityhorse.getId())); this.activeContainer = container; // CraftBukkit - Use container we passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); }
private void openCustomInventory(Inventory inventory, EntityPlayer player, String windowType) { if (player.playerConnection == null) return; Container container = new CraftContainer(inventory, this, player.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(player, container); if(container == null) return; String title = container.getBukkitView().getTitle(); int size = container.getBukkitView().getTopInventory().getSize(); // Special cases if (windowType.equals("minecraft:crafting_table") || windowType.equals("minecraft:anvil") || windowType.equals("minecraft:enchanting_table") ) { size = 0; } player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size)); getHandle().activeContainer = container; getHandle().activeContainer.addSlotListener(player); }
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_)); if (container == null) { return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true)); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public void func_146102_a(TileEntityDispenser p_146102_1_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_)); if (container == null) { p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName())); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public void tick(EntityLiving entityliving, int i) { if (this.id == REGENERATION.id) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit } } else if (this.id == POISON.id) { if (entityliving.getHealth() > 1.0F) { entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON } } else if (this.id == WITHER.id) { entityliving.damageEntity(DamageSource.WITHER, 1.0F); } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) { ((EntityHuman) entityliving).a(0.025F * (float) (i + 1)); } else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) { if (!entityliving.world.isStatic) { ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F); } } else if ((this.id != HEAL.id || entityliving.aM()) && (this.id != HARM.id || !entityliving.aM())) { if (this.id == HARM.id && !entityliving.aM() || this.id == HEAL.id && entityliving.aM()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit } }
public void e() { this.a = Math.max(0, this.a - 1); if (this.a == 4) { int i = MathHelper.floor(this.b.locX); int j = MathHelper.floor(this.b.locY); int k = MathHelper.floor(this.b.locZ); if (this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id) { // CraftBukkit start if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) { this.c.setAir(i, j, k, false); this.b.n(); } // CraftBukkit end } else if (this.c.getTypeId(i, j - 1, k) == Block.GRASS.id) { // CraftBukkit start if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) { this.c.triggerEffect(2001, i, j - 1, k, Block.GRASS.id); this.c.setTypeIdAndData(i, j - 1, k, Block.DIRT.id, 0, 2); this.b.n(); } // CraftBukkit end } } }
public void u(int i) { if (this.co()) { // CraftBukkit start - fire HorseJumpEvent, use event power if (i < 0) { i = 0; } float power; if (i >= 90) { power = 1.0F; } else { power = 0.4F + 0.4F * (float) i / 90.0F; } org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power); if (!event.isCancelled()) { this.bI = true; this.cO(); this.bt = event.getPower(); } // CraftBukkit end } }
public void processCloseWindow(C0DPacketCloseWindow p_147356_1_) { if (this.playerEntity.isDead) { return; // CraftBukkit } // Cauldron start - vanilla compatibility try { if (this.playerEntity.openContainer.getBukkitView() != null) { CraftEventFactory.handleInventoryCloseEvent(this.playerEntity); // CraftBukkit } } catch (AbstractMethodError e) { // do nothing } // Cauldron end this.playerEntity.closeContainer(); }
protected void dropDeathLoot(boolean flag, int i) { int j = this.getLootId(); if (j > 0) { // CraftBukkit start - Whole method java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int count = this.random.nextInt(2 + i); if ((j > 0) && (count > 0)) { loot.add(new org.bukkit.inventory.ItemStack(j, count)); } CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } }
public void l_() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; ++this.a; this.datawatcher.watch(8, Integer.valueOf(this.b)); int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locY); int k = MathHelper.floor(this.locZ); if (this.world.getTypeId(i, j, k) != Block.FIRE.id) { // CraftBukkit start if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) { this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id); } // CraftBukkit end } }
public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable()) { return false; } else { if (!this.dead && !this.world.isStatic) { // CraftBukkit start - All non-living entities need this if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { return false; } // CraftBukkit end this.b = 0; if (this.b <= 0) { this.die(); if (!this.world.isStatic) { this.world.explode(this, this.locX, this.locY, this.locZ, 6.0F, true); // CraftBukkit - (Entity) null -> this } } } return true; } }
protected void dropDeathLoot(boolean flag, int i) { // CraftBukkit start java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); if (j > 0) { if (this.isBurning()) { loot.add(new org.bukkit.inventory.ItemStack(Item.GRILLED_PORK.id, j)); } else { loot.add(new org.bukkit.inventory.ItemStack(Item.PORK.id, j)); } } if (this.hasSaddle()) { loot.add(new org.bukkit.inventory.ItemStack(Item.SADDLE.id, 1)); } CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end }
public void a(EntityLightning entitylightning) { if (!this.world.isStatic) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); // CraftBukkit start if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { return; } // CraftBukkit end entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); // CraftBukkit - added a reason for spawning this creature this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); this.die(); } }
public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { if (!p_149726_1_.isRemote) { if (this.field_150171_a && !p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) { p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, 4); } else if (!this.field_150171_a && p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) { // CraftBukkit start if (CraftEventFactory.callRedstoneChange(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, 0, 15).getNewCurrent() != 15) { return; } // CraftBukkit end p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, Blocks.lit_redstone_lamp, 0, 2); } } }
public void openContainer(IInventory iinventory) { if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory)); if(container == null) return; // CraftBukkit end this.nextContainerCounter(); this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 0, iinventory.getName(), iinventory.getSize(), iinventory.c())); this.activeContainer = container; // CraftBukkit - Use container we passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); }
public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse)); if(container == null) return; // CraftBukkit end if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } this.nextContainerCounter(); this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 11, iinventory.getName(), iinventory.getSize(), iinventory.c(), entityhorse.id)); this.activeContainer = container; // CraftBukkit - Use container we passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); }
public void onStruckByLightning(EntityLightningBolt p_70077_1_) { super.onStruckByLightning(p_70077_1_); // Cauldron start if (p_70077_1_ != null) { // CraftBukkit start if (CraftEventFactory.callCreeperPowerEvent(this, p_70077_1_, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { return; } } // Cauldron end this.setPowered(true); }
public void displayGUIAnvil(int p_82244_1_, int p_82244_2_, int p_82244_3_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this)); if (container == null) { return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true)); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public void func_146093_a(TileEntityHopper p_146093_1_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_146093_1_)); if (container == null) { p_146093_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.hasCustomInventoryName())); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_)); if (container == null) { return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null)); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; ++this.innerRotation; this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k) != Blocks.fire) { // CraftBukkit start if (!CraftEventFactory.callBlockIgniteEvent(this.worldObj, i, j, k, this).isCancelled()) { this.worldObj.setBlock(i, j, k, Blocks.fire); } // CraftBukkit end } }
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) { if (!p_149695_1_.isRemote) { if (this.field_150171_a && !p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) { p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, 4); } else if (!this.field_150171_a && p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) { // CraftBukkit start if (CraftEventFactory.callRedstoneChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 0, 15).getNewCurrent() != 15) { return; } // CraftBukkit end p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.lit_redstone_lamp, 0, 2); } } }
public void onStruckByLightning(EntityLightningBolt p_70077_1_) { if (!this.worldObj.isRemote) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj); // Cauldron start if (p_70077_1_ != null) { // CraftBukkit start if (CraftEventFactory.callPigZapEvent(this, p_70077_1_, entitypigzombie).isCancelled()) { return; } // CraftBukkit end } // Cauldron end entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword)); entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); // CraftBukkit - added a reason for spawning this creature this.worldObj.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); this.setDead(); } }
public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player) { super(x, y, z, world, block, blockMetadata); this.player = player; // Cauldron start - handle event on bukkit side org.bukkit.event.block.BlockBreakEvent bukkitEvent = CraftEventFactory.callBlockBreakEvent(world, x, y, z, block, blockMetadata, (EntityPlayerMP)player); if (bukkitEvent.isCancelled()) { this.setCanceled(true); } else { this.exp = bukkitEvent.getExpToDrop(); } // Cauldron end }
public void func_146101_a(TileEntityFurnace p_146101_1_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, p_146101_1_)); if (container == null) { p_146101_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 2, p_146101_1_.getInventoryName(), p_146101_1_.getSizeInventory(), p_146101_1_.hasCustomInventoryName())); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
private void openCustomInventory(Inventory inventory, net.minecraft.entity.player.EntityPlayerMP player, int windowType) { if (player.playerNetServerHandler == null) return; net.minecraft.inventory.Container container = new CraftContainer(inventory, this, player.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(player, container); if(container == null) return; String title = container.getBukkitView().getTitle(); int size = container.getBukkitView().getTopInventory().getSize(); player.playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S2DPacketOpenWindow(container.windowId, windowType, title, size, true)); getHandle().openContainer = container; getHandle().openContainer.addCraftingToCrafters(player); }