Update to Minecraft 1.11

This commit is contained in:
md_5 2016-11-17 12:41:03 +11:00
parent 51263e9718
commit c25ddf063a
279 changed files with 3722 additions and 2992 deletions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
@@ -35,7 +35,7 @@
@@ -37,7 +37,7 @@
private String name;
public static int getId(Block block) {
@ -9,7 +9,7 @@
}
public static int getCombinedId(IBlockData iblockdata) {
@@ -332,7 +332,8 @@
@@ -334,7 +334,8 @@
int j = this.getDropCount(i, world.random);
for (int k = 0; k < j; ++k) {
@ -18,8 +18,8 @@
+ if (world.random.nextFloat() < f) {
Item item = this.getDropType(iblockdata, world.random, i);
if (item != null) {
@@ -873,7 +874,7 @@
if (item != Items.a) {
@@ -896,7 +897,7 @@
if (hashset.contains(block16)) {
for (int i = 0; i < 15; ++i) {
@ -28,16 +28,16 @@
Block.REGISTRY_ID.a(block16.fromLegacyData(i), j);
}
@@ -882,7 +883,7 @@
@@ -905,7 +906,7 @@
while (iterator2.hasNext()) {
IBlockData iblockdata = (IBlockData) iterator2.next();
while (unmodifiableiterator.hasNext()) {
IBlockData iblockdata = (IBlockData) unmodifiableiterator.next();
- int k = Block.REGISTRY.a((Object) block16) << 4 | block16.toLegacyData(iblockdata);
+ int k = Block.REGISTRY.a(block16) << 4 | block16.toLegacyData(iblockdata); // CraftBukkit - decompile error
Block.REGISTRY_ID.a(iblockdata, k);
}
@@ -891,6 +892,12 @@
@@ -914,6 +915,12 @@
}

View File

@ -34,7 +34,7 @@
this.a(entityhuman, world, blockposition);
@@ -164,6 +182,16 @@
if (this.I) {
this.e(iblockdata, world, blockposition);
this.d(iblockdata, world, blockposition);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

View File

@ -19,7 +19,7 @@
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit
world.setTypeAndData(blockposition, iblockdata1, 4);
iblockdata1.doPhysics(world, blockposition1, this);
iblockdata1.doPhysics(world, blockposition1, this, blockposition);
} else {
@@ -87,7 +90,9 @@
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockCake.java
+++ b/net/minecraft/server/BlockCake.java
@@ -34,7 +34,18 @@
private void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.m(false)) {
@@ -40,7 +40,18 @@
return false;
} else {
entityhuman.b(StatisticList.J);
- entityhuman.getFoodData().eat(2, 0.1F);
+ // CraftBukkit start

View File

@ -23,7 +23,7 @@
}
}
@@ -58,17 +64,26 @@
@@ -60,18 +66,27 @@
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
@ -39,6 +39,7 @@
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return true;
@ -49,19 +50,19 @@
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
if (itemstack.count == 0) {
@@ -79,7 +94,8 @@
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -82,7 +97,8 @@
}
entityhuman.b(StatisticList.L);
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
world.a((EntityHuman) null, blockposition, SoundEffects.P, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return true;
@@ -88,6 +104,10 @@
@@ -92,6 +108,10 @@
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
@ -72,17 +73,36 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
entityhuman.b(StatisticList.L);
@@ -100,7 +120,8 @@
}
@@ -106,12 +126,17 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.K, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
return true;
@@ -109,8 +130,13 @@
} else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.b) {
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
entityhuman.b(StatisticList.L);
@@ -122,7 +147,8 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.J, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i + 1);
+ // this.a(world, blockposition, iblockdata, i + 1);
+ // CraftBukkit end
}
return true;
@@ -131,8 +157,13 @@
ItemArmor itemarmor = (ItemArmor) item;
if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) {
@ -90,23 +110,34 @@
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return true;
+ }
itemarmor.c(itemstack);
itemarmor.d(itemstack);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
entityhuman.b(StatisticList.M);
return true;
}
@@ -135,7 +161,7 @@
}
@@ -140,13 +171,18 @@
if (i > 0 && item instanceof ItemBanner) {
if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
+ return true;
+ }
itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
TileEntityBanner.c(itemstack1);
entityhuman.b(StatisticList.N);
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
- this.a(world, blockposition, iblockdata, i - 1);
+ this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH); // CraftBukkit
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
}
@@ -148,9 +174,25 @@
if (itemstack.isEmpty()) {
@@ -167,9 +203,25 @@
}
}
@ -133,12 +164,12 @@
}
public void h(World world, BlockPosition blockposition) {
@@ -161,7 +203,7 @@
@@ -180,7 +232,7 @@
IBlockData iblockdata = world.getType(blockposition);
if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) {
- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
+ a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
+ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
}
}

View File

@ -9,7 +9,7 @@
public class BlockChorusFlower extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5);
@@ -69,8 +71,20 @@
@@ -68,8 +70,20 @@
}
if (flag && a(world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
@ -32,7 +32,7 @@
} else if (i < 4) {
j = random.nextInt(4);
boolean flag2 = false;
@@ -84,18 +98,53 @@
@@ -83,18 +97,53 @@
BlockPosition blockposition2 = blockposition.shift(enumdirection);
if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) {

View File

@ -1,16 +1,16 @@
--- a/net/minecraft/server/BlockCommand.java
+++ b/net/minecraft/server/BlockCommand.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockCommand extends BlockTileEntity {
public static final BlockStateDirection a = BlockDirectional.FACING;
@@ -30,7 +32,16 @@
boolean flag1 = tileentitycommand.g();
@@ -29,7 +31,16 @@
boolean flag1 = tileentitycommand.f();
boolean flag2 = tileentitycommand.h();
- if (flag && !flag1) {
@ -27,7 +27,7 @@
tileentitycommand.a(true);
if (tileentitycommand.k() != TileEntityCommand.Type.SEQUENCE && !flag2) {
boolean flag3 = !tileentitycommand.l() || this.e(world, blockposition, iblockdata);
@@ -41,7 +52,7 @@
@@ -40,7 +51,7 @@
this.c(world, blockposition);
}
}

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockCrops.java
+++ b/net/minecraft/server/BlockCrops.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
@@ -54,7 +56,10 @@
@@ -53,7 +55,10 @@
float f = a((Block) this, world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
@ -21,7 +21,7 @@
}
}
}
@@ -69,7 +74,10 @@
@@ -68,7 +73,10 @@
i = j;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockDaylightDetector.java
+++ b/net/minecraft/server/BlockDaylightDetector.java
@@ -46,6 +46,7 @@
@@ -45,6 +45,7 @@
i = MathHelper.clamp(i, 0, 15);
if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {

View File

@ -18,13 +18,13 @@
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.y(iblockdata), 2);
world.setTypeAndData(blockposition, this.A(iblockdata), 2);
} else if (!this.d) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.x(iblockdata), 2);
world.setTypeAndData(blockposition, this.z(iblockdata), 2);
if (!flag) {
world.a(blockposition, this.x(iblockdata).getBlock(), this.D(iblockdata), -1);
world.a(blockposition, this.z(iblockdata).getBlock(), this.F(iblockdata), -1);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockDispenser.java
+++ b/net/minecraft/server/BlockDispenser.java
@@ -9,6 +9,7 @@
@@ -8,6 +8,7 @@
public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
public static final RegistryDefault<Item, IDispenseBehavior> REGISTRY = new RegistryDefault(new DispenseBehaviorItem());
protected Random d = new Random();
@ -8,11 +8,11 @@
protected BlockDispenser() {
super(Material.STONE);
@@ -84,6 +85,7 @@
@@ -82,6 +83,7 @@
IDispenseBehavior idispensebehavior = this.a(itemstack);
if (idispensebehavior != IDispenseBehavior.NONE) {
ItemStack itemstack1 = idispensebehavior.a(sourceblock, itemstack);
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setItem(i, itemstack1.count <= 0 ? null : itemstack1);
tileentitydispenser.setItem(i, idispensebehavior.a(sourceblock, itemstack));
}

View File

@ -1,44 +1,37 @@
--- a/net/minecraft/server/BlockDoor.java
+++ b/net/minecraft/server/BlockDoor.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -138,9 +140,22 @@
@@ -137,9 +139,23 @@
this.b(world, blockposition, iblockdata, 0);
}
} else {
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition2);
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3);
- if (block != this && (flag1 || block.getBlockData().m()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
- if (block != this && (flag1 || block.getBlockData().n()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ int oldPower = (Boolean)iblockdata2.get(POWERED) ? 15 : 0;
+ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
world.setTypeAndData(blockposition2, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2);
+ // CraftBukkit end
world.setTypeAndData(blockposition3, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2);
if (flag1 != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.OPEN, Boolean.valueOf(flag1)), 2);
@@ -148,6 +163,7 @@
world.a((EntityHuman) null, flag1 ? this.g() : this.e(), blockposition, 0);
}
}
+ // CraftBukkit end
}
}

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockDragonEgg.java
+++ b/net/minecraft/server/BlockDragonEgg.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
public class BlockDragonEgg extends Block {
protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D);
@@ -67,6 +69,18 @@
@@ -66,6 +68,18 @@
BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16));
if (world.getType(blockposition1).getBlock().material == Material.AIR) {

View File

@ -1,22 +1,22 @@
--- a/net/minecraft/server/BlockDropper.java
+++ b/net/minecraft/server/BlockDropper.java
@@ -1,6 +1,10 @@
@@ -1,5 +1,10 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
+// CraftBukkit end
+
public class BlockDropper extends BlockDispenser {
@@ -40,8 +44,25 @@
itemstack1 = null;
}
private final IDispenseBehavior e = new DispenseBehaviorItem();
@@ -35,8 +40,25 @@
if (iinventory == null) {
itemstack1 = this.e.a(sourceblock, itemstack);
} else {
- itemstack1 = TileEntityHopper.addItem(iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
- if (itemstack1 == null) {
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
- if (itemstack1.isEmpty()) {
+ // CraftBukkit start - Fire event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));
+
@ -33,9 +33,9 @@
+ if (event.isCancelled()) {
+ return;
+ }
+ itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
+ if (event.getItem().equals(oitemstack) && itemstack1 == null) {
+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
+ // CraftBukkit end
itemstack1 = itemstack.cloneItemStack();
if (--itemstack1.count <= 0) {
itemstack1 = null;
itemstack1.subtract(1);
} else {

View File

@ -12,7 +12,7 @@
@@ -37,6 +39,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.aX() && !world.isClientSide && entity.getBoundingBox().b(iblockdata.c(world, blockposition).a(blockposition))) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.aX() && !world.isClientSide && entity.getBoundingBox().c(iblockdata.d(world, blockposition).a(blockposition))) {
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);

View File

@ -34,7 +34,7 @@
@@ -119,14 +125,14 @@
if (!flag) {
if (!this.c(world, blockposition)) {
if (!world.getType(blockposition.down()).q() || i > 3) {
if (!world.getType(blockposition.down()).r() || i > 3) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
}
@ -96,8 +96,8 @@
@@ -276,7 +312,7 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block) {
if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
if (!world.getType(blockposition.down()).r() && !this.c(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
}
@ -106,7 +106,7 @@
@@ -284,7 +320,7 @@
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !Blocks.PORTAL.b(world, blockposition)) {
if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
if (!world.getType(blockposition.down()).r() && !this.c(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
} else {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockGrass.java
+++ b/net/minecraft/server/BlockGrass.java
@@ -3,6 +3,14 @@
@@ -2,6 +2,14 @@
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
@ -15,7 +15,7 @@
public class BlockGrass extends Block implements IBlockFragilePlantElement {
public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
@@ -23,7 +31,19 @@
@@ -22,7 +30,19 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isClientSide) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) {
@ -36,7 +36,7 @@
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
@@ -37,7 +57,19 @@
@@ -36,7 +56,19 @@
IBlockData iblockdata2 = world.getType(blockposition1);
if (iblockdata2.getBlock() == Blocks.DIRT && iblockdata2.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata1.c() <= 2) {
@ -57,7 +57,7 @@
}
}
}
@@ -81,13 +113,15 @@
@@ -79,13 +111,15 @@
IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient);
if (blockflowers.f(world, blockposition2, iblockdata1)) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockIce.java
+++ b/net/minecraft/server/BlockIce.java
@@ -51,6 +51,11 @@
@@ -47,6 +47,11 @@
}
protected void b(World world, BlockPosition blockposition) {

View File

@ -1,12 +1,12 @@
--- a/net/minecraft/server/BlockJukeBox.java
+++ b/net/minecraft/server/BlockJukeBox.java
@@ -144,6 +144,11 @@
@@ -143,6 +143,11 @@
}
public void setRecord(@Nullable ItemStack itemstack) {
public void setRecord(ItemStack itemstack) {
+ // CraftBukkit start - There can only be one
+ if (itemstack != null) {
+ itemstack.count = 1;
+ if (!itemstack.isEmpty()) {
+ itemstack.setCount(1);
+ }
+ // CraftBukkit end
this.record = itemstack;

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockLeaves.java
+++ b/net/minecraft/server/BlockLeaves.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public abstract class BlockLeaves extends Block {
public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
@@ -133,6 +135,14 @@
@@ -132,6 +134,14 @@
}
private void b(World world, BlockPosition blockposition) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockMobSpawner.java
+++ b/net/minecraft/server/BlockMobSpawner.java
@@ -24,9 +24,19 @@
@@ -22,9 +22,19 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockMycel.java
+++ b/net/minecraft/server/BlockMycel.java
@@ -3,6 +3,13 @@
@@ -2,6 +2,13 @@
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
@ -14,7 +14,7 @@
public class BlockMycel extends Block {
public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
@@ -23,7 +30,19 @@
@@ -22,7 +29,19 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isClientSide) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) {
@ -35,7 +35,7 @@
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
@@ -32,7 +51,19 @@
@@ -31,7 +50,19 @@
IBlockData iblockdata2 = world.getType(blockposition1.up());
if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata2.c() <= 2) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockNetherWart.java
+++ b/net/minecraft/server/BlockNetherWart.java
@@ -32,7 +32,8 @@
@@ -31,7 +31,8 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockOre.java
+++ b/net/minecraft/server/BlockOre.java
@@ -39,6 +39,7 @@
@@ -37,6 +37,7 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
@ -8,7 +8,7 @@
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
int j = 0;
@@ -56,9 +57,34 @@
@@ -54,9 +55,34 @@
this.dropExperience(world, blockposition, j);
}

View File

@ -19,7 +19,7 @@
public class BlockPiston extends BlockDirectional {
public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended");
@@ -99,6 +111,18 @@
@@ -103,6 +115,18 @@
world.playBlockAction(blockposition, this, 0, enumdirection.a());
}
} else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
@ -38,16 +38,16 @@
world.playBlockAction(blockposition, this, 1, enumdirection.a());
}
@@ -189,7 +213,7 @@
@@ -193,7 +217,7 @@
}
}
- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
this.a(world, blockposition, enumdirection, false);
}
} else {
@@ -286,6 +310,48 @@
@@ -274,6 +298,48 @@
int j = list.size() + list1.size();
IBlockData[] aiblockdata = new IBlockData[j];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();

View File

@ -13,7 +13,7 @@
@@ -43,7 +46,8 @@
}
if (i > 0 && !world.getType(blockposition1.up()).l()) {
if (i > 0 && !world.getType(blockposition1.up()).m()) {
- Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
+ Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
@ -52,7 +52,7 @@
entity.e(blockposition);
}
@@ -254,6 +264,7 @@
@@ -212,6 +222,7 @@
private BlockPosition position;
private int height;
private int width;
@ -60,7 +60,7 @@
public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = world;
@@ -312,6 +323,10 @@
@@ -270,6 +281,10 @@
}
protected int c() {
@ -71,7 +71,7 @@
int i;
label56:
@@ -332,11 +347,21 @@
@@ -290,11 +305,21 @@
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
@ -93,7 +93,7 @@
}
}
}
@@ -346,6 +371,11 @@
@@ -304,6 +329,11 @@
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
break;
@ -105,7 +105,7 @@
}
}
@@ -367,7 +397,27 @@
@@ -325,7 +355,27 @@
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
@ -134,7 +134,7 @@
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
@@ -376,6 +426,7 @@
@@ -334,6 +384,7 @@
}
}

