13
0
geforkt von Mirrors/Paper

Update to Minecraft 1.8

For more information please see http://www.spigotmc.org/
Dieser Commit ist enthalten in:
Thinkofdeath 2014-11-26 08:32:16 +11:00 committet von md_5
Ursprung a4805dbd77
Commit 24557bc2b3
628 geänderte Dateien mit 22151 neuen und 65098 gelöschten Zeilen

2
.gitignore vendored
Datei anzeigen

@ -5,12 +5,14 @@
# netbeans
/nbproject
nb*.xml
# we use maven!
/build.xml
# maven
/target
dependency-reduced-pom.xml
# vim
.*.sw[a-p]

16
makePatches.sh Ausführbare Datei
Datei anzeigen

@ -0,0 +1,16 @@
#!/bin/bash
if [ -z "$1" ]
then
echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
exit
fi
rm -f nms-patches/*
for file in $(ls src/main/java/net/minecraft/server)
do
echo "Diffing $file"
dos2unix -q $1/net/minecraft/server/$file $1/net/minecraft/server/$file
diff -u $1/net/minecraft/server/$file src/main/java/net/minecraft/server/$file > nms-patches/"$(echo $file | cut -d. -f1)".patch
done

Datei anzeigen

@ -0,0 +1,11 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BiomeTheEndDecorator.java 2014-11-27 08:59:46.501422728 +1100
+++ src/main/java/net/minecraft/server/BiomeTheEndDecorator.java 2014-11-27 08:42:10.136850942 +1100
@@ -21,7 +21,7 @@
EntityEnderDragon entityenderdragon = new EntityEnderDragon(this.a);
entityenderdragon.setPositionRotation(0.0D, 128.0D, 0.0D, this.b.nextFloat() * 360.0F, 0.0F);
- this.a.addEntity(entityenderdragon);
+ this.a.addEntity(entityenderdragon, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
}
}

23
nms-patches/Block.patch Normale Datei
Datei anzeigen

@ -0,0 +1,23 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/Block.java 2014-11-27 08:59:46.537422569 +1100
+++ src/main/java/net/minecraft/server/Block.java 2014-11-27 08:42:10.172850872 +1100
@@ -295,7 +295,8 @@
int j = this.getDropCount(i, world.random);
for (int k = 0; k < j; ++k) {
- if (world.random.nextFloat() <= f) {
+ // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions
+ if (world.random.nextFloat() < f) {
Item item = this.getDropType(iblockdata, world.random, i);
if (item != null) {
@@ -920,4 +921,10 @@
private static void a(int i, String s, Block block) {
a(i, new MinecraftKey(s), block);
}
+
+ // CraftBukkit start
+ public int getExpDrop(World world, IBlockData data, int enchantmentLevel) {
+ return 0;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,28 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockBloodStone.java 2014-11-27 08:59:46.505422709 +1100
+++ src/main/java/net/minecraft/server/BlockBloodStone.java 2014-11-27 08:42:10.124850965 +1100
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockBloodStone extends Block {
public BlockBloodStone() {
@@ -10,4 +12,17 @@
public MaterialMapColor g(IBlockData iblockdata) {
return MaterialMapColor.K;
}
+
+ // CraftBukkit start
+ @Override
+ public void doPhysics(World world, BlockPosition position, IBlockData iblockdata, Block block) {
+ if (block != null && block.isPowerSource()) {
+ org.bukkit.block.Block bl = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
+ int power = bl.getBlockPower();
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(bl, power, power);
+ world.getServer().getPluginManager().callEvent(event);
+ }
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,111 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockButtonAbstract.java 2014-11-27 08:59:46.505422709 +1100
+++ src/main/java/net/minecraft/server/BlockButtonAbstract.java 2014-11-27 08:42:10.160850895 +1100
@@ -3,6 +3,11 @@
import java.util.List;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
+
public abstract class BlockButtonAbstract extends Block {
public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
@@ -122,6 +127,19 @@
if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
return true;
} else {
+ // CraftBukkit start
+ boolean powered = ((Boolean) iblockdata.get(POWERED));
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = (powered) ? 15 : 0;
+ int current = (!powered) ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
+ return true;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
world.b(blockposition, blockposition);
world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
@@ -159,6 +177,16 @@
if (this.M) {
this.f(world, blockposition, iblockdata);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
this.b(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
@@ -192,8 +220,42 @@
List list = world.a(EntityArrow.class, new AxisAlignedBB((double) blockposition.getX() + this.minX, (double) blockposition.getY() + this.minY, (double) blockposition.getZ() + this.minZ, (double) blockposition.getX() + this.maxX, (double) blockposition.getY() + this.maxY, (double) blockposition.getZ() + this.maxZ));
boolean flag = !list.isEmpty();
boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue();
+
+ // CraftBukkit start - Call interact event when arrows turn on wooden buttons
+ if (flag1 != flag && flag) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ boolean allowed = false;
+
+ // If all of the events are cancelled block the button press, else allow
+ for (Object object : list) {
+ if (object != null) {
+ EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ allowed = true;
+ break;
+ }
+ }
+ }
+
+ if (!allowed) {
+ return;
+ }
+ }
+ // CraftBukkit end
if (flag && !flag1) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 0, 15);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() <= 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)));
this.b(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.b(blockposition, blockposition);
@@ -201,6 +263,16 @@
}
if (!flag && flag1) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
this.b(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.b(blockposition, blockposition);

Datei anzeigen

@ -0,0 +1,31 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockCactus.java 2014-11-27 08:59:46.509422692 +1100
+++ src/main/java/net/minecraft/server/BlockCactus.java 2014-11-27 08:42:10.152850911 +1100
@@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCactus extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
@@ -31,7 +33,8 @@
world.setTypeUpdate(blockposition1, this.getBlockData());
IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
- world.setTypeAndData(blockposition, iblockdata1, 4);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit
+ // world.setTypeAndData(blockposition, iblockdata1, 4); // CraftBukkit
this.doPhysics(world, blockposition1, iblockdata1, this);
} else {
world.setTypeAndData(blockposition, iblockdata.set(BlockCactus.AGE, Integer.valueOf(j + 1)), 4);
@@ -83,7 +86,9 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
+ CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
entity.damageEntity(DamageSource.CACTUS, 1.0F);
+ CraftEventFactory.blockDamage = null; // CraftBukkit
}
public IBlockData fromLegacyData(int i) {

22
nms-patches/BlockCake.patch Normale Datei
Datei anzeigen

@ -0,0 +1,22 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockCake.java 2014-11-27 08:59:46.509422692 +1100
+++ src/main/java/net/minecraft/server/BlockCake.java 2014-11-27 08:42:10.168850880 +1100
@@ -54,7 +54,18 @@
private void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.j(false)) {
- entityhuman.getFoodData().eat(2, 0.1F);
+ // CraftBukkit start
+ // entityhuman.getFoodData().eat(2, 0.1F);
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
+
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, 2 + oldFoodLevel);
+
+ if (!event.isCancelled()) {
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F);
+ }
+
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+ // CraftBukkit end
int i = ((Integer) iblockdata.get(BlockCake.BITES)).intValue();
if (i < 6) {

35
nms-patches/BlockCocoa.patch Normale Datei
Datei anzeigen

@ -0,0 +1,35 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockCocoa.java 2014-11-27 08:59:46.513422674 +1100
+++ src/main/java/net/minecraft/server/BlockCocoa.java 2014-11-27 08:42:10.152850911 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCocoa extends BlockDirectional implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 2);
@@ -19,7 +21,10 @@
int i = ((Integer) iblockdata.get(BlockCocoa.AGE)).intValue();
if (i < 2) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2);
+ // CraftBukkit start
+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1));
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
}
@@ -125,7 +130,10 @@
}
public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2);
+ // CraftBukkit start
+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(((Integer) iblockdata.get(AGE)).intValue() + 1));
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
public IBlockData fromLegacyData(int i) {

Datei anzeigen

@ -0,0 +1,34 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockCommand.java 2014-11-27 08:59:46.513422674 +1100
+++ src/main/java/net/minecraft/server/BlockCommand.java 2014-11-27 08:42:10.152850911 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockCommand extends BlockContainer {
public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
@@ -19,11 +21,20 @@
if (!world.isStatic) {
boolean flag = world.isBlockIndirectlyPowered(blockposition);
boolean flag1 = ((Boolean) iblockdata.get(BlockCommand.TRIGGERED)).booleanValue();
+
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = flag1 ? 15 : 0;
+ int current = flag ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ // CraftBukkit end
- if (flag && !flag1) {
+ if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
world.setTypeAndData(blockposition, iblockdata.set(BlockCommand.TRIGGERED, Boolean.valueOf(true)), 4);
world.a(blockposition, (Block) this, this.a(world));
- } else if (!flag && flag1) {
+ } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
world.setTypeAndData(blockposition, iblockdata.set(BlockCommand.TRIGGERED, Boolean.valueOf(false)), 4);
}
}

35
nms-patches/BlockCrops.patch Normale Datei
Datei anzeigen

@ -0,0 +1,35 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockCrops.java 2014-11-27 08:59:46.517422657 +1100
+++ src/main/java/net/minecraft/server/BlockCrops.java 2014-11-27 08:42:10.160850895 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
@@ -31,7 +33,10 @@
float f = a((Block) this, world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockCrops.AGE, Integer.valueOf(i + 1)), 2);
+ // CraftBukkit start
+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1));
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
}
}
@@ -45,7 +50,10 @@
i = 7;
}
- world.setTypeAndData(blockposition, iblockdata.set(BlockCrops.AGE, Integer.valueOf(i)), 2);
+ // CraftBukkit start
+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i));
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
protected static float a(Block block, World world, BlockPosition blockposition) {

Datei anzeigen

@ -0,0 +1,10 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDaylightDetector.java 2014-11-27 08:59:46.517422657 +1100
+++ src/main/java/net/minecraft/server/BlockDaylightDetector.java 2014-11-27 08:42:10.164850887 +1100
@@ -41,6 +41,7 @@
}
if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
world.setTypeAndData(blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
}

Datei anzeigen

@ -0,0 +1,30 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDiodeAbstract.java 2014-11-27 08:59:46.517422657 +1100
+++ src/main/java/net/minecraft/server/BlockDiodeAbstract.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public abstract class BlockDiodeAbstract extends BlockDirectional {
protected final boolean M;
@@ -31,8 +33,18 @@
boolean flag = this.e(world, blockposition, iblockdata);
if (this.M && !flag) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.k(iblockdata), 2);
} else if (!this.M) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.e(iblockdata), 2);
if (!flag) {
world.a(blockposition, this.e(iblockdata).getBlock(), this.m(iblockdata), -1);

Datei anzeigen

@ -0,0 +1,18 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDispenser.java 2014-11-27 08:59:46.521422639 +1100
+++ src/main/java/net/minecraft/server/BlockDispenser.java 2014-11-27 08:42:10.084851043 +1100
@@ -8,6 +8,7 @@
public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
public static final RegistryDefault M = new RegistryDefault(new DispenseBehaviorItem());
protected Random N = new Random();
+ public static boolean eventFired = false; // CraftBukkit
protected BlockDispenser() {
super(Material.STONE);
@@ -78,6 +79,7 @@
if (idispensebehavior != IDispenseBehavior.a) {
ItemStack itemstack1 = idispensebehavior.a(sourceblock, itemstack);
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setItem(i, itemstack1.count == 0 ? null : itemstack1);
}

43
nms-patches/BlockDoor.patch Normale Datei
Datei anzeigen

@ -0,0 +1,43 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDoor.java 2014-11-27 08:59:46.521422639 +1100
+++ src/main/java/net/minecraft/server/BlockDoor.java 2014-11-27 08:42:10.156850903 +1100
@@ -3,6 +3,8 @@
import com.google.common.base.Predicate;
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirectionLimit.HORIZONTAL);
@@ -151,9 +153,21 @@
this.b(world, blockposition, iblockdata, 0);
}
} else {
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition2);
+ // 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());
+
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ int oldPower = (Boolean)iblockdata2.get(POWERED) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
- if ((flag1 || block.isPowerSource()) && block != this && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
world.setTypeAndData(blockposition2, 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);
@@ -161,6 +175,7 @@
world.a((EntityHuman) null, flag1 ? 1003 : 1006, blockposition, 0);
}
}
+ // CraftBukkit end
}
}

Datei anzeigen

@ -0,0 +1,30 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDragonEgg.java 2014-11-27 08:59:46.525422622 +1100
+++ src/main/java/net/minecraft/server/BlockDragonEgg.java 2014-11-27 08:42:10.152850911 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
public class BlockDragonEgg extends Block {
public BlockDragonEgg() {
@@ -61,6 +63,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) {
+ // CraftBukkit start
+ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
+ BlockFromToEvent event = new BlockFromToEvent(from, to);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
+ // CraftBukkit end
if (world.isStatic) {
for (int j = 0; j < 128; ++j) {
double d0 = world.random.nextDouble();

Datei anzeigen

@ -0,0 +1,41 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockDropper.java 2014-11-27 08:59:46.525422622 +1100
+++ src/main/java/net/minecraft/server/BlockDropper.java 2014-11-27 08:42:10.124850965 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
+// CraftBukkit end
+
public class BlockDropper extends BlockDispenser {
private final IDispenseBehavior O = new DispenseBehaviorItem();
@@ -38,8 +43,25 @@
itemstack1 = null;
}
} else {
- itemstack1 = TileEntityHopper.addItem(iinventory, itemstack.cloneItemStack().a(1), enumdirection.opposite());
- if (itemstack1 == null) {
+ // CraftBukkit start - Fire event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));
+
+ org.bukkit.inventory.Inventory destinationInventory;
+ // Have to special case large chests as they work oddly
+ if (iinventory instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ } else {
+ destinationInventory = iinventory.getOwner().getInventory();
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
+ if (event.getItem().equals(oitemstack) && itemstack1 == null) {
+ // CraftBukkit end
itemstack1 = itemstack.cloneItemStack();
if (--itemstack1.count == 0) {
itemstack1 = null;

Datei anzeigen

@ -0,0 +1,22 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockEnderPortal.java 2014-11-27 08:59:46.529422604 +1100
+++ src/main/java/net/minecraft/server/BlockEnderPortal.java 2014-11-27 08:42:10.104851005 +1100
@@ -3,6 +3,8 @@
import java.util.List;
import java.util.Random;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockEnderPortal extends BlockContainer {
protected BlockEnderPortal(Material material) {
@@ -36,6 +38,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (entity.vehicle == null && entity.passenger == null && !world.isStatic) {
+ // 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);
+ // CraftBukkit end
entity.c(1);
}

110
nms-patches/BlockFire.patch Normale Datei
Datei anzeigen

@ -0,0 +1,110 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockFire.java 2014-11-27 08:59:46.529422604 +1100
+++ src/main/java/net/minecraft/server/BlockFire.java 2014-11-27 08:42:10.168850880 +1100
@@ -4,6 +4,12 @@
import java.util.Map;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockFire extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
@@ -109,7 +115,7 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.getGameRules().getBoolean("doFireTick")) {
if (!this.canPlace(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - invalid place location
}
Block block = world.getType(blockposition.down()).getBlock();
@@ -120,7 +126,7 @@
}
if (!flag && world.S() && this.d(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
} else {
int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
@@ -186,7 +192,26 @@
l1 = 15;
}
- world.setTypeAndData(blockposition1, iblockdata.set(BlockFire.AGE, Integer.valueOf(l1)), 3);
+ // CraftBukkit start - Call to stop spread of fire
+ if (world.getType(blockposition1) != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, i1, k1, j1, i, j, k).isCancelled()) {
+ continue;
+ }
+
+ org.bukkit.Server server = world.getServer();
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState();
+ blockState.setTypeId(Block.getId(this));
+ blockState.setData(new org.bukkit.material.MaterialData(Block.getId(this), (byte) l1));
+
+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
+ server.getPluginManager().callEvent(spreadEvent);
+
+ if (!spreadEvent.isCancelled()) {
+ blockState.update(true);
+ }
+ }
+ // CraftBukkit end
}
}
}
@@ -223,6 +248,17 @@
if (random.nextInt(i) < k) {
IBlockData iblockdata = world.getType(blockposition);
+
+ // CraftBukkit start
+ org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockBurnEvent event = new BlockBurnEvent(theBlock);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
int l = j + random.nextInt(5) / 4;
@@ -290,7 +326,7 @@
public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
if (!World.a((IBlockAccess) world, blockposition.down()) && !this.e(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
}
}
@@ -298,7 +334,7 @@
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (world.worldProvider.getDimension() > 0 || !Blocks.PORTAL.d(world, blockposition)) {
if (!World.a((IBlockAccess) world, blockposition.down()) && !this.e(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
} else {
world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10));
}
@@ -320,4 +356,12 @@
protected BlockStateList getStateList() {
return new BlockStateList(this, new IBlockState[] { BlockFire.AGE, BlockFire.NORTH, BlockFire.EAST, BlockFire.SOUTH, BlockFire.WEST, BlockFire.UPPER, BlockFire.FLIP, BlockFire.ALT});
}
+
+ // CraftBukkit start
+ private void fireExtinguished(World world, BlockPosition position) {
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) {
+ world.setAir(position);
+ }
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,83 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockFlowing.java 2014-11-27 08:59:46.529422604 +1100
+++ src/main/java/net/minecraft/server/BlockFlowing.java 2014-11-27 08:42:10.112850989 +1100
@@ -5,6 +5,11 @@
import java.util.Random;
import java.util.Set;
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.event.block.BlockFromToEvent;
+// CraftBukkit end
+
public class BlockFlowing extends BlockFluids {
int a;
@@ -18,7 +23,12 @@
}
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
- int i = ((Integer) iblockdata.get(BlockFlowing.LEVEL)).intValue();
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.Server server = world.getServer();
+ org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ // CraftBukkit end
+ int i = ((Integer) iblockdata.get(LEVEL)).intValue();
byte b0 = 1;
if (this.material == Material.LAVA && !world.worldProvider.n()) {
@@ -88,17 +98,25 @@
IBlockData iblockdata2 = world.getType(blockposition.down());
if (this.h(world, blockposition.down(), iblockdata2)) {
- if (this.material == Material.LAVA && world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER) {
- world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
- this.fizz(world, blockposition.down());
- return;
- }
+ // CraftBukkit start - Send "down" to the server
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+ if (server != null) {
+ server.getPluginManager().callEvent(event);
+ }
+ if (!event.isCancelled()) {
+ if (this.material == Material.LAVA && world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER) {
+ world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
+ this.fizz(world, blockposition.down());
+ return;
+ }
- if (i >= 8) {
- this.flow(world, blockposition.down(), iblockdata2, i);
- } else {
- this.flow(world, blockposition.down(), iblockdata2, i + 8);
+ if (i >= 8) {
+ this.flow(world, blockposition.down(), iblockdata2, i);
+ } else {
+ this.flow(world, blockposition.down(), iblockdata2, i + 8);
+ }
}
+ // CraftBukkit end
} else if (i >= 0 && (i == 0 || this.g(world, blockposition.down(), iblockdata2))) {
Set set = this.e(world, blockposition);
@@ -115,8 +133,17 @@
while (iterator1.hasNext()) {
EnumDirection enumdirection1 = (EnumDirection) iterator1.next();
-
- this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+
+ // CraftBukkit start
+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1));
+ if (server != null) {
+ server.getPluginManager().callEvent(event);
+ }
+
+ if (!event.isCancelled()) {
+ this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+ }
+ // CraftBukkit end
}
}

77
nms-patches/BlockGrass.patch Normale Datei
Datei anzeigen

@ -0,0 +1,77 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockGrass.java 2014-11-27 08:59:46.533422586 +1100
+++ src/main/java/net/minecraft/server/BlockGrass.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,14 @@
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockSpreadEvent;
+import org.bukkit.event.block.BlockFadeEvent;
+// CraftBukkit end
+
public class BlockGrass extends Block implements IBlockFragilePlantElement {
public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
@@ -22,7 +30,19 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isStatic) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).getBlock().n() > 2) {
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
+
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
@@ -31,7 +51,19 @@
IBlockData iblockdata1 = world.getType(blockposition1);
if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.n() <= 2) {
- world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.GRASS));
+
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
}
}
}
@@ -74,13 +106,15 @@
IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.l(), enumflowervarient);
if (blockflowers.f(world, blockposition2, iblockdata1)) {
- world.setTypeAndData(blockposition2, iblockdata1, 3);
+ // world.setTypeAndData(blockposition2, iblockdata1, 3); // CraftBukkit
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata1.getBlock(), iblockdata1.getBlock().toLegacyData(iblockdata1)); // CraftBukkit
}
} else {
IBlockData iblockdata2 = Blocks.TALLGRASS.getBlockData().set(BlockLongGrass.TYPE, EnumTallGrassType.GRASS);
if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) {
- world.setTypeAndData(blockposition2, iblockdata2, 3);
+ // world.setTypeAndData(blockposition2, iblockdata2, 3); // CRaftBukkit
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata2.getBlock(), iblockdata2.getBlock().toLegacyData(iblockdata2)); // CraftBukkit
}
}
}

15
nms-patches/BlockIce.patch Normale Datei
Datei anzeigen

@ -0,0 +1,15 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockIce.java 2014-11-27 08:59:46.533422586 +1100
+++ src/main/java/net/minecraft/server/BlockIce.java 2014-11-27 08:42:10.168850880 +1100
@@ -44,6 +44,12 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11 - this.n()) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.n() ? Blocks.AIR : Blocks.WATER).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
if (world.worldProvider.n()) {
world.setAir(blockposition);
} else {

Datei anzeigen

@ -0,0 +1,26 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockLeaves.java 2014-11-27 08:59:46.537422569 +1100
+++ src/main/java/net/minecraft/server/BlockLeaves.java 2014-11-27 08:42:10.132850949 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public abstract class BlockLeaves extends BlockTransparent {
public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
@@ -128,6 +130,14 @@
}
private void d(World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.b(world, blockposition, world.getType(blockposition), 0);
world.setAir(blockposition);
}

32
nms-patches/BlockLever.patch Normale Datei
Datei anzeigen

@ -0,0 +1,32 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockLever.java 2014-11-27 08:59:46.541422551 +1100
+++ src/main/java/net/minecraft/server/BlockLever.java 2014-11-27 08:42:10.168850880 +1100
@@ -2,6 +2,8 @@
import java.util.Iterator;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockLever extends Block {
public static final BlockStateEnum FACING = BlockStateEnum.of("facing", EnumLeverPosition.class);
@@ -144,6 +146,20 @@
if (world.isStatic) {
return true;
} else {
+ // CraftBukkit start - Interact Lever
+ boolean powered = (Boolean)iblockdata.get(POWERED);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = (powered) ? 15 : 0;
+ int current = (!powered) ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
+ return true;
+ }
+ // CraftBukkit end
+
iblockdata = iblockdata.a(BlockLever.POWERED);
world.setTypeAndData(blockposition, iblockdata, 3);
world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F);

Datei anzeigen

@ -0,0 +1,29 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockMinecartDetector.java 2014-11-27 08:59:46.541422551 +1100
+++ src/main/java/net/minecraft/server/BlockMinecartDetector.java 2014-11-27 08:42:10.124850965 +1100
@@ -4,6 +4,8 @@
import java.util.List;
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
public static final BlockStateEnum SHAPE = BlockStateEnum.a("shape", EnumTrackPosition.class, (Predicate) (new BlockMinecartDetectorInnerClass1()));
@@ -55,6 +57,17 @@
if (!list.isEmpty()) {
flag1 = true;
}
+
+ // CraftBukkit start
+ if (flag != flag1) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ }
+ // CraftBukkit end
if (flag1 && !flag) {
world.setTypeAndData(blockposition, iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);

Datei anzeigen

@ -0,0 +1,22 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockMobSpawner.java 2014-11-27 08:59:46.541422551 +1100
+++ src/main/java/net/minecraft/server/BlockMobSpawner.java 2014-11-27 08:42:10.172850872 +1100
@@ -22,9 +22,19 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
+ /* CraftBukkit start - Delegate to getExpDrop
int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
this.dropExperience(world, blockposition, j);
+ */
+ }
+
+ @Override
+ public int getExpDrop(World world, IBlockData iblockdata, int enchantmentLevel) {
+ int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
+
+ return j;
+ // CraftBukkit end
}
public boolean c() {

Datei anzeigen

@ -0,0 +1,20 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockMonsterEggs.java 2014-11-27 08:59:46.545422534 +1100
+++ src/main/java/net/minecraft/server/BlockMonsterEggs.java 2014-11-27 08:42:10.136850942 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
+
public class BlockMonsterEggs extends Block {
public static final BlockStateEnum VARIANT = BlockStateEnum.of("variant", EnumMonsterEggVarient.class);
@@ -50,7 +52,7 @@
EntitySilverfish entitysilverfish = new EntitySilverfish(world);
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);
- world.addEntity(entitysilverfish);
+ world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason
entitysilverfish.y();
}

Datei anzeigen

@ -0,0 +1,57 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockMushroom.java 2014-11-27 08:59:46.545422534 +1100
+++ src/main/java/net/minecraft/server/BlockMushroom.java 2014-11-27 08:42:10.100851012 +1100
@@ -3,6 +3,12 @@
import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement {
protected BlockMushroom() {
@@ -13,6 +19,7 @@
}
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ final int sourceX = blockposition.getX(), sourceY = blockposition.getY(), sourceZ = blockposition.getZ(); // CraftBukkit
if (random.nextInt(25) == 0) {
int i = 5;
boolean flag = true;
@@ -39,8 +46,20 @@
blockposition2 = blockposition.a(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1);
}
- if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) {
- world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) {
+ // CraftBukkit start
+ // world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()).getState();
+ blockState.setType(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this)); // nms: this.id, 0, 2
+
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
}
}
@@ -69,8 +88,10 @@
WorldGenHugeMushroom worldgenhugemushroom = null;
if (this == Blocks.BROWN_MUSHROOM) {
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(0);
} else if (this == Blocks.RED_MUSHROOM) {
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(1);
}

58
nms-patches/BlockMycel.patch Normale Datei
Datei anzeigen

@ -0,0 +1,58 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockMycel.java 2014-11-27 08:59:46.549422516 +1100
+++ src/main/java/net/minecraft/server/BlockMycel.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,13 @@
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockMycel extends Block {
public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
@@ -22,7 +29,19 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isStatic) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).getBlock().n() > 2) {
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, EnumDirtVariant.DIRT));
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, EnumDirtVariant.DIRT));
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
+
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
@@ -31,7 +50,19 @@
Block block = world.getType(blockposition1.up()).getBlock();
if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.n() <= 2) {
- world.setTypeUpdate(blockposition1, this.getBlockData());
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition1, this.getBlockData());
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(this));
+
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
}
}
}

Datei anzeigen

@ -0,0 +1,12 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockNetherWart.java 2014-11-27 08:59:46.549422516 +1100
+++ src/main/java/net/minecraft/server/BlockNetherWart.java 2014-11-27 08:42:10.140850934 +1100
@@ -28,7 +28,8 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
- world.setTypeAndData(blockposition, iblockdata, 2);
+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit
}
super.b(world, blockposition, iblockdata, random);

42
nms-patches/BlockOre.patch Normale Datei
Datei anzeigen

@ -0,0 +1,42 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockOre.java 2014-11-27 08:59:46.549422516 +1100
+++ src/main/java/net/minecraft/server/BlockOre.java 2014-11-27 08:42:10.144850927 +1100
@@ -33,6 +33,7 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
int j = 0;
@@ -50,7 +51,31 @@
this.dropExperience(world, blockposition, j);
}
+ // */
+ }
+
+ @Override
+ public int getExpDrop(World world, IBlockData iblockdata, int i) {
+ if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
+ int j = 0;
+
+ if (this == Blocks.COAL_ORE) {
+ j = MathHelper.nextInt(world.random, 0, 2);
+ } else if (this == Blocks.DIAMOND_ORE) {
+ j = MathHelper.nextInt(world.random, 3, 7);
+ } else if (this == Blocks.EMERALD_ORE) {
+ j = MathHelper.nextInt(world.random, 3, 7);
+ } else if (this == Blocks.LAPIS_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ } else if (this == Blocks.QUARTZ_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ }
+
+ return j;
+ }
+ return 0;
+ // CraftBukkit end
}
public int getDropData(World world, BlockPosition blockposition) {

Datei anzeigen

@ -0,0 +1,76 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPiston.java 2014-11-27 08:59:46.553422499 +1100
+++ src/main/java/net/minecraft/server/BlockPiston.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,6 +1,16 @@
package net.minecraft.server;
+import java.util.AbstractList;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
+
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockPistonRetractEvent;
+import org.bukkit.event.block.BlockPistonExtendEvent;
+// CraftBukkit end
public class BlockPiston extends Block {
@@ -52,10 +62,19 @@
boolean flag = this.b(world, blockposition, enumdirection);
if (flag && !((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
- if ((new PistonExtendsChecker(world, blockposition, enumdirection, true)).a()) {
+ if ((new PistonExtendsChecker(world, blockposition, enumdirection, true)).a()) {
world.playBlockAction(blockposition, this, 0, enumdirection.a());
}
} else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, CraftBlock.notchToBlockFace(enumdirection));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockPiston.EXTENDED, Boolean.valueOf(false)), 2);
world.playBlockAction(blockposition, this, 1, enumdirection.a());
}
@@ -286,6 +305,35 @@
if (!pistonextendschecker.a()) {
return false;
} else {
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ final List moved = pistonextendschecker.getMovedBlocks();
+ final List broken = pistonextendschecker.getBrokenBlocks();
+
+ List<org.bukkit.block.Block> blocks = new AbstractList<org.bukkit.block.Block>() {
+
+ @Override
+ public int size() {
+ return moved.size() + broken.size();
+ }
+
+ @Override
+ public org.bukkit.block.Block get(int index) {
+ if (index >= size() || index < 0) {
+ throw new ArrayIndexOutOfBoundsException(index);
+ }
+ BlockPosition pos = (BlockPosition) (index < moved.size() ? moved.get(index) : broken.get(index - moved.size()));
+ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+ }
+ };
+
+ BlockPistonExtendEvent event = new BlockPistonExtendEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
int i = list.size() + list1.size();
Block[] ablock = new Block[i];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();

Datei anzeigen

@ -0,0 +1,53 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPortal.java 2014-11-27 08:59:46.553422499 +1100
+++ src/main/java/net/minecraft/server/BlockPortal.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockPortal extends BlockHalfTransparent {
public static final BlockStateEnum AXIS = BlockStateEnum.of("axis", EnumAxis.class, new EnumAxis[] { EnumAxis.X, EnumAxis.Z});
@@ -24,7 +26,8 @@
}
if (i > 0 && !world.getType(blockposition1.up()).getBlock().isOccluding()) {
- Entity entity = ItemMonsterEgg.a(world, 57, (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, 57, (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
entity.portalCooldown = entity.ar();
@@ -66,14 +69,16 @@
PortalCreator portalcreator = new PortalCreator(world, blockposition, EnumAxis.X);
if (portalcreator.b() && PortalCreator.a(portalcreator) == 0) {
- portalcreator.c();
- return true;
+ // CraftBukkit start - return portalcreator
+ return portalcreator.c();
+ // return true;
} else {
PortalCreator portalcreator1 = new PortalCreator(world, blockposition, EnumAxis.Z);
if (portalcreator1.b() && PortalCreator.a(portalcreator1) == 0) {
- portalcreator1.c();
- return true;
+ return portalcreator1.c();
+ // return true;
+ // CraftBukkit end
} else {
return false;
}
@@ -104,6 +109,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (entity.vehicle == null && entity.passenger == null) {
+ // 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);
+ // CraftBukkit end
entity.aq();
}

Datei anzeigen

@ -0,0 +1,25 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPoweredRail.java 2014-11-27 08:59:46.557422481 +1100
+++ src/main/java/net/minecraft/server/BlockPoweredRail.java 2014-11-27 08:42:10.124850965 +1100
@@ -2,6 +2,8 @@
import com.google.common.base.Predicate;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
public static final BlockStateEnum SHAPE = BlockStateEnum.a("shape", EnumTrackPosition.class, (Predicate) (new BlockPoweredRailInnerClass1()));
@@ -108,6 +110,13 @@
boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0);
if (flag1 != flag) {
+ // CraftBukkit start
+ int power = (Boolean)iblockdata.get(POWERED) ? 15 : 0;
+ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), power, 15 - power).getNewCurrent();
+ if (newPower == power) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3);
world.applyPhysics(blockposition.down(), this);
if (((EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {

Datei anzeigen

@ -0,0 +1,31 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPressurePlateAbstract.java 2014-11-27 08:59:46.557422481 +1100
+++ src/main/java/net/minecraft/server/BlockPressurePlateAbstract.java 2014-11-27 08:42:10.144850927 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public abstract class BlockPressurePlateAbstract extends Block {
protected BlockPressurePlateAbstract(Material material) {
@@ -90,6 +92,19 @@
int j = this.e(world, blockposition);
boolean flag = i > 0;
boolean flag1 = j > 0;
+
+ // CraftBukkit start - Interact Pressure Plate
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+
+ if (flag != flag1) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, j);
+ manager.callEvent(eventRedstone);
+
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ j = eventRedstone.getNewCurrent();
+ }
+ // CraftBukkit end
if (i != j) {
iblockdata = this.a(iblockdata, j);

Datei anzeigen

@ -0,0 +1,38 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPressurePlateBinary.java 2014-11-27 08:59:46.557422481 +1100
+++ src/main/java/net/minecraft/server/BlockPressurePlateBinary.java 2014-11-27 08:42:10.152850911 +1100
@@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.List;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -44,6 +46,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.e(world.getType(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (cancellable.isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
if (!entity.aH()) {
return 15;

Datei anzeigen

@ -0,0 +1,43 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPressurePlateWeighted.java 2014-11-27 08:59:46.561422463 +1100
+++ src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java 2014-11-27 08:42:10.160850895 +1100
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockStateInteger.of("power", 0, 15);
@@ -12,7 +14,31 @@
}
protected int e(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, this.a(blockposition)).size(), this.b);
+ // CraftBukkit start
+ //int i = Math.min(world.a(Entity.class, this.a(blockposition)).size(), this.b);
+ int i = 0;
+ java.util.Iterator iterator = world.a(Entity.class, this.a(blockposition)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
+
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (!cancellable.isCancelled()) {
+ i++;
+ }
+ }
+
+ i = Math.min(i, this.b);
+ // CraftBukkit end
if (i > 0) {
float f = (float) Math.min(this.b, i) / (float) this.b;

117
nms-patches/BlockPumpkin.patch Normale Datei
Datei anzeigen

@ -0,0 +1,117 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockPumpkin.java 2014-11-27 08:59:46.561422463 +1100
+++ src/main/java/net/minecraft/server/BlockPumpkin.java 2014-11-27 08:42:10.108850996 +1100
@@ -1,5 +1,11 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockPumpkin extends BlockDirectional {
private ShapeDetector snowGolemPart;
@@ -29,31 +35,45 @@
int j;
if ((shapedetectorcollection = this.getDetectorSnowGolem().a(world, blockposition)) != null) {
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) {
ShapeDetectorBlock shapedetectorblock = shapedetectorcollection.a(0, i, 0);
- world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetectorblock.d();
+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+ // CraftBukkit end
}
EntitySnowman entitysnowman = new EntitySnowman(world);
BlockPosition blockposition1 = shapedetectorcollection.a(0, 2, 0).d();
entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F);
- world.addEntity(entitysnowman);
+ // CraftBukkit start
+ if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
+ blockList.updateList();
- for (j = 0; j < 120; ++j) {
- 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]);
- }
+ for (j = 0; j < 120; ++j) {
+ 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]);
+ }
- for (j = 0; j < this.getDetectorSnowGolem().b(); ++j) {
- ShapeDetectorBlock shapedetectorblock1 = shapedetectorcollection.a(0, j, 0);
+ for (j = 0; j < this.getDetectorSnowGolem().b(); ++j) {
+ ShapeDetectorBlock shapedetectorblock1 = shapedetectorcollection.a(0, j, 0);
- world.update(shapedetectorblock1.d(), Blocks.AIR);
+ world.update(shapedetectorblock1.d(), Blocks.AIR);
+ }
}
+ // CraftBukkit end
} else if ((shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition)) != null) {
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
for (i = 0; i < this.getDetectorIronGolem().c(); ++i) {
for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) {
- world.setTypeAndData(shapedetectorcollection.a(i, k, 0).d(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorcollection.a(i, k, 0).d(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetectorcollection.a(i, k, 0).d();
+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+ // CraftBukkit end
}
}
@@ -62,22 +82,38 @@
entityirongolem.setPlayerCreated(true);
entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
- world.addEntity(entityirongolem);
-
- for (j = 0; j < 120; ++j) {
- world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
- }
+ // CraftBukkit start
+ if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
+ blockList.updateList();
+
+ for (j = 0; j < 120; ++j) {
+ world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
+ }
- for (j = 0; j < this.getDetectorIronGolem().c(); ++j) {
- for (int l = 0; l < this.getDetectorIronGolem().b(); ++l) {
- ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(j, l, 0);
+ for (j = 0; j < this.getDetectorIronGolem().c(); ++j) {
+ for (int l = 0; l < this.getDetectorIronGolem().b(); ++l) {
+ ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(j, l, 0);
- world.update(shapedetectorblock2.d(), Blocks.AIR);
+ world.update(shapedetectorblock2.d(), Blocks.AIR);
+ }
}
}
+ // CraftBukkit end
}
+ }
+ // CraftBukkit start
+ @Override
+ public void doPhysics(World world, BlockPosition position, IBlockData data, Block block) {
+ if (block != null && block.isPowerSource()) {
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
+ int power = bukkitBlock.getBlockPower();
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ }
}
+ // CraftBukkit end
public boolean canPlace(World world, BlockPosition blockposition) {
return world.getType(blockposition).getBlock().material.isReplaceable() && World.a((IBlockAccess) world, blockposition.down());

Datei anzeigen

@ -0,0 +1,47 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockRedstoneLamp.java 2014-11-27 08:59:46.565422446 +1100
+++ src/main/java/net/minecraft/server/BlockRedstoneLamp.java 2014-11-27 08:42:10.140850934 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockRedstoneLamp extends Block {
private final boolean a;
@@ -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)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
}
@@ -31,6 +38,11 @@
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
world.a(blockposition, (Block) this, 4);
} else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
}
@@ -40,6 +52,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isStatic) {
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2);
}

Datei anzeigen

@ -0,0 +1,102 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockRedstoneOre.java 2014-11-27 08:59:46.565422446 +1100
+++ src/main/java/net/minecraft/server/BlockRedstoneOre.java 2014-11-27 08:42:10.112850989 +1100
@@ -2,6 +2,11 @@
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
+
public class BlockRedstoneOre extends Block {
private final boolean a;
@@ -20,23 +25,44 @@
}
public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
- this.d(world, blockposition);
+ this.d(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
super.attack(world, blockposition, entityhuman);
}
- public void a(World world, BlockPosition blockposition, Entity entity) {
- this.d(world, blockposition);
- super.a(world, blockposition, entity);
+ public void a(World world, BlockPosition blockposition, Entity entity) {
+ // CraftBukkit start
+ // this.d(world, blockposition);
+ // super.a(world, blockposition, entity);
+ if (entity instanceof EntityHuman) {
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+ if (!event.isCancelled()) {
+ this.d(world, blockposition, entity); // add entity
+ super.a(world, blockposition, entity);
+ }
+ } else {
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.d(world, blockposition, entity); // add entity
+ super.a(world, blockposition, entity);
+ }
+ }
+ // CraftBukkit end
}
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumDirection enumdirection, float f, float f1, float f2) {
- this.d(world, blockposition);
+ this.d(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
return super.interact(world, blockposition, iblockdata, entityhuman, enumdirection, f, f1, f2);
}
- private void d(World world, BlockPosition blockposition) {
+ private void d(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
this.e(world, blockposition);
if (this == Blocks.REDSTONE_ORE) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
}
@@ -44,6 +70,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (this == Blocks.LIT_REDSTONE_ORE) {
+ // CraftBukkit start
+ if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.REDSTONE_ORE).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
}
@@ -63,12 +94,24 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
int j = 1 + world.random.nextInt(5);
this.dropExperience(world, blockposition, j);
}
+ // */
+ }
+ @Override
+ public int getExpDrop(World world, IBlockData data, int i) {
+ if (this.getDropType(data, world.random, i) != Item.getItemOf(this)) {
+ int j = 1 + world.random.nextInt(5);
+
+ return j;
+ }
+ return 0;
+ // CraftBukkit end
}
private void e(World world, BlockPosition blockposition) {

Datei anzeigen

@ -0,0 +1,55 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockRedstoneTorch.java 2014-11-27 08:59:46.565422446 +1100
+++ src/main/java/net/minecraft/server/BlockRedstoneTorch.java 2014-11-27 08:42:10.156850903 +1100
@@ -6,6 +6,8 @@
import java.util.Map;
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
private static Map b = Maps.newHashMap();
@@ -95,9 +97,26 @@
while (list != null && !list.isEmpty() && world.getTime() - ((RedstoneUpdateInfo) list.get(0)).b > 60L) {
list.remove(0);
}
+
+ // CraftBukkit start
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int oldCurrent = this.isOn ? 15 : 0;
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
if (this.isOn) {
if (flag) {
+ // CraftBukkit start
+ if (oldCurrent != 0) {
+ event.setNewCurrent(0);
+ manager.callEvent(event);
+ if (event.getNewCurrent() != 0) {
+ return;
+ }
+ }
+ // 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.makeSound((double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -114,6 +133,16 @@
}
}
} else if (!flag && !this.a(world, blockposition, false)) {
+ // CraftBukkit start
+ if (oldCurrent != 15) {
+ event.setNewCurrent(15);
+ manager.callEvent(event);
+ if (event.getNewCurrent() != 15) {
+ return;
+ }
+ }
+ // CraftBukkit end
+
world.setTypeAndData(blockposition, Blocks.REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
}

Datei anzeigen

@ -0,0 +1,27 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockRedstoneWire.java 2014-11-27 08:59:46.569422428 +1100
+++ src/main/java/net/minecraft/server/BlockRedstoneWire.java 2014-11-27 08:42:10.136850942 +1100
@@ -8,6 +8,8 @@
import java.util.Random;
import java.util.Set;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneWire extends Block {
public static final BlockStateEnum NORTH = BlockStateEnum.of("north", EnumRedstoneWireConnection.class);
@@ -123,6 +125,15 @@
if (k > j - 1) {
j = k;
}
+
+ // CraftBukkit start
+ if (i != j) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, j);
+ world.getServer().getPluginManager().callEvent(event);
+
+ j = event.getNewCurrent();
+ }
+ // CraftBukkit end
if (i != j) {
iblockdata = iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j));

18
nms-patches/BlockReed.patch Normale Datei
Datei anzeigen

@ -0,0 +1,18 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockReed.java 2014-11-27 08:59:46.569422428 +1100
+++ src/main/java/net/minecraft/server/BlockReed.java 2014-11-27 08:42:10.120850973 +1100
@@ -29,8 +29,13 @@
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
if (j == 15) {
- world.setTypeUpdate(blockposition.up(), this.getBlockData());
- world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition.up(), this.getBlockData());
+ // world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
+ BlockPosition upPos = blockposition.up();
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, upPos.getX(), upPos.getY(), upPos.getZ(), this, 0);
+ // CraftBukkit end
+
} else {
world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4);
}