View File

@ -21,5 +21,5 @@
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3);
world.applyPhysics(blockposition.down(), this);
world.applyPhysics(blockposition.down(), this, false);
if (((BlockMinecartTrackAbstract.EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {

View File

@ -43,7 +43,7 @@
world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
@@ -62,12 +75,17 @@
world.update(shapedetectorblock1.getPosition(), Blocks.AIR);
world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false);
}
+ } // CraftBukkit end
} else {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockRedstoneLamp.java
+++ b/net/minecraft/server/BlockRedstoneLamp.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockRedstoneLamp extends Block {
private final boolean a;
@@ -21,6 +23,11 @@
@@ -20,6 +22,11 @@
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2);
} else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) {
@ -21,7 +21,7 @@
world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
}
@@ -32,6 +39,11 @@
@@ -31,6 +38,11 @@
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
world.a(blockposition, (Block) this, 4);
} else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) {
@ -33,7 +33,7 @@
world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
}
@@ -41,6 +53,11 @@
@@ -40,6 +52,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isClientSide) {
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockRedstoneOre.java
+++ b/net/minecraft/server/BlockRedstoneOre.java
@@ -3,6 +3,11 @@
@@ -2,6 +2,11 @@
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -12,7 +12,7 @@
public class BlockRedstoneOre extends Block {
private final boolean a;
@@ -21,23 +26,45 @@
@@ -20,23 +25,45 @@
}
public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
@ -45,10 +45,10 @@
}
+
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
- this.interact(world, blockposition);
+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2);
return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2);
}
- private void interact(World world, BlockPosition blockposition) {
@ -63,7 +63,7 @@
world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
}
@@ -45,6 +72,11 @@
@@ -44,6 +71,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (this == Blocks.LIT_REDSTONE_ORE) {
@ -75,7 +75,7 @@
world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
}
@@ -65,12 +97,25 @@
@@ -63,12 +95,25 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockRedstoneTorch.java
+++ b/net/minecraft/server/BlockRedstoneTorch.java
@@ -7,6 +7,8 @@
@@ -6,6 +6,8 @@
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
private static final Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> g = Maps.newHashMap();
@@ -14,7 +16,7 @@
@@ -13,7 +15,7 @@
private boolean a(World world, BlockPosition blockposition, boolean flag) {
if (!BlockRedstoneTorch.g.containsKey(world)) {
@ -18,7 +18,7 @@
}
List list = (List) BlockRedstoneTorch.g.get(world);
@@ -97,8 +99,25 @@
@@ -96,8 +98,25 @@
list.remove(0);
}
@ -43,8 +43,8 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
if (this.a(world, blockposition, true)) {
world.a((EntityHuman) null, blockposition, SoundEffects.eR, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -115,6 +134,15 @@
world.a((EntityHuman) null, blockposition, SoundEffects.fl, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -114,6 +133,15 @@
}
}
} else if (!flag && !this.a(world, blockposition, false)) {

View File

@ -21,7 +21,7 @@
+ public static TreeType treeType; // CraftBukkit
protected BlockSapling() {
this.w(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
this.y(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
@@ -25,7 +35,30 @@
if (!world.isClientSide) {
super.b(world, blockposition, iblockdata, random);
@ -89,7 +89,7 @@
}
break;
case 2:
case BIRCH:
+ treeType = TreeType.BIRCH; // CraftBukkit
object = new WorldGenForest(true, false);
break;
@ -111,7 +111,7 @@
}
break;
case 4:
case ACACIA:
+ treeType = TreeType.ACACIA; // CraftBukkit
object = new WorldGenAcaciaTree(true);
break;

View File

@ -0,0 +1,45 @@
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
@@ -89,7 +89,32 @@
tileentityshulkerbox.d(entityhuman);
}
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
+ // CraftBukkit start - override to prevent duplication when dropping
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityShulkerBox) {
+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
+
+ if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
+ ItemStack itemstack = new ItemStack(Item.getItemOf(this));
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+ nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1));
+ itemstack.setTag(nbttagcompound);
+ if (tileentityshulkerbox.hasCustomName()) {
+ itemstack.g(tileentityshulkerbox.getName());
+ tileentityshulkerbox.a("");
+ }
+
+ a(world, blockposition, itemstack);
+ }
+
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+ }
+ }
+ // CraftBukkit end
public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
if (itemstack.hasName()) {
@@ -105,7 +130,7 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
TileEntity tileentity = world.getTileEntity(blockposition);
- if (tileentity instanceof TileEntityShulkerBox) {
+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {

View File

@ -12,7 +12,7 @@
public class BlockSkull extends BlockTileEntity {
public static final BlockStateDirection FACING = BlockDirectional.FACING;
@@ -82,7 +87,25 @@
@@ -82,7 +87,29 @@
return new ItemStack(Items.SKULL, 1, i);
}
@ -21,25 +21,29 @@
+ @Override
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ if (world.random.nextFloat() < f) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition);
+ ItemStack itemstack = this.a(world, blockposition, iblockdata);
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
+ itemstack.setTag(new NBTTagCompound());
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ if (tileentity instanceof TileEntitySkull) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+ ItemStack itemstack = this.a(world, blockposition, iblockdata);
+
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
+ itemstack.getTag().set("SkullOwner", nbttagcompound);
+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
+ itemstack.setTag(new NBTTagCompound());
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
+ itemstack.getTag().set("SkullOwner", nbttagcompound);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+ }
+ // CraftBukkit end
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.abilities.canInstantlyBuild) {
@@ -95,7 +118,10 @@
@@ -95,7 +122,10 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!world.isClientSide) {
@ -51,7 +55,7 @@
TileEntity tileentity = world.getTileEntity(blockposition);
if (tileentity instanceof TileEntitySkull) {
@@ -128,24 +154,36 @@
@@ -127,24 +157,36 @@
}
public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
@ -90,7 +94,7 @@
}
}
@@ -158,14 +196,16 @@
@@ -157,14 +199,16 @@
entitywither.o();
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator();
@ -109,8 +113,8 @@
int k;
for (k = 0; k < 120; ++k) {
@@ -179,6 +219,7 @@
world.update(shapedetectorblock2.getPosition(), Blocks.AIR);
@@ -178,6 +222,7 @@
world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false);
}
}
+ } // CraftBukkit end

View File

@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockSnow.java
+++ b/net/minecraft/server/BlockSnow.java
@@ -82,6 +82,11 @@
@@ -81,6 +81,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11) {
if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.AIR).isCancelled()) {
+ return;

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockSoil.java
+++ b/net/minecraft/server/BlockSoil.java
@@ -4,6 +4,11 @@
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityInteractEvent;
@ -15,23 +15,22 @@
@@ -35,6 +40,12 @@
if (i > 0) {
world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
} else if (!this.b(world, blockposition)) {
} else if (!this.c(world, blockposition)) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
this.b(world, blockposition);
}
} else if (i < 7) {
@@ -44,11 +55,31 @@
@@ -44,11 +55,29 @@
}
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
+ super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) {
+
+ // CraftBukkit start - Interact soil
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
@ -49,12 +48,11 @@
+ return;
+ }
+ // CraftBukkit end
+
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
this.b(world, blockposition);
}
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
private boolean b(World world, BlockPosition blockposition) {
private void b(World world, BlockPosition blockposition) {

View File

@ -11,7 +11,7 @@
@@ -91,6 +92,19 @@
boolean flag = world.isBlockIndirectlyPowered(blockposition);
if (flag || block.getBlockData().m()) {
if (flag || block.getBlockData().n()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

View File

@ -9,7 +9,7 @@
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -139,6 +141,40 @@
@@ -138,6 +140,40 @@
}
}

View File

@ -32,25 +32,25 @@
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+
if (flag2 && this.x(world.getType(blockposition3))) {
if (flag2 && this.z(world.getType(blockposition3))) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true))));
} else if (flag3 && this.x(world.getType(blockposition4))) {
} else if (flag3 && this.z(world.getType(blockposition4))) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true))));
} else if (flag2 && world.isEmpty(blockposition3) && this.x(world.getType(blockposition.shift(enumdirection2)))) {
} else if (flag2 && world.isEmpty(blockposition3) && this.z(world.getType(blockposition.shift(enumdirection2)))) {
- world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true))));
} else if (flag3 && world.isEmpty(blockposition4) && this.x(world.getType(blockposition.shift(enumdirection3)))) {
} else if (flag3 && world.isEmpty(blockposition4) && this.z(world.getType(blockposition.shift(enumdirection3)))) {
- world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true))));
} else if (this.x(world.getType(blockposition2.up()))) {
} else if (this.z(world.getType(blockposition2.up()))) {
- world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData()));

View File