125
nms-patches/BlockSapling.patch Normale Datei
Datei anzeigen

@ -0,0 +1,125 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockSapling.java 2014-11-27 08:59:46.573422410 +1100
+++ src/main/java/net/minecraft/server/BlockSapling.java 2014-11-27 08:42:10.108850996 +1100
@@ -2,10 +2,20 @@
import java.util.Random;
+// CraftBukkit start
+import java.util.List;
+
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
+
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateEnum TYPE = BlockStateEnum.of("type", EnumLogVariant.class);
public static final BlockStateInteger STAGE = BlockStateInteger.of("stage", 0, 1);
+ public static TreeType treeType; // CraftBukkit
protected BlockSapling() {
this.j(this.blockStateList.getBlockData().set(BlockSapling.TYPE, EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
@@ -19,7 +29,30 @@
if (!world.isStatic) {
super.b(world, blockposition, iblockdata, random);
if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
+ // CraftBukkit start
+ world.captureTreeGeneration = true;
+ // CraftBukkit end
this.grow(world, blockposition, iblockdata, random);
+ // CraftBukkit start
+ world.captureTreeGeneration = false;
+ if (world.capturedBlockStates.size() > 0) {
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
+ world.capturedBlockStates.clear();
+ StructureGrowEvent event = null;
+ if (treeType != null) {
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event == null || !event.isCancelled()) {
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true);
+ }
+ }
+ }
+ // CraftBukkit end
}
}
@@ -35,7 +68,17 @@
}
public void e(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
- Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
+ // CraftBukkit start - Turn ternary operator into if statement to set treeType
+ // Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
+ Object object;
+ if (random.nextInt(10) == 0) {
+ treeType = TreeType.BIG_TREE;
+ object = new WorldGenBigTree(true);
+ } else {
+ treeType = TreeType.TREE;
+ object = new WorldGenTrees(true);
+ }
+ // CraftBukkit end
int i = 0;
int j = 0;
boolean flag = false;
@@ -46,6 +89,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition.a(i, 0, j), EnumLogVariant.SPRUCE) && this.a(world, blockposition.a(i + 1, 0, j), EnumLogVariant.SPRUCE) && this.a(world, blockposition.a(i, 0, j + 1), EnumLogVariant.SPRUCE) && this.a(world, blockposition.a(i + 1, 0, j + 1), EnumLogVariant.SPRUCE)) {
+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit
object = new WorldGenMegaTree(false, random.nextBoolean());
flag = true;
break label78;
@@ -56,11 +100,13 @@
if (!flag) {
j = 0;
i = 0;
+ treeType = TreeType.REDWOOD; // CraftBukkit
object = new WorldGenTaiga2(true);
}
break;
case 2:
+ treeType = TreeType.BIRCH; // CraftBukkit
object = new WorldGenForest(true, false);
break;
@@ -69,6 +115,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition.a(i, 0, j), EnumLogVariant.JUNGLE) && this.a(world, blockposition.a(i + 1, 0, j), EnumLogVariant.JUNGLE) && this.a(world, blockposition.a(i, 0, j + 1), EnumLogVariant.JUNGLE) && this.a(world, blockposition.a(i + 1, 0, j + 1), EnumLogVariant.JUNGLE)) {
+ treeType = TreeType.JUNGLE; // CraftBukkit
object = new WorldGenJungleTree(true, 10, 20, EnumLogVariant.JUNGLE.a(), EnumLogVariant.JUNGLE.a());
flag = true;
break label93;
@@ -79,11 +126,13 @@
if (!flag) {
j = 0;
i = 0;
+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
object = new WorldGenTrees(true, 4 + random.nextInt(7), EnumLogVariant.JUNGLE.a(), EnumLogVariant.JUNGLE.a(), false);
}
break;
case 4:
+ treeType = TreeType.ACACIA; // CraftBukki
object = new WorldGenAcaciaTree(true);
break;
@@ -92,6 +141,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition.a(i, 0, j), EnumLogVariant.DARK_OAK) && this.a(world, blockposition.a(i + 1, 0, j), EnumLogVariant.DARK_OAK) && this.a(world, blockposition.a(i, 0, j + 1), EnumLogVariant.DARK_OAK) && this.a(world, blockposition.a(i + 1, 0, j + 1), EnumLogVariant.DARK_OAK)) {
+ treeType = TreeType.DARK_OAK; // CraftBukkit
object = new WorldGenForestTree(true);
flag = true;
break label108;

133
nms-patches/BlockSkull.patch Normale Datei
Datei anzeigen

@ -0,0 +1,133 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockSkull.java 2014-11-27 08:59:46.573422410 +1100
+++ src/main/java/net/minecraft/server/BlockSkull.java 2014-11-27 08:42:10.156850903 +1100
@@ -4,6 +4,11 @@
import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockSkull extends BlockContainer {
public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
@@ -69,8 +74,25 @@
return tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).getSkullType() : super.getDropData(world, blockposition);
}
+
+ // CraftBukkit start - Special case dropping so we can get info from the tile entity
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ if (world.random.nextFloat() < f) {
+ ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition));
+ TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition);
+
+ 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);
+ }
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
+ a(world, blockposition, itemstack);
+ }
+ }
+ // CraftBukkit end
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.abilities.canInstantlyBuild) {
@@ -83,7 +105,10 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!world.isStatic) {
- if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
+ // CraftBukkit start - Drop item in code above, not here
+ // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
+ if (false) {
+ // CraftBukkit end
TileEntity tileentity = world.getTileEntity(blockposition);
if (tileentity instanceof TileEntitySkull) {
@@ -120,19 +145,30 @@
ShapeDetectorCollection shapedetectorcollection = shapedetector.a(world, blockposition);
if (shapedetectorcollection != null) {
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
int i;
for (i = 0; i < 3; ++i) {
ShapeDetectorBlock shapedetectorblock = shapedetectorcollection.a(i, 0, 0);
- world.setTypeAndData(shapedetectorblock.d(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock.d(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
+ BlockPosition pos = shapedetectorblock.d();
+ IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true));
+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2);
+ // CraftBukkit end
}
for (i = 0; i < shapedetector.c(); ++i) {
for (int j = 0; j < shapedetector.b(); ++j) {
ShapeDetectorBlock shapedetectorblock1 = shapedetectorcollection.a(i, j, 0);
- world.setTypeAndData(shapedetectorblock1.d(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock1.d(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetectorblock1.d();
+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2);
+ // CraftBukkit end
}
}
@@ -145,28 +181,31 @@
entitywither.n();
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D)).iterator();
- while (iterator.hasNext()) {
- EntityHuman entityhuman = (EntityHuman) iterator.next();
+ // CraftBukkit start
+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ while (iterator.hasNext()) {
+ EntityHuman entityhuman = (EntityHuman) iterator.next();
- entityhuman.b((Statistic) AchievementList.I);
- }
-
- world.addEntity(entitywither);
+ entityhuman.b((Statistic) AchievementList.I);
+ }
+
+ blockList.updateList();
- int k;
+ int k;
- for (k = 0; k < 120; ++k) {
- world.addParticle(EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
- }
+ for (k = 0; k < 120; ++k) {
+ world.addParticle(EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
+ }
- for (k = 0; k < shapedetector.c(); ++k) {
- for (int l = 0; l < shapedetector.b(); ++l) {
- ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(k, l, 0);
+ for (k = 0; k < shapedetector.c(); ++k) {
+ for (int l = 0; l < shapedetector.b(); ++l) {
+ ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(k, l, 0);
- world.update(shapedetectorblock2.d(), Blocks.AIR);
+ world.update(shapedetectorblock2.d(), Blocks.AIR);
+ }
}
}
-
+ // CraftBukkit end
}
}
}

14
nms-patches/BlockSnow.patch Normale Datei
Datei anzeigen

@ -0,0 +1,14 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockSnow.java 2014-11-27 08:59:46.577422392 +1100
+++ src/main/java/net/minecraft/server/BlockSnow.java 2014-11-27 08:42:10.144850927 +1100
@@ -85,6 +85,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.b(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;
+ }
+ // CraftBukkit end
this.b(world, blockposition, world.getType(blockposition), 0);
world.setAir(blockposition);
}

52
nms-patches/BlockSoil.patch Normale Datei
Datei anzeigen

@ -0,0 +1,52 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockSoil.java 2014-11-27 08:59:46.577422392 +1100
+++ src/main/java/net/minecraft/server/BlockSoil.java 2014-11-27 08:42:10.168850880 +1100
@@ -3,6 +3,11 @@
import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
@@ -34,6 +39,12 @@
if (i > 0) {
world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
} else if (!this.d(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());
}
} else if (i < 7) {
@@ -49,6 +60,24 @@
return;
}
+ // CraftBukkit start - Interact soil
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ if (cancellable.isCancelled()) {
+ return;
+ }
+
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
}

Datei anzeigen

@ -0,0 +1,40 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockStationary.java 2014-11-27 08:59:46.577422392 +1100
+++ src/main/java/net/minecraft/server/BlockStationary.java 2014-11-27 08:42:10.152850911 +1100
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStationary extends BlockFluids {
protected BlockStationary(Material material) {
@@ -41,6 +43,13 @@
if (block.material == Material.AIR) {
if (this.e(world, blockposition1)) {
+ // CraftBukkit start - Prevent lava putting something on fire
+ if (world.getType(blockposition1) != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
return;
}
@@ -53,6 +62,14 @@
BlockPosition blockposition2 = blockposition.a(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
if (world.isEmpty(blockposition2.up()) && this.m(world, blockposition2)) {
+ // CraftBukkit start - Prevent lava putting something on fire
+ BlockPosition up = blockposition2.up();
+ if (world.getType(up) != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, up.getX(), up.getY(), up.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData());
}
}

41
nms-patches/BlockStem.patch Normale Datei
Datei anzeigen

@ -0,0 +1,41 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockStem.java 2014-11-27 08:59:46.581422375 +1100
+++ src/main/java/net/minecraft/server/BlockStem.java 2014-11-27 08:42:10.152850911 +1100
@@ -4,6 +4,8 @@
import java.util.Iterator;
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
@@ -50,7 +52,8 @@
if (i < 7) {
iblockdata = iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1));
- world.setTypeAndData(blockposition, iblockdata, 2);
+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit
} else {
Iterator iterator = EnumDirectionLimit.HORIZONTAL.iterator();
@@ -66,7 +69,8 @@
Block block = world.getType(blockposition.down()).getBlock();
if (world.getType(blockposition).getBlock().material == Material.AIR && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.GRASS)) {
- world.setTypeUpdate(blockposition, this.blockFruit.getBlockData());
+ // world.setTypeUpdate(blockposition, this.blockFruit.getBlockData()); // CraftBukkit
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.blockFruit, 0); // CraftBukkit
}
}
}
@@ -77,7 +81,8 @@
public void g(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5);
- world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2);
+ // world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, Math.min(7, i)); // CraftBukkit
}
public void h() {

Datei anzeigen

@ -0,0 +1,31 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockTrapdoor.java 2014-11-27 08:59:46.581422375 +1100
+++ src/main/java/net/minecraft/server/BlockTrapdoor.java 2014-11-27 08:42:10.124850965 +1100
@@ -2,6 +2,8 @@
import com.google.common.base.Predicate;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockTrapdoor extends Block {
public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirectionLimit.HORIZONTAL);
@@ -101,6 +103,19 @@
boolean flag = world.isBlockIndirectlyPowered(blockposition);
if (flag || block.isPowerSource()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ int power = bblock.getBlockPower();
+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0 || block.isPowerSource()) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ flag = eventRedstone.getNewCurrent() > 0;
+ }
+ // CraftBukkit end
boolean flag1 = ((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue();
if (flag1 != flag) {

Datei anzeigen

@ -0,0 +1,52 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockTripwire.java 2014-11-27 08:59:46.585422357 +1100
+++ src/main/java/net/minecraft/server/BlockTripwire.java 2014-11-27 08:42:10.140850934 +1100
@@ -4,6 +4,8 @@
import java.util.List;
import java.util.Random;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -154,6 +156,40 @@
}
}
}
+
+ // CraftBukkit start - Call interact even when triggering connected tripwire
+ if (flag != flag1 && flag1 && (Boolean)iblockdata.get(ATTACHED)) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.block.Block block = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ boolean allowed = false;
+
+ // If all of the events are cancelled block the tripwire trigger, else allow
+ for (Object object : list) {
+ if (object != null) {
+ org.bukkit.event.Cancellable cancellable;
+
+ if (object instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+ } else if (object instanceof Entity) {
+ cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
+ manager.callEvent((EntityInteractEvent) cancellable);
+ } else {
+ continue;
+ }
+
+ if (!cancellable.isCancelled()) {
+ allowed = true;
+ break;
+ }
+ }
+ }
+
+ if (!allowed) {
+ return;
+ }
+ }
+ // CraftBukkit end
if (flag1 != flag) {
iblockdata = iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1));

Datei anzeigen

@ -0,0 +1,29 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockTripwireHook.java 2014-11-27 08:59:46.585422357 +1100
+++ src/main/java/net/minecraft/server/BlockTripwireHook.java 2014-11-27 08:42:10.144850927 +1100
@@ -5,6 +5,8 @@
import java.util.Iterator;
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockTripwireHook extends Block {
public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirectionLimit.HORIZONTAL);
@@ -141,6 +143,17 @@
this.a(world, blockposition1, flag5, flag6, flag2, flag3);
}
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0) {
+ return;
+ }
+ // CraftBukkit end
+
this.a(world, blockposition, flag5, flag6, flag2, flag3);
if (!flag) {
world.setTypeAndData(blockposition, iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);

76
nms-patches/BlockVine.patch Normale Datei
Datei anzeigen

@ -0,0 +1,76 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/BlockVine.java 2014-11-27 08:59:46.589422340 +1100
+++ src/main/java/net/minecraft/server/BlockVine.java 2014-11-27 08:42:10.156850903 +1100
@@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockVine extends Block {
public static final BlockStateBoolean UP = BlockStateBoolean.of("up");
@@ -203,7 +205,13 @@
}
if (((Boolean) iblockdata1.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.WEST)).booleanValue()) {
- world.setTypeAndData(blockposition.up(), iblockdata1, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ // world.setTypeAndData(blockposition.up(), iblockdata1, 2);
+ BlockPosition target = blockposition.up();
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(block, source, this, toLegacyData(iblockdata1));
+ // CraftBukkit end
}
}
@@ -222,18 +230,30 @@
boolean flag2 = ((Boolean) iblockdata.get(a(enumdirection2))).booleanValue();
BlockPosition blockposition2 = blockposition1.shift(enumdirection1);
BlockPosition blockposition3 = blockposition1.shift(enumdirection2);
+
+ // CraftBukkit start - Call BlockSpreadEvent
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
if (flag1 && this.c(world.getType(blockposition2).getBlock())) {
- world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, block, toLegacyData(this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true))));
} else if (flag2 && this.c(world.getType(blockposition3).getBlock())) {
- world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, block, toLegacyData(this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true))));
} else if (flag1 && world.isEmpty(blockposition2) && this.c(world.getType(blockposition.shift(enumdirection1)).getBlock())) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, block, toLegacyData(this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true))));
} else if (flag2 && world.isEmpty(blockposition3) && this.c(world.getType(blockposition.shift(enumdirection2)).getBlock())) {
- world.setTypeAndData(blockposition3, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition3, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, block, toLegacyData(this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true))));
} else if (this.c(world.getType(blockposition1.up()).getBlock())) {
- world.setTypeAndData(blockposition1, this.getBlockData(), 2);
+ // world.setTypeAndData(blockposition1, this.getBlockData(), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, block, toLegacyData(this.getBlockData()));
}
+ // CraftBukkit end
} else if (block.material.k() && block.d()) {
world.setTypeAndData(blockposition, iblockdata.set(a(enumdirection), Boolean.valueOf(true)), 2);
}
@@ -260,7 +280,12 @@
}
if (((Boolean) iblockdata3.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.WEST)).booleanValue()) {
- world.setTypeAndData(blockposition1, iblockdata3, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ // world.setTypeAndData(blockposition1, iblockdata3, 2);
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3));
+ // CraftBukkit end
}
} else if (block1 == this) {
iblockdata3 = iblockdata2;

169
nms-patches/Chunk.patch Normale Datei
Datei anzeigen

@ -0,0 +1,169 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/Chunk.java 2014-11-27 08:59:46.589422340 +1100
+++ src/main/java/net/minecraft/server/Chunk.java 2014-11-27 08:42:10.164850887 +1100
@@ -1,6 +1,7 @@
package net.minecraft.server;
import com.google.common.base.Predicate;
+import com.google.common.collect.Lists; // CraftBukkit
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
import java.util.Arrays;
@@ -14,6 +15,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit; // CraftBukkit
+
public class Chunk {
private static final Logger c = LogManager.getLogger();
@@ -23,7 +26,7 @@
private final boolean[] g;
private boolean h;
public final World world;
- private final int[] heightMap;
+ public final int[] heightMap; // CraftBukkit - make public
public final int locX;
public final int locZ;
private boolean k;
@@ -40,6 +43,34 @@
private int v;
private ConcurrentLinkedQueue w;
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
+
+ public boolean areNeighborsLoaded(final int radius) {
+ switch (radius) {
+ case 2:
+ return this.neighbors == Integer.MAX_VALUE >> 6;
+ case 1:
+ final int mask =
+ // x z offset x z offset x z offset
+ (0x1 << (1 * 5 + 1 + 12)) | (0x1 << (0 * 5 + 1 + 12)) | (0x1 << (-1 * 5 + 1 + 12)) |
+ (0x1 << (1 * 5 + 0 + 12)) | (0x1 << (0 * 5 + 0 + 12)) | (0x1 << (-1 * 5 + 0 + 12)) |
+ (0x1 << (1 * 5 + -1 + 12)) | (0x1 << (0 * 5 + -1 + 12)) | (0x1 << (-1 * 5 + -1 + 12));
+ return (this.neighbors & mask) == mask;
+ default:
+ throw new UnsupportedOperationException(String.valueOf(radius));
+ }
+ }
+
+ public void setNeighborLoaded(final int x, final int z) {
+ this.neighbors |= 0x1 << (x * 5 + 12 + z);
+ }
+
+ public void setNeighborUnloaded(final int x, final int z) {
+ this.neighbors &= ~(0x1 << (x * 5 + 12 + z));
+ }
+ // CraftBukkit end
+
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
this.e = new byte[256];
@@ -60,8 +91,17 @@
Arrays.fill(this.f, -999);
Arrays.fill(this.e, (byte) -1);
+
+ // CraftBukkit start
+ if (!(this instanceof EmptyChunk)) {
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
+ }
}
+ public org.bukkit.Chunk bukkitChunk;
+ public boolean mustSave;
+ // CraftBukkit end
+
public Chunk(World world, ChunkSnapshot chunksnapshot, int i, int j) {
this(world, i, j);
short short0 = 256;
@@ -465,7 +505,13 @@
flag = j >= i1;
}
- chunksection.setType(i, j & 15, k, iblockdata);
+ // CraftBukkit start - Delay removing containers until after they're cleaned up
+ if (!(block1 instanceof IContainer)) {
+ chunksection.setType(i, j & 15, k, iblockdata);
+ }
+ // CraftBukkit end
+
+
if (block1 != block) {
if (!this.world.isStatic) {
block1.remove(this.world, blockposition, iblockdata1);
@@ -474,6 +520,12 @@
}
}
+ // CraftBukkit start - Delay removing containers until after they're cleaned up
+ if (block1 instanceof IContainer) {
+ chunksection.setType(i, j & 15, k, iblockdata);
+ }
+ // CraftBukkit end
+
if (chunksection.b(i, j & 15, k) != block) {
return null;
} else {
@@ -505,7 +557,8 @@
}
}
- if (!this.world.isStatic && block1 != block) {
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
+ if (!this.world.isStatic && block1 != block && (!this.world.captureBlockStates || block instanceof BlockContainer)) {
block.onPlace(this.world, blockposition, iblockdata);
}
@@ -586,7 +639,11 @@
int j = MathHelper.floor(entity.locZ / 16.0D);
if (i != this.locX || j != this.locZ) {
- Chunk.c.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
+ // CraftBukkit start
+ Bukkit.getLogger().warning("Wrong location for " + entity + " in world '" + world.getWorld().getName() + "'!");
+ // Chunk.c.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
+ Bukkit.getLogger().warning("Entity is at " + entity.locX + "," + entity.locZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.locX + "," + this.locZ);
+ // CraftBukkit end
entity.die();
}
@@ -673,6 +730,13 @@
tileentity.D();
this.tileEntities.put(blockposition, tileentity);
+ // CraftBukkit start
+ } else {
+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ()
+ + " (" + org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(getType(blockposition)) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
@@ -716,7 +780,21 @@
}
for (int i = 0; i < this.entitySlices.length; ++i) {
- this.world.c((Collection) this.entitySlices[i]);
+ // CraftBukkit start
+ List<Entity> newList = Lists.newArrayList(this.entitySlices[i]);
+ java.util.Iterator<Entity> iter = newList.iterator();
+ while (iter.hasNext()) {
+ Entity entity = iter.next();
+
+ // Do not pass along players, as doing so can get them stuck outside of time.
+ // (which for example disables inventory icon updates and prevents block breaking)
+ if (entity instanceof EntityPlayer) {
+ iter.remove();
+ }
+ }
+
+ this.world.c((Collection) newList);
+ // CraftBukkit end
}
}

Datei anzeigen

@ -0,0 +1,348 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ChunkProviderServer.java 2014-11-27 08:59:46.593422322 +1100
+++ src/main/java/net/minecraft/server/ChunkProviderServer.java 2014-11-27 08:42:10.124850965 +1100
@@ -10,17 +10,28 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.Random;
+import java.util.logging.Level;
+
+import org.bukkit.Server;
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
+import org.bukkit.craftbukkit.util.LongHash;
+import org.bukkit.craftbukkit.util.LongHashSet;
+import org.bukkit.craftbukkit.util.LongObjectHashMap;
+import org.bukkit.event.world.ChunkUnloadEvent;
+// CraftBukkit end
+
public class ChunkProviderServer implements IChunkProvider {
private static final Logger b = LogManager.getLogger();
- public Set unloadQueue = Collections.newSetFromMap(new ConcurrentHashMap());
+ public LongHashSet unloadQueue = new LongHashSet(); // CraftBukkit - LongHashSet
public Chunk emptyChunk;
public IChunkProvider chunkProvider;
private IChunkLoader chunkLoader;
- public boolean forceChunkLoad = true;
- public LongHashMap chunks = new LongHashMap();
- private List chunkList = Lists.newArrayList();
- private WorldServer world;
+ public boolean forceChunkLoad = false; // CraftBukkit - true -> false
+ public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>();
+ public WorldServer world; // CraftBukkit- public
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
this.emptyChunk = new EmptyChunk(worldserver, 0, 0);
@@ -30,40 +41,93 @@
}
public boolean isChunkLoaded(int i, int j) {
- return this.chunks.contains(ChunkCoordIntPair.a(i, j));
+ return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit
}
- public List a() {
- return this.chunkList;
+ // CraftBukkit start - Change return type to Collection and return the values of our chunk map
+ public java.util.Collection a() {
+ // return this.chunkList;
+ return this.chunks.values();
+ // CraftBukkit end
}
public void queueUnload(int i, int j) {
if (this.world.worldProvider.e()) {
if (!this.world.c(i, j)) {
- this.unloadQueue.add(Long.valueOf(ChunkCoordIntPair.a(i, j)));
+ // CraftBukkit start
+ this.unloadQueue.add(i, j);
+
+ Chunk c = chunks.get(LongHash.toLong(i, j));
+ if (c != null) {
+ c.mustSave = true;
+ }
+ // CraftBukkit end
}
} else {
- this.unloadQueue.add(Long.valueOf(ChunkCoordIntPair.a(i, j)));
+ // CraftBukkit start
+ this.unloadQueue.add(i, j);
+
+ Chunk c = chunks.get(LongHash.toLong(i, j));
+ if (c != null) {
+ c.mustSave = true;
+ }
+ // CraftBukkit end
}
}
public void b() {
- Iterator iterator = this.chunkList.iterator();
+ Iterator iterator = this.chunks.values().iterator();
while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next();
this.queueUnload(chunk.locX, chunk.locZ);
}
-
+ }
+
+ // CraftBukkit start - Add async variant, provide compatibility
+ public Chunk getChunkIfLoaded(int x, int z) {
+ return chunks.get(LongHash.toLong(x, z));
}
public Chunk getChunkAt(int i, int j) {
- long k = ChunkCoordIntPair.a(i, j);
-
- this.unloadQueue.remove(Long.valueOf(k));
- Chunk chunk = (Chunk) this.chunks.getEntry(k);
+ return getChunkAt(i, j, null);
+ }
+
+ public Chunk getChunkAt(int i, int j, Runnable runnable) {
+ unloadQueue.remove(i, j);
+ Chunk chunk = chunks.get(LongHash.toLong(i, j));
+ ChunkRegionLoader loader = null;
+
+ if (this.chunkLoader instanceof ChunkRegionLoader) {
+ loader = (ChunkRegionLoader) this.chunkLoader;
+
+ }
+ // We can only use the queue for already generated chunks
+ if (chunk == null && loader != null && loader.chunkExists(world, i, j)) {
+ if (runnable != null) {
+ ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
+ return null;
+ } else {
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ }
+ } else if (chunk == null) {
+ chunk = originalGetChunkAt(i, j);
+ }
+
+ // If we didn't load the chunk async and have a callback run it now
+ if (runnable != null) {
+ runnable.run();
+ }
+
+ return chunk;
+ }
+ public Chunk originalGetChunkAt(int i, int j) {
+ this.unloadQueue.remove(i, j);
+ Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j));
+ boolean newChunk = false;
+ // CraftBukkit end
if (chunk == null) {
chunk = this.loadChunk(i, j);
@@ -78,16 +142,44 @@
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Chunk to be generated");
crashreportsystemdetails.a("Location", (Object) String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
- crashreportsystemdetails.a("Position hash", (Object) Long.valueOf(k));
+ crashreportsystemdetails.a("Position hash", (Object) Long.valueOf(LongHash.toLong(i, j))); // CraftBukkit - Use LongHash
crashreportsystemdetails.a("Generator", (Object) this.chunkProvider.getName());
throw new ReportedException(crashreport);
}
}
+ newChunk = true; // CraftBukkit
}
- this.chunks.put(k, chunk);
- this.chunkList.add(chunk);
+ this.chunks.put(LongHash.toLong(i, j), chunk);
chunk.addEntities();
+
+ // CraftBukkit start
+ Server server = world.getServer();
+ if (server != null) {
+ /*
+ * If it's a new world, the first few chunks are generated inside
+ * the World constructor. We can't reliably alter that, so we have
+ * no way of creating a CraftWorld/CraftServer at that point.
+ */
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, newChunk));
+ }
+
+ // Update neighbor counts
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
+ if (x == 0 && z == 0) {
+ continue;
+ }
+
+ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
+ if (neighbor != null) {
+ neighbor.setNeighborLoaded(-x, -z);
+ chunk.setNeighborLoaded(x, z);
+ }
+ }
+ }
+ // CraftBukkit end
+
chunk.loadNearby(this, this, i, j);
}
@@ -95,9 +187,22 @@
}
public Chunk getOrCreateChunk(int i, int j) {
- Chunk chunk = (Chunk) this.chunks.getEntry(ChunkCoordIntPair.a(i, j));
+ // CraftBukkit start
+ Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j));
- return chunk == null ? (!this.world.ad() && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
+ chunk = chunk == null ? (!this.world.ad() && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
+
+ if (chunk == emptyChunk) return chunk;
+ if (i != chunk.locX || j != chunk.locZ) {
+ b.error("Chunk (" + chunk.locX + ", " + chunk.locZ + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'");
+ b.error(chunk.getClass().getName());
+ Throwable ex = new Throwable();
+ ex.fillInStackTrace();
+ ex.printStackTrace();
+ }
+
+ return chunk;
+ // CraftBukkit end
}
public Chunk loadChunk(int i, int j) {
@@ -138,10 +243,13 @@
try {
chunk.setLastSaved(this.world.getTime());
this.chunkLoader.a(this.world, chunk);
- } catch (IOException ioexception) {
+ // CraftBukkit start - IOException to Exception
+ } catch (Exception ioexception) {
ChunkProviderServer.b.error("Couldn\'t save chunk", ioexception);
+ /* Remove extra exception
} catch (ExceptionWorldConflict exceptionworldconflict) {
ChunkProviderServer.b.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", exceptionworldconflict);
+ // CraftBukkit end */
}
}
@@ -154,6 +262,30 @@
chunk.n();
if (this.chunkProvider != null) {
this.chunkProvider.getChunkAt(ichunkprovider, i, j);
+
+ // CraftBukkit start
+ BlockSand.instaFall = true;
+ Random random = new Random();
+ random.setSeed(world.getSeed());
+ long xRand = random.nextLong() / 2L * 2L + 1L;
+ long zRand = random.nextLong() / 2L * 2L + 1L;
+ random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed());
+
+ org.bukkit.World world = this.world.getWorld();
+ if (world != null) {
+ this.world.populating = true;
+ try {
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
+ populator.populate(world, random, chunk.bukkitChunk);
+ }
+ } finally {
+ this.world.populating = false;
+ }
+ }
+ BlockSand.instaFall = false;
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
+ // CraftBukkit end
+
chunk.e();
}
}
@@ -173,9 +305,12 @@
public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
int i = 0;
-
- for (int j = 0; j < this.chunkList.size(); ++j) {
- Chunk chunk = (Chunk) this.chunkList.get(j);
+
+ // CraftBukkit start
+ Iterator iterator = this.chunks.values().iterator();
+ while (iterator.hasNext()) {
+ Chunk chunk = (Chunk) iterator.next();
+ // CraftBukkit end
if (flag) {
this.saveChunkNOP(chunk);
@@ -203,22 +338,42 @@
public boolean unloadChunks() {
if (!this.world.savingDisabled) {
- for (int i = 0; i < 100; ++i) {
- if (!this.unloadQueue.isEmpty()) {
- Long olong = (Long) this.unloadQueue.iterator().next();
- Chunk chunk = (Chunk) this.chunks.getEntry(olong.longValue());
-
+ // CraftBukkit start
+ Server server = this.world.getServer();
+ for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); ++i) {
+ long chunkcoordinates = this.unloadQueue.popFirst();
+ Chunk chunk = this.chunks.get(chunkcoordinates);
+ if (chunk == null) continue;
+
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
if (chunk != null) {
chunk.removeEntities();
this.saveChunk(chunk);
this.saveChunkNOP(chunk);
- this.chunks.remove(olong.longValue());
- this.chunkList.remove(chunk);
+ this.chunks.remove(chunkcoordinates); // CraftBukkit
}
- this.unloadQueue.remove(olong);
+ // this.unloadQueue.remove(olong);
+
+ // Update neighbor counts
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
+ if (x == 0 && z == 0) {
+ continue;
+ }
+
+ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
+ if (neighbor != null) {
+ neighbor.setNeighborUnloaded(-x, -z);
+ chunk.setNeighborUnloaded(x, z);
+ }
+ }
+ }
}
- }
+ }
+ // CraftBukkit end
if (this.chunkLoader != null) {
this.chunkLoader.a();
@@ -233,7 +388,8 @@
}
public String getName() {
- return "ServerChunkCache: " + this.chunks.count() + " Drop: " + this.unloadQueue.size();
+ // CraftBukkit - this.chunks.count() -> .size()
+ return "ServerChunkCache: " + this.chunks.size() + " Drop: " + this.unloadQueue.size();
}
public List getMobsFor(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
@@ -245,7 +401,8 @@
}
public int getLoadedChunks() {
- return this.chunks.count();
+ // CraftBukkit - this.chunks.count() -> this.chunks.size()
+ return this.chunks.size();
}
public void recreateStructures(Chunk chunk, int i, int j) {}

Datei anzeigen

@ -0,0 +1,131 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ChunkRegionLoader.java 2014-11-27 08:59:46.593422322 +1100
+++ src/main/java/net/minecraft/server/ChunkRegionLoader.java 2014-11-27 08:42:10.136850942 +1100
@@ -23,8 +23,40 @@
public ChunkRegionLoader(File file) {
this.e = file;
}
+
+ // CraftBukkit start
+ public boolean chunkExists(World world, int i, int j) {
+ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
+
+ synchronized (this.d) {
+ if (this.c.contains(chunkcoordintpair)) {
+ for (int k = 0; k < this.b.size(); ++k) {
+ if (((PendingChunkToSave) this.b.get(k)).a.equals(chunkcoordintpair)) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return RegionFileCache.a(this.e, i, j).chunkExists(i & 31, j & 31);
+ }
+ // CraftBukkit end
+ // CraftBukkit start - Add async variant, provide compatibility
public Chunk a(World world, int i, int j) {
+ Object[] data = loadChunk(world, i, j);
+ if (data != null) {
+ Chunk chunk = (Chunk) data[0];
+ NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
+ loadEntities(chunk, nbttagcompound.getCompound("Level"), world);
+ return chunk;
+ }
+
+ return null;
+ }
+
+ public Object[] loadChunk(World world, int i, int j) {
+ // CraftBukkit end
NBTTagCompound nbttagcompound = null;
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
Object object = this.d;
@@ -53,7 +85,7 @@
return this.a(world, i, j, nbttagcompound);
}
- 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 " + i + "," + j + " is missing level data, skipping");
return null;
@@ -64,18 +96,42 @@
Chunk chunk = this.a(world, nbttagcompound.getCompound("Level"));
if (!chunk.a(i, j)) {
- ChunkRegionLoader.a.error("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.locX + ", " + chunk.locZ + ")");
- nbttagcompound.setInt("xPos", i);
- nbttagcompound.setInt("zPos", j);
+ a.error("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.locX + ", " + chunk.locZ + ")");
+ nbttagcompound.getCompound("Level").setInt("xPos", i);
+ nbttagcompound.getCompound("Level").setInt("zPos", j);
+
+ // CraftBukkit start - Have to move tile entities since we don't load them at this stage
+ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10);
+ if (tileEntities != null) {
+ for (int te = 0; te < tileEntities.size(); te++) {
+ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te);
+ int x = tileEntity.getInt("x") - chunk.locX * 16;
+ int z = tileEntity.getInt("z") - chunk.locZ * 16;
+ tileEntity.setInt("x", i * 16 + x);
+ tileEntity.setInt("z", j * 16 + z);
+ }
+ }
+ // CraftBukkit end
chunk = this.a(world, nbttagcompound.getCompound("Level"));
}
- return chunk;
+ // CraftBukkit start
+ Object[] data = new Object[2];
+ data[0] = chunk;
+ data[1] = nbttagcompound;
+ return data;
+ // CraftBukkit end
}
}
public void a(World world, Chunk chunk) {
- world.checkSession();
+ // CraftBukkit start - "handle" exception
+ try {
+ world.checkSession();
+ } catch (ExceptionWorldConflict ex) {
+ ex.printStackTrace();
+ }
+ // CraftBukkit end
try {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -133,7 +189,7 @@
return true;
}
- public void a(PendingChunkToSave pendingchunktosave) {
+ public void a(PendingChunkToSave pendingchunktosave) throws java.io.IOException { // CraftBukkit - added throws
DataOutputStream dataoutputstream = RegionFileCache.d(this.e, pendingchunktosave.a.x, pendingchunktosave.a.z);
NBTCompressedStreamTools.a(pendingchunktosave.b, (DataOutput) dataoutputstream);
@@ -320,7 +376,13 @@
if (nbttagcompound.hasKeyOfType("Biomes", 7)) {
chunk.a(nbttagcompound.getByteArray("Biomes"));
}
+
+ // CraftBukkit start - End this method here and split off entity loading to another method
+ return chunk;
+ }
+ public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
+ // CraftBukkit end
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
if (nbttaglist1 != null) {
@@ -379,6 +441,6 @@
}
}
- return chunk;
+ // return chunk; // CraftBukkit
}
}