@ -28,15 +28,16 @@
return i;
}
@@ -440,11 +442,11 @@
}
@@ -441,12 +443,12 @@
}
@Nullable
- public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) {
+ public JsonElement serialize(ChatModifier object, Type type, JsonSerializationContext jsonserializationcontext) { // CraftBukkit - fix decompile error
return this.a((ChatModifier) object, type, jsonserializationcontext);
}
@Nullable
- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ public ChatModifier deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - fix decompile error
return this.a(jsonelement, type, jsondeserializationcontext);

View File

@ -11,7 +11,7 @@
private static final Logger e = LogManager.getLogger();
@@ -42,6 +45,35 @@
private ConcurrentLinkedQueue<BlockPosition> y;
private final ConcurrentLinkedQueue<BlockPosition> y;
public boolean d;
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
@ -91,7 +91,7 @@
if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) {
@@ -639,6 +687,13 @@
tileentity.z();
tileentity.A();
this.tileEntities.put(blockposition, tileentity);
+ // CraftBukkit start
+ } else {
@ -131,9 +131,9 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
- if (entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply(entity))) {
- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply(entity))) {
- list.add(entity);
+ if (entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error
+ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error
+ list.add((T) entity); // Fix decompile error
}
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkProviderGenerate.java
+++ b/net/minecraft/server/ChunkProviderGenerate.java
@@ -228,6 +228,11 @@
@@ -234,6 +234,11 @@
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
@@ -14,6 +14,11 @@
@@ -15,6 +15,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -12,7 +12,7 @@
public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger();
@@ -69,19 +74,82 @@
@@ -70,19 +75,82 @@
Chunk chunk = this.getLoadedChunkAt(i, j);
if (chunk == null) {
@ -97,7 +97,7 @@
if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j);
@@ -100,7 +168,7 @@
@@ -101,7 +169,7 @@
this.chunks.put(k, chunk);
chunk.addEntities();
@ -106,7 +106,7 @@
}
return chunk;
@@ -146,10 +214,12 @@
@@ -147,10 +215,12 @@
public boolean a(boolean flag) {
int i = 0;
@ -122,7 +122,7 @@
if (flag) {
this.saveChunkNOP(chunk);
@@ -182,10 +252,12 @@
@@ -183,10 +253,12 @@
Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) {
@ -139,7 +139,7 @@
++i;
}
}
@@ -197,6 +269,40 @@
@@ -198,6 +270,40 @@
return false;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
@@ -29,25 +29,55 @@
@@ -29,19 +29,49 @@
this.e = dataconvertermanager;
}
@ -38,9 +38,9 @@
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
if (nbttagcompound == null) {
- DataInputStream datainputstream = RegionFileCache.c(this.d, i, j);
- DataInputStream datainputstream = RegionFileCache.d(this.d, i, j);
+ // CraftBukkit start
+ nbttagcompound = RegionFileCache.c(this.d, i, j);
+ nbttagcompound = RegionFileCache.d(this.d, i, j);
- if (datainputstream == null) {
+ if (nbttagcompound == null) {
@ -53,14 +53,16 @@
}
return this.a(world, i, j, nbttagcompound);
@@ -55,7 +85,7 @@
}
@Nullable
- protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) {
+ protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", new Object[] { Integer.valueOf(i), Integer.valueOf(j)});
return null;
@@ -64,10 +94,28 @@
@@ -72,10 +102,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)});
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
@ -90,7 +92,7 @@
}
}
}
@@ -98,20 +146,27 @@
@@ -106,20 +154,27 @@
}
public boolean c() {
@ -121,13 +123,13 @@
if (nbttagcompound != null) {
try {
@@ -131,10 +186,14 @@
@@ -139,10 +194,14 @@
}
private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
- DataOutputStream dataoutputstream = RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z);
- DataOutputStream dataoutputstream = RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z);
+ // CraftBukkit start
+ RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ /*
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
@ -137,7 +139,7 @@
}
public void b(World world, Chunk chunk) throws IOException {}
@@ -149,6 +208,7 @@
@@ -157,6 +216,7 @@
if (this.c()) {
continue;
}
@ -145,7 +147,7 @@
}
} finally {
this.f = false;
@@ -326,6 +386,13 @@
@@ -334,6 +394,13 @@
chunk.a(nbttagcompound.getByteArray("Biomes"));
}
@ -158,8 +160,8 @@
+
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
if (nbttaglist1 != null) {
@@ -369,7 +436,7 @@
for (int l = 0; l < nbttaglist1.size(); ++l) {
@@ -371,7 +438,7 @@
}
}
@ -168,7 +170,7 @@
}
@Nullable
@@ -397,14 +464,20 @@
@@ -399,14 +466,20 @@
}
@Nullable
@ -190,7 +192,7 @@
return null;
} else {
if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
@@ -433,8 +506,14 @@
@@ -435,8 +508,14 @@
}
}

View File

@ -33,12 +33,25 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
@@ -124,6 +134,125 @@
@@ -124,6 +134,138 @@
}
}
+ public static int executeSafely(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) {
+ try {
+ return executeCommand(sender, bSender, command);
+ } catch (CommandException commandexception) {
+ // Taken from CommandHandler
+ ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs());
+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
+ sender.sendMessage(chatmessage);
+ }
+
+ return 0;
+ }
+
+ // CraftBukkit start
+ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) {
+ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) throws CommandException {
+ org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap();
+ Joiner joiner = Joiner.on(" ");
+ if (command.startsWith("/")) {
@ -137,7 +150,7 @@
+ return completed;
+ }
+
+ private static ArrayList<String[]> buildCommands(ICommandListener sender, String[] args, int pos) {
+ private static ArrayList<String[]> buildCommands(ICommandListener sender, String[] args, int pos) throws CommandException {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+ java.util.List<EntityPlayer> players = (java.util.List<EntityPlayer>)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class);
+

View File

@ -11,7 +11,7 @@
public class CommandExecute extends CommandAbstract {
@@ -55,7 +59,10 @@
@@ -58,7 +62,10 @@
}
String s = a(astring, b0);
@ -23,15 +23,15 @@
public String getName() {
return entity.getName();
}
@@ -100,25 +107,59 @@
return entity.h();
@@ -103,25 +110,59 @@
return entity.B_();
}
};
+ ICommandListener icommandlistener1 = new ProxyListener(); // CraftBukkit
ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
try {
- int j = icommandhandler.a(icommandlistener1, s);
- int i = icommandhandler.a(icommandlistener1, s);
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null;
+ ICommandListener listener = icommandlistener;
@ -52,10 +52,10 @@
+ throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]);
+ }
+ }
+ int j = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s);
+ int i = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s);
+ // CraftBukkit end
if (j < 1) {
if (i < 1) {
throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s});
}
} catch (Throwable throwable) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Container.java
+++ b/net/minecraft/server/Container.java
@@ -8,6 +8,17 @@
@@ -7,6 +7,17 @@
import java.util.Set;
import javax.annotation.Nullable;
@ -17,8 +17,8 @@
+
public abstract class Container {
public List<ItemStack> b = Lists.newArrayList();
@@ -19,12 +30,24 @@
public NonNullList<ItemStack> b = NonNullList.a();
@@ -18,6 +29,18 @@
protected List<ICrafting> listeners = Lists.newArrayList();
private final Set<EntityHuman> i = Sets.newHashSet();
@ -37,38 +37,28 @@
public Container() {}
protected Slot a(Slot slot) {
slot.rawSlotIndex = this.c.size();
this.c.add(slot);
- this.b.add((Object) null);
+ this.b.add(null); // CraftBukkit - fix decompile error
return slot;
}
@@ -128,6 +151,7 @@
k = playerinventory.getCarried().count;
l = playerinventory.getCarried().getCount();
Iterator iterator = this.h.iterator();
+ Map<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack)
while (iterator.hasNext()) {
Slot slot1 = (Slot) iterator.next();
@@ -145,16 +169,48 @@
ItemStack itemstack3 = playerinventory.getCarried();
@@ -143,12 +167,48 @@
}
k -= itemstack2.count - i1;
- slot1.set(itemstack2);
+ // slot1.set(itemstack2);
+ draggedSlots.put(slot1.rawSlotIndex, itemstack2); // CraftBukkit - Put in map instead of setting
}
}
- itemstack1.count = k;
- if (itemstack1.count <= 0) {
- itemstack1 = null;
l -= itemstack4.getCount() - j1;
- slot1.set(itemstack4);
+ // slot1.set(itemstack4);
+ draggedSlots.put(slot1.rawSlotIndex, itemstack4); // CraftBukkit - Put in map instead of setting
+ }
+ }
+
+ // CraftBukkit start - InventoryDragEvent
+ InventoryView view = getBukkitView();
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1);
+ newcursor.setAmount(k);
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack2);
+ newcursor.setAmount(l);
+ Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new HashMap<Integer, org.bukkit.inventory.ItemStack>();
+ for (Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) {
+ eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue()));
@ -93,12 +83,13 @@
+ if (playerinventory.getCarried() != null) {
+ playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
+ needsUpdate = true;
+ }
}
+ } else {
+ playerinventory.setCarried(oldCursor);
}
- playerinventory.setCarried(itemstack1);
- itemstack2.setCount(l);
- playerinventory.setCarried(itemstack2);
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).updateInventory(this);
+ }
@ -106,69 +97,7 @@
}
this.d();
@@ -177,8 +233,14 @@
}
if (j == 1) {
- entityhuman.drop(playerinventory.getCarried().cloneAndSubtract(1), true);
- if (playerinventory.getCarried().count == 0) {
+ // CraftBukkit start - Store a reference, don't drop unless > 0
+ ItemStack carried = playerinventory.getCarried();
+ if (carried.count > 0) {
+ entityhuman.drop(carried.cloneAndSubtract(1), true);
+ }
+
+ if (carried.count == 0) {
+ // CraftBukkit end
playerinventory.setCarried((ItemStack) null);
}
}
@@ -229,7 +291,11 @@
slot2.set(itemstack3.cloneAndSubtract(j1));
if (itemstack3.count == 0) {
playerinventory.setCarried((ItemStack) null);
+ // CraftBukkit start - Update client cursor if we didn't empty it
+ } else if (entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried()));
}
+ // CraftBukkit end
}
} else if (slot2.isAllowed(entityhuman)) {
if (itemstack3 == null) {
@@ -259,7 +325,11 @@
itemstack3.cloneAndSubtract(j1);
if (itemstack3.count == 0) {
playerinventory.setCarried((ItemStack) null);
+ // CraftBukkit start - Update client cursor if we didn't empty it
+ } else if (entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried()));
}
+ // CraftBukkit end
itemstack1.count += j1;
} else if (itemstack3.count <= slot2.getMaxStackSize(itemstack3)) {
@@ -268,7 +338,10 @@
}
} else if (itemstack1.getItem() == itemstack3.getItem() && itemstack3.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack3.getData()) && ItemStack.equals(itemstack1, itemstack3)) {
j1 = itemstack1.count;
- if (j1 > 0 && j1 + itemstack3.count <= itemstack3.getMaxStackSize()) {
+ // CraftBukkit start - itemstack3.getMaxStackSize() -> maxStack
+ int maxStack = Math.min(itemstack3.getMaxStackSize(), slot2.getMaxStackSize());
+ if (j1 > 0 && j1 + itemstack3.count <= maxStack) {
+ // CraftBukkit end
itemstack3.count += j1;
itemstack1 = slot2.a(j1);
if (itemstack1.count == 0) {
@@ -276,11 +349,24 @@
}
slot2.a(entityhuman, playerinventory.getCarried());
+ // CraftBukkit start - Update client cursor if we didn't empty it
+ } else if (entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried()));
}
+ // CraftBukkit end
}
@@ -258,6 +318,15 @@
}
slot2.f();
@ -184,25 +113,3 @@
}
}
} else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) {
@@ -434,14 +520,17 @@
if (itemstack1 != null && a(itemstack, itemstack1)) {
int l = itemstack1.count + itemstack.count;
- if (l <= itemstack.getMaxStackSize()) {
+ // CraftBukkit start - itemstack.getMaxStackSize() -> maxStack
+ int maxStack = Math.min(itemstack.getMaxStackSize(), slot.getMaxStackSize());
+ if (l <= maxStack) {
itemstack.count = 0;
itemstack1.count = l;
slot.f();
flag1 = true;
- } else if (itemstack1.count < itemstack.getMaxStackSize()) {
- itemstack.count -= itemstack.getMaxStackSize() - itemstack1.count;
- itemstack1.count = itemstack.getMaxStackSize();
+ } else if (itemstack1.count < maxStack) {
+ itemstack.count -= maxStack - itemstack1.count;
+ itemstack1.count = maxStack;
+ // CraftBukkit end
slot.f();
flag1 = true;
}

View File

@ -1,24 +1,22 @@
--- a/net/minecraft/server/ContainerAnvil.java
+++ b/net/minecraft/server/ContainerAnvil.java
@@ -7,6 +7,12 @@
@@ -6,6 +6,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+ // CraftBukkit start
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.PrepareAnvilEvent;
+// CraftBukkit end
+
public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger();
@@ -23,8 +29,13 @@
@@ -22,8 +26,13 @@
private int k;
private String l;
private final EntityHuman m;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private CraftInventoryView bukkitEntity;
+ private PlayerInventory player;
+ // CraftBukkit end
@ -27,34 +25,34 @@
this.j = blockposition;
this.i = world;
this.m = entityhuman;
@@ -110,7 +121,7 @@
@@ -110,7 +119,7 @@
byte b1 = 0;
if (itemstack == null) {
- this.g.setItem(0, (ItemStack) null);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
if (itemstack.isEmpty()) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.a = 0;
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -128,7 +139,7 @@
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.h(), itemstack1.j() / 4);
@@ -128,7 +137,7 @@
if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.i(), itemstack1.k() / 4);
if (k <= 0) {
- this.g.setItem(0, (ItemStack) null);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.a = 0;
return;
}
@@ -143,7 +154,7 @@
@@ -143,7 +152,7 @@
this.k = l;
} else {
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
- this.g.setItem(0, (ItemStack) null);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.a = 0;
return;
}
@@ -270,7 +281,7 @@
@@ -270,7 +279,7 @@
EnchantmentManager.a(map, itemstack1);
}
@ -63,18 +61,19 @@
this.b();
}
}
@@ -295,6 +306,7 @@
@@ -295,6 +304,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.e((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
}
@@ -352,6 +364,20 @@
@@ -350,4 +360,18 @@
this.e();
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
@ -88,7 +87,4 @@
+ return bukkitEntity;
+ }
+ // CraftBukkit end
+
static class SyntheticClass_1 {
static final int[] a = new int[Enchantment.Rarity.values().length];
}

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/server/ContainerBeacon.java
+++ b/net/minecraft/server/ContainerBeacon.java
@@ -1,13 +1,19 @@
@@ -1,11 +1,18 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerBeacon extends Container {
private final IInventory beacon;
@ -20,7 +19,7 @@
this.beacon = iinventory1;
this.f = new ContainerBeacon.SlotBeacon(iinventory1, 0, 136, 110);
this.a((Slot) this.f);
@@ -50,6 +56,7 @@
@@ -48,6 +55,7 @@
}
public boolean a(EntityHuman entityhuman) {
@ -28,7 +27,7 @@
return this.beacon.a(entityhuman);
}
@@ -114,4 +121,17 @@
@@ -113,4 +121,17 @@
return 1;
}
}

View File

@ -1,17 +1,17 @@
--- a/net/minecraft/server/ContainerBrewingStand.java
+++ b/net/minecraft/server/ContainerBrewingStand.java
@@ -1,6 +1,10 @@
@@ -1,5 +1,10 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerBrewingStand extends Container {
@@ -9,7 +13,13 @@
private final IInventory brewingStand;
@@ -7,7 +12,13 @@
private int g;
private int h;
@ -25,7 +25,7 @@
this.brewingStand = iinventory;
this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 0, 56, 51)));
this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 1, 79, 58)));
@@ -56,6 +66,7 @@
@@ -54,6 +65,7 @@
}
public boolean a(EntityHuman entityhuman) {
@ -33,8 +33,8 @@
return this.brewingStand.a(entityhuman);
}
@@ -185,4 +196,17 @@
}
@@ -181,4 +193,17 @@
return item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE;
}
}
+

View File

@ -1,14 +1,13 @@
--- a/net/minecraft/server/ContainerChest.java
+++ b/net/minecraft/server/ContainerChest.java
@@ -1,11 +1,38 @@
@@ -1,9 +1,37 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerChest extends Container {
private final IInventory container;
@ -39,7 +38,7 @@
public ContainerChest(IInventory iinventory, IInventory iinventory1, EntityHuman entityhuman) {
this.container = iinventory1;
@@ -13,6 +40,11 @@
@@ -11,6 +39,11 @@
iinventory1.startOpen(entityhuman);
int i = (this.f - 4) * 18;
@ -51,7 +50,7 @@
int j;
int k;
@@ -35,6 +67,7 @@
@@ -33,6 +66,7 @@
}
public boolean a(EntityHuman entityhuman) {

View File

@ -1,14 +1,13 @@
--- a/net/minecraft/server/ContainerDispenser.java
+++ b/net/minecraft/server/ContainerDispenser.java
@@ -1,13 +1,25 @@
@@ -1,11 +1,24 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerDispenser extends Container {
public final IInventory items;
@ -26,7 +25,7 @@
int i;
int j;
@@ -31,6 +43,7 @@
@@ -29,6 +42,7 @@
}
public boolean a(EntityHuman entityhuman) {
@ -34,7 +33,7 @@
return this.items.a(entityhuman);
}
@@ -66,4 +79,17 @@
@@ -63,4 +77,17 @@
return itemstack;
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/ContainerEnchantTable.java
+++ b/net/minecraft/server/ContainerEnchantTable.java
@@ -4,9 +4,22 @@
@@ -3,9 +3,22 @@
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.Map;
@ -24,7 +24,7 @@
public int getMaxStackSize() {
return 64;
}
@@ -15,6 +28,11 @@
@@ -14,6 +27,11 @@
super.update();
ContainerEnchantTable.this.a((IInventory) this);
}
@ -36,7 +36,7 @@
};
public World world;
private final BlockPosition position;
@@ -23,6 +41,10 @@
@@ -22,6 +40,10 @@
public int[] costs = new int[3];
public int[] h = new int[] { -1, -1, -1};
public int[] i = new int[] { -1, -1, -1};
@ -47,7 +47,7 @@
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
this.world = world;
@@ -55,6 +77,9 @@
@@ -54,6 +76,9 @@
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
@ -57,23 +57,23 @@
}
protected void c(ICrafting icrafting) {
@@ -91,7 +116,7 @@
@@ -90,7 +115,7 @@
ItemStack itemstack = iinventory.getItem(0);
int i;
- if (itemstack != null && itemstack.v()) {
+ if (itemstack != null) { // CraftBukkit - relax condition
- if (!itemstack.isEmpty() && itemstack.canEnchant()) {
+ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition
if (!this.world.isClientSide) {
i = 0;
@@ -140,6 +165,20 @@
@@ -139,6 +164,20 @@
}
}
+ // CraftBukkit start
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs, i);
+ event.setCancelled(!itemstack.v());
+ event.setCancelled(!itemstack.canEnchant());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@ -87,8 +87,8 @@
for (j = 0; j < 3; ++j) {
if (this.costs[j] > 0) {
List list = this.a(itemstack, j, this.costs[j]);
@@ -176,24 +215,55 @@
} else if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
@@ -175,26 +214,56 @@
} else if (this.costs[i] > 0 && !itemstack.isEmpty() && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
if (!this.world.isClientSide) {
List list = this.a(itemstack, i, this.costs[i]);
+ // CraftBukkit start - Provide an empty enchantment list
@ -96,10 +96,12 @@
+ list = new java.util.ArrayList<WeightedRandomEnchant>();
+ }
+ // CraftBukkit end
boolean flag = itemstack.getItem() == Items.BOOK;
+ boolean flag = itemstack.getItem() == Items.BOOK;
if (list != null) {
- if (!list.isEmpty()) {
- entityhuman.enchantDone(j);
- boolean flag = itemstack.getItem() == Items.BOOK;
+ if (list != null) {
+ // CraftBukkit start
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
@ -110,13 +112,14 @@
+
+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs[i], enchants, i);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ int level = event.getExpLevelCost();
+ if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) {
+ return false;
+ }
if (flag) {
itemstack.setItem(Items.ENCHANTED_BOOK);
itemstack = new ItemStack(Items.ENCHANTED_BOOK);
this.enchantSlots.setItem(0, itemstack);
}
- for (int k = 0; k < list.size(); ++k) {
@ -148,9 +151,9 @@
+
+ // CraftBukkit - TODO: let plugins change this
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.count -= j;
if (itemstack1.count <= 0) {
@@ -228,6 +298,11 @@
itemstack1.subtract(j);
if (itemstack1.isEmpty()) {
@@ -229,6 +298,11 @@
public void b(EntityHuman entityhuman) {
super.b(entityhuman);
@ -162,15 +165,15 @@
if (!this.world.isClientSide) {
for (int i = 0; i < this.enchantSlots.getSize(); ++i) {
ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i);
@@ -241,6 +316,7 @@
@@ -242,6 +316,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
@@ -294,4 +370,17 @@
@@ -294,4 +369,17 @@
return itemstack;
}

View File

@ -1,17 +1,17 @@
--- a/net/minecraft/server/ContainerFurnace.java
+++ b/net/minecraft/server/ContainerFurnace.java
@@ -1,6 +1,10 @@
@@ -1,5 +1,10 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerFurnace extends Container {
@@ -10,11 +14,28 @@
private final IInventory furnace;
@@ -8,11 +13,28 @@
private int h;
private int i;
@ -40,7 +40,7 @@
int i;
@@ -65,6 +86,7 @@
@@ -63,6 +85,7 @@
}
public boolean a(EntityHuman entityhuman) {

View File

@ -1,14 +1,13 @@
--- a/net/minecraft/server/ContainerHopper.java
+++ b/net/minecraft/server/ContainerHopper.java
@@ -1,13 +1,34 @@
@@ -1,11 +1,33 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerHopper extends Container {
private final IInventory hopper;
@ -35,7 +34,7 @@
iinventory.startOpen(entityhuman);
boolean flag = true;
@@ -30,6 +51,7 @@
@@ -28,6 +50,7 @@
}
public boolean a(EntityHuman entityhuman) {

View File

@ -1,19 +1,18 @@
--- a/net/minecraft/server/ContainerHorse.java
+++ b/net/minecraft/server/ContainerHorse.java
@@ -1,13 +1,34 @@
@@ -1,11 +1,33 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.inventory.InventoryView;
+// CraftBukkit end
+
public class ContainerHorse extends Container {
private final IInventory a;
private final EntityHorse f;
private final EntityHorseAbstract f;
+ // CraftBukkit start
+ org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity;
@ -29,9 +28,9 @@
+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), inventory, this);
+ }
+
public ContainerHorse(IInventory iinventory, final IInventory iinventory1, final EntityHorse entityhorse, EntityHuman entityhuman) {
public ContainerHorse(IInventory iinventory, final IInventory iinventory1, final EntityHorseAbstract entityhorseabstract, EntityHuman entityhuman) {
+ player = (PlayerInventory) iinventory;
+ // CraftBukkit end
this.a = iinventory1;
this.f = entityhorse;
this.f = entityhorseabstract;
boolean flag = true;

View File

@ -1,14 +1,13 @@
--- a/net/minecraft/server/ContainerMerchant.java
+++ b/net/minecraft/server/ContainerMerchant.java
@@ -1,6 +1,7 @@
@@ -1,11 +1,26 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerMerchant extends Container {
@@ -8,6 +9,19 @@
private final IMerchant merchant;
private final InventoryMerchant f;
private final World g;
@ -28,7 +27,7 @@
public ContainerMerchant(PlayerInventory playerinventory, IMerchant imerchant, World world) {
this.merchant = imerchant;
this.g = world;
@@ -15,6 +29,7 @@
@@ -13,6 +28,7 @@
this.a(new Slot(this.f, 0, 36, 53));
this.a(new Slot(this.f, 1, 62, 53));
this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.f, 2, 120, 53)));

View File

@ -1,17 +1,17 @@
--- a/net/minecraft/server/ContainerPlayer.java
+++ b/net/minecraft/server/ContainerPlayer.java
@@ -1,6 +1,10 @@
@@ -1,5 +1,10 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerPlayer extends Container {
@@ -9,10 +13,20 @@
private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
@@ -7,10 +12,20 @@
public IInventory resultInventory = new InventoryCraftResult();
public boolean g;
private final EntityHuman owner;
@ -32,7 +32,7 @@
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28)));
int i;
@@ -25,7 +39,7 @@
@@ -23,7 +38,7 @@
}
for (i = 0; i < 4; ++i) {
@ -41,9 +41,18 @@
this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) {
public int getMaxStackSize() {
@@ -59,11 +73,22 @@
return super.isAllowed(itemstack);
}
@@ -31,7 +46,7 @@
}
public boolean isAllowed(ItemStack itemstack) {
- return enumitemslot == EntityInsentient.d(itemstack);
+ return enumitemslot1 == EntityInsentient.d(itemstack); // CraftBukkit - decompile error
}
public boolean isAllowed(EntityHuman entityhuman) {
@@ -54,11 +69,22 @@
this.a(new Slot(playerinventory, 40, 77, 62) {
});
- this.a((IInventory) this.craftInventory);
+ // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty
@ -66,7 +75,7 @@
}
public void b(EntityHuman entityhuman) {
@@ -150,4 +175,17 @@
@@ -148,4 +174,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}

View File

@ -0,0 +1,34 @@
--- a/net/minecraft/server/ContainerShulkerBox.java
+++ b/net/minecraft/server/ContainerShulkerBox.java
@@ -1,11 +1,31 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerShulkerBox extends Container {
private final IInventory a;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.a), this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerShulkerBox(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) {
this.a = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
iinventory.startOpen(entityhuman);
boolean flag = true;
boolean flag1 = true;

View File

@ -1,14 +1,13 @@
--- a/net/minecraft/server/ContainerWorkbench.java
+++ b/net/minecraft/server/ContainerWorkbench.java
@@ -1,15 +1,29 @@
@@ -1,13 +1,28 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerWorkbench extends Container {
- public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3);
@ -32,7 +31,7 @@
this.g = world;
this.h = blockposition;
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35)));
@@ -37,7 +51,21 @@
@@ -35,7 +50,21 @@
}
public void a(IInventory iinventory) {
@ -55,15 +54,15 @@
}
public void b(EntityHuman entityhuman) {
@@ -55,6 +83,7 @@
@@ -53,6 +82,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.e((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D;
return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D;
}
@@ -104,4 +133,17 @@
@@ -106,4 +136,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/CraftingManager.java
+++ b/net/minecraft/server/CraftingManager.java
@@ -10,10 +10,16 @@
@@ -9,10 +9,16 @@
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
@ -17,7 +17,7 @@
public static CraftingManager getInstance() {
return CraftingManager.a;
@@ -178,7 +184,12 @@
@@ -179,7 +185,12 @@
this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, BlockDoubleStepAbstract.EnumStoneSlabVariant.STONE.a())});
this.registerShapedRecipe(new ItemStack(Blocks.END_ROD, 4), new Object[] { "/", "#", Character.valueOf('/'), Items.BLAZE_ROD, Character.valueOf('#'), Items.CHORUS_FRUIT_POPPED});
this.registerShapedRecipe(new ItemStack(Blocks.di, 1), new Object[] { "XXX", "XXX", "XXX", Character.valueOf('X'), new ItemStack(Items.DYE, 1, EnumColor.WHITE.getInvColorIndex())});
@ -36,7 +36,7 @@
do {
if (!iterator.hasNext()) {
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
return null;
return ItemStack.a;
}
irecipe = (IRecipe) iterator.next();
@ -50,4 +50,4 @@
+ // CraftBukkit end
}
public ItemStack[] b(InventoryCrafting inventorycrafting, World world) {
public NonNullList<ItemStack> b(InventoryCrafting inventorycrafting, World world) {

View File

@ -98,7 +98,7 @@
+
thread.setDaemon(true);
thread.start();
DedicatedServer.LOGGER.info("Starting minecraft server version 1.10.2");
DedicatedServer.LOGGER.info("Starting minecraft server version 1.11");
@@ -78,7 +125,7 @@
}
@ -108,7 +108,7 @@
this.r = new EULA(new File("eula.txt"));
if (!this.r.a()) {
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
@@ -134,6 +181,8 @@
@@ -135,6 +182,8 @@
return false;
}
@ -117,7 +117,7 @@
if (!this.getOnlineMode()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -148,7 +197,7 @@
@@ -149,7 +198,7 @@
if (!NameReferencingFileConverter.a(this.propertyManager)) {
return false;
} else {
@ -126,7 +126,7 @@
long j = System.nanoTime();
if (this.S() == null) {
@@ -206,7 +255,18 @@
@@ -207,7 +256,18 @@
DedicatedServer.LOGGER.info("Starting remote control listener");
this.p = new RemoteControlListener(this);
this.p.a();
@ -143,18 +143,9 @@
}
+ // CraftBukkit end
if (this.aP() > 0L) {
if (this.aQ() > 0L) {
Thread thread1 = new Thread(new ThreadWatchdog(this));
@@ -266,7 +326,7 @@
return this.propertyManager.getBoolean("hardcore", false);
}
- protected void a(CrashReport crashreport) {}
+ public void a(CrashReport crashreport) {}
public CrashReport b(CrashReport crashreport) {
crashreport = super.b(crashreport);
@@ -293,11 +353,11 @@
@@ -292,11 +352,11 @@
return crashreport;
}
@ -166,9 +157,9 @@
- protected void D() {
+ public void D() { // CraftBukkit - fix decompile error
super.D();
this.aL();
this.aM();
}
@@ -328,7 +388,15 @@
@@ -327,7 +387,15 @@
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
@ -185,7 +176,7 @@
}
}
@@ -535,16 +603,70 @@
@@ -534,16 +602,70 @@
}
public String getPlugins() {
@ -252,7 +243,7 @@
}
public PlayerList getPlayerList() {
return this.aM();
return this.aN();
}
+
+ // CraftBukkit start

View File

@ -18,7 +18,7 @@
- a(isourceblock.getWorld(), itemstack1, 6, enumdirection, iposition);
+ // CraftBukkit start
+ if (!a(isourceblock.getWorld(), itemstack1, 6, enumdirection, isourceblock)) {
+ itemstack.count++;
+ itemstack.add(1);
+ }
+ // CraftBukkit end
return itemstack;

View File

@ -16,7 +16,7 @@
IProjectile iprojectile = this.a(world, iposition, itemstack);
- iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a());
+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(), this.a());
+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a());
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@ -28,12 +28,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -47,8 +47,8 @@
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
+ // CraftBukkit end
world.addEntity((Entity) iprojectile);
- itemstack.cloneAndSubtract(1);
+ // itemstack.cloneAndSubtract(1); // CraftBukkit - Handled during event processing
- itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing
return itemstack;
}

View File

@ -32,7 +32,7 @@
@@ -106,14 +111,46 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d1 = (double) ((float) (isourceblock.getBlockPosition().getY() + enumdirection.getAdjacentY()) + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
@ -49,12 +49,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -73,8 +73,8 @@
}
ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity);
- itemstack.cloneAndSubtract(1);
+ // itemstack.cloneAndSubtract(1);// Handled during event processing
- itemstack.subtract(1);
+ // itemstack.subtract(1);// Handled during event processing
+ // CraftBukkit end
return itemstack;
}
@ -96,12 +96,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -115,8 +115,8 @@
+ EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);
isourceblock.getWorld().addEntity(entityfireworks);
- itemstack.cloneAndSubtract(1);
+ // itemstack.cloneAndSubtract(1); // Handled during event processing
- itemstack.subtract(1);
+ // itemstack.subtract(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
@ -126,7 +126,7 @@
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
- world.addEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
- itemstack.cloneAndSubtract(1);
- itemstack.subtract(1);
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@ -138,12 +138,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -157,15 +157,16 @@
+ fireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
+
+ world.addEntity(fireball);
+ // itemstack.a(1); // Handled during event processing
+ // itemstack.subtract(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
@@ -169,9 +265,48 @@
@@ -169,7 +265,53 @@
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
- return itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition) ? new ItemStack(Items.BUCKET) : this.b.a(isourceblock, itemstack);
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
+ int x = blockposition.getX();
@ -198,22 +199,25 @@
+ }
+ // CraftBukkit end
+
if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
- itemstack.setItem(Items.BUCKET);
- itemstack.count = 1;
+ if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
+ // CraftBukkit start - Handle stacked buckets
+ Item item = Items.BUCKET;
+ if (--itemstack.count == 0) {
+ itemstack.subtract(1);
+ if (itemstack.isEmpty()) {
+ itemstack.setItem(Items.BUCKET);
+ itemstack.count = 1;
+ itemstack.setCount(1);
+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
+ this.b.a(isourceblock, new ItemStack(item));
+ }
+ // CraftBukkit end
return itemstack;
} else {
return this.b.a(isourceblock, itemstack);
@@ -202,6 +337,30 @@
+ return itemstack;
+ } else {
+ return this.b.a(isourceblock, itemstack);
+ }
}
};
@@ -196,6 +338,30 @@
item = Items.LAVA_BUCKET;
}
@ -242,11 +246,11 @@
+ // CraftBukkit end
+
world.setAir(blockposition);
if (--itemstack.count == 0) {
itemstack.setItem(item);
@@ -220,11 +379,39 @@
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -213,14 +379,42 @@
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@ -272,22 +276,25 @@
+ }
+ // CraftBukkit end
+
this.b = true;
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
if (world.isEmpty(blockposition)) {
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
- if (itemstack.isDamaged(1, world.random)) {
- itemstack.count = 0;
- itemstack.setCount(0);
+ // CraftBukkit start - Ignition by dispensing flint and steel
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()).isCancelled()) {
+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ if (itemstack.isDamaged(1, world.random)) {
+ itemstack.count = 0;
+ itemstack.setCount(0);
+ }
}
+ // CraftBukkit end
} else if (world.getType(blockposition).getBlock() == Blocks.TNT) {
Blocks.TNT.postBreak(world, blockposition, Blocks.TNT.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(true)));
world.setAir(blockposition);
@@ -252,6 +439,30 @@
@@ -238,6 +432,30 @@
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
@ -318,7 +325,7 @@
if (ItemDye.a(itemstack, world, blockposition)) {
if (!world.isClientSide) {
world.triggerEffect(2005, blockposition, 0);
@@ -279,11 +490,40 @@
@@ -256,11 +474,40 @@
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
@ -336,12 +343,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -355,13 +362,13 @@
+ // CraftBukkit end
world.addEntity(entitytntprimed);
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gz, SoundCategory.BLOCKS, 1.0F, 1.0F);
- --itemstack.count;
+ // --itemstack.count; // CraftBukkit - handled above
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gV, SoundCategory.BLOCKS, 1.0F, 1.0F);
- itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - handled above
return itemstack;
}
});
@@ -296,6 +536,30 @@
@@ -271,6 +518,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
BlockSkull blockskull = Blocks.SKULL;
@ -389,10 +396,10 @@
+ }
+ // CraftBukkit end
+
this.b = true;
if (world.isEmpty(blockposition) && blockskull.b(world, blockposition, itemstack)) {
if (!world.isClientSide) {
world.setTypeAndData(blockposition, blockskull.getBlockData().set(BlockSkull.FACING, EnumDirection.UP), 3);
@@ -354,6 +618,30 @@
@@ -319,6 +590,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
BlockPumpkin blockpumpkin = (BlockPumpkin) Blocks.PUMPKIN;
@ -420,10 +427,10 @@
+ }
+ // CraftBukkit end
+
this.b = true;
if (world.isEmpty(blockposition) && blockpumpkin.b(world, blockposition)) {
if (!world.isClientSide) {
world.setTypeAndData(blockposition, blockpumpkin.getBlockData(), 3);
@@ -437,12 +725,40 @@
@@ -456,12 +751,40 @@
d3 = 0.0D;
}
@ -440,12 +447,12 @@
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ itemstack.add(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ itemstack.add(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
@ -459,10 +466,10 @@
+ // CraftBukkit end
entityboat.setType(this.c);
entityboat.yaw = enumdirection.opposite().l();
entityboat.yaw = enumdirection.l();
world.addEntity(entityboat);
- itemstack.cloneAndSubtract(1);
+ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing
- itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - handled during event processing
return itemstack;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Enchantment.java
+++ b/net/minecraft/server/Enchantment.java
@@ -18,7 +18,7 @@
@@ -19,7 +19,7 @@
}
public static int getId(Enchantment enchantment) {
@ -9,10 +9,10 @@
}
@Nullable
@@ -139,6 +139,11 @@
Enchantment.enchantments.a(61, new MinecraftKey("luck_of_the_sea"), new EnchantmentLootBonus(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND}));
@@ -149,6 +149,11 @@
Enchantment.enchantments.a(62, new MinecraftKey("lure"), new EnchantmentLure(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND}));
Enchantment.enchantments.a(70, new MinecraftKey("mending"), new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values()));
Enchantment.enchantments.a(71, new MinecraftKey("vanishing_curse"), new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values()));
+ // CraftBukkit start
+ for (Object enchantment : Enchantment.enchantments) {
+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment));

View File

@ -12,7 +12,7 @@
@@ -42,8 +45,18 @@
IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1);
if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null, (ItemStack) null)) {
if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) {
- world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData());
- world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker

View File

@ -47,19 +47,19 @@
+ // CraftBukikt end
+
private static final Logger a = LogManager.getLogger();
private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static double c = 1.0D;
@@ -99,6 +139,9 @@
private static final List<ItemStack> b = Collections.emptyList();
private static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
@@ -98,6 +138,9 @@
public boolean glowing;
private final Set<String> aH;
private boolean aI;
private final Set<String> aG;
private boolean aH;
+ public boolean valid; // CraftBukkit
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
+ public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
public Entity(World world) {
this.id = Entity.entityCount++;
@@ -197,6 +240,33 @@
@@ -202,6 +245,33 @@
}
protected void setYawPitch(float f, float f1) {
@ -93,8 +93,8 @@
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
@@ -240,7 +310,7 @@
if (this.al) {
@@ -245,7 +315,7 @@
if (this.ak) {
MinecraftServer minecraftserver = this.world.getMinecraftServer();
- if (minecraftserver.getAllowNether()) {
@ -102,7 +102,7 @@
if (!this.isPassenger()) {
int i = this.V();
@@ -325,6 +395,27 @@
@@ -330,6 +400,27 @@
protected void burnFromLava() {
if (!this.fireProof) {
this.damageEntity(DamageSource.LAVA, 4.0F);
@ -130,8 +130,8 @@
this.setOnFire(15);
}
}
@@ -365,6 +456,22 @@
this.a(this.getBoundingBox().c(d0, d1, d2));
@@ -370,6 +461,22 @@
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
} else {
+ // CraftBukkit start - Don't do anything if we aren't moving
@ -153,7 +153,25 @@
this.world.methodProfiler.a("move");
double d3 = this.locX;
double d4 = this.locY;
@@ -587,6 +694,28 @@
@@ -470,7 +577,7 @@
}
}
- boolean flag1 = this.onGround || d1 != d1 && d1 < 0.0D;
+ boolean flag1 = this.onGround || d1 != d7 && d1 < 0.0D; // CraftBukkit - decompile error
double d10;
if (this.P > 0.0F && flag1 && (d6 != d0 || d8 != d2)) {
@@ -568,7 +675,7 @@
this.world.methodProfiler.a("rest");
this.recalcPosition();
this.positionChanged = d6 != d0 || d8 != d2;
- this.B = d1 != d1;
+ this.B = d1 != d7; // CraftBukkit - decompile error
this.onGround = this.B && d7 < 0.0D;
this.C = this.positionChanged || this.B;
j = MathHelper.floor(this.locX);
@@ -603,6 +710,28 @@
block1.a(this.world, this);
}
@ -182,7 +200,7 @@
if (this.playStepSound() && !flag && !this.isPassenger()) {
double d21 = this.locX - d3;
double d22 = this.locY - d4;
@@ -618,6 +747,8 @@
@@ -634,6 +763,8 @@
}
}
@ -191,7 +209,7 @@
try {
this.checkBlockCollisions();
} catch (Throwable throwable) {
@@ -627,6 +758,8 @@
@@ -643,6 +774,8 @@
this.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
@ -200,7 +218,7 @@
boolean flag2 = this.ai();
@@ -635,7 +768,14 @@
@@ -651,7 +784,14 @@
if (!flag2) {
++this.fireTicks;
if (this.fireTicks == 0) {
@ -216,7 +234,7 @@
}
}
} else if (this.fireTicks <= 0) {
@@ -756,7 +896,7 @@
@@ -772,7 +912,7 @@
return null;
}
@ -225,7 +243,7 @@
if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i);
}
@@ -922,6 +1062,13 @@
@@ -938,6 +1078,13 @@
}
public void spawnIn(World world) {
@ -239,7 +257,7 @@
this.world = world;
}
@@ -1126,6 +1273,18 @@
@@ -1170,6 +1317,18 @@
try {
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ}));
nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
@ -258,7 +276,7 @@
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
@@ -1135,6 +1294,12 @@
@@ -1179,6 +1338,12 @@
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.a("UUID", this.getUniqueID());
@ -268,10 +286,10 @@
+ nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
+ // CraftBukkit end
if (this.getCustomName() != null && !this.getCustomName().isEmpty()) {
if (this.hasCustomName()) {
nbttagcompound.setString("CustomName", this.getCustomName());
}
@@ -1210,6 +1375,8 @@
@@ -1254,6 +1419,8 @@
this.motX = nbttaglist1.e(0);
this.motY = nbttaglist1.e(1);
this.motZ = nbttaglist1.e(2);
@ -280,7 +298,7 @@
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
@@ -1221,6 +1388,7 @@
@@ -1265,6 +1432,7 @@
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
@ -288,7 +306,7 @@
this.locX = nbttaglist.e(0);
this.locY = nbttaglist.e(1);
@@ -1278,6 +1446,58 @@
@@ -1322,6 +1490,58 @@
this.setPosition(this.locX, this.locY, this.locZ);
}
@ -347,10 +365,10 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
@@ -1337,6 +1557,12 @@
public EntityItem a(ItemStack itemstack, float f) {
if (itemstack.count != 0 && itemstack.getItem() != null) {
@@ -1389,6 +1609,12 @@
if (itemstack.isEmpty()) {
return null;
} else {
+ // CraftBukkit start - Capture drops for death event
+ if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
@ -360,7 +378,7 @@
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.q();
@@ -1458,6 +1684,24 @@
@@ -1514,6 +1740,24 @@
if (entity.bB() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
@ -385,7 +403,7 @@
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) {
this.passengers.add(0, entity);
} else {
@@ -1471,6 +1715,22 @@
@@ -1527,6 +1771,22 @@
if (entity.bB() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
@ -408,7 +426,7 @@
this.passengers.remove(entity);
entity.j = 60;
}
@@ -1610,14 +1870,48 @@
@@ -1666,14 +1926,48 @@
}
public void setAirTicks(int i) {
@ -460,10 +478,10 @@
}
}
@@ -1752,19 +2046,67 @@
@@ -1818,19 +2112,67 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = this.h();
MinecraftServer minecraftserver = this.B_();
- int j = this.dimension;
- WorldServer worldserver = minecraftserver.getWorldServer(j);
- WorldServer worldserver1 = minecraftserver.getWorldServer(i);
@ -531,7 +549,7 @@
BlockPosition blockposition;
if (i == 1) {
@@ -1793,12 +2135,18 @@
@@ -1859,12 +2201,18 @@
blockposition = new BlockPosition(this);
}
@ -543,7 +561,7 @@
+ // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity
+ // CraftBukkit end
this.world.methodProfiler.c("reloading");
Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1);
Entity entity = EntityTypes.a(this.getClass(), (World) worldserver1);
if (entity != null) {
entity.a(this);
@ -551,7 +569,7 @@
if (j == 1 && i == 1) {
BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
@@ -1806,6 +2154,7 @@
@@ -1872,6 +2220,7 @@
} else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
@ -559,7 +577,7 @@
boolean flag = entity.attachedToPlayer;
@@ -1813,6 +2162,14 @@
@@ -1879,6 +2228,14 @@
worldserver1.addEntity(entity);
entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false);
@ -574,7 +592,7 @@
}
this.dead = true;
@@ -1923,6 +2280,11 @@
@@ -1989,6 +2346,11 @@
}
public void setCustomName(String s) {
@ -586,7 +604,7 @@
this.datawatcher.set(Entity.aA, s);
}
@@ -1980,7 +2342,26 @@
@@ -2046,7 +2408,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@ -614,7 +632,7 @@
}
public float getHeadHeight() {
@@ -2154,7 +2535,7 @@
@@ -2220,7 +2601,7 @@
for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) {
entity = (Entity) iterator.next();
if (oclass.isAssignableFrom(entity.getClass())) {

View File

@ -2,13 +2,13 @@
+++ b/net/minecraft/server/EntityAgeable.java
@@ -10,6 +10,7 @@
protected int c;
private float by = -1.0F;
private float bz;
private float bx = -1.0F;
private float by;
+ public boolean ageLocked; // CraftBukkit
public EntityAgeable(World world) {
super(world);
@@ -28,13 +29,18 @@
@@ -31,7 +32,7 @@
if (entityageable != null) {
entityageable.setAgeRaw(-24000);
entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
@ -17,18 +17,7 @@
if (itemstack.hasName()) {
entityageable.setCustomName(itemstack.getName());
}
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
+ // CraftBukkit start - allow less than 0 stacks as "infinite"
+ if (itemstack.count == 0) {
+ entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
+ }
+ // CraftBukkit end
}
}
}
@@ -97,12 +103,14 @@
@@ -110,12 +111,14 @@
super.b(nbttagcompound);
nbttagcompound.setInt("Age", this.getAge());
nbttagcompound.setInt("ForcedAge", this.b);
@ -43,7 +32,7 @@
}
public void a(DataWatcherObject<?> datawatcherobject) {
@@ -115,7 +123,7 @@
@@ -128,7 +131,7 @@
public void n() {
super.n();

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/EntityAnimal.java
+++ b/net/minecraft/server/EntityAnimal.java
@@ -7,6 +7,7 @@
protected Block bA;
private int bx;
private EntityHuman by;
@@ -5,6 +5,7 @@
protected Block bz;
private int bw;
private EntityHuman bx;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
public EntityAnimal(World world) {
super(world);
@@ -40,6 +41,9 @@
@@ -38,6 +39,9 @@
}
@ -18,18 +18,18 @@
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable(damagesource)) {
return false;
@@ -48,6 +52,7 @@
@@ -46,6 +50,7 @@
return super.damageEntity(damagesource, f);
}
}
+ // CraftBukkit end */
public float a(BlockPosition blockposition) {
return this.world.getType(blockposition.down()).getBlock() == Blocks.GRASS ? 10.0F : this.world.n(blockposition) - 0.5F;
return this.world.getType(blockposition.down()).getBlock() == this.bz ? 10.0F : this.world.n(blockposition) - 0.5F;
@@ -120,6 +125,7 @@
public void c(EntityHuman entityhuman) {
this.bx = 600;
this.by = entityhuman;
this.bw = 600;
this.bx = entityhuman;
+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit
this.world.broadcastEntityEffect(this, (byte) 18);
}

View File

@ -11,7 +11,7 @@
import java.util.Map.Entry;
import javax.annotation.Nullable;
@@ -96,6 +100,22 @@
@@ -101,6 +105,22 @@
}
@ -34,7 +34,7 @@
public int getColor() {
return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.b)).intValue();
}
@@ -265,6 +285,7 @@
@@ -270,6 +290,7 @@
if (!list.isEmpty()) {
Iterator iterator2 = list.iterator();
@ -42,7 +42,7 @@
while (iterator2.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator2.next();
@@ -274,6 +295,17 @@
@@ -279,6 +300,17 @@
double d2 = d0 * d0 + d1 * d1;
if (d2 <= (double) (f * f)) {
@ -57,6 +57,6 @@
+ if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
this.au.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay));
this.at.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay));
Iterator iterator3 = arraylist.iterator();