Datei anzeigen

@ -0,0 +1,21 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ChunkSection.java 2014-11-27 08:59:46.597422305 +1100
+++ src/main/java/net/minecraft/server/ChunkSection.java 2014-11-27 08:42:10.172850872 +1100
@@ -19,6 +19,18 @@
}
+ // CraftBukkit start
+ public ChunkSection(int y, boolean flag, char[] blockIds) {
+ this.yPos = y;
+ this.blockIds = blockIds;
+ this.emittedLight = new NibbleArray();
+ if (flag) {
+ this.skyLight = new NibbleArray();
+ }
+ recalcBlockCounts();
+ }
+ // CraftBukkit end
+
public IBlockData getType(int i, int j, int k) {
IBlockData iblockdata = (IBlockData) Block.d.a(this.blockIds[j << 8 | k << 4 | i]);

Datei anzeigen

@ -0,0 +1,162 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/CommandBlockListenerAbstract.java 2014-11-27 08:59:46.597422305 +1100
+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-11-27 08:42:10.172850872 +1100
@@ -4,6 +4,13 @@
import java.util.Date;
import java.util.concurrent.Callable;
+// CraftBukkit start
+import java.util.ArrayList;
+import org.apache.logging.log4j.Level;
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+import com.google.common.base.Joiner;
+// CraftBukkit end
+
public abstract class CommandBlockListenerAbstract implements ICommandListener {
private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss");
@@ -13,6 +20,7 @@
public String e = "";
private String f = "@";
private final CommandObjectiveExecutor g = new CommandObjectiveExecutor();
+ protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender
public CommandBlockListenerAbstract() {}
@@ -79,7 +87,109 @@
try {
this.d = null;
- this.b = icommandhandler.a(this, this.e);
+ // this.b = icommandhandler.a(this, this.e);
+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
+ org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap();
+ Joiner joiner = Joiner.on(" ");
+ String command = this.e;
+ if (this.e.startsWith("/")) {
+ command = this.e.substring(1);
+ }
+ String[] args = command.split(" ");
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+
+ // Block disallowed commands
+ if (args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("op") ||
+ args[0].equalsIgnoreCase("deop") || args[0].equalsIgnoreCase("ban") || args[0].equalsIgnoreCase("ban-ip") ||
+ args[0].equalsIgnoreCase("pardon") || args[0].equalsIgnoreCase("pardon-ip") || args[0].equalsIgnoreCase("reload")) {
+ this.b = 0;
+ return;
+ }
+
+ // If the world has no players don't run
+ if (this.getWorld().players.isEmpty()) {
+ this.b = 0;
+ return;
+ }
+
+ // Handle vanilla commands;
+ if (minecraftserver.server.getCommandBlockOverride(args[0])) {
+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
+ this.b = ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(this, this.e);
+ return;
+ }
+ }
+
+ // Make sure this is a valid command
+ if (commandMap.getCommand(args[0]) == null) {
+ this.b = 0;
+ return;
+ }
+
+ // testfor command requires special handling
+ if (args[0].equalsIgnoreCase("testfor")) {
+ if (args.length < 2) {
+ this.b = 0;
+ return;
+ }
+
+ EntityPlayer[] players = ((java.util.List<EntityPlayer>)PlayerSelector.getPlayers(this, args[1], EntityPlayer.class)).toArray(new EntityPlayer[0]);
+
+ if (players != null && players.length > 0) {
+ this.b = players.length;
+ return;
+ } else {
+ EntityPlayer player = MinecraftServer.getServer().getPlayerList().getPlayer(args[1]);
+ if (player == null) {
+ this.b = 0;
+ return;
+ } else {
+ this.b = 1;
+ return;
+ }
+ }
+ }
+
+ commands.add(args);
+
+ // Find positions of command block syntax, if any
+ ArrayList<String[]> newCommands = new ArrayList<String[]>();
+ for (int i = 0; i < args.length; i++) {
+ if (PlayerSelector.isPattern(args[i])) {
+ for (int j = 0; j < commands.size(); j++) {
+ newCommands.addAll(this.buildCommands(commands.get(j), i));
+ }
+ ArrayList<String[]> temp = commands;
+ commands = newCommands;
+ newCommands = temp;
+ newCommands.clear();
+ }
+ }
+
+ int completed = 0;
+
+ // Now dispatch all of the commands we ended up with
+ for (int i = 0; i < commands.size(); i++) {
+ try {
+ if (commandMap.dispatch(sender, joiner.join(java.util.Arrays.asList(commands.get(i))))) {
+ completed++;
+ }
+ } catch (Throwable exception) {
+ if(this instanceof TileEntityCommandListener) {
+ TileEntityCommandListener listener = (TileEntityCommandListener) this;
+ MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
+ } else if (this instanceof EntityMinecartCommandBlockListener) {
+ EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) this;
+ MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
+ } else {
+ MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), exception);
+ }
+ }
+ }
+
+ this.b = completed;
+ // CraftBukkit end
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
@@ -91,8 +201,26 @@
} else {
this.b = 0;
}
+ }
+
+ // CraftBukkit start
+ private ArrayList<String[]> buildCommands(String[] args, int pos) {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+ EntityPlayer[] players = ((java.util.List<EntityPlayer>)PlayerSelector.getPlayers(this, args[pos], EntityPlayer.class)).toArray(new EntityPlayer[0]);
+ if (players != null) {
+ for (EntityPlayer player : players) {
+ if (player.world != this.getWorld()) {
+ continue;
+ }
+ String[] command = args.clone();
+ command[pos] = player.getName();
+ commands.add(command);
+ }
+ }
+ return commands;
}
+ // CraftBukkit end
public String getName() {
return this.f;

204
nms-patches/Container.patch Normale Datei
Datei anzeigen

@ -0,0 +1,204 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/Container.java 2014-11-27 08:59:46.617422217 +1100
+++ src/main/java/net/minecraft/server/Container.java 2014-11-27 08:42:10.156850903 +1100
@@ -7,6 +7,17 @@
import java.util.List;
import java.util.Set;
+// CraftBukkit start
+import java.util.HashMap;
+import java.util.Map;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.InventoryDragEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.InventoryView;
+// CraftBukkit end
+
public abstract class Container {
public List b = Lists.newArrayList();
@@ -17,6 +28,18 @@
private final Set h = Sets.newHashSet();
protected List listeners = Lists.newArrayList();
private Set i = Sets.newHashSet();
+
+ // CraftBukkit start
+ public boolean checkReachable = true;
+ public abstract InventoryView getBukkitView();
+ public void transferTo(Container other, org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ InventoryView source = this.getBukkitView(), destination = other.getBukkitView();
+ ((CraftInventory) source.getTopInventory()).getInventory().onClose(player);
+ ((CraftInventory) source.getBottomInventory()).getInventory().onClose(player);
+ ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player);
+ ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player);
+ }
+ // CraftBukkit end
public Container() {}
@@ -124,6 +147,7 @@
l = playerinventory.getCarried().count;
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();
@@ -141,16 +165,49 @@
}
l -= itemstack2.count - j1;
- slot1.set(itemstack2);
+ // slot1.set(itemstack2);
+ draggedSlots.put(slot1.rawSlotIndex, itemstack2); // CraftBukkit - Put in map instead of setting
}
}
+
+ // CraftBukkit start - InventoryDragEvent
+ InventoryView view = getBukkitView();
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1);
+ 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()));
+ }
+
+ // It's essential that we set the cursor to the new value here to prevent item duplication if a plugin closes the inventory.
+ ItemStack oldCursor = playerinventory.getCarried();
+ playerinventory.setCarried(CraftItemStack.asNMSCopy(newcursor));
+
+ InventoryDragEvent event = new InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), CraftItemStack.asBukkitCopy(oldCursor), this.dragType == 1, eventmap);
+ entityhuman.world.getServer().getPluginManager().callEvent(event);
+
+ // Whether or not a change was made to the inventory that requires an update.
+ boolean needsUpdate = event.getResult() != Result.DEFAULT;
+
+ if (event.getResult() != Result.DENY) {
+ for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
+ view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
+ }
+ // The only time the carried item will be set to null is if the inventory is closed by the server.
+ // If the inventory is closed by the server, then the cursor items are dropped. This is why we change the cursor early.
+ if (playerinventory.getCarried() != null) {
+ playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
+ needsUpdate = true;
- itemstack1.count = l;
- if (itemstack1.count <= 0) {
- itemstack1 = null;
+ }
+ } else {
+ playerinventory.setCarried(oldCursor);
}
- playerinventory.setCarried(itemstack1);
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).updateInventory(this);
+ }
+ // CraftBukkit end
}
this.d();
@@ -173,8 +230,14 @@
}
if (j == 1) {
- entityhuman.drop(playerinventory.getCarried().a(1), true);
- if (playerinventory.getCarried().count == 0) {
+ // CraftBukkit start - Store a reference
+ ItemStack itemstack4 = playerinventory.getCarried();
+ if (itemstack4.count > 0) {
+ entityhuman.drop(itemstack4.a(1), true);
+ }
+
+ if (itemstack4.count == 0) {
+ // CraftBukkit end
playerinventory.setCarried((ItemStack) null);
}
}
@@ -223,7 +286,11 @@
if (itemstack4.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 (itemstack4 == null) {
@@ -249,7 +316,11 @@
itemstack4.a(k1);
if (itemstack4.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 += k1;
} else if (itemstack4.count <= slot2.getMaxStackSize(itemstack4)) {
@@ -258,7 +329,9 @@
}
} else if (itemstack1.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack4.getData()) && ItemStack.equals(itemstack1, itemstack4)) {
k1 = itemstack1.count;
- if (k1 > 0 && k1 + itemstack4.count <= itemstack4.getMaxStackSize()) {
+ // CraftBukkit start - itemstack4.getMaxStackSize() -> maxStack
+ int maxStack = Math.min(itemstack4.getMaxStackSize(), slot2.getMaxStackSize());
+ if (k1 > 0 && k1 + itemstack4.count <= maxStack) {
itemstack4.count += k1;
itemstack1 = slot2.a(k1);
if (itemstack1.count == 0) {
@@ -266,11 +339,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
}
}
slot2.f();
+ // CraftBukkit start - Make sure the client has the right slot contents
+ if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem()));
+ // Updating a crafting inventory makes the client reset the result slot, have to send it again
+ if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem()));
+ }
+ }
+ // CraftBukkit end
}
}
} else if (k == 2 && j >= 0 && j < 9) {
@@ -411,17 +497,20 @@
if (itemstack1 != null && itemstack1.getItem() == itemstack.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(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;
slot.f();
flag1 = true;
}
+ // CraftBukkit end
}
if (flag) {

Datei anzeigen

@ -0,0 +1,51 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerAnvil.java 2014-11-27 08:59:46.601422287 +1100
+++ src/main/java/net/minecraft/server/ContainerAnvil.java 2014-11-27 08:42:10.144850927 +1100
@@ -6,6 +6,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger();
@@ -17,8 +19,13 @@
private int k;
private String l;
private final EntityHuman m;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerAnvil(PlayerInventory playerinventory, World world, BlockPosition blockposition, EntityHuman entityhuman) {
+ this.player = playerinventory; // CraftBukkit
this.j = blockposition;
this.i = world;
this.m = entityhuman;
@@ -265,6 +272,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;
}
@@ -328,4 +336,17 @@
static int b(ContainerAnvil containeranvil) {
return containeranvil.k;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(this.h, this.g);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,58 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerAnvilInventory.java 2014-11-27 08:59:46.597422305 +1100
+++ src/main/java/net/minecraft/server/ContainerAnvilInventory.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,8 +1,43 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class ContainerAnvilInventory extends InventorySubcontainer {
final ContainerAnvil a;
+
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ public org.bukkit.entity.Player player;
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents() {
+ return this.items;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return this.player;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
ContainerAnvilInventory(ContainerAnvil containeranvil, String s, boolean flag, int i) {
super(s, flag, i);
@@ -13,4 +48,11 @@
super.update();
this.a.a((IInventory) this);
}
+
+ // CraftBukkit start - override inherited maxStack from InventorySubcontainer
+ @Override
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,47 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerBeacon.java 2014-11-27 08:59:46.601422287 +1100
+++ src/main/java/net/minecraft/server/ContainerBeacon.java 2014-11-27 08:42:10.156850903 +1100
@@ -1,11 +1,18 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerBeacon extends Container {
private IInventory a;
private final SlotBeacon f;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerBeacon(IInventory iinventory, IInventory iinventory1) {
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
this.a = iinventory1;
this.a((Slot) (this.f = new SlotBeacon(this, iinventory1, 0, 136, 110)));
byte b0 = 36;
@@ -35,6 +42,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.a.a(entityhuman);
}
@@ -83,4 +91,17 @@
return itemstack;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon((TileEntityBeacon) this.a); // TODO - check this
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,52 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerBrewingStand.java 2014-11-27 08:59:46.605422269 +1100
+++ src/main/java/net/minecraft/server/ContainerBrewingStand.java 2014-11-27 08:42:10.172850872 +1100
@@ -1,12 +1,23 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerBrewingStand extends Container {
private IInventory brewingStand;
private final Slot f;
private int g;
+
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerBrewingStand(PlayerInventory playerinventory, IInventory iinventory) {
+ player = playerinventory; // CraftBukkit
this.brewingStand = iinventory;
this.a((Slot) (new SlotPotionBottle(playerinventory.player, iinventory, 0, 56, 46)));
this.a((Slot) (new SlotPotionBottle(playerinventory.player, iinventory, 1, 79, 53)));
@@ -47,6 +58,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.brewingStand.a(entityhuman);
}
@@ -101,4 +113,17 @@
return itemstack;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryBrewer inventory = new CraftInventoryBrewer(this.brewingStand);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,59 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerChest.java 2014-11-27 08:59:46.605422269 +1100
+++ src/main/java/net/minecraft/server/ContainerChest.java 2014-11-27 08:42:10.172850872 +1100
@@ -1,15 +1,48 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerChest extends Container {
public IInventory container;
private int f;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory;
+ if (this.container instanceof PlayerInventory) {
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((PlayerInventory) this.container);
+ } else if (this.container instanceof InventoryLargeChest) {
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) this.container);
+ } else {
+ inventory = new CraftInventory(this.container);
+ }
+
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerChest(IInventory iinventory, IInventory iinventory1, EntityHuman entityhuman) {
this.container = iinventory1;
this.f = iinventory1.getSize() / 9;
iinventory1.startOpen(entityhuman);
int i = (this.f - 4) * 18;
+
+ // CraftBukkit start - Save player
+ // TODO: Should we check to make sure it really is an InventoryPlayer?
+ this.player = (PlayerInventory) iinventory;
+ // CraftBukkit end
int j;
int k;
@@ -33,6 +66,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.container.a(entityhuman);
}

Datei anzeigen

@ -0,0 +1,54 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerDispenser.java 2014-11-27 08:59:46.605422269 +1100
+++ src/main/java/net/minecraft/server/ContainerDispenser.java 2014-11-27 08:42:10.148850918 +1100
@@ -1,11 +1,24 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerDispenser extends Container {
- private IInventory items;
+ public IInventory items; // CraftBukkit - private -> public
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerDispenser(IInventory iinventory, IInventory iinventory1) {
this.items = iinventory1;
+ // CraftBukkit start - Save player
+ // TODO: Should we check to make sure it really is an InventoryPlayer?
+ this.player = (PlayerInventory)iinventory;
+ // CraftBukkit end
int i;
int j;
@@ -29,6 +42,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.items.a(entityhuman);
}
@@ -63,4 +77,17 @@
return itemstack;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory = new CraftInventory(this.items);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,170 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerEnchantTable.java 2014-11-27 08:59:46.609422252 +1100
+++ src/main/java/net/minecraft/server/ContainerEnchantTable.java 2014-11-27 08:42:10.120850973 +1100
@@ -3,15 +3,31 @@
import java.util.List;
import java.util.Random;
+// CraftBukkit start
+import java.util.Map;
+
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.enchantment.EnchantItemEvent;
+import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class ContainerEnchantTable extends Container {
- public IInventory enchantSlots = new ContainerEnchantTableInventory(this, "Enchant", true, 2);
+ // CraftBukkit - make type specific (changed from IInventory)
+ public ContainerEnchantTableInventory enchantSlots = new ContainerEnchantTableInventory(this, "Enchant", true, 2);
private World world;
private BlockPosition position;
private Random k = new Random();
public int f;
public int[] costs = new int[3];
public int[] h = new int[] { -1, -1, -1};
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+ // CraftBukkit end
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
this.world = world;
@@ -31,7 +47,11 @@
for (i = 0; i < 9; ++i) {
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
-
+
+ // CraftBukkit start
+ player = (Player) playerinventory.player.getBukkitEntity();
+ enchantSlots.player = player;
+ // CraftBukkit end
}
public void addSlotListener(ICrafting icrafting) {
@@ -67,7 +87,7 @@
ItemStack itemstack = iinventory.getItem(0);
int i;
- if (itemstack != null && itemstack.v()) {
+ if (itemstack != null) { // CraftBukkit - relax condition
if (!this.world.isStatic) {
i = 0;
@@ -114,6 +134,20 @@
this.costs[j] = 0;
}
}
+
+ // 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());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ for (i = 0; i < 3; ++i) {
+ this.costs[i] = 0;
+ }
+ return;
+ }
+ // CraftBukkit end
for (j = 0; j < 3; ++j) {
if (this.costs[j] > 0) {
@@ -149,24 +183,56 @@
} else if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
if (!this.world.isStatic) {
List list = this.a(itemstack, i, this.costs[i]);
+ // CraftBukkit start - Provide an empty enchantment list
+ if (list == null) {
+ list = new java.util.ArrayList<WeightedRandomEnchant>();
+ }
+ // CraftBukkit end
boolean flag = itemstack.getItem() == Items.BOOK;
if (list != null) {
- entityhuman.b(j);
+ // CraftBukkit start
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
+ enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level);
+ }
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+
+ 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);
}
+
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
+ try {
+ if (flag) {
+ int enchantId = entry.getKey().getId();
+ if (Enchantment.getById(enchantId) == null) {
+ continue;
+ }
- for (int k = 0; k < list.size(); ++k) {
- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(k);
-
- if (flag) {
- Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
- } else {
- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
+ WeightedRandomEnchant enchantment = new WeightedRandomEnchant(Enchantment.getById(enchantId), entry.getValue());
+ Items.ENCHANTED_BOOK.a(itemstack, enchantment);
+ } else {
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
+ }
+ } catch (IllegalArgumentException e) {
+ /* Just swallow invalid enchantments */
}
}
+
+ entityhuman.b(level);
+ // CraftBukkit end
+ // CraftBukkit - TODO: let plugins change this
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.count -= j;
if (itemstack1.count <= 0) {
@@ -212,6 +278,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;
}
@@ -263,5 +330,18 @@
}
return itemstack;
+ }
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots);
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
}
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,58 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerEnchantTableInventory.java 2014-11-27 08:59:46.609422252 +1100
+++ src/main/java/net/minecraft/server/ContainerEnchantTableInventory.java 2014-11-27 08:42:10.088851036 +1100
@@ -1,8 +1,45 @@
package net.minecraft.server;
-class ContainerEnchantTableInventory extends InventorySubcontainer {
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
+// CraftBukkit -> public
+public class ContainerEnchantTableInventory extends InventorySubcontainer {
final ContainerEnchantTable enchantTable;
+
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ public org.bukkit.entity.Player player;
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents() {
+ return this.items;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return this.player;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+ // CraftBukkit end
ContainerEnchantTableInventory(ContainerEnchantTable containerenchanttable, String s, boolean flag, int i) {
super(s, flag, i);
@@ -10,7 +47,7 @@
}
public int getMaxStackSize() {
- return 64;
+ return maxStack; // CraftBukkit
}
public void update() {

Datei anzeigen

@ -0,0 +1,51 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerFurnace.java 2014-11-27 08:59:46.613422234 +1100
+++ src/main/java/net/minecraft/server/ContainerFurnace.java 2014-11-27 08:42:10.116850981 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerFurnace extends Container {
private final IInventory furnace;
@@ -7,12 +12,29 @@
private int g;
private int h;
private int i;
+
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.furnace);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerFurnace(PlayerInventory playerinventory, IInventory iinventory) {
this.furnace = iinventory;
this.a(new Slot(iinventory, 0, 56, 17));
this.a((Slot) (new SlotFurnaceFuel(iinventory, 1, 56, 53)));
this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)));
+ this.player = playerinventory; // CraftBukkit - save player
int i;
@@ -63,6 +85,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.furnace.a(entityhuman);
}

Datei anzeigen

@ -0,0 +1,44 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerHopper.java 2014-11-27 08:59:46.613422234 +1100
+++ src/main/java/net/minecraft/server/ContainerHopper.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,11 +1,33 @@
package net.minecraft.server;
+// 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;
+
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory = new CraftInventory(this.hopper);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerHopper(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) {
this.hopper = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
iinventory.startOpen(entityhuman);
byte b0 = 51;
@@ -28,6 +50,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.a(entityhuman);
}

Datei anzeigen

@ -0,0 +1,36 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerHorse.java 2014-11-27 08:59:46.613422234 +1100
+++ src/main/java/net/minecraft/server/ContainerHorse.java 2014-11-27 08:42:10.124850965 +1100
@@ -1,11 +1,33 @@
package net.minecraft.server;
+// 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 IInventory a;
private EntityHorse f;
+
+ // CraftBukkit start
+ org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity;
+ PlayerInventory player;
+
+ @Override
+ public InventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryHorse(this.a);
+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), inventory, this);
+ }
public ContainerHorse(IInventory iinventory, IInventory iinventory1, EntityHorse entityhorse, EntityHuman entityhuman) {
+ player = (PlayerInventory) iinventory;
+ // CraftBukkit end
this.a = iinventory1;
this.f = entityhorse;
byte b0 = 3;

Datei anzeigen

@ -0,0 +1,36 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerMerchant.java 2014-11-27 08:59:46.617422217 +1100
+++ src/main/java/net/minecraft/server/ContainerMerchant.java 2014-11-27 08:42:10.136850942 +1100
@@ -1,10 +1,25 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerMerchant extends Container {
private IMerchant merchant;
private InventoryMerchant f;
private final World g;
+
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity == null) {
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant((InventoryMerchant) f), this);
+ }
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerMerchant(PlayerInventory playerinventory, IMerchant imerchant, World world) {
this.merchant = imerchant;
@@ -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)));
+ this.player = playerinventory; // CraftBukkit - save player
int i;

Datei anzeigen

@ -0,0 +1,74 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerPlayer.java 2014-11-27 08:59:46.621422199 +1100
+++ src/main/java/net/minecraft/server/ContainerPlayer.java 2014-11-27 08:42:10.104851005 +1100
@@ -1,15 +1,28 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerPlayer extends Container {
public InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2);
public IInventory resultInventory = new InventoryCraftResult();
public boolean g;
private final EntityHuman h;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, EntityHuman entityhuman) {
this.g = flag;
this.h = entityhuman;
+ this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
+ this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
+ this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot
+ this.player = playerinventory; // CraftBukkit - save player
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 144, 36)));
int i;
@@ -35,11 +48,22 @@
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
- this.a((IInventory) this.craftInventory);
+ // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty
}
public void a(IInventory iinventory) {
- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.h.world));
+ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.h.world));
+ // CraftBukkit start (Note: the following line would cause an error if called during construction)
+ CraftingManager.getInstance().lastCraftView = getBukkitView();
+ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.h.world);
+ this.resultInventory.setItem(0, craftResult);
+ if (super.listeners.size() < 1) {
+ return;
+ }
+
+ EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it.
+ player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult));
+ // CraftBukkit end
}
public void b(EntityHuman entityhuman) {
@@ -119,4 +143,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,79 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ContainerWorkbench.java 2014-11-27 08:59:46.621422199 +1100
+++ src/main/java/net/minecraft/server/ContainerWorkbench.java 2014-11-27 08:42:10.156850903 +1100
@@ -1,13 +1,28 @@
package net.minecraft.server;
+// 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);
- public IInventory resultInventory = new InventoryCraftResult();
+ public InventoryCrafting craftInventory; // CraftBukkit - move initialization into constructor
+ public IInventory resultInventory; // CraftBukkit - move initialization into constructor
private World g;
private BlockPosition h;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerWorkbench(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
+ // CraftBukkit start - Switched order of IInventory construction and stored player
+ this.resultInventory = new InventoryCraftResult();
+ this.craftInventory = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player
+ this.craftInventory.resultInventory = this.resultInventory;
+ this.player = playerinventory;
+ // CraftBukkit end
this.g = world;
this.h = blockposition;
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35)));
@@ -35,7 +50,18 @@
}
public void a(IInventory iinventory) {
- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.g));
+ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.g));
+ // CraftBukkit start
+ CraftingManager.getInstance().lastCraftView = getBukkitView();
+ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.g);
+ this.resultInventory.setItem(0, craftResult);
+ if (super.listeners.size() < 1) {
+ return;
+ }
+
+ EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it.
+ player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult));
+ // CraftBukkit end
}
public void b(EntityHuman entityhuman) {
@@ -53,6 +79,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;
}
@@ -101,4 +128,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -0,0 +1,23 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ControllerLook.java 2014-11-27 08:59:46.621422199 +1100
+++ src/main/java/net/minecraft/server/ControllerLook.java 2014-11-27 08:42:10.172850872 +1100
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.TrigMath; // CraftBukkit
+
public class ControllerLook {
private EntityInsentient a;
@@ -45,8 +47,10 @@
double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight());
double d2 = this.g - this.a.locZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
- float f = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
- float f1 = (float) (-(Math.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
+ // CraftBukkit start - Math -> TrigMath
+ float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
+ float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
+ // CraftBukkit end
this.a.pitch = this.a(this.a.pitch, f1, this.c);
this.a.aI = this.a(this.a.aI, f, this.b);

Datei anzeigen

@ -0,0 +1,12 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/ControllerMove.java 2014-11-27 08:59:46.625422182 +1100
+++ src/main/java/net/minecraft/server/ControllerMove.java 2014-11-27 08:42:10.164850887 +1100
@@ -43,7 +43,8 @@
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 >= 2.500000277905201E-7D) {
- float f = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
+ // CraftBukkit - Math -> TrigMath
+ float f = (float) (org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.a.yaw = this.a(this.a.yaw, f, 30.0F);
this.a.j((float) (this.e * this.a.getAttributeInstance(GenericAttributes.d).getValue()));

Datei anzeigen

@ -0,0 +1,57 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/CraftingManager.java 2014-11-27 08:59:46.625422182 +1100
+++ src/main/java/net/minecraft/server/CraftingManager.java 2014-11-27 08:42:10.112850989 +1100
@@ -8,10 +8,16 @@
import java.util.Iterator;
import java.util.List;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class CraftingManager {
private static final CraftingManager a = new CraftingManager();
public List recipes = Lists.newArrayList();
+ // CraftBukkit start
+ public IRecipe lastRecipe;
+ public org.bukkit.inventory.InventoryView lastCraftView;
+ // CraftBukkit end
public static CraftingManager getInstance() {
return CraftingManager.a;
@@ -166,8 +172,15 @@
this.registerShapedRecipe(new ItemStack(Blocks.DAYLIGHT_DETECTOR), new Object[] { "GGG", "QQQ", "WWW", Character.valueOf('G'), Blocks.GLASS, Character.valueOf('Q'), Items.QUARTZ, Character.valueOf('W'), Blocks.WOODEN_SLAB});
this.registerShapedRecipe(new ItemStack(Blocks.HOPPER), new Object[] { "I I", "ICI", " I ", Character.valueOf('I'), Items.IRON_INGOT, Character.valueOf('C'), Blocks.CHEST});
this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, EnumStoneSlabVariant.STONE.a())});
+ // Collections.sort(this.recipes, new RecipeSorter(this)); // CraftBukkit - moved below
+ sort();
+ }
+
+ // CraftBukkit start
+ public void sort() {
Collections.sort(this.recipes, new RecipeSorter(this));
}
+ // CraftBukkit end
public ShapedRecipes registerShapedRecipe(ItemStack itemstack, Object... aobject) {
String s = "";
@@ -265,13 +278,18 @@
do {
if (!iterator.hasNext()) {
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
return null;
}
irecipe = (IRecipe) iterator.next();
- } while (!irecipe.a(inventorycrafting, world));
-
- return irecipe.a(inventorycrafting);
+ } while (!irecipe.a(inventorycrafting, world));
+
+ // CraftBukkit start - INVENTORY_PRE_CRAFT event
+ inventorycrafting.currentRecipe = irecipe;
+ ItemStack result = irecipe.a(inventorycrafting);
+ return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false);
+ // CraftBukkit end
}
public ItemStack[] b(InventoryCrafting inventorycrafting, World world) {

Datei anzeigen

@ -0,0 +1,10 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/CrashReport.java 2014-11-27 08:59:46.629422164 +1100
+++ src/main/java/net/minecraft/server/CrashReport.java 2014-11-27 08:42:10.172850872 +1100
@@ -40,6 +40,7 @@
this.d.a("Memory", (Callable) (new CrashReportMemory(this)));
this.d.a("JVM Flags", (Callable) (new CrashReportJVMFlags(this)));
this.d.a("IntCache", (Callable) (new CrashReportIntCacheSize(this)));
+ this.d.a("CraftBukkit Information", (Callable) (new org.bukkit.craftbukkit.CraftCrashReport())); // CraftBukkit
}
public String a() {

Datei anzeigen

@ -0,0 +1,162 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DedicatedServer.java 2014-11-27 08:59:46.629422164 +1100
+++ src/main/java/net/minecraft/server/DedicatedServer.java 2014-11-27 08:42:10.172850872 +1100
@@ -13,6 +13,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.io.PrintStream;
+import org.apache.logging.log4j.Level;
+
+import org.bukkit.craftbukkit.LoggerOutputStream;
+import org.bukkit.event.server.ServerCommandEvent;
+// CraftBukkit end
+
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger();
@@ -25,23 +33,48 @@
private EnumGamemode q;
private boolean r;
- public DedicatedServer(File file) {
- super(file, Proxy.NO_PROXY, DedicatedServer.a);
+ // CraftBukkit start - Signature changed
+ public DedicatedServer(joptsimple.OptionSet options) {
+ super(options, Proxy.NO_PROXY, a);
+ // super(file, Proxy.NO_PROXY, a);
+ // CraftBukkit end
new ThreadSleepForever(this, "Server Infinisleeper");
}
- protected boolean init() {
+ protected boolean init() throws java.net.UnknownHostException { // CraftBukkit - throws UnknownHostException
ThreadCommandReader threadcommandreader = new ThreadCommandReader(this, "Server console handler");
threadcommandreader.setDaemon(true);
threadcommandreader.start();
+
+ // CraftBukkit start - TODO: handle command-line logging arguments
+ java.util.logging.Logger global = java.util.logging.Logger.getLogger("");
+ global.setUseParentHandlers(false);
+ for (java.util.logging.Handler handler : global.getHandlers()) {
+ global.removeHandler(handler);
+ }
+ global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
+
+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) {
+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) {
+ logger.removeAppender(appender);
+ }
+ }
+
+ new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start();
+
+ System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
+ System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
+ // CraftBukkit end
+
DedicatedServer.LOGGER.info("Starting minecraft server version 1.8");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
}
DedicatedServer.LOGGER.info("Loading properties");
- this.propertyManager = new PropertyManager(new File("server.properties"));
+ this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support
this.o = new EULA(new File("eula.txt"));
if (!this.o.a()) {
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
@@ -90,13 +123,15 @@
try {
this.ao().a(inetaddress, this.Q());
- } catch (IOException ioexception) {
+ } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
DedicatedServer.LOGGER.warn("**** FAILED TO BIND TO PORT!");
DedicatedServer.LOGGER.warn("The exception was: {}", new Object[] { ioexception.toString()});
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
return false;
}
+ this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit
+
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.");
@@ -111,7 +146,8 @@
if (!NameReferencingFileConverter.a(this.propertyManager)) {
return false;
} else {
- this.a((PlayerList) (new DedicatedPlayerList(this)));
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up
+ this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
long j = System.nanoTime();
if (this.T() == null) {
@@ -166,7 +202,18 @@
DedicatedServer.LOGGER.info("Starting remote control listener");
this.m = new RemoteControlListener(this);
this.m.a();
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ if (this.server.getBukkitSpawnRadius() > -1) {
+ DedicatedServer.LOGGER.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
+ this.propertyManager.properties.remove("spawn-protection");
+ this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius());
+ this.server.removeBukkitSpawnRadius();
+ this.propertyManager.savePropertiesFile();
}
+ // CraftBukkit end
if (this.aQ() > 0L) {
Thread thread = new Thread(new ThreadWatchdog(this));
@@ -181,6 +228,12 @@
}
}
+ // CraftBukkit start
+ public PropertyManager getPropertyManager() {
+ return this.propertyManager;
+ }
+ // CraftBukkit end
+
public void setGamemode(EnumGamemode enumgamemode) {
super.setGamemode(enumgamemode);
this.q = enumgamemode;
@@ -203,6 +256,7 @@
}
protected void a(CrashReport crashreport) {
+ /* CraftBukkit start - not sure why you would want to continue running commands once the server crashed
while (this.isRunning()) {
this.aM();
@@ -212,7 +266,7 @@
;
}
}
-
+ // CraftBukkit end */
}
public CrashReport b(CrashReport crashreport) {
@@ -257,7 +311,14 @@
while (!this.k.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.k.remove(0);
- this.getCommandHandler().a(servercommand.source, servercommand.command);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
+ server.getPluginManager().callEvent(event);
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
+
+ // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
+ server.dispatchServerCommand(console, servercommand);
+ // CraftBukkit end
}
}

Datei anzeigen

@ -0,0 +1,59 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorArmor.java 2014-11-27 08:59:46.629422164 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorArmor.java 2014-11-27 08:42:10.144850927 +1100
@@ -3,6 +3,11 @@
import com.google.common.base.Predicates;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorArmor extends DispenseBehaviorItem {
DispenseBehaviorArmor() {}
@@ -19,15 +24,42 @@
EntityLiving entityliving = (EntityLiving) list.get(0);
int l = entityliving instanceof EntityHuman ? 1 : 0;
int i1 = EntityInsentient.c(itemstack);
- ItemStack itemstack1 = itemstack.cloneItemStack();
+
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.a(1);
+ World world = isourceblock.i();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
itemstack1.count = 1;
entityliving.setEquipment(i1 - l, itemstack1);
if (entityliving instanceof EntityInsentient) {
((EntityInsentient) entityliving).a(i1, 2.0F);
}
- --itemstack.count;
+ // --itemstack.count; // CraftBukkit - handled above
return itemstack;
} else {
return super.b(isourceblock, itemstack);

Datei anzeigen

@ -0,0 +1,54 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorBoat.java 2014-11-27 08:59:46.633422146 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorBoat.java 2014-11-27 08:42:10.164850887 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorBoat extends DispenseBehaviorItem {
private final DispenseBehaviorItem b = new DispenseBehaviorItem();
@@ -26,10 +31,38 @@
d3 = 0.0D;
}
- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
+ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ // CraftBukkit end
world.addEntity(entityboat);
- itemstack.a(1);
+ // itemstack.a(1); // CraftBukkit - handled during event processing
return itemstack;
}

Datei anzeigen

@ -0,0 +1,44 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorBonemeal.java 2014-11-27 08:59:46.633422146 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java 2014-11-27 08:42:10.120850973 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorBonemeal extends DispenseBehaviorItem {
private boolean b = true;
@@ -10,6 +15,30 @@
if (EnumColor.WHITE == EnumColor.fromInvColorIndex(itemstack.getData())) {
World world = isourceblock.i();
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asNewCraftStack(itemstack.getItem());
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
if (ItemDye.a(itemstack, world, blockposition)) {
if (!world.isStatic) {

Datei anzeigen

@ -0,0 +1,44 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorEmptyBucket.java 2014-11-27 08:59:46.633422146 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java 2014-11-27 08:42:10.124850965 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorEmptyBucket extends DispenseBehaviorItem {
private final DispenseBehaviorItem b = new DispenseBehaviorItem();
@@ -23,6 +28,30 @@
item = Items.LAVA_BUCKET;
}
+
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
world.setAir(blockposition);
if (--itemstack.count == 0) {

Datei anzeigen

@ -0,0 +1,65 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorFilledBucket.java 2014-11-27 08:59:46.637422129 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java 2014-11-27 08:42:10.088851036 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorFilledBucket extends DispenseBehaviorItem {
private final DispenseBehaviorItem b = new DispenseBehaviorItem();
@@ -9,10 +14,49 @@
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+
+ // CraftBukkit start
+ World world = isourceblock.i();
+ int x = blockposition.getX();
+ int y = blockposition.getY();
+ int z = blockposition.getZ();
+ if (world.isEmpty(blockposition) || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
+ }
+ // CraftBukkit end
if (itembucket.a(isourceblock.i(), blockposition)) {
- itemstack.setItem(Items.BUCKET);
- itemstack.count = 1;
+ // CraftBukkit start - Handle stacked buckets
+ Item item = Items.BUCKET;
+ if (--itemstack.count == 0) {
+ itemstack.setItem(Items.BUCKET);
+ itemstack.count = 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);

Datei anzeigen

@ -0,0 +1,55 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorFireball.java 2014-11-27 08:59:46.637422129 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorFireball.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,11 @@
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorFireball extends DispenseBehaviorItem {
DispenseBehaviorFireball() {}
@@ -18,8 +23,38 @@
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
- world.addEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
- itemstack.a(1);
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
+
+ world.addEntity(entitysmallfireball);
+ // itemstack.a(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}

Datei anzeigen

@ -0,0 +1,57 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorFlintAndSteel.java 2014-11-27 08:59:46.641422111 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem {
private boolean b = true;
@@ -10,11 +15,39 @@
World world = isourceblock.i();
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
- if (world.isEmpty(blockposition)) {
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
- if (itemstack.isDamaged(1, world.random)) {
- itemstack.count = 0;
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
+ if (world.isEmpty(blockposition)) {
+ // 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;
+ }
}
+ // 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);

Datei anzeigen

@ -0,0 +1,76 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorItem.java 2014-11-27 08:59:46.641422111 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorItem.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
public class DispenseBehaviorItem implements IDispenseBehavior {
public DispenseBehaviorItem() {}
@@ -17,11 +22,18 @@
IPosition iposition = BlockDispenser.a(isourceblock);
ItemStack itemstack1 = itemstack.a(1);
- a(isourceblock.i(), itemstack1, 6, enumdirection, iposition);
+ // CraftBukkit start
+ if (!a(isourceblock.i(), itemstack1, 6, enumdirection, isourceblock)) {
+ itemstack.count++;
+ }
+ // CraftBukkit end
return itemstack;
}
- public static void a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument
+ public static boolean a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) {
+ IPosition iposition = BlockDispenser.a(isourceblock);
+ // CraftBukkit end
double d0 = iposition.getX();
double d1 = iposition.getY();
double d2 = iposition.getZ();
@@ -41,7 +53,41 @@
entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
+
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(entityitem.motX, entityitem.motY, entityitem.motZ));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ return false;
+ }
+
+ entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem()));
+ entityitem.motX = event.getVelocity().getX();
+ entityitem.motY = event.getVelocity().getY();
+ entityitem.motZ = event.getVelocity().getZ();
+
+ if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
+ idispensebehavior.a(isourceblock, eventStack);
+ } else {
+ world.addEntity(entityitem);
+ }
+ return false;
+ }
+
world.addEntity(entityitem);
+
+ return true;
+ // CraftBukkit end
}
protected void a(ISourceBlock isourceblock) {

Datei anzeigen

@ -0,0 +1,58 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorMinecart.java 2014-11-27 08:59:46.641422111 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java 2014-11-27 08:42:10.084851043 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorMinecart extends DispenseBehaviorItem {
private final DispenseBehaviorItem b = new DispenseBehaviorItem();
@@ -38,14 +43,42 @@
}
}
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ItemMinecart.a((ItemMinecart) itemstack.getItem()));
+ // CraftBukkit start
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ItemMinecart.a((ItemMinecart) itemstack.getItem()));
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block2 = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ItemMinecart.a((ItemMinecart) itemstack1.getItem()));
if (itemstack.hasName()) {
entityminecartabstract.setCustomName(itemstack.getName());
}
world.addEntity(entityminecartabstract);
- itemstack.a(1);
+ // itemstack.a(1); // CraftBukkit - handled during event processing
return itemstack;
}