View File

@ -15,10 +15,10 @@
+
public class EntityArmorStand extends EntityLiving {
private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F);
@@ -373,6 +382,21 @@
if (itemstack1 == null || (this.bB & 1 << enumitemslot.c() + 8) == 0) {
if (itemstack1 != null || (this.bB & 1 << enumitemslot.c() + 16) == 0) {
private static final Vector3f bq = new Vector3f(0.0F, 0.0F, 0.0F);
@@ -364,6 +373,21 @@
if (itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 8) == 0) {
if (!itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 16) == 0) {
ItemStack itemstack2;
+ // CraftBukkit start
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
@ -36,9 +36,9 @@
+ }
+ // CraftBukkit end
if (entityhuman.abilities.canInstantlyBuild && (itemstack1 == null || itemstack1.getItem() == Item.getItemOf(Blocks.AIR)) && itemstack != null) {
if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.cloneItemStack();
@@ -394,6 +418,11 @@
@@ -385,6 +409,11 @@
}
public boolean damageEntity(DamageSource damagesource, float f) {

View File

@ -1,19 +1,20 @@
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
@@ -5,6 +5,12 @@
@@ -5,6 +5,13 @@
import java.util.List;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
public abstract class EntityArrow extends Entity implements IProjectile {
private static final Predicate<Entity> f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() {
@@ -50,6 +56,7 @@
@@ -50,6 +57,7 @@
public EntityArrow(World world, EntityLiving entityliving) {
this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
this.shooter = entityliving;
@ -21,7 +22,7 @@
if (entityliving instanceof EntityHuman) {
this.fromPlayer = EntityArrow.PickupStatus.ALLOWED;
}
@@ -236,7 +243,7 @@
@@ -236,7 +244,7 @@
protected void a(MovingObjectPosition movingobjectposition) {
Entity entity = movingobjectposition.entity;
@ -30,7 +31,7 @@
if (entity != null) {
float f = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
int i = MathHelper.f((double) f * this.damage);
@@ -254,7 +261,13 @@
@@ -254,7 +262,13 @@
}
if (this.isBurning() && !(entity instanceof EntityEnderman)) {
@ -45,7 +46,7 @@
}
if (entity.damageEntity(damagesource, (float) i)) {
@@ -410,6 +423,20 @@
@@ -422,6 +436,20 @@
public void d(EntityHuman entityhuman) {
if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
@ -66,16 +67,19 @@
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
@@ -468,6 +495,12 @@
return (b0 & 1) != 0;
}
@@ -493,7 +521,14 @@
}
+ // CraftBukkit start
+ public boolean isInGround() {
+ return inGround;
+ }
+ // CraftBukkit end
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) {
- this.setOnFire(100);
+ // CraftBukkit start - call EntityCombustEvent
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 100);
+ this.world.getServer().getPluginManager().callEvent(event);
+
public static enum PickupStatus {
+ if (!event.isCancelled()) {
+ this.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
}
DISALLOWED, ALLOWED, CREATIVE_ONLY;
}

View File

@ -17,8 +17,8 @@
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
@@ -32,6 +41,14 @@
private EntityBoat.EnumStatus aI;
private double aJ;
private EntityBoat.EnumStatus aH;
private double aI;
+ // CraftBukkit start
+ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
@ -101,16 +101,15 @@
super.collide(entity);
}
@@ -158,6 +214,8 @@
@@ -158,6 +214,7 @@
return this.getDirection().e();
}
+ private Location lastLocation; // CraftBukkit
+
public void m() {
this.aI = this.aH;
this.aH = this.t();
@@ -178,7 +236,6 @@
public void A_() {
this.aH = this.aG;
this.aG = this.t();
@@ -178,7 +235,6 @@
if (this.n() > 0.0F) {
this.setDamage(this.n() - 1.0F);
}
@ -118,7 +117,7 @@
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
@@ -202,6 +259,22 @@
@@ -202,6 +258,22 @@
this.motZ = 0.0D;
}
@ -141,7 +140,7 @@
for (int i = 0; i <= 1; ++i) {
if (this.a(i)) {
this.f[i] = (float) ((double) this.f[i] + 0.01D);
@@ -599,6 +672,11 @@
@@ -593,6 +665,11 @@
this.e(this.fallDistance, 1.0F);
if (!this.world.isClientSide && !this.dead) {
@ -153,7 +152,7 @@
this.die();
if (this.world.getGameRules().getBoolean("doEntityDrops")) {
int i;
@@ -612,6 +690,7 @@
@@ -606,6 +683,7 @@
}
}
}

View File

@ -10,15 +10,15 @@
+ }
+ // CraftBukkit end
super.n();
this.bB = this.bx;
this.bz = this.by;
this.bA = this.bw;
this.by = this.bx;
@@ -61,7 +66,9 @@
this.bx += this.bC * 2.0F;
if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bD <= 0) {
this.a(SoundEffects.aa, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.bw += this.bB * 2.0F;
if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bC <= 0) {
this.a(SoundEffects.ac, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.a(Items.EGG, 1);
+ this.forceDrops = false; // CraftBukkit
this.bD = this.random.nextInt(6000) + 6000;
this.bC = this.random.nextInt(6000) + 6000;
}

View File

@ -11,10 +11,10 @@
public class EntityCow extends EntityAnimal {
@@ -57,12 +61,22 @@
@@ -59,13 +63,23 @@
ItemStack itemstack = entityhuman.b(enumhand);
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
+ // 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(), null, itemstack, Items.MILK_BUCKET);
@ -24,12 +24,12 @@
+ }
+
+ ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
entityhuman.a(SoundEffects.ap, 1.0F, 1.0F);
- if (--itemstack.count == 0) {
entityhuman.a(SoundEffects.ar, 1.0F, 1.0F);
itemstack.subtract(1);
if (itemstack.isEmpty()) {
- entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET));
- } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
- entityhuman.drop(new ItemStack(Items.MILK_BUCKET), false);
+ if (--itemstack.count <= 0) {
+ entityhuman.a(enumhand, result);
+ } else if (!entityhuman.inventory.pickup(result)) {
+ entityhuman.drop(result, false);

View File

@ -10,8 +10,8 @@
+
public abstract class EntityCreature extends EntityInsentient {
public static final UUID bv = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
@@ -71,6 +75,7 @@
public static final UUID bu = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
@@ -68,6 +72,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) {
@ -19,11 +19,11 @@
this.unleash(true, true);
}
@@ -103,6 +108,7 @@
}
@@ -76,6 +81,7 @@
this.q(f);
if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
} else if (!this.isLeashed() && this.bx) {
this.goalSelector.c(1);
} else if (f > 6.0F) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityCreeper.java
+++ b/net/minecraft/server/EntityCreeper.java
@@ -1,6 +1,10 @@
package net.minecraft.server;
@@ -3,6 +3,10 @@
import java.util.Collection;
import java.util.Iterator;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,7 +11,7 @@
public class EntityCreeper extends EntityMonster {
@@ -123,7 +127,7 @@
@@ -125,7 +129,7 @@
}
public void die(DamageSource damagesource) {
@ -20,7 +20,7 @@
if (this.world.getGameRules().getBoolean("doMobLoot")) {
if (damagesource.getEntity() instanceof EntitySkeleton) {
int i = Item.getId(Items.RECORD_13);
@@ -136,6 +140,7 @@
@@ -138,6 +142,7 @@
this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
}
}
@ -28,7 +28,7 @@
}
@@ -162,9 +167,19 @@
@@ -164,9 +169,19 @@
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
@ -46,23 +46,25 @@
+ }
+ // CraftBukkit end
+
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
this.world.a(entityhuman, this.locX, this.locY, this.locZ, SoundEffects.by, this.bC(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F);
@@ -184,9 +199,17 @@
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -188,10 +203,18 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;
- this.aV = true;
- this.aU = true;
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
- this.die();
- this.do_();
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.aV = true;
+ this.aU = true;
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
+ this.die();
+ this.do_();
+ } else {
+ fuseTicks = 0;
+ }

View File

@ -2,7 +2,7 @@
+++ b/net/minecraft/server/EntityDamageSourceIndirect.java
@@ -29,4 +29,10 @@
return itemstack != null && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.B()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent});
return !itemstack.isEmpty() && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent});
}
+
+ // CraftBukkit start

View File

@ -13,54 +13,50 @@
public class EntityEgg extends EntityProjectile {
public EntityEgg(World world) {
@@ -23,21 +30,37 @@
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F);
@@ -24,20 +31,40 @@
}
- if (!this.world.isClientSide && this.random.nextInt(8) == 0) {
- byte b0 = 1;
+ // CraftBukkit start - Fire PlayerEggThrowEvent
+ boolean hatching = !this.world.isClientSide && this.random.nextInt(8) == 0;
+ int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1;
+ if (!hatching) {
+ numHatching = 0;
+ }
+
+ EntityType hatchingType = EntityType.CHICKEN;
+
+ Entity shooter = this.getShooter();
+ if (shooter instanceof EntityPlayer) {
+ Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity();
+
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ hatching = event.isHatching();
+ numHatching = event.getNumHatches();
+ hatchingType = event.getHatchingType();
+ }
if (!this.world.isClientSide) {
- if (this.random.nextInt(8) == 0) {
+ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit
+ if (true) {
byte b0 = 1;
- if (this.random.nextInt(32) == 0) {
- b0 = 4;
- }
-
- for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = new EntityChicken(this.world);
-
- entitychicken.setAgeRaw(-24000);
- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
- this.world.addEntity(entitychicken);
- }
+ if (hatching) {
+ for (int k = 0; k < numHatching; k++) {
+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass());
+ if (entity.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entity.getBukkitEntity()).setBaby();
if (this.random.nextInt(32) == 0) {
b0 = 4;
}
- for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = new EntityChicken(this.world);
+ // CraftBukkit start
+ if (!hatching) {
+ b0 = 0;
+ }
+ EntityType hatchingType = EntityType.CHICKEN;
+
+ Entity shooter = this.getShooter();
+ if (shooter instanceof EntityPlayer) {
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ b0 = event.getNumHatches();
+ hatching = event.isHatching();
+ hatchingType = event.getHatchingType();
+ }
+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ }
}
+ // CraftBukkit end
double d0 = 0.08D;
- entitychicken.setAgeRaw(-24000);
- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
- this.world.addEntity(entitychicken);
+ if (hatching) {
+ for (int i = 0; i < b0; ++i) {
+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass());
+ if (entity.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entity.getBukkitEntity()).setBaby();
+ }
+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ }
}
+ // CraftBukkit end
}
this.world.broadcastEntityEffect(this, (byte) 3);

View File

@ -12,16 +12,16 @@
+// PAIL: Fixme
public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster {
private static final Logger bJ = LogManager.getLogger();
private static final Logger bI = LogManager.getLogger();
@@ -33,6 +38,7 @@
private final PathPoint[] bO = new PathPoint[24];
private final int[] bP = new int[24];
private final Path bQ = new Path();
private final PathPoint[] bN = new PathPoint[24];
private final int[] bO = new int[24];
private final Path bP = new Path();
+ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
public EntityEnderDragon(World world) {
super(world);
@@ -170,7 +176,7 @@
@@ -171,7 +177,7 @@
Vec3D vec3d = idragoncontroller.g();
@ -30,7 +30,7 @@
d0 = vec3d.x - this.locX;
d1 = vec3d.y - this.locY;
d2 = vec3d.z - this.locZ;
@@ -314,7 +320,14 @@
@@ -327,7 +333,14 @@
if (this.currentEnderCrystal.dead) {
this.currentEnderCrystal = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
@ -46,7 +46,7 @@
}
}
@@ -387,6 +400,10 @@
@@ -400,6 +413,10 @@
int j1 = MathHelper.floor(axisalignedbb.f);
boolean flag = false;
boolean flag1 = false;
@ -57,7 +57,7 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
@@ -400,7 +417,11 @@
@@ -413,7 +430,11 @@
flag = true;
} else if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.END_PORTAL && block != Blocks.END_PORTAL_FRAME) {
if (block != Blocks.COMMAND_BLOCK && block != Blocks.dc && block != Blocks.dd && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) {
@ -70,7 +70,7 @@
} else {
flag = true;
}
@@ -412,6 +433,41 @@
@@ -425,6 +446,41 @@
}
}

View File

@ -36,7 +36,7 @@
}
@@ -320,8 +333,12 @@
@@ -317,8 +330,12 @@
boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition);
if (EntityEnderman.c.contains(block) && flag) {
@ -51,7 +51,7 @@
}
}
@@ -351,8 +368,12 @@
@@ -348,8 +365,12 @@
IBlockData iblockdata2 = this.a.getCarried();
if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) {

View File

@ -14,8 +14,8 @@
public int a;
@@ -34,6 +40,7 @@
public void m() {
super.m();
public void A_() {
super.A_();
+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
if (this.c > 0) {
--this.c;
@ -45,8 +45,8 @@
+ // CraftBukkit end
}
this.move(this.motX, this.motY, this.motZ);
@@ -154,7 +173,7 @@
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
@@ -153,7 +172,7 @@
}
if (this.value > 0) {
@ -55,7 +55,7 @@
}
this.die();
@@ -176,6 +195,24 @@
@@ -175,6 +194,24 @@
}
public static int getOrbValue(int i) {

View File

@ -31,9 +31,9 @@
if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) {
this.die();
if (!this.f) {
- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) {
- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) {
+ // CraftBukkit start
+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) {
+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
+ return;
+ }
@ -42,7 +42,7 @@
if (block instanceof BlockFalling) {
((BlockFalling) block).a_(this.world, blockposition);
}
@@ -154,7 +162,9 @@
@@ -156,7 +164,9 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

View File

@ -7,8 +7,8 @@
+
public abstract class EntityFireball extends Entity {
private int e = -1;
@@ -13,6 +15,8 @@
public EntityLiving shooter;
@@ -8,6 +10,8 @@
public double dirX;
public double dirY;
public double dirZ;
@ -17,7 +17,7 @@
public EntityFireball(World world) {
super(world);
@@ -36,12 +40,19 @@
@@ -31,12 +35,19 @@
public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(world);
this.shooter = entityliving;
@ -37,7 +37,7 @@
d0 += this.random.nextGaussian() * 0.4D;
d1 += this.random.nextGaussian() * 0.4D;
d2 += this.random.nextGaussian() * 0.4D;
@@ -85,6 +96,12 @@
@@ -61,6 +72,12 @@
if (movingobjectposition != null) {
this.a(movingobjectposition);
@ -50,7 +50,7 @@
}
this.locX += this.motX;
@@ -191,6 +208,11 @@
@@ -150,6 +167,11 @@
} else {
this.ap();
if (damagesource.getEntity() != null) {
@ -62,7 +62,7 @@
Vec3D vec3d = damagesource.getEntity().aB();
if (vec3d != null) {
@@ -204,6 +226,7 @@
@@ -163,6 +185,7 @@
if (damagesource.getEntity() instanceof EntityLiving) {
this.shooter = (EntityLiving) damagesource.getEntity();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityFireworks.java
+++ b/net/minecraft/server/EntityFireworks.java
@@ -80,7 +80,7 @@
@@ -77,7 +77,7 @@
}
if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) {

View File

@ -1,52 +1,51 @@
--- a/net/minecraft/server/EntityFishingHook.java
+++ b/net/minecraft/server/EntityFishingHook.java
@@ -3,6 +3,12 @@
@@ -2,6 +2,11 @@
import java.util.Iterator;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Fish;
+import org.bukkit.event.player.PlayerFishEvent;
+// CraftBukkit end
+
public class EntityFishingHook extends Entity {
private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityFishingHook.class, DataWatcherRegistry.b);
@@ -193,6 +199,7 @@
}
@@ -220,6 +225,7 @@
vec3d = new Vec3D(this.locX, this.locY, this.locZ);
vec3d1 = new Vec3D(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
vec3d1 = new Vec3D(movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z);
}
if (movingobjectposition != null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
if (movingobjectposition.entity != null) {
this.hooked = movingobjectposition.entity;
this.getDataWatcher().set(EntityFishingHook.c, Integer.valueOf(this.hooked.getId() + 1));
@@ -266,6 +273,10 @@
if (this.au <= 0) {
this.av = 0;
this.aw = 0;
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ // CraftBukkit end
}
} else {
double d10;
@@ -278,6 +289,13 @@
if (this.aw > 0) {
this.aw -= l;
if (this.aw <= 0) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ if (playerFishEvent.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.motY -= 0.20000000298023224D;
this.a(SoundEffects.G, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
f2 = (float) MathHelper.floor(this.getBoundingBox().b);
@@ -390,6 +408,14 @@
@@ -283,6 +289,10 @@
if (this.g <= 0) {
this.h = 0;
this.at = 0;
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ // CraftBukkit end
} else {
this.motY -= 0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat();
}
@@ -318,6 +328,13 @@
worldserver.a(EnumParticle.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]);
}
} else {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ if (playerFishEvent.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.motY = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F));
this.a(SoundEffects.H, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
double d3 = this.getBoundingBox().b + 0.5D;
@@ -374,6 +391,14 @@
int i = 0;
if (this.hooked != null) {
@ -61,7 +60,7 @@
this.k();
this.world.broadcastEntityEffect(this, (byte) 31);
i = this.hooked instanceof EntityItem ? 3 : 5;
@@ -402,6 +428,15 @@
@@ -386,6 +411,15 @@
while (iterator.hasNext()) {
ItemStack itemstack = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
@ -77,7 +76,7 @@
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
@@ -412,15 +447,36 @@
@@ -396,15 +430,36 @@
entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D;
entityitem.motZ = d2 * 0.1D;
this.world.addEntity(entityitem);
@ -114,4 +113,4 @@
+ // CraftBukkit end
this.die();
this.owner.hookedFish = null;
return i;

View File

@ -146,7 +146,7 @@
this.a(damagesource.getEntity());
@@ -151,6 +198,18 @@
public void move(double d0, double d1, double d2) {
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (this.dead) return; // CraftBukkit
+
@ -166,7 +166,7 @@
@@ -158,7 +217,7 @@
}
public void g(double d0, double d1, double d2) {
public void f(double d0, double d1, double d2) {
- if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
this.die();

View File

@ -1,32 +1,31 @@
--- a/net/minecraft/server/EntityHorse.java
+++ b/net/minecraft/server/EntityHorse.java
@@ -7,6 +7,8 @@
--- a/net/minecraft/server/EntityHorseAbstract.java
+++ b/net/minecraft/server/EntityHorseAbstract.java
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable {
private static final Predicate<Entity> bD = new Predicate() {
@@ -52,6 +54,7 @@
private int ce;
private String cf;
private final String[] cg = new String[3];
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable {
@@ -39,6 +40,7 @@
private float bS;
protected boolean bE = true;
protected int bF;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
public EntityHorse(World world) {
public EntityHorseAbstract(World world) {
super(world);
@@ -320,7 +323,7 @@
public void loadChest() {
@@ -214,7 +216,7 @@
protected void dx() {
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN());
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN(), this); // CraftBukkit
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.di());
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.di(), this); // CraftBukkit
this.inventoryChest.a(this.getName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
@@ -473,7 +476,7 @@
@@ -354,7 +356,7 @@
}
public int getMaxDomestication() {
@ -34,31 +33,34 @@
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
protected float ch() {
@@ -563,7 +566,7 @@
}
protected float ci() {
@@ -414,7 +416,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -654,11 +657,11 @@
@@ -465,7 +467,7 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // Moved down
if (!this.world.isClientSide) {
this.dropChest();
if (!this.world.isClientSide && this.inventoryChest != null) {
for (int i = 0; i < this.inventoryChest.getSize(); ++i) {
ItemStack itemstack = this.inventoryChest.getItem(i);
@@ -476,6 +478,7 @@
}
}
-
+ super.die(damagesource); // CraftBukkit
}
public void n() {
@@ -669,7 +672,7 @@
@@ -486,7 +489,7 @@
super.n();
if (!this.world.isClientSide) {
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
@ -66,29 +68,28 @@
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
}
if (!this.dr() && !this.isVehicle() && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) {
@@ -929,6 +932,7 @@
if (this.dE()) {
@@ -719,6 +722,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
if (this.hasChest()) {
NBTTagList nbttaglist = new NBTTagList();
@@ -984,6 +988,12 @@
if (!this.inventoryChest.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
@@ -745,6 +749,11 @@
if (!s.isEmpty()) {
this.setOwnerUUID(UUID.fromString(s));
}
+ // CraftBukkit start
+ if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
+ this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
+ }
+ // CraftBukkit end
+
AttributeInstance attributeinstance = this.getAttributeMap().a("Speed");
if (attributeinstance != null) {
@@ -1156,6 +1166,18 @@
@@ -797,6 +806,18 @@
}
public void b(int i) {
@ -105,5 +106,5 @@
+ }
+ // CraftBukkit end
this.canSlide = true;
this.setStanding();
this.dL();
}

View File

@ -1,13 +1,12 @@
--- a/net/minecraft/server/EntityHuman.java
+++ b/net/minecraft/server/EntityHuman.java
@@ -10,6 +10,19 @@
@@ -9,6 +9,18 @@
import java.util.UUID;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftItem;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerBedEnterEvent;
@ -20,17 +19,21 @@
public abstract class EntityHuman extends EntityLiving {
private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
@@ -20,7 +33,7 @@
private InventoryEnderChest enderChest = new InventoryEnderChest();
@@ -16,10 +28,10 @@
protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
protected static final DataWatcherObject<Byte> br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
public PlayerInventory inventory = new PlayerInventory(this);
- private InventoryEnderChest enderChest = new InventoryEnderChest();
+ private InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
public Container defaultContainer;
public Container activeContainer;
- protected FoodMetaData foodData = new FoodMetaData();
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
protected int bx;
protected int bw;
public float bx;
public float by;
public float bz;
@@ -52,6 +65,17 @@
private final ItemCooldown bW = this.l();
@@ -52,6 +64,17 @@
@Nullable
public EntityFishingHook hookedFish;
+ // CraftBukkit start
@ -47,7 +50,7 @@
protected ItemCooldown l() {
return new ItemCooldown();
}
@@ -307,7 +331,8 @@
@@ -312,7 +335,8 @@
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
@ -57,7 +60,7 @@
}
if (this.foodData.c() && this.ticksLived % 10 == 0) {
@@ -331,7 +356,7 @@
@@ -336,7 +360,7 @@
this.l((float) attributeinstance.getValue());
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
@ -66,7 +69,7 @@
if (f > 0.1F) {
f = 0.1F;
@@ -423,28 +448,34 @@
@@ -442,28 +466,34 @@
public void b(Entity entity, int i) {
if (entity != this) {
this.addScore(i);
@ -107,7 +110,7 @@
String s = entity instanceof EntityHuman ? entity.getName() : entity.bf();
ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName());
@@ -469,7 +500,10 @@
@@ -488,7 +518,10 @@
int j = scoreboardteam1.m().b();
if (j >= 0 && j < IScoreboardCriteria.m.length) {
@ -119,15 +122,15 @@
}
}
@@ -478,6 +512,7 @@
@@ -497,6 +530,7 @@
@Nullable
public EntityItem a(boolean flag) {
+ // Called only when dropped by Q or CTRL-Q
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true);
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true);
}
@@ -522,6 +557,30 @@
@@ -539,6 +573,30 @@
entityitem.motZ += Math.sin((double) f1) * (double) f;
}
@ -158,7 +161,7 @@
ItemStack itemstack1 = this.a(entityitem);
if (flag1) {
@@ -630,6 +689,13 @@
@@ -646,6 +704,13 @@
this.a(true, true, false);
}
@ -172,20 +175,15 @@
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
this.f = nbttagcompound.getBoolean("SpawnForced");
@@ -667,6 +733,12 @@
@@ -683,6 +748,7 @@
this.foodData.b(nbttagcompound);
this.abilities.a(nbttagcompound);
nbttagcompound.set("EnderItems", this.enderChest.h());
+ ItemStack itemstack = this.inventory.getItemInHand();
+
+ if (itemstack != null && itemstack.getItem() != null) {
+ nbttagcompound.set("SelectedItem", itemstack.save(new NBTTagCompound()));
+ }
nbttagcompound.set("EnderItems", this.enderChest.i());
+ nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
}
public boolean damageEntity(DamageSource damagesource, float f) {
@@ -685,7 +757,7 @@
@@ -701,7 +767,7 @@
if (damagesource.r()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
@ -194,7 +192,7 @@
}
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
@@ -697,16 +769,35 @@
@@ -713,7 +779,7 @@
}
}
@ -203,6 +201,8 @@
}
}
}
@@ -727,10 +793,29 @@
}
public boolean a(EntityHuman entityhuman) {
- ScoreboardTeamBase scoreboardteambase = this.aQ();
@ -234,8 +234,8 @@
}
protected void damageArmor(float f) {
@@ -750,7 +841,12 @@
return (float) i / (float) this.inventory.armor.length;
@@ -773,7 +858,12 @@
return (float) i / (float) this.inventory.armor.size();
}
- protected void damageEntity0(DamageSource damagesource, float f) {
@ -248,7 +248,7 @@
if (!this.isInvulnerable(damagesource)) {
f = this.applyArmorModifier(damagesource, f);
f = this.applyMagicModifier(damagesource, f);
@@ -770,6 +866,7 @@
@@ -793,6 +883,7 @@
}
}
@ -256,7 +256,7 @@
}
public void openSign(TileEntitySign tileentitysign) {}
@@ -894,8 +991,15 @@
@@ -914,8 +1005,15 @@
if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isBurning()) {
@ -274,7 +274,7 @@
}
}
@@ -925,8 +1029,11 @@
@@ -945,8 +1043,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) {
@ -287,7 +287,7 @@
}
}
@@ -935,11 +1042,28 @@
@@ -955,11 +1056,28 @@
}
if (entity instanceof EntityPlayer && entity.velocityChanged) {
@ -316,19 +316,9 @@
}
if (flag2) {
@@ -1001,7 +1125,8 @@
@@ -1012,7 +1130,14 @@
if (itemstack3 != null && object instanceof EntityLiving) {
itemstack3.a((EntityLiving) object, this);
- if (itemstack3.count <= 0) {
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
+ if (itemstack3.count == 0) {
this.a(EnumHand.MAIN_HAND, (ItemStack) null);
}
}
@@ -1011,7 +1136,14 @@
this.a(StatisticList.y, Math.round(f5 * 10.0F));
this.a(StatisticList.y, Math.round(f4 * 10.0F));
if (j > 0) {
- entity.setOnFire(j * 4);
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
@ -341,8 +331,8 @@
+ // CraftBukkit end
}
if (this.world instanceof WorldServer && f5 > 2.0F) {
@@ -1100,6 +1232,20 @@
if (this.world instanceof WorldServer && f4 > 2.0F) {
@@ -1118,6 +1243,20 @@
this.stopRiding();
}
@ -362,8 +352,8 @@
+
this.setSize(0.2F, 0.2F);
if (this.world.isLoaded(blockposition)) {
EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
@@ -1184,6 +1330,23 @@
float f = 0.5F + (float) enumdirection.getAdjacentX() * 0.4F;
@@ -1177,6 +1316,23 @@
this.world.everyoneSleeping();
}
@ -387,7 +377,7 @@
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
this.setRespawnPosition(this.bedPosition, false);
@@ -1235,9 +1398,11 @@
@@ -1228,9 +1384,11 @@
if (blockposition != null) {
this.e = blockposition;
this.f = flag;

View File

@ -16,7 +16,7 @@
public abstract class EntityInsentient extends EntityLiving {
private static final DataWatcherObject<Byte> a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
@@ -52,6 +61,9 @@
@@ -57,6 +66,9 @@
this.r();
}
@ -26,20 +26,7 @@
}
protected void r() {}
@@ -66,9 +78,10 @@
}
public float a(PathType pathtype) {
- Float float = (Float) this.bB.get(pathtype);
+ // CraftBukkit - decompile error
+ Float ofloat = (Float) this.bB.get(pathtype);
- return float == null ? pathtype.a() : float.floatValue();
+ return ofloat == null ? pathtype.a() : ofloat.floatValue();
}
public void a(PathType pathtype, float f) {
@@ -105,7 +118,38 @@
@@ -110,7 +122,38 @@
}
public void setGoalTarget(@Nullable EntityLiving entityliving) {
@ -78,7 +65,7 @@
}
public boolean d(Class<? extends EntityLiving> oclass) {
@@ -350,11 +394,20 @@
@@ -340,11 +383,20 @@
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
@ -101,7 +88,7 @@
NBTTagList nbttaglist;
int i;
@@ -579,11 +632,11 @@
@@ -569,11 +621,11 @@
double d2 = entityhuman.locZ - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
@ -115,9 +102,9 @@
this.die();
} else if (d3 < 1024.0D) {
this.ticksFarFromPlayer = 0;
@@ -965,9 +1018,21 @@
@@ -942,12 +994,24 @@
public final boolean a(EntityHuman entityhuman, @Nullable ItemStack itemstack, EnumHand enumhand) {
public final boolean b(EntityHuman entityhuman, EnumHand enumhand) {
if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
@ -127,19 +114,22 @@
+ // CraftBukkit end
this.unleash(true, !entityhuman.abilities.canInstantlyBuild);
return true;
} else if (itemstack != null && itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
+ // CraftBukkit start - fire PlayerLeashEntityEvent
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
+ return false;
+ }
+ // CraftBukkit end
this.setLeashHolder(entityhuman, true);
--itemstack.count;
return true;
@@ -987,10 +1052,12 @@
} else {
ItemStack itemstack = entityhuman.b(enumhand);
if (this.bE) {
if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
+ // CraftBukkit start - fire PlayerLeashEntityEvent
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
+ return false;
+ }
+ // CraftBukkit end
this.setLeashHolder(entityhuman, true);
itemstack.subtract(1);
return true;
@@ -968,10 +1032,12 @@
if (this.bD) {
if (!this.isAlive()) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit
this.unleash(true, true);
@ -150,8 +140,8 @@
this.unleash(true, true);
}
}
@@ -1001,7 +1068,9 @@
this.bE = false;
@@ -982,7 +1048,9 @@
this.bD = false;
this.leashHolder = null;
if (!this.world.isClientSide && flag1) {
+ this.forceDrops = true; // CraftBukkit
@ -160,9 +150,9 @@
}
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
@@ -1071,6 +1140,7 @@
@@ -1052,6 +1120,7 @@
this.leashHolder = entityleash;
this.setLeashHolder(entityleash, true);
} else {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.unleash(false, true);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityIronGolem.java
+++ b/net/minecraft/server/EntityIronGolem.java
@@ -72,7 +72,7 @@
@@ -73,7 +73,7 @@
protected void C(Entity entity) {
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityItem.java
+++ b/net/minecraft/server/EntityItem.java
@@ -5,6 +5,7 @@
@@ -4,6 +4,7 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -8,7 +8,7 @@
public class EntityItem extends Entity {
@@ -16,6 +17,7 @@
@@ -15,6 +16,7 @@
private String g;
private String h;
public float a;
@ -16,7 +16,7 @@
public EntityItem(World world, double d0, double d1, double d2) {
super(world);
@@ -31,6 +33,11 @@
@@ -30,6 +32,11 @@
public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) {
this(world, d0, d1, d2);
@ -28,10 +28,10 @@
this.setItemStack(itemstack);
}
@@ -55,9 +62,12 @@
@@ -54,9 +61,12 @@
this.die();
} else {
super.m();
super.A_();
- if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
- --this.pickupDelay;
- }
@ -44,7 +44,7 @@
this.lastX = this.locX;
this.lastY = this.locY;
@@ -96,12 +106,20 @@
@@ -104,9 +114,11 @@
this.motY *= -0.5D;
}
@ -55,6 +55,10 @@
+ // Craftbukkit end */
this.ak();
if (!this.world.isClientSide) {
@@ -121,6 +133,12 @@
}
if (!this.world.isClientSide && this.age >= 6000) {
+ // CraftBukkit start - fire ItemDespawnEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
@ -65,16 +69,16 @@
this.die();
}
@@ -143,6 +161,7 @@
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
@@ -162,6 +180,7 @@
} else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) {
return false;
} else {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(this, entityitem).isCancelled()) return false; // CraftBukkit
itemstack1.count += itemstack.count;
itemstack1.add(itemstack.getCount());
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
entityitem.age = Math.min(entityitem.age, this.age);
@@ -189,6 +208,11 @@
} else if (this.getItemStack() != null && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) {
@@ -208,6 +227,11 @@
} else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) {
return false;
} else {
+ // CraftBukkit start
@ -85,40 +89,33 @@
this.ap();
this.f = (int) ((float) this.f - f);
if (this.f <= 0) {
@@ -238,7 +262,18 @@
@@ -257,6 +281,12 @@
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item");
- this.setItemStack(ItemStack.createStack(nbttagcompound1));
+ // CraftBukkit start - Handle missing "Item" compounds
+ if (nbttagcompound1 != null) {
+ ItemStack itemstack = ItemStack.createStack(nbttagcompound1);
+ if (itemstack != null) {
+ this.setItemStack(itemstack);
+ } else {
+ this.die();
+ }
+ } else {
+ if (nbttagcompound1 == null) {
+ this.die();
+ return;
+ }
+ // CraftBukkit end
if (this.getItemStack() == null) {
this.setItemStack(new ItemStack(nbttagcompound1));
if (this.getItemStack().isEmpty()) {
this.die();
}
@@ -250,6 +285,26 @@
ItemStack itemstack = this.getItemStack();
int i = itemstack.count;
@@ -270,6 +300,26 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
+ // CraftBukkit start - fire PlayerPickupItemEvent
+ int canHold = entityhuman.inventory.canHold(itemstack);
+ int remaining = itemstack.count - canHold;
+ int remaining = i - canHold;
+
+ if (this.pickupDelay <= 0 && canHold > 0) {
+ itemstack.count = canHold;
+ itemstack.setCount(canHold);
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
+ itemstack.count = canHold + remaining;
+ itemstack.setCount(canHold + remaining);
+
+ if (event.isCancelled()) {
+ return;
@ -130,5 +127,5 @@
+ // CraftBukkit end
+
if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) {
if (itemstack.getItem() == Item.getItemOf(Blocks.LOG)) {
if (item == Item.getItemOf(Blocks.LOG)) {
entityhuman.b((Statistic) AchievementList.g);

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityItemFrame.java
+++ b/net/minecraft/server/EntityItemFrame.java
@@ -32,6 +32,11 @@
@@ -31,6 +31,11 @@
return false;
} else if (!damagesource.isExplosion() && this.getItem() != null) {
} else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
if (!this.world.isClientSide) {
+ // CraftBukkit start - fire EntityDamageEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) {
@ -10,5 +10,5 @@
+ }
+ // CraftBukkit end
this.b(damagesource.getEntity(), false);
this.a(SoundEffects.cX, 1.0F, 1.0F);
this.setItem((ItemStack) null);
this.a(SoundEffects.dh, 1.0F, 1.0F);
this.setItem(ItemStack.a);

View File

@ -8,20 +8,19 @@
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
@@ -74,6 +76,12 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ continue;
+ }
+ // CraftBukkit end
entityinsentient.setLeashHolder(this, true);
flag = true;
}
@@ -81,8 +89,11 @@
@@ -71,22 +73,42 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ continue;
+ }
+ // CraftBukkit end
entityinsentient.setLeashHolder(this, true);
flag = true;
}
}
if (!flag) {
@ -32,10 +31,8 @@
+ boolean die = true;
+ // CraftBukkit end
+ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well
d0 = 7.0D;
list = this.world.a(EntityInsentient.class, new AxisAlignedBB(this.locX - 7.0D, this.locY - 7.0D, this.locZ - 7.0D, this.locX + 7.0D, this.locY + 7.0D, this.locZ + 7.0D));
iterator = list.iterator();
@@ -90,9 +101,20 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {

View File

@ -46,12 +46,12 @@
}
}
@@ -41,7 +53,24 @@
public void m() {
super.m();
public void A_() {
super.A_();
if (this.lifeTicks == 2) {
- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dn, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dx, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ // CraftBukkit start - Use relative location for far away sounds
+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dn, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dv, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ float pitch = 0.8F + this.random.nextFloat() * 0.2F;
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) (List) this.world.players) {
@ -62,13 +62,13 @@
+ double deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance;
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dn, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
+ } else {
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dn, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch));
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch));
+ }
+ }
+ // CraftBukkit end
this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dm, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dw, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
@@ -57,13 +86,17 @@

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityLiving.java
+++ b/net/minecraft/server/EntityLiving.java
@@ -10,6 +10,22 @@
import java.util.UUID;
import javax.annotation.Nullable;
@@ -13,6 +13,24 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.ArrayList;
@ -12,18 +12,20 @@
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import org.bukkit.event.entity.EntityResurrectEvent;
+import org.bukkit.event.entity.EntityTeleportEvent;
+import org.bukkit.event.player.PlayerItemConsumeEvent;
+// CraftBukkit end
+
public abstract class EntityLiving extends Entity {
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -83,6 +99,14 @@
private static final Logger a = LogManager.getLogger();
@@ -87,6 +105,14 @@
private BlockPosition bE;
private DamageSource bF;
private long bG;
@ -38,17 +40,17 @@
public void Q() {
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
@@ -91,7 +115,8 @@
public EntityLiving(World world) {
super(world);
@@ -101,7 +127,8 @@
this.updateEffects = true;
this.activeItem = ItemStack.a;
this.initAttributes();
- this.setHealth(this.getMaxHealth());
+ // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
+ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue());
this.i = true;
this.aN = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.setPosition(this.locX, this.locY, this.locZ);
@@ -129,7 +154,13 @@
@@ -139,7 +166,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1);
@ -63,7 +65,7 @@
}
}
@@ -191,7 +222,11 @@
@@ -201,7 +234,11 @@
this.stopRiding();
}
} else {
@ -76,7 +78,7 @@
}
if (!this.world.isClientSide) {
@@ -248,6 +283,18 @@
@@ -258,6 +295,18 @@
this.world.methodProfiler.b();
}
@ -95,9 +97,9 @@
protected void b(BlockPosition blockposition) {
int i = EnchantmentManager.a(Enchantments.j, this);
@@ -263,19 +310,19 @@
@@ -273,19 +322,19 @@
protected void bF() {
protected void bG() {
++this.deathTicks;
- if (this.deathTicks == 20) {
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
@ -105,14 +107,14 @@
- if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) {
- i = this.getExpValue(this.killer);
-
- while (i > 0) {
- int j = EntityExperienceOrb.getOrbValue(i);
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ i = this.expToDrop;
+ while (i > 0) {
+ int j = EntityExperienceOrb.getOrbValue(i);
- while (i > 0) {
- int j = EntityExperienceOrb.getOrbValue(i);
-
- i -= j;
- this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
- }
@ -124,7 +126,7 @@
this.die();
@@ -430,6 +477,17 @@
@@ -441,6 +490,17 @@
}
}
@ -132,9 +134,9 @@
+ if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
+ NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
+ if (nbtbase.getTypeId() == 5) {
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagFloat) nbtbase).h()); // PAIL: rename
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagFloat) nbtbase).asDouble());
+ } else if (nbtbase.getTypeId() == 3) {
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagInt) nbtbase).h()); // PAIL: rename
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagInt) nbtbase).asDouble());
+ }
+ }
+ // CraftBukkit end
@ -142,7 +144,7 @@
if (nbttagcompound.hasKeyOfType("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
@@ -449,9 +507,15 @@
@@ -463,9 +523,15 @@
}
@ -155,12 +157,12 @@
Iterator iterator = this.effects.keySet().iterator();
+ isTickingEffects = true; // CraftBukkit
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist);
@@ -465,6 +529,16 @@
this.a(mobeffect, false);
}
try {
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
@@ -483,6 +549,16 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
+ // CraftBukkit start
+ isTickingEffects = false;
@ -175,7 +177,7 @@
if (this.updateEffects) {
if (!this.world.isClientSide) {
@@ -562,6 +636,12 @@
@@ -580,6 +656,12 @@
}
public void addEffect(MobEffect mobeffect) {
@ -188,7 +190,7 @@
if (this.d(mobeffect)) {
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
@@ -594,6 +674,12 @@
@@ -612,6 +694,12 @@
@Nullable
public MobEffect c(@Nullable MobEffectList mobeffectlist) {
@ -201,7 +203,7 @@
return (MobEffect) this.effects.remove(mobeffectlist);
}
@@ -633,20 +719,52 @@
@@ -651,20 +739,52 @@
}
@ -255,27 +257,27 @@
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
}
@@ -662,14 +780,16 @@
@@ -680,14 +800,16 @@
} else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
} else {
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
f *= 0.75F;
}
- boolean flag = false;
+ boolean flag = f > 0.0F && this.d(damagesource); // Copied from below
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
- if (f > 0.0F && this.d(damagesource)) {
- if (f > 0.0F && this.applyBlockingModifier(damagesource)) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && f > 0.0F && this.d(damagesource)) {
this.k(f);
if (damagesource.a()) {
f = 0.0F;
@@ -688,20 +808,39 @@
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
this.damageShield(f);
f = 0.0F;
if (!damagesource.a()) {
@@ -706,20 +828,39 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) {
@ -301,8 +303,8 @@
- this.damageEntity0(damagesource, f);
+ // this.damageEntity0(damagesource, f);
+ // CraftBukkit end
this.aA = 10;
this.hurtTicks = this.aA;
this.az = 10;
this.hurtTicks = this.az;
}
+ // CraftBukkit start
@ -314,10 +316,25 @@
+ }
+ // CraftBukkit end
+
this.aB = 0.0F;
Entity entity = damagesource.getEntity();
this.aA = 0.0F;
Entity entity1 = damagesource.getEntity();
@@ -855,6 +994,12 @@
@@ -817,7 +958,13 @@
}
}
- if (flag) {
+ // CraftBukkit start
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
+ event.setCancelled(!flag);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ // CraftBukkit end
if (this instanceof EntityHuman) {
((EntityHuman) this).b(StatisticList.b(Items.cY));
}
@@ -914,6 +1061,12 @@
boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource);
@ -330,7 +347,7 @@
}
}
@@ -944,8 +1089,13 @@
@@ -1003,8 +1156,13 @@
int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) {
@ -345,7 +362,7 @@
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
int l = MathHelper.floor(this.locZ);
@@ -972,7 +1122,7 @@
@@ -1031,7 +1189,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) {
@ -354,7 +371,7 @@
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue());
}
@@ -985,7 +1135,8 @@
@@ -1044,7 +1202,8 @@
} else {
int i;
@ -364,7 +381,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1006,22 +1157,127 @@
@@ -1065,22 +1224,129 @@
}
}
@ -385,7 +402,7 @@
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(EnumItemSlot.HEAD) != null) {
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ return -(f - (f * 0.75F));
+
+ }
@ -398,7 +415,7 @@
+ Function<Double, Double> blocking = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ return -((EntityLiving.this.d(damagesource)) ? ((damagesource.a()) ? f : (f - (f * 0.33F))) : 0.0); // PAIL: rename
+ return -((EntityLiving.this.applyBlockingModifier(damagesource)) ? f : 0.0);
+ }
+ };
+ float blockingModifier = blocking.apply((double) f).floatValue();
@ -463,14 +480,13 @@
+ this.damageArmor(armorDamage);
+ }
+
+ // Apply blocking code
+ // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.k((float) event.getDamage()); // PAIL: rename
+ if (damagesource.i() instanceof EntityLiving) {// PAIL: rename
+ ((EntityLiving) damagesource.i()).a(EntityLiving.this, 0.5F, EntityLiving.this.locX - damagesource.i().locX, EntityLiving.this.locZ - damagesource.i().locZ);
+ }
+ if (f <= 0) {
+ return false;
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
+ Entity entity = damagesource.i();
+
+ if (entity instanceof EntityLiving) {
+ this.c((EntityLiving) entity);
+ }
+ }
+
@ -494,23 +510,26 @@
+ if (!human) {
+ this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
+ }
+
+ return true;
+ } else {
+ return event.getDamage(DamageModifier.BLOCKING) < 0;
+ // CraftBukkit end
}
+ return true;
}
+ return false; // CraftBukkit
}
public CombatTracker getCombatTracker() {
@@ -1088,6 +1344,7 @@
@@ -1147,6 +1413,7 @@
public AttributeMapBase getAttributeMap() {
if (this.br == null) {
this.br = new AttributeMapServer();
+ this.craftAttributes = new CraftAttributeMap(br); // CraftBukkit // PAIL: rename
if (this.attributeMap == null) {
this.attributeMap = new AttributeMapServer();
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
}
return this.br;
@@ -1376,6 +1633,7 @@
return this.attributeMap;
@@ -1438,6 +1705,7 @@
}
if (this.onGround && !this.world.isClientSide) {
@ -518,7 +537,7 @@
this.setFlag(7, false);
}
} else {
@@ -1736,6 +1994,7 @@
@@ -1798,6 +2066,7 @@
}
if (!this.world.isClientSide) {
@ -526,7 +545,7 @@
this.setFlag(7, flag);
}
@@ -1824,11 +2083,11 @@
@@ -1895,11 +2164,11 @@
}
public boolean isInteractable() {
@ -535,18 +554,18 @@
}
public boolean isCollidable() {
- return !this.dead;
+ return !this.dead && this.collides; // CraftBukkit
- return this.isAlive() && !this.m_();
+ return this.isAlive() && !this.m_() && this.collides; // CraftBukkit
}
protected void ap() {
@@ -1965,7 +2224,22 @@
@@ -2036,7 +2305,23 @@
protected void v() {
if (this.bo != null && this.cx()) {
this.a(this.bo, 16);
- ItemStack itemstack = this.bo.a(this.world, this);
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.a(this.activeItem, 16);
- this.a(this.cz(), this.activeItem.a(this.world, this));
+ // CraftBukkit start - fire PlayerItemConsumeEvent
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.bo); // PAIL: rename
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem);
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
+ world.getServer().getPluginManager().callEvent(event);
+
@ -559,12 +578,13 @@
+ return;
+ }
+
+ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.bo.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
+ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
+ this.a(this.cz(), itemstack);
+ // CraftBukkit end
this.cF();
}
if (itemstack != null && itemstack.count == 0) {
itemstack = null;
@@ -2051,10 +2325,18 @@
@@ -2115,10 +2400,18 @@
}
if (flag1) {

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/server/EntityLlamaSpit.java
+++ b/net/minecraft/server/EntityLlamaSpit.java
@@ -7,7 +7,7 @@
public class EntityLlamaSpit extends Entity implements IProjectile {
- public EntityLlama shooter;
+ public EntityLiving shooter; // CraftBukkit - type
private NBTTagCompound b;
public EntityLlamaSpit(World world) {

View File

@ -17,8 +17,8 @@
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b);
@@ -23,6 +32,17 @@
private double ax;
private double ay;
private double az;
+ // CraftBukkit start
+ public boolean slowWhenEmpty = true;
@ -79,10 +79,10 @@
this.az();
if (flag && !this.hasCustomName()) {
this.die();
@@ -150,6 +194,14 @@
@@ -146,6 +190,14 @@
}
public void m() {
public void A_() {
+ // CraftBukkit start
+ double prevX = this.locX;
+ double prevY = this.locY;
@ -94,16 +94,16 @@
if (this.getType() > 0) {
this.d(this.getType() - 1);
}
@@ -170,7 +222,7 @@
@@ -166,7 +218,7 @@
i = this.V();
if (this.al) {
if (this.ak) {
- if (minecraftserver.getAllowNether()) {
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled
if (!this.isPassenger() && this.am++ >= i) {
this.am = i;
if (!this.isPassenger() && this.al++ >= i) {
this.al = i;
this.portalCooldown = this.aE();
@@ -270,6 +322,18 @@
@@ -266,6 +318,18 @@
}
this.setYawPitch(this.yaw, this.pitch);
@ -122,7 +122,7 @@
if (this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D) {
List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this));
@@ -278,8 +342,24 @@
@@ -274,8 +338,24 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
@ -147,7 +147,7 @@
entity.collide(this);
}
}
@@ -291,6 +371,14 @@
@@ -287,6 +367,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) {
@ -162,7 +162,7 @@
entity1.collide(this);
}
}
@@ -301,7 +389,7 @@
@@ -297,7 +385,7 @@
}
protected double o() {
@ -171,7 +171,7 @@
}
public void a(int i, int j, int k, boolean flag) {}
@@ -312,16 +400,20 @@
@@ -308,16 +396,20 @@
this.motX = MathHelper.a(this.motX, -d0, d0);
this.motZ = MathHelper.a(this.motZ, -d0, d0);
if (this.onGround) {
@ -185,7 +185,7 @@
+ // CraftBukkit end
}
this.move(this.motX, this.motY, this.motZ);
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
if (!this.onGround) {
- this.motX *= 0.949999988079071D;
- this.motY *= 0.949999988079071D;
@ -198,7 +198,7 @@
}
}
@@ -509,7 +601,7 @@
@@ -505,7 +597,7 @@
}
protected void r() {
@ -207,7 +207,7 @@
this.motX *= 0.996999979019165D;
this.motY *= 0.0D;
this.motZ *= 0.996999979019165D;
@@ -854,4 +946,26 @@
@@ -780,4 +872,26 @@
}
}

View File

@ -1,16 +1,12 @@
--- a/net/minecraft/server/EntityMinecartCommandBlock.java
+++ b/net/minecraft/server/EntityMinecartCommandBlock.java
@@ -4,9 +4,12 @@
public class EntityMinecartCommandBlock extends EntityMinecartAbstract {
- private static final DataWatcherObject<String> a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d);
+ public static final DataWatcherObject<String> a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); // PAIL: private -> public
@@ -5,6 +5,9 @@
public static final DataWatcherObject<String> COMMAND = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d);
private static final DataWatcherObject<IChatBaseComponent> b = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.e);
private final CommandBlockListenerAbstract c = new CommandBlockListenerAbstract() {
+ {
+ this.sender = (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity(); // CraftBukkit - Set the sender
+ }
public void i() {
EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.a, this.getCommand());
EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.COMMAND, this.getCommand());
EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.b, this.l());

Some files were not shown because too many files have changed in this diff Show More