Datei anzeigen

@ -0,0 +1,61 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorMonsterEgg.java 2014-11-27 08:59:46.645422093 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java 2014-11-27 08:42:10.096851020 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorMonsterEgg extends DispenseBehaviorItem {
DispenseBehaviorMonsterEgg() {}
@@ -9,13 +14,45 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
- Entity entity = ItemMonsterEgg.a(isourceblock.i(), itemstack.getData(), d0, d1, d2);
+ // Entity entity = ItemMonsterEgg.a(isourceblock.i(), itemstack.getData(), d0, d1, d2);
+
+ // CraftBukkit start
+ World world = isourceblock.i();
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
+
+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.i(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
if (entity instanceof EntityLiving && itemstack.hasName()) {
((EntityInsentient) entity).setCustomName(itemstack.getName());
}
- itemstack.a(1);
+ // itemstack.a(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
}

Datei anzeigen

@ -0,0 +1,54 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorProjectile.java 2014-11-27 08:59:46.645422093 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java 2014-11-27 08:42:10.152850911 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem {
public DispenseBehaviorProjectile() {}
@@ -10,9 +15,38 @@
EnumDirection enumdirection = BlockDispenser.b(isourceblock.f());
IProjectile iprojectile = this.a(world, iposition);
- 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.b(), this.a());
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ()));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
+ // CraftBukkit end
world.addEntity((Entity) iprojectile);
- itemstack.a(1);
+ // itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}

Datei anzeigen

@ -0,0 +1,56 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorTNT.java 2014-11-27 08:59:46.645422093 +1100
+++ src/main/java/net/minecraft/server/DispenseBehaviorTNT.java 2014-11-27 08:42:10.140850934 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
final class DispenseBehaviorTNT extends DispenseBehaviorItem {
DispenseBehaviorTNT() {}
@@ -7,11 +12,40 @@
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.i();
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.a(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX() + 0.5, blockposition.getY() + 0.5, blockposition.getZ() + 0.5));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.count++;
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.count++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
+ idispensebehavior.a(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
+ // CraftBukkit end
world.addEntity(entitytntprimed);
world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
- --itemstack.count;
+ // --itemstack.count; // CraftBukkit - handled above
return itemstack;
}
}

Datei anzeigen

@ -0,0 +1,19 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/Enchantment.java 2014-11-27 08:59:46.649422075 +1100
+++ src/main/java/net/minecraft/server/Enchantment.java 2014-11-27 08:42:10.096851020 +1100
@@ -8,6 +8,7 @@
public abstract class Enchantment {
+ // CraftBukkit - update CraftEnchant.getName(i) if this changes
private static final Enchantment[] byId = new Enchantment[256];
public static final Enchantment[] b;
private static final Map E = Maps.newHashMap();
@@ -55,6 +56,8 @@
Enchantment.byId[i] = this;
Enchantment.E.put(minecraftkey, this);
}
+
+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(this)); // CraftBukkit
}
public static Enchantment getByName(String s) {

578
nms-patches/Entity.patch Normale Datei
Datei anzeigen

@ -0,0 +1,578 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/Entity.java 2014-11-27 08:59:46.697421864 +1100
+++ src/main/java/net/minecraft/server/Entity.java 2014-11-27 08:42:10.176850864 +1100
@@ -6,8 +6,40 @@
import java.util.UUID;
import java.util.concurrent.Callable;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.TravelAgent;
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Painting;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
+import org.bukkit.event.painting.PaintingBreakByEntityEvent;
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
+import org.bukkit.event.vehicle.VehicleEnterEvent;
+import org.bukkit.event.vehicle.VehicleExitEvent;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.entity.EntityPortalEvent;
+import org.bukkit.plugin.PluginManager;
+// CraftBukkit end
+
public abstract class Entity implements ICommandListener {
+ // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2;
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
+ }
+ // CraftBukikt end
+
private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static int entityCount;
private int id;
@@ -77,6 +109,8 @@
private boolean invulnerable;
public UUID uniqueID;
private final CommandObjectiveExecutor as;
+ public boolean valid; // CraftBukkit
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
public int getId() {
return this.id;
@@ -150,6 +184,33 @@
}
protected void setYawPitch(float f, float f1) {
+ // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
+ if (Float.isNaN(f)) {
+ f = 0;
+ }
+
+ if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
+ if (this instanceof EntityPlayer) {
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
+ }
+ f = 0;
+ }
+
+ // pitch was sometimes set to NaN, so we need to set it back to 0
+ if (Float.isNaN(f1)) {
+ f1 = 0;
+ }
+
+ if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
+ if (this instanceof EntityPlayer) {
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
+ }
+ f1 = 0;
+ }
+ // CraftBukkit end
+
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
@@ -186,7 +247,7 @@
int i = this.L();
if (this.ak) {
- if (minecraftserver.getAllowNether()) {
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit
if (this.vehicle == null && this.al++ >= i) {
this.al = i;
this.portalCooldown = this.ar();
@@ -263,6 +324,27 @@
protected void burnFromLava() {
if (!this.fireProof) {
this.damageEntity(DamageSource.LAVA, 4.0F);
+
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
+ if (this instanceof EntityLiving) {
+ if (fireTicks <= 0) {
+ // not on fire yet
+ // TODO: shouldn't be sending null for the block
+ org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
+ this.world.getServer().getPluginManager().callEvent(combustEvent);
+
+ if (!combustEvent.isCancelled()) {
+ this.setOnFire(combustEvent.getDuration());
+ }
+ } else {
+ // This will be called every single tick the entity is in lava, so don't throw an event
+ this.setOnFire(15);
+ }
+ return;
+ }
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.setOnFire(15);
}
}
@@ -300,6 +382,22 @@
this.a(this.getBoundingBox().c(d0, d1, d2));
this.recalcPosition();
} else {
+ // CraftBukkit start - Don't do anything if we aren't moving
+ // We need to do this regardless of whether or not we are moving thanks to portals
+ try {
+ this.checkBlockCollisions();
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision");
+
+ this.appendEntityCrashDetails(crashreportsystemdetails);
+ throw new ReportedException(crashreport);
+ }
+ // Check if we're moving
+ if (d0 == 0 && d1 == 0 && d2 == 0 && this.vehicle == null && this.passenger == null) {
+ return;
+ }
+ // CraftBukkit end
this.world.methodProfiler.a("move");
double d3 = this.locX;
double d4 = this.locY;
@@ -520,6 +618,28 @@
block.a(this.world, this);
}
+ // CraftBukkit start
+ if (positionChanged && getBukkitEntity() instanceof Vehicle) {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY - (double) this.getHeadHeight()), MathHelper.floor(this.locZ));
+
+ // PAIL: using local vars may break between updates, name them above?
+
+ if (d6 > d0) {
+ bl = bl.getRelative(BlockFace.EAST);
+ } else if (d6 < d0) {
+ bl = bl.getRelative(BlockFace.WEST);
+ } else if (d8 > d2) {
+ bl = bl.getRelative(BlockFace.SOUTH);
+ } else if (d8 < d2) {
+ bl = bl.getRelative(BlockFace.NORTH);
+ }
+
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
+ world.getServer().getPluginManager().callEvent(event);
+ }
+ // CraftBukkit end
+
if (this.r_() && !flag && this.vehicle == null) {
double d21 = this.locX - d3;
double d22 = this.locY - d4;
@@ -530,7 +650,7 @@
}
if (block != null && this.onGround) {
- block.a(this.world, blockposition, this);
+ // block.a(this.world, blockposition, this); // CraftBukkit removed down
}
this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
@@ -548,9 +668,12 @@
}
this.a(blockposition, block);
+ block.a(this.world, blockposition, this); // CraftBukkit - moved from above
}
}
+ // CraftBukkit start - Move to the top of the method
+ /*
try {
this.checkBlockCollisions();
} catch (Throwable throwable) {
@@ -560,6 +683,8 @@
this.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
+ */
+ // CraftBukkit end
boolean flag2 = this.U();
@@ -567,7 +692,16 @@
this.burn(1);
if (!flag2) {
++this.fireTicks;
- if (this.fireTicks == 0) {
+ // CraftBukkit start - Not on fire yet
+ if (this.fireTicks <= 0) { // Only throw events on the first combust, otherwise it spams
+ EntityCombustEvent event = new EntityCombustEvent(getBukkitEntity(), 8);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ setOnFire(event.getDuration());
+ }
+ } else {
+ // CraftBukkit end
this.setOnFire(8);
}
}
@@ -673,7 +807,7 @@
return null;
}
- protected void burn(int i) {
+ protected void burn(float i) { // CraftBukkit - int -> float
if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i);
}
@@ -823,6 +957,13 @@
}
public void spawnIn(World world) {
+ // CraftBukkit start
+ if (world == null) {
+ die();
+ this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ return;
+ }
+ // CraftBukkit end
this.world = world;
}
@@ -1015,6 +1156,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}));
+
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
+ // TODO: make sure this is the best way to address this.
+ if (Float.isNaN(this.yaw)) {
+ this.yaw = 0;
+ }
+
+ if (Float.isNaN(this.pitch)) {
+ this.pitch = 0;
+ }
+ // CraftBukkit end
+
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
@@ -1025,6 +1178,11 @@
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
+ // CraftBukkit start
+ nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits());
+ nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
+ // CraftBukkit end
if (this.getCustomName() != null && this.getCustomName().length() > 0) {
nbttagcompound.setString("CustomName", this.getCustomName());
nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible());
@@ -1062,6 +1220,7 @@
this.motX = nbttaglist1.d(0);
this.motY = nbttaglist1.d(1);
this.motZ = nbttaglist1.d(2);
+ /* CraftBukkit start - Moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
@@ -1073,6 +1232,7 @@
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
+ // CraftBukkit end */
this.lastX = this.P = this.locX = nbttaglist.d(0);
this.lastY = this.Q = this.locY = nbttaglist.d(1);
@@ -1105,7 +1265,57 @@
if (this.af()) {
this.setPosition(this.locX, this.locY, this.locZ);
}
+ // CraftBukkit start
+ if (this instanceof EntityLiving) {
+ EntityLiving entity = (EntityLiving) this;
+
+ // Reset the persistence for tamed animals
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent();
+ }
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - Exempt Vehicles from notch's sanity check
+ if (!(getBukkitEntity() instanceof Vehicle)) {
+ if (Math.abs(this.motX) > 10.0D) {
+ this.motX = 0.0D;
+ }
+
+ if (Math.abs(this.motY) > 10.0D) {
+ this.motY = 0.0D;
+ }
+
+ if (Math.abs(this.motZ) > 10.0D) {
+ this.motZ = 0.0D;
+ }
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - Reset world
+ if (this instanceof EntityPlayer) {
+ Server server = Bukkit.getServer();
+ org.bukkit.World bworld = null;
+ // TODO: Remove World related checks, replaced with WorldUID
+ String worldName = nbttagcompound.getString("world");
+
+ if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
+ bworld = server.getWorld(uid);
+ } else {
+ bworld = server.getWorld(worldName);
+ }
+
+ if (bworld == null) {
+ EntityPlayer entityPlayer = (EntityPlayer) this;
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld();
+ }
+
+ spawnIn(bworld == null? null : ((CraftWorld) bworld).getHandle());
+ }
+ // CraftBukkit end
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
@@ -1167,6 +1377,12 @@
public EntityItem a(ItemStack itemstack, float f) {
if (itemstack.count != 0 && itemstack.getItem() != null) {
+ // CraftBukkit start - Capture drops for death event
+ if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) {
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
+ return null;
+ }
+ // CraftBukkit end
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.p();
@@ -1276,16 +1492,76 @@
}
public void mount(Entity entity) {
+ // CraftBukkit start
+ setPassengerOf(entity);
+ }
+
+ protected CraftEntity bukkitEntity;
+
+ public CraftEntity getBukkitEntity() {
+ if (bukkitEntity == null) {
+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
+ }
+ return bukkitEntity;
+ }
+
+ public void setPassengerOf(Entity entity) {
+ // b(null) doesn't really fly for overloaded methods,
+ // so this method is needed
+
+ Entity originalVehicle = this.vehicle;
+ Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger;
+ PluginManager pluginManager = Bukkit.getPluginManager();
+ getBukkitEntity(); // make sure bukkitEntity is initialised
+ // CraftBukkit end
this.ap = 0.0D;
this.aq = 0.0D;
if (entity == null) {
if (this.vehicle != null) {
+ // CraftBukkit start
+ if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
+ VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ pluginManager.callEvent(event);
+
+ if (event.isCancelled() || vehicle != originalVehicle) {
+ return;
+ }
+ }
+ // CraftBukkit end
this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null;
}
this.vehicle = null;
} else {
+ // CraftBukkit start
+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
+ // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
+ VehicleExitEvent exitEvent = null;
+ if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) {
+ exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ pluginManager.callEvent(exitEvent);
+
+ if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
+ return;
+ }
+ }
+
+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity);
+ pluginManager.callEvent(event);
+
+ // If a plugin messes with the vehicle or the vehicle's passenger
+ if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
+ // If we only cancelled the enterevent then we need to put the player in a decent position.
+ if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) {
+ this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
+ this.vehicle.passenger = null;
+ this.vehicle = null;
+ }
+ return;
+ }
+ }
+ // CraftBukkit end
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
@@ -1406,10 +1682,50 @@
}
public void onLightningStrike(EntityLightning entitylightning) {
- this.damageEntity(DamageSource.LIGHTNING, 5.0F);
+ // CraftBukkit start
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
+ final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
+ final PluginManager pluginManager = Bukkit.getPluginManager();
+
+ if (thisBukkitEntity instanceof Hanging) {
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
+ PaintingBreakByEntityEvent paintingEvent = null;
+
+ if (thisBukkitEntity instanceof Painting) {
+ paintingEvent = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
+ }
+
+ pluginManager.callEvent(hangingEvent);
+
+ if (paintingEvent != null) {
+ paintingEvent.setCancelled(hangingEvent.isCancelled());
+ pluginManager.callEvent(paintingEvent);
+ }
+
+ if (hangingEvent.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
+ return;
+ }
+ }
+
+ if (this.fireProof) {
+ return;
+ }
+ CraftEventFactory.entityDamage = entitylightning;
+ if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) {
+ CraftEventFactory.entityDamage = null;
+ return;
+ }
+ // CraftBukkit end
++this.fireTicks;
if (this.fireTicks == 0) {
this.setOnFire(8);
+ // CraftBukkit start - Call a combust event when lightning strikes
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
+ pluginManager.callEvent(entityCombustEvent);
+ if (!entityCombustEvent.isCancelled()) {
+ this.setOnFire(entityCombustEvent.getDuration());
+ }
+ // CraftBukkit end
}
}
@@ -1546,32 +1862,78 @@
if (!this.world.isStatic && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
- int j = this.dimension;
- WorldServer worldserver = minecraftserver.getWorldServer(j);
- WorldServer worldserver1 = minecraftserver.getWorldServer(i);
+ // CraftBukkit start - Move logic into new function "teleportToLocation"
+ // int j = this.dimension;
+ // WorldServer worldserver = minecraftserver.getWorldServer(j);
+ // WorldServer worldserver1 = minecraftserver.getWorldServer(i);
+ WorldServer exitWorld = null;
+ if (this.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // Plugins must specify exit from custom Bukkit worlds
+ // Only target existing worlds (compensate for allow-nether/allow-end as false)
+ for (WorldServer world : minecraftserver.worlds) {
+ if (world.dimension == i) {
+ exitWorld = world;
+ }
+ }
+ }
+
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = exitWorld != null ? minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i)) : null;
+ boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
+
+ TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
+ event.useTravelAgent(useTravelAgent);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
+ return;
+ }
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
+ this.teleportTo(exit, true);
+ }
+ }
+
+ public void teleportTo(Location exit, boolean portal) {
+ if (true) {
+ WorldServer worldserver = ((CraftWorld) getBukkitEntity().getLocation().getWorld()).getHandle();
+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
+ int i = worldserver1.dimension;
+ // CraftBukkit end
this.dimension = i;
+ /* CraftBukkit start - TODO: Check if we need this
if (j == 1 && i == 1) {
worldserver1 = minecraftserver.getWorldServer(0);
this.dimension = 0;
}
+ // CraftBukkit end */
this.world.kill(this);
this.dead = false;
this.world.methodProfiler.a("reposition");
- minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
+ // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
+ // minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
+ boolean before = worldserver1.chunkProviderServer.forceChunkLoad;
+ worldserver1.chunkProviderServer.forceChunkLoad = true;
+ worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal);
+ worldserver1.chunkProviderServer.forceChunkLoad = before;
+ // CraftBukkit end
this.world.methodProfiler.c("reloading");
Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1);
if (entity != null) {
entity.n(this);
+ /* CraftBukkit start - We need to do this...
if (j == 1 && i == 1) {
BlockPosition blockposition = this.world.r(worldserver1.getSpawn());
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
-
+ // CraftBukkit end */
worldserver1.addEntity(entity);
+ // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity);
+ entity.bukkitEntity = this.getBukkitEntity();
+ // CraftBukkit end
}
this.dead = true;

Datei anzeigen

@ -0,0 +1,48 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityAgeable.java 2014-11-27 08:59:46.649422075 +1100
+++ src/main/java/net/minecraft/server/EntityAgeable.java 2014-11-27 08:42:10.144850927 +1100
@@ -7,6 +7,7 @@
protected int c;
private float bk = -1.0F;
private float bl;
+ public boolean ageLocked = false; // CraftBukkit
public EntityAgeable(World world) {
super(world);
@@ -27,14 +28,14 @@
if (entityageable != null) {
entityageable.setAgeRaw(-24000);
entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
- this.world.addEntity(entityageable);
+ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
if (itemstack.hasName()) {
entityageable.setCustomName(itemstack.getName());
}
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
- if (itemstack.count <= 0) {
+ if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite"
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
}
@@ -99,17 +100,19 @@
super.b(nbttagcompound);
nbttagcompound.setInt("Age", this.getAge());
nbttagcompound.setInt("ForcedAge", this.b);
+ nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setAgeRaw(nbttagcompound.getInt("Age"));
this.b = nbttagcompound.getInt("ForcedAge");
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
}
public void m() {
super.m();
- if (this.world.isStatic) {
+ if (this.world.isStatic || ageLocked) { // CraftBukkit
if (this.c > 0) {
if (this.c % 4 == 0) {
this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]);

106
nms-patches/EntityArrow.patch Normale Datei
Datei anzeigen

@ -0,0 +1,106 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityArrow.java 2014-11-27 08:59:46.653422058 +1100
+++ src/main/java/net/minecraft/server/EntityArrow.java 2014-11-27 08:42:10.100851012 +1100
@@ -2,6 +2,12 @@
import java.util.List;
+// CraftBukkit start
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+// CraftBukkit end
+
public class EntityArrow extends Entity implements IProjectile {
private int d = -1;
@@ -35,6 +41,7 @@
super(world);
this.j = 10.0D;
this.shooter = entityliving;
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
this.fromPlayer = 1;
}
@@ -62,6 +69,7 @@
super(world);
this.j = 10.0D;
this.shooter = entityliving;
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
this.fromPlayer = 1;
}
@@ -175,7 +183,7 @@
MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);
if (movingobjectposition1 != null) {
- double d1 = vec3d.f(movingobjectposition1.pos);
+ double d1 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
@@ -202,6 +210,8 @@
float f4;
if (movingobjectposition != null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
+
if (movingobjectposition.entity != null) {
f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
int k = MathHelper.f((double) f2 * this.damage);
@@ -217,12 +227,20 @@
} else {
damagesource = DamageSource.arrow(this, this.shooter);
}
+
+ // CraftBukkit start - Moved damage call
+ if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) {
+ if (this.isBurning() && !(movingobjectposition.entity instanceof EntityEnderman) && (!(movingobjectposition.entity instanceof EntityPlayer) || !(this.shooter instanceof EntityPlayer) || this.world.pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a player
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
- if (this.isBurning() && !(movingobjectposition.entity instanceof EntityEnderman)) {
- movingobjectposition.entity.setOnFire(5);
+ if (!combustEvent.isCancelled()) {
+ movingobjectposition.entity.setOnFire(combustEvent.getDuration());
+ }
+ // CraftBukkit end
}
- if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) {
+ // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { // CraftBukkit - moved up
if (movingobjectposition.entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;
@@ -382,6 +400,21 @@
public void d(EntityHuman entityhuman) {
if (!this.world.isStatic && this.inGround && this.shake <= 0) {
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(Items.ARROW);
+ if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0);
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
+
boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild;
if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Items.ARROW, 1))) {
@@ -433,4 +466,10 @@
return (b0 & 1) != 0;
}
+
+ // CraftBukkit start
+ public boolean isInGround() {
+ return inGround;
+ }
+ // CraftBukkit end
}

249
nms-patches/EntityBoat.patch Normale Datei
Datei anzeigen

@ -0,0 +1,249 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityBoat.java 2014-11-27 08:59:46.653422058 +1100
+++ src/main/java/net/minecraft/server/EntityBoat.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,16 @@
import java.util.List;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
+import org.bukkit.event.vehicle.VehicleMoveEvent;
+// CraftBukkit end
+
public class EntityBoat extends Entity {
private boolean a;
@@ -12,6 +22,27 @@
private double f;
private double g;
private double h;
+
+ // CraftBukkit start
+ public double maxSpeed = 0.4D;
+ public double occupiedDeceleration = 0.2D;
+ public double unoccupiedDeceleration = -1;
+ public boolean landBoats = false;
+
+ @Override
+ public void collide(Entity entity) {
+ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
+
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ super.collide(entity);
+ }
+ // CraftBukkit end
public EntityBoat(World world) {
super(world);
@@ -52,6 +83,8 @@
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
+
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
public double an() {
@@ -65,6 +98,19 @@
if (this.passenger != null && this.passenger == damagesource.getEntity() && damagesource instanceof EntityDamageSourceIndirect) {
return false;
} else {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
+
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return true;
+ }
+ // f = event.getDamage(); // TODO Why don't we do this?
+ // CraftBukkit end
+
this.b(-this.m());
this.a(10);
this.setDamage(this.j() + f * 10.0F);
@@ -72,6 +118,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
if (flag || this.j() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
+ return true;
+ }
+ // CraftBukkit end
if (this.passenger != null) {
this.passenger.mount(this);
}
@@ -95,6 +150,13 @@
}
public void s_() {
+ // CraftBukkit start
+ double prevX = this.locX;
+ double prevY = this.locY;
+ double prevZ = this.locZ;
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
+ // CraftBukkit end
super.s_();
if (this.l() > 0) {
this.a(this.l() - 1);
@@ -196,6 +258,19 @@
this.motX += -Math.sin((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.aY * 0.05000000074505806D;
this.motZ += Math.cos((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.aY * 0.05000000074505806D;
}
+ // CraftBukkit start - Support unoccupied deceleration
+ else if (unoccupiedDeceleration >= 0) {
+ this.motX *= unoccupiedDeceleration;
+ this.motZ *= unoccupiedDeceleration;
+ // Kill lingering speed
+ if (motX <= 0.00001) {
+ motX = 0;
+ }
+ if (motZ <= 0.00001) {
+ motZ = 0;
+ }
+ }
+ // CraftBukkit end
d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
if (d4 > 0.35D) {
@@ -230,16 +305,26 @@
Block block = this.world.getType(blockposition).getBlock();
if (block == Blocks.SNOW_LAYER) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
this.world.setAir(blockposition);
this.positionChanged = false;
} else if (block == Blocks.WATERLILY) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
this.world.setAir(blockposition, true);
this.positionChanged = false;
}
}
}
- if (this.onGround) {
+ if (this.onGround && !this.landBoats) { // CraftBukkit
this.motX *= 0.5D;
this.motY *= 0.5D;
this.motZ *= 0.5D;
@@ -247,16 +332,23 @@
this.move(this.motX, this.motY, this.motZ);
if (this.positionChanged && d3 > 0.2D) {
- if (!this.world.isStatic && !this.dead) {
- this.die();
+ if (!this.world.isStatic && !this.dead) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ if (!destroyEvent.isCancelled()) {
+ this.die();
- for (k = 0; k < 3; ++k) {
- this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
- }
+ for (k = 0; k < 3; ++k) {
+ this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
+ }
- for (k = 0; k < 2; ++k) {
- this.a(Items.STICK, 1, 0.0F);
+ for (k = 0; k < 2; ++k) {
+ this.a(Items.STICK, 1, 0.0F);
+ }
}
+ // CraftBukkit end
}
} else {
this.motX *= 0.9900000095367432D;
@@ -284,6 +376,23 @@
this.yaw = (float) ((double) this.yaw + d12);
this.setYawPitch(this.yaw, this.pitch);
+
+ // CraftBukkit start
+ org.bukkit.Server server = this.world.getServer();
+ org.bukkit.World bworld = this.world.getWorld();
+
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+
+ if (!from.equals(to)) {
+ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to);
+ server.getPluginManager().callEvent(event);
+ }
+ // CraftBukkit end
+
if (!this.world.isStatic) {
List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
@@ -298,6 +407,7 @@
}
if (this.passenger != null && this.passenger.dead) {
+ this.passenger.vehicle = null; // CraftBukkit
this.passenger = null;
}
@@ -335,17 +445,24 @@
if (this.fallDistance > 3.0F) {
this.e(this.fallDistance, 1.0F);
if (!this.world.isStatic && !this.dead) {
- this.die();
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ if (!destroyEvent.isCancelled()) {
+ this.die();
- int i;
+ int i;
- for (i = 0; i < 3; ++i) {
- this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
- }
+ for (i = 0; i < 3; ++i) {
+ this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
+ }
- for (i = 0; i < 2; ++i) {
- this.a(Items.STICK, 1, 0.0F);
+ for (i = 0; i < 2; ++i) {
+ this.a(Items.STICK, 1, 0.0F);
+ }
}
+ // CraftBukkit end
}
this.fallDistance = 0.0F;

Datei anzeigen

@ -0,0 +1,14 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityChicken.java 2014-11-27 08:59:46.657422040 +1100
+++ src/main/java/net/minecraft/server/EntityChicken.java 2014-11-27 08:42:10.104851005 +1100
@@ -35,6 +35,11 @@
}
public void m() {
+ // CraftBukkit start
+ if (this.isChickenJockey()) {
+ this.persistent = !this.isTypeNotPersistent();
+ }
+ // CraftBukkit end
super.m();
this.bo = this.bk;
this.bn = this.bm;

42
nms-patches/EntityCow.patch Normale Datei
Datei anzeigen

@ -0,0 +1,42 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityCow.java 2014-11-27 08:59:46.657422040 +1100
+++ src/main/java/net/minecraft/server/EntityCow.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class EntityCow extends EntityAnimal {
public EntityCow(World world) {
@@ -69,13 +74,23 @@
public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
-
+
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild) {
- if (itemstack.count-- == 1) {
- entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MILK_BUCKET));
- } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
- entityhuman.drop(new ItemStack(Items.MILK_BUCKET, 1, 0), false);
+ // 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);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+
+ ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
+ if (--itemstack.count <= 0) {
+ entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, result);
+ } else if (!entityhuman.inventory.pickup(result)) {
+ entityhuman.drop(result, false);
}
+ // CraftBukkit end
return true;
} else {

Datei anzeigen

@ -0,0 +1,31 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityCreature.java 2014-11-27 08:59:46.657422040 +1100
+++ src/main/java/net/minecraft/server/EntityCreature.java 2014-11-27 08:42:10.172850872 +1100
@@ -2,6 +2,12 @@
import java.util.UUID;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityUnleashEvent;
+// CraftBukkit end
+
public abstract class EntityCreature extends EntityInsentient {
public static final UUID bi = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
@@ -69,6 +75,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
@@ -100,6 +107,7 @@
}
if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
} else if (!this.cb() && this.bk) {

Datei anzeigen

@ -0,0 +1,104 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityCreeper.java 2014-11-27 08:59:46.661422023 +1100
+++ src/main/java/net/minecraft/server/EntityCreeper.java 2014-11-27 08:42:10.168850880 +1100
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityCreeper extends EntityMonster {
private int b;
@@ -7,6 +12,7 @@
private int maxFuseTicks = 30;
private int explosionRadius = 3;
private int bm = 0;
+ private int record = -1; // CraftBukkit
public EntityCreeper(World world) {
super(world);
@@ -111,19 +117,36 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit - Moved to end
if (damagesource.getEntity() instanceof EntitySkeleton) {
int i = Item.getId(Items.RECORD_13);
int j = Item.getId(Items.RECORD_WAIT);
int k = i + this.random.nextInt(j - i + 1);
- this.a(Item.getById(k), 1);
+ // CraftBukkit start - Store record for now, drop in dropDeathLoot
+ // this.a(Item.getById(k), 1);
+ this.record = k;
+ // CraftBukkit end
} else if (damagesource.getEntity() instanceof EntityCreeper && damagesource.getEntity() != this && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).cn()) {
((EntityCreeper) damagesource.getEntity()).co();
this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
}
-
+
+ super.die(damagesource); // CraftBukkit - Moved from above
+ }
+
+ // CraftBukkit start - Whole method
+ @Override
+ protected void dropDeathLoot(boolean flag, int i) {
+ super.dropDeathLoot(flag, i);
+
+ // Drop a music disc?
+ if (this.record != -1) {
+ this.a(Item.getById(this.record), 1);
+ this.record = -1;
+ }
}
+ // CraftBukkit end
public boolean r(Entity entity) {
return true;
@@ -147,7 +170,21 @@
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
- this.datawatcher.watch(17, Byte.valueOf((byte) 1));
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
+ }
+
+ this.setPowered(true);
+ }
+
+ public void setPowered(boolean powered) {
+ if (!powered) {
+ this.datawatcher.watch(17, Byte.valueOf((byte) 0));
+ } else {
+ this.datawatcher.watch(17, Byte.valueOf((byte) 1));
+ }
+ // CraftBukkit end
}
protected boolean a(EntityHuman entityhuman) {
@@ -170,9 +207,16 @@
if (!this.world.isStatic) {
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;
-
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
- this.die();
+
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
+ this.die();
+ } else {
+ fuseTicks = 0;
+ }
+ // CraftBukkit end
}
}

Datei anzeigen

@ -0,0 +1,14 @@
--- ../work/decompile-bb26c12b/net/minecraft/server/EntityDamageSourceIndirect.java 2014-11-27 08:59:46.661422023 +1100
+++ src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java 2014-11-27 08:42:10.164850887 +1100
@@ -24,5 +24,11 @@
String s1 = s + ".item";
return itemstack != null && 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
+ public Entity getProximateDamageSource() {
+ return super.getEntity();
}
+ // CraftBukkit end
}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen