Update to Minecraft 1.13-pre7

This commit is contained in:
md_5 2018-07-15 10:00:00 +10:00
parent 57ab4cfc6f
commit 421c1728c8
608 changed files with 17788 additions and 9378 deletions

1
.gitignore vendored
View File

@ -24,6 +24,7 @@ dependency-reduced-pom.xml
/manifest.mf
/world
/logs
# Mac filesystem dust
.DS_Store

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Advancement.java
+++ b/net/minecraft/server/Advancement.java
@@ -24,6 +24,7 @@
@@ -27,6 +27,7 @@
private final String[][] f;
private final Set<Advancement> g = Sets.newLinkedHashSet();
private final IChatBaseComponent h;
@ -8,3 +8,12 @@
public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) {
this.d = minecraftkey;
@@ -206,7 +207,7 @@
}
public Advancement b(MinecraftKey minecraftkey) {
- if (!this.a((minecraftkey) -> {
+ if (!this.a((Function<MinecraftKey, Advancement>) (minecraftkey1) -> { // CraftBukkit - decompile error
return null;
})) {
throw new IllegalStateException("Tried to build incomplete advancement!");

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -31,7 +31,7 @@
@@ -38,7 +38,7 @@
private static final Logger a = LogManager.getLogger();
private static final Gson b = (new GsonBuilder()).registerTypeAdapter(AdvancementProgress.class, new AdvancementProgress.a()).registerTypeAdapter(MinecraftKey.class, new MinecraftKey.a()).setPrettyPrinting().create();
@ -9,7 +9,7 @@
};
private final MinecraftServer d;
private final File e;
@@ -93,7 +93,7 @@
@@ -100,7 +100,7 @@
Iterator iterator = this.data.entrySet().iterator();
while (iterator.hasNext()) {
@ -18,29 +18,38 @@
if (((AdvancementProgress) entry.getValue()).isDone()) {
arraylist.add(entry.getKey());
@@ -129,7 +129,7 @@
if (this.e.isFile()) {
try {
String s = Files.toString(this.e, StandardCharsets.UTF_8);
- Map map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType());
+ Map<MinecraftKey, AdvancementProgress> map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); // CraftBukkit
@@ -140,7 +140,7 @@
if (map == null) {
throw new JsonParseException("Found null for advancements");
@@ -143,7 +143,11 @@
Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey());
try {
jsonreader.setLenient(false);
- Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader));
+ Dynamic<?> dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader)); // CraftBukkit - decompile error
if (advancement == null) {
- AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?");
+ // CraftBukkit start
+ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) {
+ AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?");
+ }
+ // CraftBukkit end
} else {
this.a(advancement, (AdvancementProgress) entry.getValue());
}
@@ -195,6 +199,7 @@
if (!dynamic.get("DataVersion").flatMap(Dynamic::getNumberValue).isPresent()) {
dynamic = dynamic.set("DataVersion", dynamic.createInt(1343));
@@ -148,7 +148,7 @@
dynamic = this.d.aB().update(DataFixTypes.ADVANCEMENTS, dynamic, dynamic.getInt("DataVersion"), 1513);
dynamic = dynamic.remove("DataVersion");
- Map map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue());
+ Map<MinecraftKey, AdvancementProgress> map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue()); // CraftBukkit - decompile error
if (map == null) {
throw new JsonParseException("Found null for advancements");
@@ -162,7 +162,11 @@
Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey());
if (advancement == null) {
- AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e);
+ // CraftBukkit start
+ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) {
+ AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e);
+ }
+ // CraftBukkit end
} else {
this.a(advancement, (AdvancementProgress) entry.getValue());
}
@@ -231,6 +235,7 @@
this.i.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {

View File

@ -1,52 +0,0 @@
--- a/net/minecraft/server/AdvancementRewards.java
+++ b/net/minecraft/server/AdvancementRewards.java
@@ -66,7 +66,24 @@
CustomFunction customfunction = this.e.a(minecraftserver.aL());
if (customfunction != null) {
- ICommandListener icommandlistener = new ICommandListener() {
+ // CraftBukkit start
+ ICommandListener icommandlistener = new AdvancementCommandListener(entityplayer, minecraftserver);
+
+ minecraftserver.aL().a(customfunction, icommandlistener);
+ }
+
+ }
+
+ public static class AdvancementCommandListener implements ICommandListener {
+
+ private final EntityPlayer entityplayer;
+ private final MinecraftServer minecraftserver;
+
+ public AdvancementCommandListener(EntityPlayer entityplayer, MinecraftServer minecraftserver) {
+ this.entityplayer = entityplayer;
+ this.minecraftserver = minecraftserver;
+ }
+
public String getName() {
return entityplayer.getName();
}
@@ -108,12 +125,8 @@
public MinecraftServer C_() {
return entityplayer.C_();
}
- };
-
- minecraftserver.aL().a(customfunction, icommandlistener);
- }
-
- }
+ }
+ // CraftBukkit end
public String toString() {
return "AdvancementRewards{experience=" + this.b + ", loot=" + Arrays.toString(this.c) + ", recipes=" + Arrays.toString(this.d) + ", function=" + this.e + '}';
@@ -156,7 +169,7 @@
return new AdvancementRewards(i, aminecraftkey, aminecraftkey1, customfunction_a);
}
- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ public AdvancementRewards deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - decompile error
return this.a(jsonelement, type, jsondeserializationcontext);
}
}

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/server/Advancements.java
+++ b/net/minecraft/server/Advancements.java
@@ -71,7 +71,7 @@
@@ -72,7 +72,7 @@
}
}
- Advancements.a.info("Loaded " + this.advancements.size() + " advancements");
+ // Advancements.a.info("Loaded " + this.b.size() + " advancements"); // CraftBukkit - moved to AdvancementDataWorld#reload
- Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size()));
+ // Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size())); // CraftBukkit - moved to AdvancementDataWorld#reload
}
public void a() {

View File

@ -1,28 +1,28 @@
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
@@ -37,7 +37,7 @@
private String name;
public static int getId(Block block) {
- return Block.REGISTRY.a((Object) block);
+ return Block.REGISTRY.a(block); // CraftBukkit - decompile error
@@ -213,7 +213,7 @@
}
public static int getCombinedId(IBlockData iblockdata) {
@@ -343,7 +343,8 @@
int j = this.getDropCount(i, world.random);
public Block(Block.Info block_info) {
- BlockStateList.a blockstatelist_a = new BlockStateList.a(this);
+ BlockStateList.a<Block, IBlockData> blockstatelist_a = new BlockStateList.a(this); // CraftBukkit - decompile error
this.a(blockstatelist_a);
this.blockStateList = blockstatelist_a.a(BlockData::new);
@@ -428,7 +428,8 @@
int j = this.getDropCount(iblockdata, i, world, blockposition, world.random);
for (int k = 0; k < j; ++k) {
- if (world.random.nextFloat() <= f) {
- if (f >= 1.0F || 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 (f >= 1.0F || world.random.nextFloat() < f) {
Item item = this.getDropType(iblockdata, world, blockposition, i).getItem();
if (item != Items.a) {
@@ -364,7 +365,13 @@
if (item != Items.AIR) {
@@ -449,7 +450,13 @@
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
entityitem.q();
entityitem.n();
- world.addEntity(entityitem);
+ // CraftBukkit start
+ if (world.captureDrops != null) {
@ -34,34 +34,25 @@
}
}
@@ -931,7 +938,7 @@
@@ -668,7 +675,7 @@
}
if (hashset.contains(block16)) {
for (int i = 0; i < 15; ++i) {
- int j = Block.REGISTRY.a((Object) block16) << 4 | i;
+ int j = Block.REGISTRY.a(block16) << 4 | i; // CraftBukkit - decompile error
public String toString() {
- return "Block{" + Block.REGISTRY.b(this) + "}";
+ return Block.REGISTRY.b(this).toString(); // CraftBukkit - cheap hack
}
Block.REGISTRY_ID.a(block16.fromLegacyData(i), j);
}
@@ -940,7 +947,7 @@
while (unmodifiableiterator.hasNext()) {
IBlockData iblockdata = (IBlockData) unmodifiableiterator.next();
- int k = Block.REGISTRY.a((Object) block16) << 4 | block16.toLegacyData(iblockdata);
+ int k = Block.REGISTRY.a(block16) << 4 | block16.toLegacyData(iblockdata); // CraftBukkit - decompile error
Block.REGISTRY_ID.a(iblockdata, k);
}
@@ -949,6 +956,12 @@
public static boolean c(Block block) {
@@ -1380,6 +1387,12 @@
}
+ // CraftBukkit start
+ public int getExpDrop(World world, IBlockData data, int enchantmentLevel) {
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ return 0;
+ }
+ // CraftBukkit end
+
private static void a(int i, MinecraftKey minecraftkey, Block block) {
Block.REGISTRY.a(i, minecraftkey, block);
private static void a(MinecraftKey minecraftkey, Block block) {
Block.REGISTRY.a(minecraftkey, block);
}

View File

@ -9,10 +9,10 @@
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
+
public abstract class BlockButtonAbstract extends BlockDirectional {
public abstract class BlockButtonAbstract extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -126,6 +131,19 @@
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -77,6 +82,19 @@
if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
return true;
} else {
@ -29,27 +29,27 @@
+ return true;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
world.b(blockposition, blockposition);
this.a(entityhuman, world, blockposition);
@@ -167,6 +185,16 @@
if (this.I) {
this.d(iblockdata, world, blockposition);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
this.a(entityhuman, world, blockposition, true);
this.c(iblockdata, world, blockposition);
@@ -118,6 +136,16 @@
if (this.F) {
this.b(iblockdata, world, blockposition);
} 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);
+ 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.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
this.b(world, blockposition);
@@ -192,7 +220,41 @@
+ if (eventRedstone.getNewCurrent() > 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)), 3);
this.c(iblockdata, world, blockposition);
this.a((EntityHuman) null, world, blockposition, false);
@@ -137,7 +165,44 @@
boolean flag = !list.isEmpty();
boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue();
@ -77,34 +77,20 @@
+ }
+ // CraftBukkit end
+
if (flag && !flag1) {
if (flag != flag1) {
+ // CraftBukkit start
+ boolean powered = flag1;
+ 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, 0, 15);
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() <= 0) {
+ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)));
this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.b(blockposition, blockposition);
@@ -200,6 +262,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.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.b(blockposition, blockposition);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(flag)), 3);
this.c(iblockdata, world, blockposition);
this.a((EntityHuman) null, world, blockposition, flag);

View File

@ -8,26 +8,23 @@
+
public class BlockCactus extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
@@ -30,9 +32,10 @@
int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
public static final BlockStateInteger AGE = BlockProperties.W;
@@ -31,7 +33,7 @@
int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
if (j == 15) {
- world.setTypeUpdate(blockposition1, this.getBlockData());
+ // world.setTypeUpdate(blockposition1, this.getBlockData()); // CraftBukkit
IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
if (j == 15) {
- world.setTypeUpdate(blockposition1, this.getBlockData());
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.getBlockData()); // CraftBukkit
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit
world.setTypeAndData(blockposition, iblockdata1, 4);
iblockdata1.doPhysics(world, blockposition1, this, blockposition);
} else {
@@ -87,7 +90,9 @@
world.setTypeAndData(blockposition, iblockdata1, 4);
@@ -92,7 +94,9 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, 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) {
public TextureType c() {

View File

@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockCake.java
+++ b/net/minecraft/server/BlockCake.java
@@ -40,7 +40,18 @@
@@ -33,7 +33,18 @@
return false;
} else {
entityhuman.b(StatisticList.H);
entityhuman.a(StatisticList.EAT_CAKE_SLICE);
- entityhuman.getFoodData().eat(2, 0.1F);
+ // CraftBukkit start
+ // entityhuman.getFoodData().eat(2, 0.1F);

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockCauldron.java
+++ b/net/minecraft/server/BlockCauldron.java
@@ -3,6 +3,7 @@
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
+
public class BlockCauldron extends Block {
@@ -43,8 +44,13 @@
public static final BlockStateInteger LEVEL = BlockProperties.ae;
@@ -32,8 +34,13 @@
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.getBoundingBox().b <= (double) f) {
@ -23,7 +23,7 @@
}
}
@@ -60,18 +66,27 @@
@@ -49,18 +56,27 @@
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
@ -35,11 +35,11 @@
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
}
entityhuman.b(StatisticList.I);
entityhuman.a(StatisticList.FILL_CAULDRON);
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
world.a((EntityHuman) null, blockposition, SoundEffects.Q, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return true;
@ -52,17 +52,17 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -82,7 +97,8 @@
@@ -71,7 +87,8 @@
}
entityhuman.b(StatisticList.J);
entityhuman.a(StatisticList.USE_CAULDRON);
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
world.a((EntityHuman) null, blockposition, SoundEffects.S, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -92,6 +108,10 @@
@@ -81,6 +98,10 @@
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
@ -72,11 +72,11 @@
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
entityhuman.b(StatisticList.J);
@@ -106,12 +126,17 @@
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -95,12 +116,17 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
@ -91,44 +91,44 @@
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
entityhuman.b(StatisticList.J);
@@ -122,7 +147,8 @@
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -111,7 +137,8 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.M, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i + 1);
+ // this.a(world, blockposition, iblockdata, i + 1);
+ // CraftBukkit end
}
return true;
@@ -131,8 +157,13 @@
ItemArmor itemarmor = (ItemArmor) item;
@@ -120,8 +147,13 @@
ItemArmorColorable itemarmorcolorable = (ItemArmorColorable) item;
if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) {
if (itemarmorcolorable.e(itemstack) && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return true;
+ }
itemarmor.d(itemstack);
itemarmorcolorable.g(itemstack);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
entityhuman.b(StatisticList.K);
entityhuman.a(StatisticList.CLEAN_ARMOR);
return true;
}
@@ -140,13 +171,18 @@
@@ -129,13 +161,18 @@
if (i > 0 && item instanceof ItemBanner) {
if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
if (TileEntityBanner.a(itemstack) > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
+ return true;
+ }
itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
TileEntityBanner.c(itemstack1);
entityhuman.b(StatisticList.L);
TileEntityBanner.b(itemstack1);
entityhuman.a(StatisticList.CLEAN_BANNER);
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
- this.a(world, blockposition, iblockdata, i - 1);
@ -137,13 +137,13 @@
}
if (itemstack.isEmpty()) {
@@ -167,9 +203,25 @@
@@ -171,9 +208,25 @@
}
}
+ // CraftBukkit start
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2);
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2);
+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
+ }
+
@ -157,19 +157,19 @@
+ if (event.isCancelled()) {
+ return false;
+ }
+ world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
world.updateAdjacentComparators(blockposition, this);
+ return true;
+ // CraftBukkit end
}
public void h(World world, BlockPosition blockposition) {
@@ -180,7 +232,7 @@
public void c(World world, BlockPosition blockposition) {
@@ -184,7 +237,7 @@
IBlockData iblockdata = world.getType(blockposition);
if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) {
- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
+ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
+ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
}
}

View File

@ -8,46 +8,31 @@
+
public class BlockChorusFlower extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5);
@@ -68,8 +70,20 @@
public static final BlockStateInteger AGE = BlockProperties.U;
@@ -61,8 +63,12 @@
}
if (flag && a(world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
- world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
- this.a(world, blockposition1, i);
+ // world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
+ // this.a(world, blockposition1, i);
if (flag && a((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
- world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
- this.b(world, blockposition1, i);
+ // CraftBukkit start - add event
+ BlockPosition target = blockposition1;
+ if (CraftEventFactory.handleBlockSpreadEvent(
+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
+ this,
+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)))
+ )) {
+ world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
+ world.triggerEffect(1033, blockposition, 0);
+ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) {
+ world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
+ this.b(world, blockposition1, i);
+ }
+ // CraftBukkit end
} else if (i < 4) {
j = random.nextInt(4);
boolean flag2 = false;
@@ -83,18 +97,53 @@
if (flag1) {
@@ -76,18 +82,30 @@
BlockPosition blockposition2 = blockposition.shift(enumdirection);
if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) {
- this.a(world, blockposition2, i + 1);
if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a((IWorldReader) world, blockposition2, enumdirection.opposite())) {
- this.b(world, blockposition2, i + 1);
- flag2 = true;
+ // CraftBukkit start - add event
+ // this.a(world, blockposition2, i + 1);
+ BlockPosition target = blockposition2;
+ if (CraftEventFactory.handleBlockSpreadEvent(
+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
+ this,
+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)))
+ )) {
+ world.triggerEffect(1033, blockposition, 0);
+ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) {
+ this.b(world, blockposition2, i + 1);
+ flag2 = true;
+ }
+ // CraftBukkit end
@ -55,37 +40,21 @@
}
if (flag2) {
world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
} else {
- this.c(world, blockposition);
- this.a(world, blockposition);
+ // CraftBukkit - add event
+ if (CraftEventFactory.handleBlockGrowEvent(
+ world,
+ blockposition.getX(),
+ blockposition.getY(),
+ blockposition.getZ(),
+ this,
+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5)))
+ )) {
+ world.triggerEffect(1034, blockposition, 0);
+ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
+ this.a(world, blockposition);
+ }
+ // this.c(world, blockposition);
+ // CraftBukkit end
}
} else if (i == 4) {
- this.c(world, blockposition);
} else {
- this.a(world, blockposition);
+ // CraftBukkit - add event
+ if (CraftEventFactory.handleBlockGrowEvent(
+ world,
+ blockposition.getX(),
+ blockposition.getY(),
+ blockposition.getZ(),
+ this,
+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5)))
+ )) {
+ world.triggerEffect(1034, blockposition, 0);
+ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
+ this.a(world, blockposition);
+ }
+ // this.c(world, blockposition);
+ // CraftBukkit end
}

View File

@ -1,35 +1,29 @@
--- a/net/minecraft/server/BlockCocoa.java
+++ b/net/minecraft/server/BlockCocoa.java
@@ -2,6 +2,8 @@
@@ -3,6 +3,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 2);
@@ -23,7 +25,10 @@
public static final BlockStateInteger AGE = BlockProperties.S;
@@ -21,7 +23,7 @@
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
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2); // CraftBukkkit
}
}
@@ -124,7 +129,10 @@
@@ -109,7 +111,7 @@
}
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
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2); // CraftBukkit
}
public IBlockData fromLegacyData(int i) {
public TextureType c() {

View File

@ -12,7 +12,7 @@
@@ -30,6 +32,15 @@
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
boolean flag = world.isBlockIndirectlyPowered(blockposition);
boolean flag1 = tileentitycommand.f();
boolean flag1 = tileentitycommand.d();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = flag1 ? 15 : 0;
@ -24,4 +24,4 @@
+ // CraftBukkit end
tileentitycommand.a(flag);
if (!flag1 && !tileentitycommand.h() && tileentitycommand.l() != TileEntityCommand.Type.SEQUENCE) {
if (!flag1 && !tileentitycommand.e() && tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE) {

View File

@ -1,22 +1,46 @@
--- a/net/minecraft/server/BlockConcretePowder.java
+++ b/net/minecraft/server/BlockConcretePowder.java
@@ -11,8 +11,8 @@
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.event.block.BlockFormEvent;
+// CraftBukkit end
+
public class BlockConcretePowder extends BlockFalling {
private final IBlockData a;
@@ -10,8 +15,8 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {
- if (iblockdata1.getMaterial().isLiquid()) {
- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3);
+ if (iblockdata1.getMaterial().isLiquid() && world.getType(blockposition).getBlock() != Blocks.dR) { // CraftBukkit - don't double concrete
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit
- world.setTypeAndData(blockposition, this.a, 3);
+ if (iblockdata1.getMaterial().isLiquid() && !(world.getType(blockposition).getBlock() instanceof BlockConcretePowder)) { // CraftBukkit - don't double concrete
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3);
}
}
@@ -36,7 +36,7 @@
}
@@ -45,6 +50,20 @@
}
if (flag) {
- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit
}
return flag;
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit start
+ if (a((IBlockAccess) generatoraccess, blockposition)) {
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(this.a);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+ }
+
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit end
}
}

View File

@ -8,28 +8,22 @@
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
@@ -53,7 +55,10 @@
float f = a((Block) this, world, blockposition);
public static final BlockStateInteger AGE = BlockProperties.V;
@@ -49,7 +51,7 @@
float f = a((Block) this, (IBlockAccess) world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
- world.setTypeAndData(blockposition, this.setAge(i + 1), 2);
+ // CraftBukkit start
+ IBlockData data = this.setAge(i + 1);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i + 1), 2); // CraftBukkit
}
}
}
@@ -68,7 +73,10 @@
@@ -64,7 +66,7 @@
i = j;
}
- world.setTypeAndData(blockposition, this.setAge(i), 2);
+ // CraftBukkit start
+ IBlockData data = this.setAge(i);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i), 2); // CraftBukkit
}
protected int b(World world) {
protected int a(World world) {

View File

@ -1,10 +1,10 @@
--- a/net/minecraft/server/BlockDaylightDetector.java
+++ b/net/minecraft/server/BlockDaylightDetector.java
@@ -45,6 +45,7 @@
@@ -36,6 +36,7 @@
i = MathHelper.clamp(i, 0, 15);
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);
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
}

View File

@ -8,23 +8,23 @@
+
public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
protected static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D);
@@ -35,8 +37,18 @@
boolean flag = this.e(world, blockposition, iblockdata);
protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
@@ -29,8 +31,18 @@
boolean flag1 = this.a(world, blockposition, iblockdata);
if (this.d && !flag) {
if (flag && !flag1) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.z(iblockdata), 2);
} else if (!this.d) {
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(false)), 2);
} else if (!flag) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, this.y(iblockdata), 2);
if (!flag) {
world.a(blockposition, this.y(iblockdata).getBlock(), this.E(iblockdata), -1);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(true)), 2);
if (!flag1) {
world.I().a(blockposition, this, this.j(iblockdata), TickListPriority.HIGH);

View File

@ -0,0 +1,23 @@
--- a/net/minecraft/server/BlockDirtSnowSpreadable.java
+++ b/net/minecraft/server/BlockDirtSnowSpreadable.java
@@ -23,6 +23,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!world.isClientSide) {
if (!a((IWorldReader) world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
@@ -34,7 +39,7 @@
}
if (world.getType(blockposition1).getBlock() == Blocks.DIRT && b(world, blockposition1)) {
- world.setTypeUpdate(blockposition1, this.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData()); // CraftBukkit
}
}
}

View File

@ -1,18 +1,18 @@
--- a/net/minecraft/server/BlockDispenser.java
+++ b/net/minecraft/server/BlockDispenser.java
@@ -8,6 +8,7 @@
public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
@@ -7,6 +7,7 @@
public static final BlockStateDirection FACING = BlockDirectional.FACING;
public static final BlockStateBoolean TRIGGERED = BlockProperties.w;
public static final RegistryDefault<Item, IDispenseBehavior> REGISTRY = new RegistryDefault(new DispenseBehaviorItem());
protected Random d = new Random();
+ public static boolean eventFired = false; // CraftBukkit
protected BlockDispenser() {
super(Material.STONE);
@@ -82,6 +83,7 @@
IDispenseBehavior idispensebehavior = this.a(itemstack);
public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
BlockDispenser.REGISTRY.a(imaterial.getItem(), idispensebehavior);
@@ -52,6 +53,7 @@
IDispenseBehavior idispensebehavior = this.a(itemstack);
if (idispensebehavior != IDispenseBehavior.NONE) {
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setItem(i, idispensebehavior.a(sourceblock, itemstack));
}
if (idispensebehavior != IDispenseBehavior.NONE) {
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
}

View File

@ -2,36 +2,37 @@
+++ b/net/minecraft/server/BlockDoor.java
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -137,9 +139,23 @@
this.b(world, blockposition, iblockdata, 0);
}
} else {
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3);
@@ -169,9 +171,24 @@
}
- if (block != this && (flag1 || block.getBlockData().m()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
- boolean flag = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN));
+ // CraftBukkit start
+ BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN);
+
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0;
+ 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(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ());
+
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ int oldPower = ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue() ? 15 : 0;
+
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
world.setTypeAndData(blockposition3, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2);
if (flag1 != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.OPEN, Boolean.valueOf(flag1)), 2);
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
- if (block != this && flag != ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue()) {
+ boolean flag = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
if (flag != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
this.b(world, blockposition, flag);
}

View File

@ -1,30 +1,29 @@
--- a/net/minecraft/server/BlockDragonEgg.java
+++ b/net/minecraft/server/BlockDragonEgg.java
@@ -2,6 +2,8 @@
import java.util.Random;
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
public class BlockDragonEgg extends Block {
public class BlockDragonEgg extends BlockFalling {
protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D);
@@ -66,6 +68,18 @@
BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16));
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
@@ -26,6 +28,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 (world.getType(blockposition1).isAir()) {
+ // 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;
+ }
+ if (event.isCancelled()) {
+ return;
+ }
+
+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
+ // CraftBukkit end
if (world.isClientSide) {
for (int j = 0; j < 128; ++j) {
double d0 = world.random.nextDouble();
+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
+ // CraftBukkit end
if (world.isClientSide) {
for (int j = 0; j < 128; ++j) {
double d0 = world.random.nextDouble();

View File

@ -10,32 +10,32 @@
+
public class BlockDropper extends BlockDispenser {
private final IDispenseBehavior e = new DispenseBehaviorItem();
@@ -35,8 +40,25 @@
if (iinventory == null) {
itemstack1 = this.e.a(sourceblock, itemstack);
private static final IDispenseBehavior c = new DispenseBehaviorItem();
@@ -34,8 +39,25 @@
if (iinventory == null) {
itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack);
} else {
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
- if (itemstack1.isEmpty()) {
+ // CraftBukkit start - Fire event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));
+
+ 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(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
+ // CraftBukkit end
itemstack1 = itemstack.cloneItemStack();
itemstack1.subtract(1);
} else {
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
- if (itemstack1.isEmpty()) {
+ // CraftBukkit start - Fire event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));
+
+ 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(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
+ // CraftBukkit end
itemstack1 = itemstack.cloneItemStack();
itemstack1.subtract(1);
} else {

View File

@ -1,22 +1,22 @@
--- a/net/minecraft/server/BlockEnderPortal.java
+++ b/net/minecraft/server/BlockEnderPortal.java
@@ -4,6 +4,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockEnderPortal extends BlockTileEntity {
protected static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D);
@@ -37,6 +39,10 @@
protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
@@ -28,6 +30,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bf() && entity.getBoundingBox().c(iblockdata.e(world, blockposition).a(blockposition))) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bm() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.g(world, blockposition), OperatorBoolean.AND)) {
+ // 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.b(1);
entity.d(1);
}

View File

@ -1,39 +1,65 @@
--- a/net/minecraft/server/BlockFire.java
+++ b/net/minecraft/server/BlockFire.java
@@ -5,6 +5,12 @@
import java.util.Random;
@@ -8,6 +8,16 @@
import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
+
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockFire extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
@@ -95,7 +101,7 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
public static final BlockStateInteger AGE = BlockProperties.W;
@@ -32,7 +42,20 @@
}
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData();
+ // CraftBukkit start
+ if (!iblockdata.canPlace(generatoraccess, blockposition)) {
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(Blocks.AIR.getBlockData());
+
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+ }
+ return this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE));
+ // CraftBukkit end
}
@Nullable
@@ -82,7 +105,7 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (world.getGameRules().getBoolean("doFireTick")) {
if (!this.canPlace(world, blockposition)) {
if (!iblockdata.canPlace(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - invalid place location
}
Block block = world.getType(blockposition.down()).getBlock();
@@ -108,7 +114,7 @@
@@ -90,7 +113,7 @@
int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
if (!flag && world.isRaining() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
if (!flag && world.isRaining() && this.a(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
} else {
if (i < 15) {
iblockdata = iblockdata.set(BlockFire.AGE, Integer.valueOf(i + random.nextInt(3) / 2));
@@ -119,14 +125,14 @@
if (!flag) {
if (!this.c(world, blockposition)) {
int j = Math.min(15, i + random.nextInt(3) / 2);
@@ -103,14 +126,14 @@
world.I().a(blockposition, this, this.a((IWorldReader) world) + random.nextInt(10));
if (!this.d(world, blockposition)) {
if (!world.getType(blockposition.down()).q() || i > 3) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
@ -42,68 +68,57 @@
return;
}
if (!this.c((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) {
if (i == 15 && random.nextInt(4) == 0 && !this.j(world.getType(blockposition.down()))) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
return;
}
}
@@ -138,12 +144,14 @@
b0 = -50;
}
@@ -118,12 +141,14 @@
boolean flag1 = world.x(blockposition);
int k = flag1 ? -50 : 0;
- this.a(world, blockposition.east(), 300 + b0, random, i);
- this.a(world, blockposition.west(), 300 + b0, random, i);
- this.a(world, blockposition.down(), 250 + b0, random, i);
- this.a(world, blockposition.up(), 250 + b0, random, i);
- this.a(world, blockposition.north(), 300 + b0, random, i);
- this.a(world, blockposition.south(), 300 + b0, random, i);
- this.a(world, blockposition.east(), 300 + k, random, i);
- this.a(world, blockposition.west(), 300 + k, random, i);
- this.a(world, blockposition.down(), 250 + k, random, i);
- this.a(world, blockposition.up(), 250 + k, random, i);
- this.a(world, blockposition.north(), 300 + k, random, i);
- this.a(world, blockposition.south(), 300 + k, random, i);
+ // CraftBukkit start - add source blockposition to burn calls
+ this.a(world, blockposition.east(), 300 + b0, random, i, blockposition);
+ this.a(world, blockposition.west(), 300 + b0, random, i, blockposition);
+ this.a(world, blockposition.down(), 250 + b0, random, i, blockposition);
+ this.a(world, blockposition.up(), 250 + b0, random, i, blockposition);
+ this.a(world, blockposition.north(), 300 + b0, random, i, blockposition);
+ this.a(world, blockposition.south(), 300 + b0, random, i, blockposition);
+ this.a(world, blockposition.east(), 300 + k, random, i, blockposition);
+ this.a(world, blockposition.west(), 300 + k, random, i, blockposition);
+ this.a(world, blockposition.down(), 250 + k, random, i, blockposition);
+ this.a(world, blockposition.up(), 250 + k, random, i, blockposition);
+ this.a(world, blockposition.north(), 300 + k, random, i, blockposition);
+ this.a(world, blockposition.south(), 300 + k, random, i, blockposition);
+ // CraftBukkit end
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
for (int j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) {
@@ -172,7 +180,26 @@
l1 = 15;
}
for (int l = -1; l <= 1; ++l) {
@@ -149,7 +174,15 @@
if (i2 > 0 && random.nextInt(k1) <= i2 && (!world.isRaining() || !this.a(world, (BlockPosition) blockposition_mutableblockposition))) {
int j2 = Math.min(15, i + random.nextInt(5) / 4);
- world.setTypeAndData(blockposition1, iblockdata.set(BlockFire.AGE, Integer.valueOf(l1)), 3);
- world.setTypeAndData(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3);
+ // CraftBukkit start - Call to stop spread of fire
+ if (world.getType(blockposition1) != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
+ if (world.getType(blockposition_mutableblockposition) != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition_mutableblockposition, blockposition).isCancelled()) {
+ continue;
+ }
+
+ org.bukkit.Server server = world.getServer();
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).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(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
+ server.getPluginManager().callEvent(spreadEvent);
+
+ if (!spreadEvent.isCancelled()) {
+ blockState.update(true);
+ }
+ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3); // CraftBukkit
+ }
+ // CraftBukkit end
}
}
}
@@ -204,12 +231,24 @@
return integer == null ? 0 : integer.intValue();
@@ -173,12 +206,24 @@
return this.flameChances.getInt(block);
}
- private void a(World world, BlockPosition blockposition, int i, Random random, int j) {
+ private void a(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition
int k = this.e(world.getType(blockposition).getBlock());
int k = this.f(world.getType(blockposition).getBlock());
if (random.nextInt(i) < k) {
IBlockData iblockdata = world.getType(blockposition);
@ -121,34 +136,25 @@
+ // CraftBukkit end
+
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
int l = j + random.nextInt(5) / 4;
int l = Math.min(j + random.nextInt(5) / 4, 15);
@@ -276,7 +315,7 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
}
}
@@ -284,7 +323,7 @@
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !Blocks.PORTAL.b(world, blockposition)) {
if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
} else {
world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10));
}
@@ -310,4 +349,12 @@
public EnumBlockFaceShape a(IBlockAccess iblockaccess, IBlockData iblockdata, BlockPosition blockposition, EnumDirection enumdirection) {
return EnumBlockFaceShape.UNDEFINED;
@@ -241,7 +286,7 @@
if (iblockdata1.getBlock() != iblockdata.getBlock()) {
if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) {
if (!iblockdata.canPlace(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
} else {
world.I().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10));
}
@@ -387,4 +432,12 @@
blockfire.a(Blocks.BLACK_CARPET, 60, 20);
blockfire.a(Blocks.DRIED_KELP_BLOCK, 30, 60);
}
+
+ // CraftBukkit start
+ private void fireExtinguished(World world, BlockPosition position) {
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) {
+ private void fireExtinguished(GeneratorAccess world, BlockPosition position) {
+ if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.setAir(position);
+ }
+ }

View File

@ -1,66 +0,0 @@
--- a/net/minecraft/server/BlockFlowing.java
+++ b/net/minecraft/server/BlockFlowing.java
@@ -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;
@@ -85,12 +90,25 @@
this.f(world, blockposition, iblockdata);
}
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
IBlockData iblockdata2 = world.getType(blockposition.down());
if (this.h(world, blockposition.down(), iblockdata2)) {
+ // CraftBukkit start
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) {
- world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
- this.fizz(world, blockposition.down());
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE.getBlockData(), null)) {
+ this.fizz(world, blockposition.down());
+ }
+ // CraftBukkit end
return;
}
@@ -116,14 +134,21 @@
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));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+ }
+ // CraftBukkit end
}
}
}
private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
- if (this.h(world, blockposition, iblockdata)) {
+ if (world.isLoaded(blockposition) && this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check
if (iblockdata.getMaterial() != Material.AIR) {
if (this.material == Material.LAVA) {
this.fizz(world, blockposition);

View File

@ -1,27 +1,41 @@
--- a/net/minecraft/server/BlockFluids.java
+++ b/net/minecraft/server/BlockFluids.java
@@ -175,14 +175,20 @@
Integer integer = (Integer) iblockdata.get(BlockFluids.LEVEL);
@@ -46,10 +46,10 @@
public VoxelShape a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
Fluid fluid = iblockaccess.b(blockposition.up());
if (integer.intValue() == 0) {
- return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata) -> {
- Fluid fluid = iblockdata.s();
+ return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata1) -> { // CraftBukkit - decompile errors
+ Fluid fluid1 = iblockdata1.s();
- return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.f(), 1.0D);
+ return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid1.f(), 1.0D);
});
}
@@ -106,14 +106,20 @@
Fluid fluid = world.b(blockposition);
if (fluid.d()) {
- world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData(), null)) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return true;
return false;
}
if (integer.intValue() <= 4) {
if (fluid.f() >= 0.44444445F) {
- world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData(), null)) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return true;
return false;
}
}

View File

@ -1,77 +1,11 @@
--- a/net/minecraft/server/BlockGrass.java
+++ b/net/minecraft/server/BlockGrass.java
@@ -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.isClientSide) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 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) {
@@ -36,7 +56,19 @@
IBlockData iblockdata2 = world.getType(blockposition1);
if (iblockdata2.getBlock() == Blocks.DIRT && iblockdata2.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata1.c() <= 2) {
- 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
@@ -51,7 +51,7 @@
}
}
}
@@ -79,13 +111,15 @@
IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_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, BlockLongGrass.EnumTallGrassType.GRASS);
if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) {
if (iblockdata2.canPlace(world, blockposition2)) {
- 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
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition2, iblockdata2, 3); // CraftBukkit
}
}
}

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockIce.java
+++ b/net/minecraft/server/BlockIce.java
@@ -47,6 +47,11 @@
@@ -52,6 +52,11 @@
}
protected void b(World world, BlockPosition blockposition) {
protected void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.l() ? Blocks.AIR : Blocks.WATER).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.worldProvider.isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
if (world.worldProvider.l()) {
if (world.worldProvider.isNether()) {
world.setAir(blockposition);
} else {

View File

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

View File

@ -1,26 +1,26 @@
--- a/net/minecraft/server/BlockLeaves.java
+++ b/net/minecraft/server/BlockLeaves.java
@@ -2,6 +2,8 @@
@@ -3,6 +3,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public abstract class BlockLeaves extends Block {
public class BlockLeaves extends Block {
public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
@@ -132,6 +134,14 @@
}
public static final BlockStateInteger DISTANCE = BlockProperties.aa;
@@ -20,6 +22,14 @@
private void b(World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!((Boolean) iblockdata.get(BlockLeaves.PERSISTENT)).booleanValue() && ((Integer) iblockdata.get(BlockLeaves.DISTANCE)).intValue() == 7) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) {
+ return;
+ }
+ // CraftBukkit end
this.b(world, blockposition, world.getType(blockposition), 0);
world.setAir(blockposition);
}
+ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) {
+ return;
+ }
+ // CraftBukkit end
iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
}

View File

@ -1,16 +1,15 @@
--- a/net/minecraft/server/BlockLever.java
+++ b/net/minecraft/server/BlockLever.java
@@ -3,6 +3,8 @@
import java.util.Iterator;
import javax.annotation.Nullable;
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockLever extends Block {
public class BlockLever extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -73,6 +75,20 @@
public static final BlockStateEnum<BlockLever.EnumLeverPosition> FACING = BlockStateEnum.of("facing", BlockLever.EnumLeverPosition.class);
@@ -129,6 +131,20 @@
if (world.isClientSide) {
return true;
} else {
+ // CraftBukkit start - Interact Lever
@ -27,6 +26,6 @@
+ }
+ // CraftBukkit end
+
iblockdata = iblockdata.a((IBlockState) BlockLever.POWERED);
world.setTypeAndData(blockposition, iblockdata, 3);
float f3 = ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F;
float f3 = flag ? 0.6F : 0.5F;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockMagma.java
+++ b/net/minecraft/server/BlockMagma.java
@@ -17,7 +17,9 @@
@@ -10,7 +10,9 @@
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockMinecartDetector.java
+++ b/net/minecraft/server/BlockMinecartDetector.java
@@ -6,6 +6,8 @@
import java.util.Random;
import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockMinecartTrackAbstract.EnumTrackPosition> SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() {
@@ -66,6 +68,17 @@
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.R;
@@ -55,6 +57,17 @@
flag1 = true;
}
@ -25,5 +25,5 @@
+ // CraftBukkit end
+
if (flag1 && !flag) {
world.setTypeAndData(blockposition, iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);
this.b(world, blockposition, iblockdata, true);

View File

@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockMobSpawner.java
+++ b/net/minecraft/server/BlockMobSpawner.java
@@ -22,9 +22,19 @@
@@ -16,9 +16,19 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegate to getExpDrop
int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
@ -12,11 +12,11 @@
+ }
+
+ @Override
+ public int getExpDrop(World world, IBlockData iblockdata, int enchantmentLevel) {
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
+
+ return j;
+ // CraftBukkit end
}
public boolean b(IBlockData iblockdata) {
public EnumRenderType c(IBlockData iblockdata) {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockMonsterEggs.java
+++ b/net/minecraft/server/BlockMonsterEggs.java
@@ -2,6 +2,8 @@
@@ -4,6 +4,8 @@
import java.util.Map;
import java.util.Random;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
+
public class BlockMonsterEggs extends Block {
public static final BlockStateEnum<BlockMonsterEggs.EnumMonsterEggVarient> VARIANT = BlockStateEnum.of("variant", BlockMonsterEggs.EnumMonsterEggVarient.class);
@@ -50,7 +52,7 @@
private final Block a;
@@ -36,7 +38,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);

View File

@ -1,55 +1,41 @@
--- a/net/minecraft/server/BlockMushroom.java
+++ b/net/minecraft/server/BlockMushroom.java
@@ -3,6 +3,12 @@
@@ -3,6 +3,10 @@
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 static final AxisAlignedBB a = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.4000000059604645D, 0.699999988079071D);
@@ -16,6 +22,7 @@
protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D);
@@ -16,6 +20,7 @@
}
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, 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;
@@ -43,7 +50,19 @@
@@ -43,7 +48,7 @@
}
if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) {
- world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ // 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
if (world.isEmpty(blockposition2) && iblockdata.canPlace(world, blockposition2)) {
- world.setTypeAndData(blockposition2, iblockdata, 2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata, 2); // CraftBukkit
}
}
@@ -72,8 +91,10 @@
WorldGenHugeMushroom worldgenhugemushroom = null;
@@ -66,8 +71,10 @@
WorldGenerator worldgenerator = null;
if (this == Blocks.BROWN_MUSHROOM) {
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
worldgenerator = WorldGenerator.U;
} else if (this == Blocks.RED_MUSHROOM) {
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK);
worldgenerator = WorldGenerator.T;
}

View File

@ -1,58 +0,0 @@
--- a/net/minecraft/server/BlockMycel.java
+++ b/net/minecraft/server/BlockMycel.java
@@ -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.isClientSide) {
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) {
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.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 @@
IBlockData iblockdata2 = world.getType(blockposition1.up());
if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata2.c() <= 2) {
- 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
}
}
}

View File

@ -1,12 +1,11 @@
--- a/net/minecraft/server/BlockNetherWart.java
+++ b/net/minecraft/server/BlockNetherWart.java
@@ -31,7 +31,8 @@
@@ -25,7 +25,7 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
iblockdata = (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
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
}
super.b(world, blockposition, iblockdata, random);
super.a(iblockdata, world, blockposition, random);

View File

@ -0,0 +1,46 @@
--- a/net/minecraft/server/BlockNote.java
+++ b/net/minecraft/server/BlockNote.java
@@ -24,7 +24,7 @@
if (flag != ((Boolean) iblockdata.get(BlockNote.POWERED)).booleanValue()) {
if (flag) {
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
}
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, Boolean.valueOf(flag)), 3);
@@ -32,9 +32,14 @@
}
- private void play(World world, BlockPosition blockposition) {
+ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
if (world.getType(blockposition.up()).isAir()) {
- world.playBlockAction(blockposition, this, 0, 0);
+ // CraftBukkit start
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE));
+ if (!event.isCancelled()) {
+ world.playBlockAction(blockposition, this, 0, 0);
+ }
+ // CraftBukkit end
}
}
@@ -45,7 +50,7 @@
} else {
iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE);
world.setTypeAndData(blockposition, iblockdata, 3);
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
entityhuman.a(StatisticList.TUNE_NOTEBLOCK);
return true;
}
@@ -53,7 +58,7 @@
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
if (!world.isClientSide) {
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
entityhuman.a(StatisticList.PLAY_NOTEBLOCK);
}
}

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockOre.java
+++ b/net/minecraft/server/BlockOre.java
@@ -37,6 +37,7 @@
@@ -32,6 +32,7 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 0;
@@ -54,9 +55,34 @@
@@ -49,9 +50,34 @@
this.dropExperience(world, blockposition, j);
}
@ -17,8 +17,8 @@
}
+ @Override
+ public int getExpDrop(World world, IBlockData iblockdata, int i) {
+ if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
+ int j = 0;
+
+ if (this == Blocks.COAL_ORE) {
@ -29,7 +29,7 @@
+ 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) {
+ } else if (this == Blocks.NETHER_QUARTZ_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ }
+
@ -40,6 +40,6 @@
+ // CraftBukkit end
+ }
+
public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) {
public ItemStack a(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
return new ItemStack(this);
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockPiston.java
+++ b/net/minecraft/server/BlockPiston.java
@@ -5,6 +5,18 @@
@@ -7,6 +7,18 @@
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.AbstractList;
@ -18,39 +18,30 @@
+
public class BlockPiston extends BlockDirectional {
public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended");
@@ -103,6 +115,18 @@
world.playBlockAction(blockposition, this, 0, enumdirection.a());
}
} else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
+ // CraftBukkit start
+ if (!this.sticky) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // PAIL: checkME - what happened to setTypeAndData?
+ // CraftBukkit end
world.playBlockAction(blockposition, this, 1, enumdirection.a());
}
@@ -193,7 +217,7 @@
public static final BlockStateBoolean EXTENDED = BlockProperties.f;
@@ -109,6 +121,18 @@
b0 = 2;
}
}
+ // CraftBukkit start
+ if (!this.sticky) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // PAIL: checkME - what happened to setTypeAndData?
+ // CraftBukkit end
}
- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
this.a(world, blockposition, enumdirection, false);
}
} else {
@@ -277,6 +301,48 @@
int j = list.size() + list1.size();
world.playBlockAction(blockposition, this, b0, enumdirection.a());
@@ -271,6 +295,48 @@
IBlockData[] aiblockdata = new IBlockData[j];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
HashSet hashset = Sets.newHashSet(list);
+ // CraftBukkit start
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+

View File

@ -1,14 +1,18 @@
--- a/net/minecraft/server/BlockPlant.java
+++ b/net/minecraft/server/BlockPlant.java
@@ -40,6 +40,11 @@
@@ -13,7 +13,14 @@
}
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!this.f(world, blockposition, iblockdata)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
+ return;
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit start
+ if (!iblockdata.canPlace(generatoraccess, blockposition)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) {
+ return Blocks.AIR.getBlockData();
+ }
+ // CraftBukkit end
this.b(world, blockposition, iblockdata, 0);
world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
}
+ }
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit end
}
public boolean canPlace(IBlockData iblockdata, IWorldReader iworldreader, BlockPosition blockposition) {

View File

@ -1,50 +1,45 @@
--- a/net/minecraft/server/BlockPortal.java
+++ b/net/minecraft/server/BlockPortal.java
@@ -4,6 +4,9 @@
@@ -4,6 +4,12 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+import org.bukkit.event.world.PortalCreateEvent; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.entity.EntityPortalEnterEvent;
+import org.bukkit.event.world.PortalCreateEvent;
+// CraftBukkit end
+
public class BlockPortal extends BlockHalfTransparent {
public class BlockPortal extends Block {
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockStateEnum.of("axis", EnumDirection.EnumAxis.class, new EnumDirection.EnumAxis[] { EnumDirection.EnumAxis.X, EnumDirection.EnumAxis.Z});
@@ -43,7 +46,8 @@
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.y;
@@ -37,7 +43,8 @@
}
if (i > 0 && !world.getType(blockposition1.up()).l()) {
- Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
if (i > 0 && !world.getType(blockposition1.up()).isOccluding()) {
- Entity entity = EntityTypes.ZOMBIE_PIGMAN.a(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
+ Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
entity.portalCooldown = entity.aM();
@@ -70,14 +74,16 @@
BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X);
entity.portalCooldown = entity.aQ();
@@ -55,8 +62,10 @@
BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
if (blockportal_shape.d() && blockportal_shape.e == 0) {
if (blockportal_shape != null) {
- blockportal_shape.createPortal();
- return true;
+ // CraftBukkit start - return portalcreator
+ return blockportal_shape.createPortal();
+ // return true;
+ // CraftBukkit end
} else {
BlockPortal.Shape blockportal_shape1 = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.Z);
return false;
}
@@ -93,6 +102,10 @@
if (blockportal_shape1.d() && blockportal_shape1.e == 0) {
- blockportal_shape1.createPortal();
- return true;
+ return blockportal_shape1.createPortal();
+ // return true;
+ // CraftBukkit end
} else {
return false;
}
@@ -108,6 +114,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.bf()) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) {
+ // 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);
@ -52,33 +47,32 @@
entity.e(blockposition);
}
@@ -216,6 +226,7 @@
@@ -193,6 +206,7 @@
private BlockPosition position;
private int height;
private int width;
+ java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field
public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = world;
@@ -274,6 +285,10 @@
public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = generatoraccess;
@@ -251,6 +265,9 @@
}
protected int c() {
+ // CraftBukkit start
+ this.blocks.clear();
+ org.bukkit.World bworld = this.a.getWorld();
+ // CraftBukkit end
int i;
label56:
@@ -294,11 +309,21 @@
@@ -273,11 +290,21 @@
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.d);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
} else if (i == this.width - 1) {
@ -88,31 +82,31 @@
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.c);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
}
}
@@ -308,6 +333,11 @@
@@ -287,6 +314,11 @@
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
break;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = this.position.shift(this.c, i).up(this.height);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
}
@@ -329,7 +359,27 @@
@@ -310,7 +342,27 @@
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
- public void createPortal() {
+ // CraftBukkit start - return boolean
+ public boolean createPortal() {
+ org.bukkit.World bworld = this.a.getWorld();
+ org.bukkit.World bworld = this.a.getMinecraftWorld().getWorld();
+
+ // Copy below for loop
+ for (int i = 0; i < this.width; ++i) {
@ -125,7 +119,7 @@
+ }
+
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
+ this.a.getServer().getPluginManager().callEvent(event);
+ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@ -134,11 +128,11 @@
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
@@ -338,6 +388,7 @@
@@ -319,6 +371,7 @@
}
}
+ return true; // CraftBukkit
}
}
}
private boolean g() {

View File

@ -1,25 +1,24 @@
--- a/net/minecraft/server/BlockPoweredRail.java
+++ b/net/minecraft/server/BlockPoweredRail.java
@@ -3,6 +3,8 @@
import com.google.common.base.Predicate;
import javax.annotation.Nullable;
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockMinecartTrackAbstract.EnumTrackPosition> SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() {
@@ -117,6 +119,13 @@
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.R;
@@ -106,6 +108,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();
+ int power = flag ? 15 : 0;
+ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition, 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, false);
if (((BlockMinecartTrackAbstract.EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3);
world.applyPhysics(blockposition.down(), this);
if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockPressurePlateAbstract.java
+++ b/net/minecraft/server/BlockPressurePlateAbstract.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public abstract class BlockPressurePlateAbstract extends Block {
protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.03125D, 0.9375D);
@@ -95,6 +97,19 @@
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D);
@@ -65,6 +67,19 @@
boolean flag = i > 0;
boolean flag1 = j > 0;

View File

@ -8,7 +8,7 @@
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -63,6 +65,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

View File

@ -7,11 +7,11 @@
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockStateInteger.of("power", 0, 15);
@@ -16,7 +18,31 @@
public static final BlockStateInteger POWER = BlockProperties.ak;
@@ -12,7 +14,31 @@
}
protected int e(World world, BlockPosition blockposition) {
protected int b(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ // CraftBukkit start
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);

View File

@ -1,81 +0,0 @@
--- a/net/minecraft/server/BlockPumpkin.java
+++ b/net/minecraft/server/BlockPumpkin.java
@@ -4,6 +4,12 @@
import java.util.Iterator;
import javax.annotation.Nullable;
+// 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 BlockFacingHorizontal {
private ShapeDetector snowGolemPart;
@@ -43,18 +49,25 @@
EntityPlayer entityplayer;
int j;
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
if (shapedetector_shapedetectorcollection != null) {
for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) {
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetectorblock.getPosition();
+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+ // CraftBukkit end
}
EntitySnowman entitysnowman = new EntitySnowman(world);
BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
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();
iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator();
while (iterator.hasNext()) {
@@ -71,12 +84,17 @@
world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false);
}
+ } // CraftBukkit end
} else {
shapedetector_shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition);
if (shapedetector_shapedetectorcollection != null) {
for (i = 0; i < this.getDetectorIronGolem().c(); ++i) {
for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) {
- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition();
+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+ // CraftBukkit end
}
}
@@ -85,7 +103,9 @@
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);
+ // CraftBukkit start
+ if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
+ blockList.updateList();
iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();
while (iterator.hasNext()) {
@@ -105,6 +125,7 @@
}
}
}
+ } // CraftBukkit end
}
}

View File

@ -0,0 +1,65 @@
--- a/net/minecraft/server/BlockPumpkinCarved.java
+++ b/net/minecraft/server/BlockPumpkinCarved.java
@@ -3,6 +3,12 @@
import java.util.Iterator;
import java.util.function.Predicate;
+// 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 BlockPumpkinCarved extends BlockFacingHorizontal {
public static final BlockStateDirection a = BlockFacingHorizontal.FACING;
@@ -38,18 +44,24 @@
int j;
int k;
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
if (shapedetector_shapedetectorcollection != null) {
for (i = 0; i < this.d().b(); ++i) {
ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, i, 0);
- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
+ blockList.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
}
EntitySnowman entitysnowman = new EntitySnowman(world);
BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
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)) {
+ return;
+ }
+ blockList.updateList();
+ // CraftBukkit end
iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator();
while (iterator.hasNext()) {
@@ -70,7 +82,7 @@
if (shapedetector_shapedetectorcollection != null) {
for (i = 0; i < this.f().c(); ++i) {
for (int l = 0; l < this.f().b(); ++l) {
- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
}
}
@@ -79,7 +91,12 @@
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);
+ // CraftBukkit start
+ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
+ return;
+ }
+ blockList.updateList();
+ // CraftBukkit end
iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();
while (iterator.hasNext()) {

View File

@ -1,54 +1,35 @@
--- a/net/minecraft/server/BlockRedstoneLamp.java
+++ b/net/minecraft/server/BlockRedstoneLamp.java
@@ -2,6 +2,8 @@
@@ -3,6 +3,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockRedstoneLamp extends Block {
private final boolean a;
@@ -18,8 +20,18 @@
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
@@ -33,6 +35,11 @@
if (flag) {
world.I().a(blockposition, this, 4);
} else {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
}
}
@@ -43,6 +50,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!world.isClientSide) {
if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
if (((Boolean) iblockdata.get(BlockRedstoneLamp.a)).booleanValue() && !world.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
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 +43,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 +57,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (!world.isClientSide) {
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);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
}

View File

@ -11,76 +11,75 @@
+
public class BlockRedstoneOre extends Block {
private final boolean a;
@@ -20,23 +25,45 @@
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
@@ -16,23 +21,44 @@
}
public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
- this.interact(world, blockposition);
+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
super.attack(world, blockposition, entityhuman);
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
- interact(iblockdata, world, blockposition);
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
super.attack(iblockdata, world, blockposition, entityhuman);
}
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
- this.interact(world, blockposition);
- interact(world.getType(blockposition), world, blockposition);
- super.stepOn(world, blockposition, entity);
+ // CraftBukkit start
+ // this.interact(world, blockposition);
+ // interact(world.getType(blockposition), world, blockposition);
+ // super.stepOn(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, null);
+ if (!event.isCancelled()) {
+ this.interact(world, blockposition, entity); // add entity
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(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.interact(world, blockposition, entity); // add entity
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(world, blockposition, entity);
+ }
+ }
+ // CraftBukkit end
}
+
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
- this.interact(world, blockposition);
+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2);
public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
- interact(iblockdata, world, blockposition);
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2);
}
- private void interact(World world, BlockPosition blockposition) {
+ private void interact(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
this.playEffect(world, blockposition);
if (this == Blocks.REDSTONE_ORE) {
- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
playEffect(world, blockposition);
if (!((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true)), 3);
}
@@ -44,6 +71,11 @@
@@ -40,6 +66,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (this == Blocks.LIT_REDSTONE_ORE) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) {
+ // CraftBukkit start
+ if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.REDSTONE_ORE).isCancelled()) {
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false)), 3);
}
@@ -63,12 +95,25 @@
@@ -59,12 +90,25 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 1 + world.random.nextInt(5);
this.dropExperience(world, blockposition, j);
@ -88,16 +87,16 @@
+ // */
+
+ }
+
+ @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);
+ @Override
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
+ int j = 1 + world.random.nextInt(5);
+
+ return j;
+ }
+ return 0;
+ // CraftBukkit end
}
private void playEffect(World world, BlockPosition blockposition) {
private static void playEffect(World world, BlockPosition blockposition) {

View File

@ -8,29 +8,19 @@
+
public class BlockRedstoneTorch extends BlockTorch {
private static final Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> g = Maps.newHashMap();
@@ -13,7 +15,7 @@
private boolean a(World world, BlockPosition blockposition, boolean flag) {
if (!BlockRedstoneTorch.g.containsKey(world)) {
- BlockRedstoneTorch.g.put(world, Lists.newArrayList());
+ BlockRedstoneTorch.g.put(world, Lists.<BlockRedstoneTorch.RedstoneUpdateInfo>newArrayList()); // CraftBukkit - fix decompile error
}
List list = (List) BlockRedstoneTorch.g.get(world);
@@ -96,8 +98,25 @@
public static final BlockStateBoolean LIT = BlockProperties.o;
@@ -65,8 +67,24 @@
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;
+ int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0;
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
+
if (this.isOn) {
if (((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue()) {
if (flag) {
+ // CraftBukkit start
+ if (oldCurrent != 0) {
@ -41,13 +31,13 @@
+ }
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
if (this.a(world, blockposition, true)) {
world.a((EntityHuman) null, blockposition, SoundEffects.gm, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -114,6 +133,15 @@
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(false)), 3);
if (a(world, blockposition, true)) {
world.a((EntityHuman) null, blockposition, SoundEffects.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -83,6 +101,15 @@
}
}
} else if (!flag && !this.a(world, blockposition, false)) {
} else if (!flag && !a(world, blockposition, false)) {
+ // CraftBukkit start
+ if (oldCurrent != 15) {
+ event.setNewCurrent(15);
@ -57,6 +47,15 @@
+ }
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(true)), 3);
}
@@ -112,7 +139,7 @@
}
private static boolean a(World world, BlockPosition blockposition, boolean flag) {
- Object object = (List) BlockRedstoneTorch.b.get(world);
+ List<RedstoneUpdateInfo> object = (List) BlockRedstoneTorch.b.get(world); // CraftBukkit - decompile error
if (object == null) {
object = Lists.newArrayList();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockRedstoneWire.java
+++ b/net/minecraft/server/BlockRedstoneWire.java
@@ -9,6 +9,8 @@
@@ -11,6 +11,8 @@
import java.util.Set;
import javax.annotation.Nullable;
@ -8,8 +8,8 @@
+
public class BlockRedstoneWire extends Block {
public static final BlockStateEnum<BlockRedstoneWire.EnumRedstoneWireConnection> NORTH = BlockStateEnum.of("north", BlockRedstoneWire.EnumRedstoneWireConnection.class);
@@ -168,6 +170,15 @@
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.L;
@@ -216,6 +218,15 @@
j = k;
}
@ -23,5 +23,5 @@
+ // CraftBukkit end
+
if (i != j) {
iblockdata = iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j));
iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j));
if (world.getType(blockposition) == iblockdata1) {

View File

@ -1,16 +1,11 @@
--- a/net/minecraft/server/BlockReed.java
+++ b/net/minecraft/server/BlockReed.java
@@ -32,8 +32,12 @@
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
@@ -29,7 +29,7 @@
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
if (j == 15) {
- world.setTypeUpdate(blockposition.up(), this.getBlockData());
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition.up(), this.getBlockData()); // CraftBukkit
+ BlockPosition upPos = blockposition.up();
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, upPos.getX(), upPos.getY(), upPos.getZ(), this, 0);
world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
+ // CraftBukkit end
} else {
world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4);
}
if (j == 15) {
- world.setTypeUpdate(blockposition.up(), this.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.up(), this.getBlockData()); // CraftBukkit
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
} else {
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4);

View File

@ -15,112 +15,41 @@
+
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateEnum<BlockWood.EnumLogVariant> TYPE = BlockStateEnum.of("type", BlockWood.EnumLogVariant.class);
public static final BlockStateInteger STAGE = BlockStateInteger.of("stage", 0, 1);
protected static final AxisAlignedBB d = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
public static final BlockStateInteger STAGE = BlockProperties.al;
protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
private final WorldGenTreeProvider c;
+ public static TreeType treeType; // CraftBukkit
protected BlockSapling() {
this.w(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
@@ -25,7 +35,30 @@
if (!world.isClientSide) {
super.b(world, blockposition, iblockdata, random);
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);
+ }
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, Block.Info block_info) {
super(block_info);
@@ -21,7 +31,30 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
super.a(iblockdata, world, blockposition, 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
}
+ }
+ // CraftBukkit end
}
@@ -41,7 +74,17 @@
}
public void d(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;
@@ -53,6 +96,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.SPRUCE)) {
+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit
object = new WorldGenMegaTree(false, random.nextBoolean());
flag = true;
break label66;
@@ -63,11 +107,13 @@
if (!flag) {
i = 0;
j = 0;
+ treeType = TreeType.REDWOOD; // CraftBukkit
object = new WorldGenTaiga2(true);
}
break;
case BIRCH:
+ treeType = TreeType.BIRCH; // CraftBukkit
object = new WorldGenForest(true, false);
break;
@@ -79,6 +125,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.JUNGLE)) {
+ treeType = TreeType.JUNGLE; // CraftBukkit
object = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2);
flag = true;
break label78;
@@ -89,11 +136,13 @@
if (!flag) {
i = 0;
j = 0;
+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
object = new WorldGenTrees(true, 4 + random.nextInt(7), iblockdata1, iblockdata2, false);
}
break;
case ACACIA:
+ treeType = TreeType.ACACIA; // CraftBukkit
object = new WorldGenAcaciaTree(true);
break;
@@ -102,6 +151,7 @@
for (i = 0; i >= -1; --i) {
for (j = 0; j >= -1; --j) {
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.DARK_OAK)) {
+ treeType = TreeType.DARK_OAK; // CraftBukkit
object = new WorldGenForestTree(true);
flag = true;
break label90;

View File

@ -1,32 +1,31 @@
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
@@ -92,7 +92,32 @@
@@ -81,7 +81,31 @@
super.a(world, blockposition, iblockdata, entityhuman);
}
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {}
+ // CraftBukkit start - override to prevent duplication when dropping
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+ @Override
+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
+ if (true) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityShulkerBox) {
+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
+ if (tileentity instanceof TileEntityShulkerBox) {
+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
+
+ if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
+ ItemStack itemstack = new ItemStack(Item.getItemOf(this));
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+ if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) {
+ ItemStack itemstack = new ItemStack(this);
+
+ nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1));
+ itemstack.setTag(nbttagcompound);
+ if (tileentityshulkerbox.hasCustomName()) {
+ itemstack.g(tileentityshulkerbox.getName());
+ tileentityshulkerbox.setCustomName("");
+ itemstack.getOrCreateTag().set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).g(new NBTTagCompound()));
+ if (tileentityshulkerbox.hasCustomName()) {
+ itemstack.a(tileentityshulkerbox.getCustomName());
+ tileentityshulkerbox.setCustomName((IChatBaseComponent) null);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+ }
+ }
@ -34,22 +33,22 @@
public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
if (itemstack.hasName()) {
@@ -108,7 +133,7 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
TileEntity tileentity = world.getTileEntity(blockposition);
@@ -98,7 +122,7 @@
if (iblockdata.getBlock() != iblockdata1.getBlock()) {
TileEntity tileentity = world.getTileEntity(blockposition);
- if (tileentity instanceof TileEntityShulkerBox) {
+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
- if (tileentity instanceof TileEntityShulkerBox) {
+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
@@ -126,8 +151,8 @@
a(world, blockposition, itemstack);
if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) {
@@ -113,8 +137,8 @@
a(world, blockposition, itemstack);
}
- world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
}
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
- world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
super.remove(iblockdata, world, blockposition, iblockdata1, flag);
}
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
super.remove(world, blockposition, iblockdata);
}

View File

@ -1,123 +0,0 @@
--- a/net/minecraft/server/BlockSkull.java
+++ b/net/minecraft/server/BlockSkull.java
@@ -5,6 +5,11 @@
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockSkull extends BlockTileEntity {
public static final BlockStateDirection FACING = BlockDirectional.FACING;
@@ -82,7 +87,29 @@
return new ItemStack(Items.SKULL, 1, i);
}
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
+ // CraftBukkit start - Special case dropping so we can get info from the tile entity
+ @Override
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ if (world.random.nextFloat() < f) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntitySkull) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+ ItemStack itemstack = this.a(world, blockposition, iblockdata);
+
+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
+ itemstack.setTag(new NBTTagCompound());
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
+ itemstack.getTag().set("SkullOwner", nbttagcompound);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+ }
+ }
+ // CraftBukkit end
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.abilities.canInstantlyBuild) {
@@ -95,7 +122,10 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!world.isClientSide) {
- 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) {
@@ -127,24 +157,36 @@
}
public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
+ if (world.captureBlockStates) return; // CraftBukkit
if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide) {
ShapeDetector shapedetector = this.g();
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
if (shapedetector_shapedetectorcollection != null) {
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
int i;
for (i = 0; i < 3; ++i) {
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0);
- world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
+ BlockPosition pos = shapedetectorblock.getPosition();
+ 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 = shapedetector_shapedetectorcollection.a(i, j, 0);
- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
+ // world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
+ BlockPosition pos = shapedetectorblock1.getPosition();
+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2);
+ // CraftBukkit end
}
}
@@ -157,14 +199,16 @@
entitywither.p();
Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
+ // CraftBukkit start
+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ blockList.updateList();
+
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
CriterionTriggers.m.a(entityplayer, (Entity) entitywither);
}
- world.addEntity(entitywither);
-
int k;
for (k = 0; k < 120; ++k) {
@@ -178,6 +222,7 @@
world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false);
}
}
+ } // CraftBukkit end
}
}

View File

@ -0,0 +1,45 @@
--- a/net/minecraft/server/BlockSkullAbstract.java
+++ b/net/minecraft/server/BlockSkullAbstract.java
@@ -17,7 +17,32 @@
return new TileEntitySkull();
}
- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {}
+ // CraftBukkit start - Special case dropping so we can get info from the tile entity
+ @Override
+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
+ if (world.random.nextFloat() < f) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntitySkull) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+
+ if (tileentityskull.shouldDrop()) {
+ ItemStack itemstack = this.a((IBlockAccess) world, blockposition, iblockdata);
+ Block block = tileentityskull.getBlock().getBlock();
+
+ if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
+ itemstack.getOrCreateTag().set("SkullOwner", nbttagcompound);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+ }
+ }
+ }
+ // CraftBukkit end
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (!world.isClientSide && entityhuman.abilities.canInstantlyBuild) {
@@ -35,7 +60,7 @@
if (iblockdata.getBlock() != iblockdata1.getBlock() && !world.isClientSide) {
TileEntity tileentity = world.getTileEntity(blockposition);
- if (tileentity instanceof TileEntitySkull) {
+ if (false && tileentity instanceof TileEntitySkull) { // CraftBukkit - Drop item in code above, not here
TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
if (tileentityskull.shouldDrop()) {

View File

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

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockSnowBlock.java
+++ b/net/minecraft/server/BlockSnowBlock.java
@@ -20,6 +20,11 @@
@@ -18,6 +18,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.AIR).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.b(world, blockposition, world.getType(blockposition), 0);
iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
}

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/server/BlockSoil.java
+++ b/net/minecraft/server/BlockSoil.java
@@ -4,6 +4,11 @@
import java.util.List;
@@ -3,6 +3,11 @@
import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
@ -11,8 +11,8 @@
+
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
@@ -45,14 +50,38 @@
public static final BlockStateInteger MOISTURE = BlockProperties.ah;
@@ -63,14 +68,37 @@
}
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
@ -31,24 +31,23 @@
+ return;
+ }
+
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
b(world, blockposition);
b(world.getType(blockposition), world, blockposition);
}
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
protected static void b(World world, BlockPosition blockposition) {
protected static void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
AxisAlignedBB axisalignedbb = BlockSoil.c.a(blockposition);
List list = world.getEntities((Entity) null, axisalignedbb);
world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), (GeneratorAccess) world, blockposition));
}

View File

@ -0,0 +1,18 @@
--- a/net/minecraft/server/BlockStateInteger.java
+++ b/net/minecraft/server/BlockStateInteger.java
@@ -9,9 +9,15 @@
public class BlockStateInteger extends BlockState<Integer> {
private final ImmutableSet<Integer> a;
+ // CraftBukkit start
+ public final int min;
+ public final int max;
protected BlockStateInteger(String s, int i, int j) {
super(s, Integer.class);
+ this.min = i;
+ this.max = j;
+ // CraftBukkit end
if (i < 0) {
throw new IllegalArgumentException("Min value of " + s + " must be 0 or greater");
} else if (j <= i) {

View File

@ -1,40 +0,0 @@
--- a/net/minecraft/server/BlockStationary.java
+++ b/net/minecraft/server/BlockStationary.java
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStationary extends BlockFluids {
protected BlockStationary(Material material) {
@@ -45,6 +47,13 @@
if (block.material == Material.AIR) {
if (this.c(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;
}
@@ -61,6 +70,14 @@
}
if (world.isEmpty(blockposition2.up()) && this.d(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());
}
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockStem.java
+++ b/net/minecraft/server/BlockStem.java
@@ -4,6 +4,8 @@
@@ -3,6 +3,8 @@
import java.util.Random;
import javax.annotation.Nullable;
@ -8,34 +8,30 @@
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
@@ -54,7 +56,8 @@
public static final BlockStateInteger AGE = BlockProperties.V;
@@ -33,14 +35,14 @@
if (i < 7) {
iblockdata = iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1));
iblockdata = (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
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
} else {
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
BlockPosition blockposition1 = blockposition.shift(enumdirection);
Block block = world.getType(blockposition1.down()).getBlock();
@@ -70,7 +73,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
if (world.getType(blockposition1).isAir() && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) {
- world.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.blockFruit.getBlockData()); // CraftBukkit
world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
}
}
}
@@ -81,7 +85,8 @@
public void g(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5);
@@ -94,7 +96,7 @@
int i = Math.min(7, ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5));
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, Integer.valueOf(i));
- 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 dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
- world.setTypeAndData(blockposition, iblockdata1, 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata1, 2); // CraftBukkit
if (i == 7) {
iblockdata1.a(world, blockposition, world.random);
}

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockTNT.java
+++ b/net/minecraft/server/BlockTNT.java
@@ -75,6 +75,11 @@
@@ -72,6 +72,11 @@
EntityArrow entityarrow = (EntityArrow) entity;
if (entityarrow.isBurning()) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR, 0).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.a(world, blockposition, world.getType(blockposition).set(BlockTNT.EXPLODE, Boolean.valueOf(true)), entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
this.a(world, blockposition, entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
world.setAir(blockposition);
}

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockTallPlant.java
+++ b/net/minecraft/server/BlockTallPlant.java
@@ -48,6 +48,11 @@
}
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!this.f(world, blockposition, iblockdata)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
boolean flag = iblockdata.get(BlockTallPlant.HALF) == BlockTallPlant.EnumTallPlantHalf.UPPER;
BlockPosition blockposition1 = flag ? blockposition : blockposition.up();
BlockPosition blockposition2 = flag ? blockposition.down() : blockposition;
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF);
boolean flag = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER;
BlockPosition blockposition1 = flag ? blockposition.up() : blockposition.down();

View File

@ -6,12 +6,12 @@
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class BlockTrapdoor extends Block {
public class BlockTrapdoor extends BlockFacingHorizontal implements IFluidSource, IFluidContainer {
@@ -91,6 +92,19 @@
@@ -94,6 +95,19 @@
boolean flag = world.isBlockIndirectlyPowered(blockposition);
if (flag || block.getBlockData().m()) {
if (flag != ((Boolean) iblockdata.get(BlockTrapdoor.c)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@ -19,12 +19,12 @@
+ int power = bblock.getBlockPower();
+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0 || block.getBlockData().n()) {
+ if (oldPower == 0 ^ power == 0 || block.getBlockData().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) {
if (((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue() != flag) {
iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, Boolean.valueOf(flag));
this.a((EntityHuman) null, world, blockposition, flag);

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockTripwire.java
+++ b/net/minecraft/server/BlockTripwire.java
@@ -5,6 +5,8 @@
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -138,6 +140,40 @@
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -134,6 +136,40 @@
}
}
@ -48,5 +48,5 @@
+ // CraftBukkit end
+
if (flag1 != flag) {
iblockdata = iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1));
iblockdata = (IBlockData) iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1));
world.setTypeAndData(blockposition, iblockdata, 3);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockTripwireHook.java
+++ b/net/minecraft/server/BlockTripwireHook.java
@@ -5,6 +5,8 @@
@@ -4,6 +4,8 @@
import java.util.Random;
import javax.annotation.Nullable;
@ -9,7 +9,7 @@
public class BlockTripwireHook extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -160,6 +162,17 @@
@@ -137,6 +139,17 @@
this.a(world, blockposition1, flag4, flag5, flag2, flag3);
}
@ -26,4 +26,4 @@
+
this.a(world, blockposition, flag4, flag5, flag2, flag3);
if (!flag) {
world.setTypeAndData(blockposition, iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);
world.setTypeAndData(blockposition, (IBlockData) iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);

View File

@ -1,71 +1,59 @@
--- a/net/minecraft/server/BlockVine.java
+++ b/net/minecraft/server/BlockVine.java
@@ -4,6 +4,8 @@
import java.util.Random;
@@ -7,6 +7,8 @@
import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockVine extends Block {
public static final BlockStateBoolean UP = BlockStateBoolean.of("up");
@@ -177,7 +179,13 @@
}
public static final BlockStateBoolean UP = BlockSprawling.q;
@@ -183,20 +185,24 @@
BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
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(blockposition1, iblockdata1, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ // world.setTypeAndData(blockposition1, iblockdata1, 2);
+ BlockPosition target = blockposition1;
+ 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
}
} else {
@@ -198,15 +206,26 @@
BlockPosition blockposition3 = blockposition2.shift(enumdirection2);
BlockPosition blockposition4 = blockposition2.shift(enumdirection3);
+ // 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(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+ // CraftBukkit start - Call BlockSpreadEvent
+ BlockPosition source = blockposition;
+
if (flag2 && this.a(world, blockposition3.shift(enumdirection2), enumdirection2)) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true))));
} else if (flag3 && this.a(world, blockposition4.shift(enumdirection3), enumdirection3)) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true))));
} else if (flag2 && world.isEmpty(blockposition3) && this.a(world, blockposition3, enumdirection)) {
- world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true))));
} else if (flag3 && world.isEmpty(blockposition4) && this.a(world, blockposition4, enumdirection)) {
- world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true))));
if (flag && this.b(world, blockposition3, enumdirection1)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2);
} else if (flag1 && this.b(world, blockposition4, enumdirection2)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
} else {
EnumDirection enumdirection3 = enumdirection.opposite();
if (flag && world.isEmpty(blockposition3) && this.b(world, blockposition.shift(enumdirection1), enumdirection3)) {
- world.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
} else if (flag1 && world.isEmpty(blockposition4) && this.b(world, blockposition.shift(enumdirection2), enumdirection3)) {
- world.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
} else if ((double) world.random.nextFloat() < 0.05D && this.b(world, blockposition2.up(), EnumDirection.UP)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2);
}
+ // CraftBukkit end
} else if (iblockdata2.d(world, blockposition2, enumdirection) == EnumBlockFaceShape.SOLID) {
world.setTypeAndData(blockposition, iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2);
}
@@ -233,7 +252,12 @@
}
} else if (this.b(world, blockposition2, enumdirection)) {
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2);
@@ -226,7 +232,7 @@
}
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(blockposition2, iblockdata3, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ // world.setTypeAndData(blockposition2, iblockdata3, 2);
+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3));
+ // CraftBukkit end
}
} else if (block == this) {
iblockdata3 = iblockdata2;
if (this.x(iblockdata3)) {
- world.setTypeAndData(blockposition1, iblockdata3, 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit
}
return;
@@ -241,7 +247,7 @@
IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random);
if (iblockdata4 != iblockdata5 && this.x(iblockdata5)) {
- world.setTypeAndData(blockposition2, iblockdata5, 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit
}
}
}

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/server/BlockWaterLily.java
+++ b/net/minecraft/server/BlockWaterLily.java
@@ -20,7 +20,7 @@
@@ -10,7 +10,7 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
super.a(world, blockposition, iblockdata, entity);
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
super.a(iblockdata, world, blockposition, entity);
- if (entity instanceof EntityBoat) {
+ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR, 0).isCancelled()) { // CraftBukkit
+ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit
world.setAir(new BlockPosition(blockposition), true);
}

View File

@ -0,0 +1,66 @@
--- a/net/minecraft/server/BlockWitherSkull.java
+++ b/net/minecraft/server/BlockWitherSkull.java
@@ -3,6 +3,11 @@
import java.util.Iterator;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockWitherSkull extends BlockSkull {
private static ShapeDetector c;
@@ -23,6 +28,7 @@
}
public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
+ if (world.captureBlockStates) return; // CraftBukkit
Block block = tileentityskull.getBlock().getBlock();
boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL;
@@ -31,6 +37,8 @@
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
if (shapedetector_shapedetectorcollection != null) {
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world);
int i;
for (i = 0; i < 3; ++i) {
@@ -39,7 +47,7 @@
for (i = 0; i < shapedetector.c(); ++i) {
for (int j = 0; j < shapedetector.b(); ++j) {
- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
}
}
@@ -50,6 +58,16 @@
entitywither.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
entitywither.aQ = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
entitywither.l();
+ // CraftBukkit start
+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ // Restore drop status from above
+ for (i = 0; i < 3; ++i) {
+ TileEntitySkull.setShouldDrop(world, shapedetector_shapedetectorcollection.a(i, 0, 0).getPosition(), true);
+ }
+ return;
+ }
+ blockList.updateList();
+ // CraftBukkit end
Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
while (iterator.hasNext()) {
@@ -58,7 +76,7 @@
CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
}
- world.addEntity(entitywither);
+ // world.addEntity(entitywither); // CraftBukkit - moved up
int k;

View File

@ -1,11 +0,0 @@
--- a/net/minecraft/server/ChatBaseComponent.java
+++ b/net/minecraft/server/ChatBaseComponent.java
@@ -112,7 +112,7 @@
}
public int hashCode() {
- return 31 * this.b.hashCode() + this.a.hashCode();
+ return 31 * this.getChatModifier().hashCode() + this.a.hashCode(); // CraftBukkit - fix null pointer
}
public String toString() {

View File

@ -1,45 +0,0 @@
--- a/net/minecraft/server/ChatModifier.java
+++ b/net/minecraft/server/ChatModifier.java
@@ -263,16 +263,18 @@
}
public int hashCode() {
- int i = this.b.hashCode();
+ // CraftBukkit start - fix npe
+ int i = b == null ? 0 : this.b.hashCode();
- i = 31 * i + this.c.hashCode();
- i = 31 * i + this.d.hashCode();
- i = 31 * i + this.e.hashCode();
- i = 31 * i + this.f.hashCode();
- i = 31 * i + this.g.hashCode();
- i = 31 * i + this.h.hashCode();
- i = 31 * i + this.i.hashCode();
- i = 31 * i + this.j.hashCode();
+ i = 31 * i + (c == null ? 0 : this.c.hashCode());
+ i = 31 * i + (d == null ? 0 : this.d.hashCode());
+ i = 31 * i + (e == null ? 0 : this.e.hashCode());
+ i = 31 * i + (f == null ? 0 : this.f.hashCode());
+ i = 31 * i + (g == null ? 0 : this.g.hashCode());
+ i = 31 * i + (h == null ? 0 : this.h.hashCode());
+ i = 31 * i + (this.i == null ? 0 : this.i.hashCode());
+ i = 31 * i + (j == null ? 0 : this.j.hashCode());
+ // CraftBukkit end
return i;
}
@@ -441,12 +443,12 @@
}
@Nullable
- public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) {
+ public JsonElement serialize(ChatModifier object, Type type, JsonSerializationContext jsonserializationcontext) { // CraftBukkit - fix decompile error
return this.a((ChatModifier) object, type, jsonserializationcontext);
}
@Nullable
- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ public ChatModifier deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - fix decompile error
return this.a(jsonelement, type, jsondeserializationcontext);
}
}

View File

@ -1,18 +1,17 @@
--- a/net/minecraft/server/Chunk.java
+++ b/net/minecraft/server/Chunk.java
@@ -14,6 +14,9 @@
@@ -23,6 +23,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import com.google.common.collect.Lists; // CraftBukkit
+import org.bukkit.Server; // CraftBukkit
+
public class Chunk {
public class Chunk implements IChunkAccess {
private static final Logger e = LogManager.getLogger();
@@ -42,6 +45,35 @@
private final ConcurrentLinkedQueue<BlockPosition> y;
public boolean d;
@@ -58,6 +60,35 @@
private int E;
private final AtomicInteger F;
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
@ -43,13 +42,13 @@
+ }
+ // CraftBukkit end
+
public Chunk(World world, int i, int j) {
public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long k) {
this.sections = new ChunkSection[16];
this.g = new byte[256];
@@ -62,8 +94,15 @@
Arrays.fill(this.h, -999);
Arrays.fill(this.g, (byte) -1);
this.h = new boolean[256];
@@ -95,8 +126,16 @@
this.t = ticklist;
this.u = ticklist1;
this.A = k;
+ // CraftBukkit start
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
+ this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ);
@ -57,22 +56,41 @@
+ public org.bukkit.Chunk bukkitChunk;
+ public boolean mustSave;
+ public boolean newChunk;
+ // CraftBukkit end
+
public Chunk(World world, ChunkSnapshot chunksnapshot, int i, int j) {
this(world, i, j);
boolean flag = true;
@@ -467,7 +506,8 @@
public Chunk(World world, ProtoChunk protochunk, int i, int j) {
this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.n(), protochunk.o(), protochunk.m());
@@ -136,14 +175,15 @@
HeightMap.Type heightmap_type = (HeightMap.Type) iterator.next();
if (heightmap_type.c() == HeightMap.Use.LIVE_WORLD) {
- ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type) -> {
- return new HeightMap(this, heightmap_type);
+ ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type1) -> { // CraftBukkit - decompile error
+ return new HeightMap(this, heightmap_type1); // CraftBukkit - decompile error
})).a(protochunk.b(heightmap_type).b());
}
}
this.y = true;
this.a(ChunkStatus.FULLCHUNK);
+ this.newChunk = true; // CraftBukkit
}
public Set<BlockPosition> t() {
@@ -474,7 +514,8 @@
}
}
- if (!this.world.isClientSide && block1 != block) {
- if (!this.world.isClientSide) {
+ // 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.isClientSide && block1 != block && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
block.onPlace(this.world, blockposition, iblockdata);
+ if (!this.world.isClientSide && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
iblockdata.onPlace(this.world, blockposition, iblockdata1);
}
@@ -604,7 +644,15 @@
@@ -654,7 +695,15 @@
@Nullable
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@ -89,21 +107,21 @@
if (tileentity == null) {
if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) {
@@ -639,6 +687,13 @@
@@ -689,6 +738,13 @@
tileentity.A();
tileentity.z();
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(getBlockData(blockposition).getBlock()) + ") where there was no entity tile!");
+ + " (" + getType(blockposition) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
@@ -681,9 +736,21 @@
@@ -735,9 +791,21 @@
int i = aentityslice.length;
for (int j = 0; j < i; ++j) {
@ -127,80 +145,49 @@
}
}
@@ -745,8 +812,8 @@
@@ -799,8 +867,8 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply(entity))) {
- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(entity))) {
- list.add(entity);
+ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error
+ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test((T) entity))) { // CraftBukkit - fix decompile error
+ list.add((T) entity); // Fix decompile error
}
}
}
@@ -773,7 +840,34 @@
return false;
@@ -1006,13 +1074,13 @@
@Nullable
public LongSet b(String s) {
- return (LongSet) this.r.computeIfAbsent(s, (s) -> {
+ return (LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error
return new LongOpenHashSet();
});
}
- public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) {
+ // CraftBukkit start
+ public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator, boolean newChunk) {
+ 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(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 = getWorld().getChunkIfLoaded(locX + x, locZ + z);
+ if (neighbor != null) {
+ neighbor.setNeighborLoaded(-x, -z);
+ setNeighborLoaded(x, z);
+ }
+ }
+ }
+ // CraftBukkit end
+
Chunk chunk = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ - 1);
Chunk chunk1 = ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ);
Chunk chunk2 = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ + 1);
@@ -809,6 +903,29 @@
} else {
this.o();
chunkgenerator.recreateStructures(this.locX, this.locZ);
+
+ // 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) locX * xRand + (long) locZ * 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, bukkitChunk);
+ }
+ } finally {
+ this.world.populating = false;
+ }
+ }
+ BlockSand.instaFall = false;
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
+ // CraftBukkit end
this.markDirty();
}
public void a(String s, long i) {
- ((LongSet) this.r.computeIfAbsent(s, (s) -> {
+ ((LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error
return new LongOpenHashSet();
})).add(i);
}
@@ -1061,14 +1129,14 @@
}
if (this.t instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.t).a(this.world.I(), (blockposition) -> {
- return this.world.getType(blockposition).getBlock();
+ ((ProtoChunkTickList<Block>) this.t).a(this.world.I(), (blockposition1) -> { // CraftBukkit - decompile error
+ return this.world.getType(blockposition1).getBlock();
});
}
if (this.u instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.u).a(this.world.H(), (blockposition) -> {
- return this.world.b(blockposition).c();
+ ((ProtoChunkTickList<FluidType>) this.u).a(this.world.H(), (blockposition1) -> { // CraftBukkit - decompile error
+ return this.world.b(blockposition1).c();
});
}

View File

@ -0,0 +1,88 @@
--- a/net/minecraft/server/ChunkMap.java
+++ b/net/minecraft/server/ChunkMap.java
@@ -31,6 +31,54 @@
}
}
+ org.bukkit.Server server = chunk.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, chunk.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.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z));
+ if (neighbor != null) {
+ neighbor.setNeighborLoaded(-x, -z);
+ chunk.setNeighborLoaded(x, z);
+ }
+ }
+ }
+
+ if (chunk.newChunk) {
+ BlockSand.instaFall = true;
+ java.util.Random random = new java.util.Random();
+ random.setSeed(chunk.world.getSeed());
+ long xRand = random.nextLong() / 2L * 2L + 1L;
+ long zRand = random.nextLong() / 2L * 2L + 1L;
+ random.setSeed((long) chunk.locX * xRand + (long) chunk.locZ * zRand ^ chunk.world.getSeed());
+
+ org.bukkit.World world = chunk.world.getWorld();
+ if (world != null) {
+ chunk.world.populating = true;
+ try {
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
+ populator.populate(world, random, chunk.bukkitChunk);
+ }
+ } finally {
+ chunk.world.populating = false;
+ }
+ }
+ BlockSand.instaFall = false;
+ chunk.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
+ }
+
return chunk1;
}
@@ -69,23 +117,25 @@
throw new RuntimeException("Not yet implemented");
}
- public Object remove(Object object) {
+ // CraftBukkit start - decompile errors
+ public Chunk remove(Object object) {
return this.a(object);
}
- public Object remove(long i) {
+ public Chunk remove(long i) {
return this.a(i);
}
- public Object put(Long olong, Object object) {
+ public Chunk put(Long olong, Chunk object) {
return this.a(olong, (Chunk) object);
}
- public Object put(long i, Object object) {
+ public Chunk put(long i, Chunk object) {
return this.a(i, (Chunk) object);
}
- public Object put(Object object, Object object1) {
+ public Object put(Object object, Chunk object1) {
return this.a((Long) object, (Chunk) object1);
}
+ // CraftBukkit end
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkProviderGenerate.java
+++ b/net/minecraft/server/ChunkProviderGenerate.java
@@ -234,6 +234,11 @@
@@ -166,6 +166,11 @@
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}
@ -10,5 +10,14 @@
+ }
+ // CraftBukkit end
float f7 = this.r[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
float f7 = this.o[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
@@ -267,7 +272,7 @@
return this.a.getSeaLevel() + 1;
}
- public GeneratorSettings getSettings() {
+ public GeneratorSettingsOverworld getSettings() { // CraftBukkit - decompile error
return this.f();
}
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
@@ -15,6 +15,11 @@
@@ -20,6 +20,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -12,40 +12,31 @@
public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger();
@@ -70,19 +75,82 @@
Chunk chunk = this.getLoadedChunkAt(i, j);
@@ -35,7 +40,7 @@
this.world = worldserver;
this.chunkLoader = ichunkloader;
this.chunkGenerator = chunkgenerator;
- this.f = new ChunkTaskScheduler(2, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler);
+ this.f = new ChunkTaskScheduler(0, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); // CraftBukkit - very buggy, broken in lots of __subtle__ ways. Same goes for async chunk loading. Also Bukkit API / plugins can't handle async events at all anyway.
this.g = new SchedulerBatch(this.f);
}
@@ -77,9 +82,10 @@
@Nullable
private Chunk loadChunkAt(int i, int j) {
try {
- Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk) -> {
- chunk.setLastSaved(this.world.getTime());
- this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
+ // CraftBukkit - decompile error
+ Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk1) -> {
+ chunk1.setLastSaved(this.world.getTime());
+ this.chunks.put(ChunkCoordIntPair.a(i, j), chunk1);
});
if (chunk == null) {
+ // CraftBukkit start
+ ChunkRegionLoader loader = null;
+
+ if (this.chunkLoader instanceof ChunkRegionLoader) {
+ loader = (ChunkRegionLoader) this.chunkLoader;
+ }
+ if (loader != null && loader.chunkExists(i, j)) {
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ }
+ }
+
+ return chunk;
+ }
+
+ @Nullable
+ public Chunk originalGetOrLoadChunkAt(int i, int j) {
+ // CraftBukkit end
+ Chunk chunk = this.getLoadedChunkAt(i, j);
+
+ if (chunk == null) {
chunk = this.loadChunk(i, j);
if (chunk != null) {
this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
chunk.addEntities();
- chunk.loadNearby(this, this.chunkGenerator);
+ chunk.loadNearby(this, this.chunkGenerator, false); // CraftBukkit
}
@@ -104,6 +110,12 @@
}
return chunk;
}
+ // CraftBukkit start
@ -55,74 +46,27 @@
+ // CraftBukkit end
+
public Chunk getChunkAt(int i, int j) {
- Chunk chunk = this.getOrLoadChunkAt(i, j);
+ return getChunkAt(i, j, null);
+ }
+
+ public Chunk getChunkAt(int i, int j, Runnable runnable) {
+ return getChunkAt(i, j, runnable, true);
+ }
+
+ public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) {
+ Chunk chunk = getLoadedChunkAt(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(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 && generate) {
+ 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) {
+ Chunk chunk = this.originalGetOrLoadChunkAt(i, j);
+ // CraftBukkit end
Chunk chunk = this.getOrLoadChunkAt(i, j);
if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j);
@@ -101,7 +169,7 @@
@@ -125,7 +137,7 @@
synchronized (this.chunks) {
IChunkAccess ichunkaccess = (IChunkAccess) this.chunks.get(ChunkCoordIntPair.a(i, j));
this.chunks.put(k, chunk);
chunk.addEntities();
- chunk.loadNearby(this, this.chunkGenerator);
+ chunk.loadNearby(this, this.chunkGenerator, true); // CraftBukkit
- return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((Object) (new ChunkCoordIntPair(i, j)));
+ return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((new ChunkCoordIntPair(i, j))); // CraftBukkit - decompile error
}
}
return chunk;
@@ -147,10 +215,12 @@
@@ -150,7 +162,7 @@
public CompletableFuture<Chunk> generateChunk(int i, int j) {
this.g.b();
this.g.a(new ChunkCoordIntPair(i, j));
- CompletableFuture completablefuture = this.g.c();
+ CompletableFuture<ProtoChunk> completablefuture = this.g.c(); // CraftBukkit - decompile error
public boolean a(boolean flag) {
int i = 0;
- ArrayList arraylist = Lists.newArrayList(this.chunks.values());
- for (int j = 0; j < arraylist.size(); ++j) {
- Chunk chunk = (Chunk) arraylist.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);
@@ -183,10 +253,12 @@
return completablefuture.thenApply(this::a);
}
@@ -268,10 +280,12 @@
Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) {
@ -139,7 +83,7 @@
++i;
}
}
@@ -198,6 +270,40 @@
@@ -284,6 +298,40 @@
return false;
}

View File

@ -1,112 +1,123 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
@@ -19,29 +19,47 @@
private static final Logger a = LogManager.getLogger();
private final Map<ChunkCoordIntPair, NBTTagCompound> b = Maps.newConcurrentMap();
- private final Set<ChunkCoordIntPair> c = Collections.newSetFromMap(Maps.newConcurrentMap());
+ // CraftBukkit
+ // private final Set<ChunkCoordIntPair> c = Collections.newSetFromMap(Maps.newConcurrentMap());
private final File d;
private final DataConverterManager e;
@@ -34,7 +34,7 @@
private final File c;
private final DataFixer d;
private PersistentStructureLegacy e;
- private boolean f;
+ // private boolean f;
+ // CraftBukkit
+ // private boolean f; // CraftBukkit
public ChunkRegionLoader(File file, DataConverterManager dataconvertermanager) {
this.d = file;
this.e = dataconvertermanager;
public ChunkRegionLoader(File file, DataFixer datafixer) {
this.c = file;
@@ -50,12 +50,13 @@
@Nullable
private NBTTagCompound b(GeneratorAccess generatoraccess, int i, int j) throws IOException {
- DataInputStream datainputstream = RegionFileCache.d(this.c, i, j);
+ // CraftBukkit start
+ NBTTagCompound nbttagcompound = RegionFileCache.d(this.c, i, j);
- if (datainputstream == null) {
+ if (nbttagcompound == null) {
return null;
} else {
- NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream);
+ // CraftBukkit end
int k = nbttagcompound.hasKeyOfType("DataVersion", 99) ? nbttagcompound.getInt("DataVersion") : -1;
if (k < 1493) {
@@ -78,13 +79,29 @@
}
}
+ // CraftBukkit start - Add async variant, provide compatibility
@Nullable
public Chunk a(World world, int i, int j) throws IOException {
+ Object[] data = loadChunk(world, i, j);
public synchronized Chunk a(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
+ Object[] data = loadChunk(generatoraccess, i, j, consumer);
+ if (data != null) {
+ Chunk chunk = (Chunk) data[0];
+ NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
+ loadEntities(chunk, nbttagcompound.getCompound("Level"), world);
+ consumer.accept(chunk);
+ this.loadEntities(nbttagcompound.getCompound("Level"), chunk);
+ return chunk;
+ }
+
+ return null;
+ }
+
+ public Object[] loadChunk(World world, int i, int j) throws IOException {
+ public synchronized Object[] loadChunk(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
+ // CraftBukkit end
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
NBTTagCompound nbttagcompound = this.a(generatoraccess, i, j);
if (nbttagcompound == null) {
- DataInputStream datainputstream = RegionFileCache.d(this.d, i, j);
+ // CraftBukkit start
+ nbttagcompound = RegionFileCache.d(this.d, i, j);
return null;
} else {
+ /*
Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
- if (datainputstream == null) {
+ if (nbttagcompound == null) {
return null;
if (chunk != null) {
@@ -93,6 +110,9 @@
}
- nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, NBTCompressedStreamTools.a(datainputstream));
+ nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, nbttagcompound);
+ // CraftBukkit end
return chunk;
+ */
+
+ return this.a(generatoraccess, i, j, nbttagcompound);
}
}
return this.a(world, i, j, nbttagcompound);
@@ -55,7 +73,7 @@
@@ -121,7 +141,7 @@
}
@Nullable
- protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) {
+ protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j));
return null;
@@ -72,10 +90,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ));
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
- protected Chunk a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) {
+ protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
@@ -140,10 +160,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ));
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
+
+ // 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 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(generatoraccess, nbttagcompound1);
}
- return chunk;
+ // CraftBukkit start
+ Object[] data = new Object[2];
+ data[0] = chunk;
+ data[1] = nbttagcompound;
+ return data;
+ // CraftBukkit end
chunk = this.a(world, nbttagcompound1);
}
- return chunk;
+ // CraftBukkit start
+ Object[] data = new Object[2];
+ data[0] = chunk;
+ data[1] = nbttagcompound;
+ return data;
+ // CraftBukkit end
}
}
}
@@ -98,7 +134,9 @@
} else {
@@ -158,7 +196,7 @@
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
- return new ProtoChunkExtension(this.a(generatoraccess, i, j, nbttagcompound));
+ return new ProtoChunkExtension((IChunkAccess) this.a(generatoraccess, i, j, nbttagcompound)[0]); // CraftBukkit - fix up access
} else {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
@@ -204,19 +242,30 @@
}
protected void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) {
- if (!this.c.contains(chunkcoordintpair)) {
+ // CraftBukkit
+ // if (!this.c.contains(chunkcoordintpair))
+ {
this.b.put(chunkcoordintpair, nbttagcompound);
}
@@ -106,20 +144,32 @@
}
public boolean a() {
public synchronized boolean a() {
- if (this.b.isEmpty()) {
- if (this.f) {
+ // CraftBukkit start
@ -118,7 +129,7 @@
+ if (!iter.hasNext()) {
+ if (logCompletion) {
+ // CraftBukkit end
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.d.getName());
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
}
return false;
@ -133,40 +144,37 @@
boolean flag;
try {
- this.c.add(chunkcoordintpair);
- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair);
+ // this.c.add(chunkcoordintpair);
+ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair);
+ // CraftBukkit
- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
+ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); // CraftBukkit
if (nbttagcompound != null) {
try {
@@ -131,7 +181,7 @@
@@ -228,7 +277,7 @@
flag = true;
} finally {
- this.c.remove(chunkcoordintpair);
- this.b.remove(chunkcoordintpair);
+ this.b.remove(chunkcoordintpair, nbttagcompound); // CraftBukkit
}
return flag;
@@ -139,10 +189,14 @@
@@ -248,10 +297,14 @@
}
private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
- DataOutputStream dataoutputstream = RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z);
- DataOutputStream dataoutputstream = RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z);
+ // CraftBukkit start
+ RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ /*
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
dataoutputstream.close();
+ */
+ // CraftBukkit end
}
public void b(World world, Chunk chunk) throws IOException {}
@@ -151,15 +205,16 @@
if (this.e != null) {
this.e.a(chunkcoordintpair.a());
}
@@ -264,15 +317,16 @@
public void c() {
try {
@ -186,30 +194,52 @@
}
}
@@ -334,6 +389,13 @@
chunk.a(nbttagcompound.getByteArray("Biomes"));
}
@@ -301,7 +355,7 @@
+ // 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);
for (int l = 0; l < nbttaglist1.size(); ++l) {
@@ -371,7 +433,7 @@
if (abiomebase != null) {
for (int k = 0; k < abiomebase.length; ++k) {
- aint[k] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[k]);
+ aint[k] = BiomeBase.REGISTRY_ID.a(abiomebase[k]); // CraftBukkit - decompile error
}
}
- return chunk;
+ // return chunk; // CraftBukkit
}
@@ -383,7 +437,7 @@
int[] aint = new int[abiomebase.length];
@Nullable
@@ -399,14 +461,20 @@
for (int i = 0; i < abiomebase.length; ++i) {
- aint[i] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[i]);
+ aint[i] = BiomeBase.REGISTRY_ID.a(abiomebase[i]); // CraftBukkit - decompile error
}
nbttagcompound.setIntArray("Biomes", aint);
@@ -485,7 +539,7 @@
}
ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
- Predicate predicate = (block) -> {
+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile error
return block.getBlockData().isAir();
};
RegistryBlocks registryblocks = Block.REGISTRY;
@@ -497,7 +551,7 @@
Block.REGISTRY.getClass();
ProtoChunkTickList protochunkticklist = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j));
- predicate = (fluidtype) -> {
+ Predicate<FluidType> predicate1 = (fluidtype) -> { // CraftBukkit - decompile error
return fluidtype == FluidTypes.a;
};
registryblocks = FluidType.c;
@@ -505,7 +559,7 @@
function = registryblocks::b;
registryblocks1 = FluidType.c;
FluidType.c.getClass();
- ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j));
+ ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate1, function, registryblocks1::get, new ChunkCoordIntPair(i, j)); // CraftBukkit - decompile error
long i1 = nbttagcompound.getLong("InhabitedTime");
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
@@ -852,17 +906,29 @@
}
@Nullable
@ -220,30 +250,40 @@
+
+ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
Entity entity = a(nbttagcompound, world);
if (entity == null) {
return null;
} else {
return a(nbttagcompound, world, (entity) -> {
entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch);
- if (flag && !world.addEntity(entity)) {
+ if (flag && !world.addEntity(entity, spawnReason)) { // CraftBukkit
return null;
} else {
if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
@@ -435,8 +503,14 @@
- return flag && !world.addEntity(entity) ? null : entity;
+ return flag && !world.addEntity(entity, spawnReason) ? null : entity;
});
}
@Nullable
+ // CraftBukkit start
public static Entity a(NBTTagCompound nbttagcompound, World world, boolean flag) {
+ return spawnEntity(nbttagcompound, world, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
return a(nbttagcompound, world, (entity) -> {
- return flag && !world.addEntity(entity) ? null : entity;
+ return flag && !world.addEntity(entity, spawnReason) ? null : entity; // CraftBukkit
});
}
@@ -876,8 +942,14 @@
}
}
+ // CraftBukkit start
public static void a(Entity entity, World world) {
- if (world.addEntity(entity) && entity.isVehicle()) {
+ a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
public static void a(Entity entity, GeneratorAccess generatoraccess) {
- if (generatoraccess.addEntity(entity) && entity.isVehicle()) {
+ a(entity, generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ if (world.addEntity(entity, reason) && entity.isVehicle()) {
+ public static void a(Entity entity, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ if (generatoraccess.addEntity(entity, reason) && entity.isVehicle()) {
+ // CraftBukkit end
Iterator iterator = entity.bF().iterator();
Iterator iterator = entity.bP().iterator();
while (iterator.hasNext()) {

View File

@ -1,31 +1,15 @@
--- a/net/minecraft/server/ChunkSection.java
+++ b/net/minecraft/server/ChunkSection.java
@@ -19,6 +19,24 @@
@@ -15,7 +15,7 @@
}
+ // CraftBukkit start
+ public ChunkSection(int y, boolean flag, char[] blockIds) {
+ this.yPos = y;
+ this.blockIds = new DataPaletteBlock();
+ for (int i = 0; i < blockIds.length; i++) {
+ int xx = i & 15;
+ int yy = (i >> 8) & 15;
+ int zz = (i >> 4) & 15;
+ this.blockIds.setBlock(xx, yy, zz, Block.REGISTRY_ID.fromId(blockIds[i]));
+ }
+ this.emittedLight = new NibbleArray();
+ if (flag) {
+ this.skyLight = new NibbleArray();
+ }
+ recalcBlockCounts();
+ }
+ // CraftBukkit end
+
public IBlockData getType(int i, int j, int k) {
return this.blockIds.a(i, j, k);
}
@@ -46,7 +64,7 @@
public ChunkSection(int i, boolean flag) {
this.yPos = i;
- this.blockIds = new DataPaletteBlock(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData());
+ this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // CraftBukkit - decompile error
this.emittedLight = new NibbleArray();
if (flag) {
this.skyLight = new NibbleArray();
@@ -62,7 +62,7 @@
}
public boolean a() {
@ -33,4 +17,4 @@
+ return false; // CraftBukkit - MC-80966
}
public boolean shouldTick() {
public boolean b() {

View File

@ -1,209 +1,37 @@
--- a/net/minecraft/server/CommandBlockListenerAbstract.java
+++ b/net/minecraft/server/CommandBlockListenerAbstract.java
@@ -4,6 +4,15 @@
@@ -5,6 +5,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.ArrayList;
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+import com.google.common.base.Joiner;
+import java.util.logging.Level;
+import org.bukkit.command.CommandSender;
+import org.bukkit.event.server.ServerCommandEvent;
+// CraftBukkit end
+
public abstract class CommandBlockListenerAbstract implements ICommandListener {
private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss");
@@ -15,6 +24,7 @@
@@ -16,6 +17,10 @@
private IChatBaseComponent f;
private String g = "";
private String h = "@";
private final CommandObjectiveExecutor i = new CommandObjectiveExecutor();
+ protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender
private IChatBaseComponent h = new ChatComponentText("@");
+ // CraftBukkit start
+ @Override
+ public abstract CommandSender getBukkitSender(CommandListenerWrapper wrapper);
+ // CraftBukkit end
public CommandBlockListenerAbstract() {}
@@ -107,7 +117,9 @@
if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) {
@@ -103,14 +108,7 @@
if (minecraftserver != null && minecraftserver.F() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.g)) {
try {
this.f = null;
- this.d = minecraftserver.getCommandHandler().a(this, this.g);
+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
+ this.d = executeSafely(this, sender, this.g);
+ // CraftBukkit end
- CommandListenerWrapper commandlistenerwrapper = this.getWrapper().a((commandcontext, flag, i) -> {
- if (flag) {
- ++this.d;
- }
-
- });
-
- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.g);
+ this.d = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.g); // CraftBukkit
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
@@ -149,6 +161,171 @@
}
}
+ public static int executeSafely(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) {
+ try {
+ return executeCommand(sender, bSender, command);
+ } catch (CommandException commandexception) {
+ // Taken from CommandHandler
+ ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs());
+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
+ sender.sendMessage(chatmessage);
+ }
+
+ return 0;
+ }
+
+ // CraftBukkit start
+ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) throws CommandException {
+ org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap();
+ Joiner joiner = Joiner.on(" ");
+ if (command.startsWith("/")) {
+ command = command.substring(1);
+ }
+
+ ServerCommandEvent event = new ServerCommandEvent(bSender, command);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return 0;
+ }
+ command = event.getCommand();
+
+ String[] args = command.split(" ");
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+
+ String cmd = args[0];
+ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
+ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length());
+
+ // Block disallowed commands
+ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op")
+ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip")
+ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) {
+ return 0;
+ }
+
+ // Handle vanilla commands;
+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand(args[0]);
+ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) {
+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
+ }
+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
+ command = command.trim();
+ if (command.startsWith("/")) {
+ command = command.substring(1);
+ }
+ String as[] = command.split(" ");
+ as = VanillaCommandWrapper.dropFirstArgument(as);
+ if (!sender.getWorld().getServer().getPermissionOverride(sender) && !((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) {
+ return 0;
+ }
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as);
+ }
+
+ // Make sure this is a valid command
+ if (commandMap.getCommand(args[0]) == null) {
+ return 0;
+ }
+
+ commands.add(args);
+
+ // Find positions of command block syntax, if any
+ WorldServer[] prev = MinecraftServer.getServer().worldServer;
+ MinecraftServer server = MinecraftServer.getServer();
+ server.worldServer = new WorldServer[server.worlds.size()];
+ server.worldServer[0] = (WorldServer) sender.getWorld();
+ int bpos = 0;
+ for (int pos = 1; pos < server.worldServer.length; pos++) {
+ WorldServer world = server.worlds.get(bpos++);
+ if (server.worldServer[0] == world) {
+ pos--;
+ continue;
+ }
+ server.worldServer[pos] = world;
+ }
+ try {
+ 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(buildCommands(sender, commands.get(j), i));
+ }
+ ArrayList<String[]> temp = commands;
+ commands = newCommands;
+ newCommands = temp;
+ newCommands.clear();
+ }
+ }
+ } finally {
+ MinecraftServer.getServer().worldServer = prev;
+ }
+
+ 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(bSender, joiner.join(java.util.Arrays.asList(commands.get(i))))) {
+ completed++;
+ }
+ } catch (Throwable exception) {
+ if (sender.f() instanceof EntityMinecartCommandBlock) {
+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", sender.getChunkCoordinates().getX(), sender.getChunkCoordinates().getY(), sender.getChunkCoordinates().getZ()), exception);
+ } else if (sender instanceof CommandBlockListenerAbstract) {
+ CommandBlockListenerAbstract listener = (CommandBlockListenerAbstract) sender;
+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
+ } else {
+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("Unknown CommandBlock failed to handle command"), exception);
+ }
+ }
+ }
+
+ return completed;
+ }
+
+ private static ArrayList<String[]> buildCommands(ICommandListener sender, String[] args, int pos) throws CommandException {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+ java.util.List<EntityPlayer> players = (java.util.List<EntityPlayer>)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class);
+
+ if (players != null) {
+ for (EntityPlayer player : players) {
+ if (player.world != sender.getWorld()) {
+ continue;
+ }
+ String[] command = args.clone();
+ command[pos] = player.getName();
+ commands.add(command);
+ }
+ }
+
+ return commands;
+ }
+
+ public static CommandSender unwrapSender(ICommandListener listener) {
+ org.bukkit.command.CommandSender sender = null;
+ while (sender == null) {
+ if (listener instanceof DedicatedServer) {
+ sender = ((DedicatedServer) listener).console;
+ } else if (listener instanceof RemoteControlCommandListener) {
+ sender = ((RemoteControlCommandListener) listener).C_().remoteConsole;
+ } else if (listener instanceof CommandBlockListenerAbstract) {
+ sender = ((CommandBlockListenerAbstract) listener).sender;
+ } else if (listener instanceof CustomFunctionData.CustomFunctionListener) {
+ sender = ((CustomFunctionData.CustomFunctionListener) listener).sender;
+ } else if (listener instanceof CommandListenerWrapper) {
+ listener = ((CommandListenerWrapper) listener).base; // Search deeper
+ } else if (VanillaCommandWrapper.lastSender != null) {
+ sender = VanillaCommandWrapper.lastSender;
+ } else if (listener.f() != null) {
+ sender = listener.f().getBukkitEntity();
+ } else {
+ throw new RuntimeException("Unhandled executor " + listener.getClass().getSimpleName());
+ }
+ }
+
+ return sender;
+ }
+ // CraftBukkit end
+
public String getName() {
return this.h;
}

View File

@ -1,32 +1,32 @@
--- a/net/minecraft/server/CommandDebug.java
+++ b/net/minecraft/server/CommandDebug.java
@@ -34,6 +34,14 @@
@@ -35,6 +35,14 @@
}
public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
private static int a(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur)
+ if (!minecraftserver.methodProfiler.ENABLED) {
+ icommandlistener.sendMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
+ icommandlistener.sendMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
+ icommandlistener.sendMessage(new ChatComponentText("Use `/timings' for plugin timings."));
+ return;
+ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) {
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings."));
+ return 0;
+ }
+ // CraftBukkit end
if (astring.length < 1) {
throw new ExceptionUsage("commands.debug.usage", new Object[0]);
} else {
@@ -142,6 +150,13 @@
MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
MethodProfiler methodprofiler = minecraftserver.methodProfiler;
@@ -48,6 +56,14 @@
}
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
- return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.emptyList();
+ return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.<String>emptyList(); // CraftBukkit - decompile error
+ }
+
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
}
+ // CraftBukkit end
}
private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur)
+ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) {
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings."));
+ return 0;
+ }
+ // CraftBukkit end
MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
MethodProfiler methodprofiler = minecraftserver.methodProfiler;

View File

@ -0,0 +1,189 @@
--- a/net/minecraft/server/CommandDispatcher.java
+++ b/net/minecraft/server/CommandDispatcher.java
@@ -26,12 +26,19 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import com.google.common.base.Joiner;
+import org.apache.logging.log4j.Level;
+import org.bukkit.event.server.ServerCommandEvent;
+// CraftBukkit end
+
public class CommandDispatcher {
private static final Logger a = LogManager.getLogger();
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> b = new com.mojang.brigadier.CommandDispatcher();
- public CommandDispatcher(boolean flag) {
+ // CraftBukkit start
+ public final CommandDispatcher init(boolean flag) {
CommandAdvancement.a(this.b);
CommandExecute.a(this.b);
CommmandBossBar.a(this.b);
@@ -100,6 +107,11 @@
this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
CommandDispatcher.a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection);
});
+ return this;
+ }
+
+ public CommandDispatcher() {
+ // CraftBukkit end
this.b.setConsumer((commandcontext, flag, i) -> {
((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
});
@@ -114,7 +126,58 @@
}
+ // CraftBukkit start
+ public int dispatchServerCommand(CommandListenerWrapper sender, String command) {
+ Joiner joiner = Joiner.on(" ");
+ if (command.startsWith("/")) {
+ command = command.substring(1);
+ }
+
+ ServerCommandEvent event = new ServerCommandEvent(sender.getBukkitSender(), command);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return 0;
+ }
+ command = event.getCommand();
+
+ String[] args = command.split(" ");
+
+ String cmd = args[0];
+ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
+ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length());
+
+ // Block disallowed commands
+ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op")
+ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip")
+ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) {
+ return 0;
+ }
+
+ // Handle vanilla commands;
+ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) {
+ args[0] = "minecraft:" + args[0];
+ }
+
+ return this.a(sender, joiner.join(args));
+ }
+
public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
+ // Some commands use the worldserver variable but we leave it full of null values,
+ // so we must temporarily populate it with the world of the commandsender
+ WorldServer[] prev = MinecraftServer.getServer().worldServer;
+ MinecraftServer server = MinecraftServer.getServer();
+ server.worldServer = new WorldServer[server.worlds.size()];
+ server.worldServer[0] = (WorldServer) commandlistenerwrapper.getWorld();
+ int bpos = 0;
+ for (int pos = 1; pos < server.worldServer.length; pos++) {
+ WorldServer world = server.worlds.get(bpos++);
+ if (server.worldServer[0] == world) {
+ pos--;
+ continue;
+ }
+ server.worldServer[pos] = world;
+ }
+ // CraftBukkit end
String s1 = s;
if (s.startsWith("/")) {
@@ -126,7 +189,6 @@
byte b0;
try {
- byte b1;
ChatComponentText chatcomponenttext;
try {
@@ -135,54 +197,59 @@
return i;
} catch (CommandException commandexception) {
commandlistenerwrapper.sendFailureMessage(commandexception.a());
- b1 = 0;
- return b1;
+ b0 = 0;
+ return b0;
} catch (CommandSyntaxException commandsyntaxexception) {
commandlistenerwrapper.sendFailureMessage(ChatComponentUtils.a(commandsyntaxexception.getRawMessage()));
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
- IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).a((chatmodifier) -> {
- chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
- });
+ chatcomponenttext = new ChatComponentText("");
if (j > 10) {
- ichatbasecomponent.a("...");
+ chatcomponenttext.a("...");
}
- ichatbasecomponent.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j));
+ chatcomponenttext.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j));
if (j < commandsyntaxexception.getInput().length()) {
- IChatBaseComponent ichatbasecomponent1 = (new ChatComponentText(commandsyntaxexception.getInput().substring(j))).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.UNDERLINE});
+ ChatComponentText chatcomponenttext1 = new ChatComponentText(commandsyntaxexception.getInput().substring(j));
- ichatbasecomponent.addSibling(ichatbasecomponent1);
+ chatcomponenttext1.getChatModifier().setColor(EnumChatFormat.RED);
+ chatcomponenttext1.getChatModifier().setUnderline(Boolean.valueOf(true));
+ chatcomponenttext.addSibling(chatcomponenttext1);
}
- ichatbasecomponent.addSibling((new ChatMessage("command.context.here", new Object[0])).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.ITALIC}));
- commandlistenerwrapper.sendFailureMessage(ichatbasecomponent);
+ ChatMessage chatmessage = new ChatMessage("command.context.here", new Object[0]);
+
+ chatmessage.getChatModifier().setItalic(Boolean.valueOf(true));
+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
+ chatcomponenttext.addSibling(chatmessage);
+ chatcomponenttext.getChatModifier().setColor(EnumChatFormat.GRAY);
+ chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s1));
+ commandlistenerwrapper.sendFailureMessage(chatcomponenttext);
}
- b1 = 0;
- return b1;
+ b0 = 0;
} catch (Exception exception) {
- chatcomponenttext = new ChatComponentText;
- }
+ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]);
- chatcomponenttext.<init>(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
- ChatComponentText chatcomponenttext1 = chatcomponenttext;
+ chatcomponenttext = new ChatComponentText(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
+ if (CommandDispatcher.a.isDebugEnabled()) {
+ StackTraceElement[] astacktraceelement = exception.getStackTrace();
- if (CommandDispatcher.a.isDebugEnabled()) {
- StackTraceElement[] astacktraceelement = exception.getStackTrace();
-
- for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
- chatcomponenttext1.a("\n\n").a(astacktraceelement[k].getMethodName()).a("\n ").a(astacktraceelement[k].getFileName()).a(":").a(String.valueOf(astacktraceelement[k].getLineNumber()));
+ for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
+ chatcomponenttext.a("\n\n" + astacktraceelement[k].getMethodName() + "\n " + astacktraceelement[k].getFileName() + ":" + astacktraceelement[k].getLineNumber());
+ }
}
- }
- commandlistenerwrapper.sendFailureMessage((new ChatMessage("command.failed", new Object[0])).a((chatmodifier) -> {
- chatmodifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, ichatbasecomponent));
- }));
- b0 = 0;
+ chatmessage1.getChatModifier().setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, chatcomponenttext));
+ commandlistenerwrapper.sendFailureMessage(chatmessage1);
+ byte b1 = 0;
+
+ return b1;
+ }
} finally {
commandlistenerwrapper.getServer().methodProfiler.e();
+ MinecraftServer.getServer().worldServer = prev; // CraftBukkit
}
return b0;

View File

@ -1,58 +0,0 @@
--- a/net/minecraft/server/CommandExecute.java
+++ b/net/minecraft/server/CommandExecute.java
@@ -4,6 +4,10 @@
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+// CraftBukkit end
public class CommandExecute extends CommandAbstract {
@@ -59,26 +63,41 @@
}
String s = a(astring, b0);
- CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worldServer[0].getGameRules().getBoolean("commandBlockOutput"));
+ CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worlds.get(0).getGameRules().getBoolean("commandBlockOutput")); // CraftBukkit
ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
try {
- int i = icommandhandler.a(commandlistenerwrapper, s);
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener);
+ int i = CommandBlockListenerAbstract.executeCommand(commandlistenerwrapper, new ProxiedNativeCommandSender(commandlistenerwrapper, sender, entity.getBukkitEntity()), s);
+ // CraftBukkit end
if (i < 1) {
throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s});
}
} catch (Throwable throwable) {
+ // CraftBukkit start
+ if (throwable instanceof CommandException) {
+ throw (CommandException) throwable;
+ }
+ // CraftBukkit end
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
}
}
}
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
- return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.emptyList())));
+ return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.<String>emptyList()))); // CraftBukkit - decompile error
}
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
+
+ // CraftBukkit start - fix decompiler error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}

View File

@ -1,34 +1,15 @@
--- a/net/minecraft/server/CommandGamemode.java
+++ b/net/minecraft/server/CommandGamemode.java
@@ -28,6 +28,12 @@
EntityPlayer entityplayer = astring.length >= 2 ? b(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener);
@@ -57,6 +57,12 @@
entityplayer.a(enumgamemode);
+ // CraftBukkit start - handle event cancelling the change
+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
+ icommandlistener.sendMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
+ return;
+ }
+ // CraftBukkit end
ChatMessage chatmessage = new ChatMessage("gameMode." + enumgamemode.b(), new Object[0]);
if (icommandlistener.getWorld().getGameRules().getBoolean("sendCommandFeedback")) {
@@ -50,10 +56,17 @@
}
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
- return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.emptyList());
+ return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.<String>emptyList()); // CraftBukkit - decompile error
}
public boolean isListStart(String[] astring, int i) {
return i == 1;
}
+
+ // CraftBukkit start - fix decompiler error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}
if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
entityplayer.a(enumgamemode);
+ // CraftBukkit start - handle event cancelling the change
+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
+ commandcontext.getSource().sendFailureMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
+ continue;
+ }
+ // CraftBukkit end
a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode);
++i;
}

View File

@ -1,23 +0,0 @@
--- a/net/minecraft/server/CommandGamerule.java
+++ b/net/minecraft/server/CommandGamerule.java
@@ -23,7 +23,7 @@
}
public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
- GameRules gamerules = this.a(minecraftserver);
+ GameRules gamerules = icommandlistener.getWorld().getGameRules(); // CraftBukkit - Use current world
String s = astring.length > 0 ? astring[0] : "";
String s1 = astring.length > 1 ? a(astring, 1) : "";
@@ -92,4 +92,11 @@
private GameRules a(MinecraftServer minecraftserver) {
return minecraftserver.getWorldServer(0).getGameRules();
}
+
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,46 @@
--- a/net/minecraft/server/CommandListenerWrapper.java
+++ b/net/minecraft/server/CommandListenerWrapper.java
@@ -7,6 +7,7 @@
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import com.mojang.brigadier.tree.CommandNode;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -31,9 +32,10 @@
private final ResultConsumer<CommandListenerWrapper> l;
private final ArgumentAnchor.Anchor m;
private final Vec2F n;
+ public CommandNode currentCommand; // CraftBukkit
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
- this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, i) -> {
+ this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, ix) -> { // CraftBukkit - decompile error
}, ArgumentAnchor.Anchor.FEET);
}
@@ -119,6 +121,12 @@
}
public boolean hasPermission(int i) {
+ // CraftBukkit start
+ if (currentCommand != null) {
+ return this.f >= i || getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
+ }
+ // CraftBukkit end
+
return this.f >= i;
}
@@ -232,4 +240,10 @@
public Collection<ICompletionProvider.a> a(boolean flag) {
return Collections.singleton(ICompletionProvider.a.b);
}
+
+ // CraftBukkit start
+ public org.bukkit.command.CommandSender getBukkitSender() {
+ return base.getBukkitSender(this);
+ }
+ // CraftBukkit end
}

View File

@ -1,50 +1,32 @@
--- a/net/minecraft/server/CommandSpreadPlayers.java
+++ b/net/minecraft/server/CommandSpreadPlayers.java
@@ -240,9 +240,16 @@
}
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
- return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.emptyList();
+ return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.<String>emptyList(); // CraftBukkit - decompile error
}
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a(o);
+ }
+ // CraftBukkit end
+
static class Location2D {
double a;
@@ -309,7 +316,7 @@
@@ -269,7 +269,7 @@
}
blockposition = blockposition.down();
- } while (world.getType(blockposition).getMaterial() == Material.AIR);
+ } while (getType(world, blockposition).getMaterial() == Material.AIR); // CraftBukkit
- } while (iblockaccess.getType(blockposition).isAir());
+ } while (getType(iblockaccess, blockposition).isAir()); // CraftBukkit
return blockposition.getY() + 1;
}
@@ -325,7 +332,7 @@
@@ -285,7 +285,7 @@
}
blockposition = blockposition.down();
- material = world.getType(blockposition).getMaterial();
+ material = getType(world, blockposition).getMaterial(); // CraftBukkit
} while (material == Material.AIR);
- iblockdata = iblockaccess.getType(blockposition);
+ iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
} while (iblockdata.isAir());
return !material.isLiquid() && material != Material.FIRE;
@@ -335,5 +342,12 @@
Material material = iblockdata.getMaterial();
@@ -297,5 +297,12 @@
this.a = MathHelper.a(random, d0, d2);
this.b = MathHelper.a(random, d1, d3);
}
+
+ // CraftBukkit start - add a version of getType which force loads chunks
+ private static IBlockData getType(World world, BlockPosition position) {
+ ((ChunkProviderServer) world.chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4);
+ return world.getType(position);
+ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
+ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4);
+ return iblockaccess.getType(position);
+ }
+ // CraftBukkit end
}

View File

@ -1,23 +1,14 @@
--- a/net/minecraft/server/CommandTeleport.java
+++ b/net/minecraft/server/CommandTeleport.java
@@ -69,7 +69,7 @@
@@ -116,9 +116,9 @@
if (entity instanceof EntityPlayer) {
entity.stopRiding();
if (worldserver == entity.world) {
- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set);
+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
} else {
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1);
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
}
entity.stopRiding();
- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset);
+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
entity.setHeadRotation(f);
} else {
float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a());
@@ -94,4 +94,11 @@
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
+
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}

View File

@ -1,45 +0,0 @@
--- a/net/minecraft/server/CommandTp.java
+++ b/net/minecraft/server/CommandTp.java
@@ -53,17 +53,11 @@
} else {
Entity entity = c(minecraftserver, icommandlistener, astring[astring.length - 1]);
- if (entity.world != ((Entity) object).world) {
- throw new CommandException("commands.tp.notSameDimension", new Object[0]);
- } else {
- ((Entity) object).stopRiding();
- if (object instanceof EntityPlayer) {
- ((EntityPlayer) object).playerConnection.a(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
- } else {
- ((Entity) object).setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
- }
-
+ // CraftBukkit Start
+ // Use Bukkit teleport method in all cases. It has cross dimensional handling, events
+ if (((Entity) object).getBukkitEntity().teleport(entity.getBukkitEntity(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND)) {
a(icommandlistener, (ICommand) this, "commands.tp.success", new Object[] { ((Entity) object).getName(), entity.getName()});
+ // CraftBukkit End
}
}
}
@@ -107,7 +101,7 @@
}
entity.stopRiding();
- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset);
+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
entity.setHeadRotation(f);
} else {
float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a());
@@ -132,4 +126,11 @@
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
+
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}

View File

@ -96,7 +96,7 @@
+ // CraftBukkit end
}
this.d();
this.c();
@@ -165,8 +225,11 @@
if (i == -999) {
if (!playerinventory.getCarried().isEmpty()) {
@ -126,11 +126,11 @@
}
}
} else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) {
@@ -564,6 +636,7 @@
inventorycraftresult.a(irecipe);
itemstack = irecipe.craftItem(inventorycrafting);
@@ -567,6 +639,7 @@
if (inventorycraftresult.a(world, entityplayer, irecipe) && irecipe != null) {
itemstack = irecipe.craftItem(iinventory);
}
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, itemstack, getBukkitView(), false); // CraftBukkit
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(iinventory, inventorycraftresult, itemstack, getBukkitView(), false); // CraftBukkit
inventorycraftresult.setItem(0, itemstack);
entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));

View File

@ -26,7 +26,7 @@
this.j = blockposition;
this.i = world;
this.m = entityhuman;
@@ -110,7 +120,7 @@
@@ -111,7 +121,7 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
@ -35,25 +35,25 @@
this.levelCost = 0;
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -128,7 +138,7 @@
if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.i(), itemstack1.k() / 4);
@@ -129,7 +139,7 @@
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
if (k <= 0) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
return;
}
@@ -143,7 +153,7 @@
@@ -144,7 +154,7 @@
this.k = l;
} else {
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) {
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
return;
}
@@ -236,7 +246,7 @@
@@ -237,7 +247,7 @@
}
if (flag2 && !flag1) {
@ -62,7 +62,7 @@
this.levelCost = 0;
return;
}
@@ -283,7 +293,7 @@
@@ -284,7 +294,7 @@
EnchantmentManager.a(map, itemstack1);
}
@ -71,17 +71,17 @@
this.b();
}
}
@@ -301,6 +311,7 @@
@@ -302,6 +312,7 @@
}
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
return !this.i.getType(this.j).a(TagsBlock.x) ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
}
@@ -356,4 +367,33 @@
@@ -357,4 +368,33 @@
this.e();
this.d();
}
+
+ // CraftBukkit start

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerEnchantTable.java
+++ b/net/minecraft/server/ContainerEnchantTable.java
@@ -3,6 +3,19 @@
@@ -3,6 +3,21 @@
import java.util.List;
import java.util.Random;
@ -8,9 +8,11 @@
+import java.util.Collections;
+import java.util.Map;
+import org.bukkit.Location;
+import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.enchantments.EnchantmentOffer;
+import org.bukkit.event.enchantment.EnchantItemEvent;
+import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
@ -19,8 +21,8 @@
+
public class ContainerEnchantTable extends Container {
public IInventory enchantSlots = new InventorySubcontainer("Enchant", true, 2) {
@@ -14,6 +27,13 @@
public IInventory enchantSlots = new InventorySubcontainer(new ChatComponentText("Enchant"), 2) {
@@ -14,6 +29,13 @@
super.update();
ContainerEnchantTable.this.a((IInventory) this);
}
@ -34,7 +36,7 @@
};
public World world;
private final BlockPosition position;
@@ -22,6 +42,10 @@
@@ -22,6 +44,10 @@
public int[] costs = new int[3];
public int[] h = new int[] { -1, -1, -1};
public int[] i = new int[] { -1, -1, -1};
@ -45,7 +47,7 @@
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
this.world = world;
@@ -54,6 +78,9 @@
@@ -54,6 +80,9 @@
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
@ -55,7 +57,7 @@
}
protected void c(ICrafting icrafting) {
@@ -90,7 +117,7 @@
@@ -90,7 +119,7 @@
ItemStack itemstack = iinventory.getItem(0);
int i;
@ -64,7 +66,14 @@
if (!this.world.isClientSide) {
i = 0;
@@ -152,6 +179,41 @@
@@ -146,12 +175,47 @@
if (list != null && !list.isEmpty()) {
WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.l.nextInt(list.size()));
- this.h[j] = Enchantment.enchantments.a((Object) weightedrandomenchant.enchantment);
+ this.h[j] = Enchantment.enchantments.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error
this.i[j] = weightedrandomenchant.level;
}
}
}
@ -72,7 +81,7 @@
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3];
+ for (j = 0; j < 3; ++j) {
+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[j]) : null;
+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(Enchantment.enchantments.getId(this.h[j])))) : null;
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null;
+ }
+
@ -93,7 +102,7 @@
+ EnchantmentOffer offer = event.getOffers()[j];
+ if (offer != null) {
+ this.costs[j] = offer.getCost();
+ this.h[j] = offer.getEnchantment().getId();
+ this.h[j] = Enchantment.enchantments.a(Enchantment.fromId(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey())));
+ this.i[j] = offer.getEnchantmentLevel();
+ } else {
+ this.costs[j] = 0;
@ -106,7 +115,7 @@
this.b();
}
} else {
@@ -176,25 +238,52 @@
@@ -176,25 +240,53 @@
if (!this.world.isClientSide) {
List list = this.a(itemstack, i, this.costs[i]);
@ -119,7 +128,7 @@
+ 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(Enchantment.getId(instance.enchantment)), instance.level);
+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(instance.enchantment))), instance.level);
+ }
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+
@ -141,8 +150,9 @@
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
+ try {
+ if (flag) {
+ int enchantId = entry.getKey().getId();
+ if (Enchantment.c(enchantId) == null) {
+ NamespacedKey enchantId = entry.getKey().getKey();
+ Enchantment nms = Enchantment.fromId(CraftNamespacedKey.toMinecraft(enchantId));
+ if (nms == null) {
+ continue;
+ }
@ -150,7 +160,7 @@
- ItemEnchantedBook.a(itemstack, weightedrandomenchant);
- } else {
- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(Enchantment.c(enchantId), entry.getValue());
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue());
+ ItemEnchantedBook.a(itemstack, weightedrandomenchant);
+ } else {
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
@ -167,7 +177,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.subtract(j);
if (itemstack1.isEmpty()) {
@@ -233,12 +322,18 @@
@@ -233,12 +325,18 @@
public void b(EntityHuman entityhuman) {
super.b(entityhuman);
@ -186,7 +196,7 @@
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
@@ -291,4 +386,17 @@
@@ -291,4 +389,17 @@
return itemstack;
}

View File

@ -1,19 +1,19 @@
--- a/net/minecraft/server/ContainerFurnace.java
+++ b/net/minecraft/server/ContainerFurnace.java
@@ -1,5 +1,10 @@
@@ -1,6 +1,10 @@
package net.minecraft.server;
import java.util.Iterator;
+// 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;
@@ -8,11 +13,28 @@
private int h;
public class ContainerFurnace extends ContainerRecipeBook {
@@ -11,12 +15,29 @@
private int i;
private int j;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
@ -33,6 +33,7 @@
+
public ContainerFurnace(PlayerInventory playerinventory, IInventory iinventory) {
this.furnace = iinventory;
this.f = playerinventory.player.world;
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)));
@ -40,7 +41,7 @@
int i;
@@ -63,6 +85,7 @@
@@ -95,6 +116,7 @@
}
public boolean canUse(EntityHuman entityhuman) {

View File

@ -8,10 +8,10 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerPlayer extends Container {
public class ContainerPlayer extends ContainerRecipeBook {
private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
@@ -7,10 +12,20 @@
private static final String[] h = new String[] { "item/empty_armor_slot_boots", "item/empty_armor_slot_leggings", "item/empty_armor_slot_chestplate", "item/empty_armor_slot_helmet"};
@@ -8,10 +13,20 @@
public InventoryCraftResult resultInventory = new InventoryCraftResult();
public boolean g;
private final EntityHuman owner;
@ -32,27 +32,9 @@
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28)));
int i;
@@ -23,7 +38,7 @@
}
for (i = 0; i < 4; ++i) {
- final EnumItemSlot enumitemslot = ContainerPlayer.h[i];
+ final EnumItemSlot enumitemslot1 = ContainerPlayer.h[i];
this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) {
public int getMaxStackSize() {
@@ -31,7 +46,7 @@
}
public boolean isAllowed(ItemStack itemstack) {
- return enumitemslot == EntityInsentient.d(itemstack);
+ return enumitemslot1 == EntityInsentient.d(itemstack); // CraftBukkit - decompile error
}
public boolean isAllowed(EntityHuman entityhuman) {
@@ -141,4 +156,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
@@ -167,4 +182,17 @@
public int g() {
return this.craftInventory.n();
}
+
+ // CraftBukkit start

View File

@ -8,7 +8,7 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerWorkbench extends Container {
public class ContainerWorkbench extends ContainerRecipeBook {
- public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3);
- public InventoryCraftResult resultInventory = new InventoryCraftResult();
@ -32,7 +32,7 @@
this.g = world;
this.h = blockposition;
this.i = playerinventory.player;
@@ -47,6 +62,7 @@
@@ -60,6 +75,7 @@
}
public boolean canUse(EntityHuman entityhuman) {
@ -40,9 +40,9 @@
return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D;
}
@@ -100,4 +116,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
@@ -125,4 +141,17 @@
public int g() {
return this.craftInventory.n();
}
+
+ // CraftBukkit start

View File

@ -1,57 +1,32 @@
--- a/net/minecraft/server/CraftingManager.java
+++ b/net/minecraft/server/CraftingManager.java
@@ -34,6 +34,7 @@
public static boolean init() {
try {
+ CraftingManager.c = 0; // Reset recipe ID count
a("armordye", new RecipeArmorDye());
a("bookcloning", new RecipeBookClone());
a("mapcloning", new RecipeMapClone());
@@ -147,6 +148,7 @@
if (CraftingManager.recipes.d(minecraftkey)) {
throw new IllegalStateException("Duplicate recipe ignored with ID " + minecraftkey);
} else {
+ irecipe.setKey(minecraftkey); // CraftBukkit
CraftingManager.recipes.a(CraftingManager.c++, minecraftkey, irecipe);
}
}
@@ -158,12 +160,14 @@
@@ -96,12 +96,14 @@
do {
if (!iterator.hasNext()) {
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
+ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
return ItemStack.a;
}
irecipe = (IRecipe) iterator.next();
} while (!irecipe.a(inventorycrafting, world));
} while (!irecipe.a(iinventory, world));
+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit
return irecipe.craftItem(inventorycrafting);
+ iinventory.setCurrentRecipe(irecipe); // CraftBukkit
return irecipe.craftItem(iinventory);
}
@@ -175,12 +179,14 @@
@@ -113,12 +115,14 @@
do {
if (!iterator.hasNext()) {
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
+ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
return null;
}
irecipe = (IRecipe) iterator.next();
} while (!irecipe.a(inventorycrafting, world));
} while (!irecipe.a(iinventory, world));
+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit
+ iinventory.setCurrentRecipe(irecipe); // CraftBukkit
return irecipe;
}
@@ -210,7 +216,7 @@
}
public static int a(IRecipe irecipe) {
- return CraftingManager.recipes.a((Object) irecipe);
+ return CraftingManager.recipes.a(irecipe); // CraftBukkit - decompile error
}
@Nullable

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/server/CrashReport.java
+++ b/net/minecraft/server/CrashReport.java
@@ -125,6 +125,7 @@
return this.a();
}
@@ -63,6 +63,7 @@
return String.format("%d total; %s", new Object[] { Integer.valueOf(list.size()), list.stream().collect(Collectors.joining(" "))});
});
+ this.d.a("CraftBukkit Information", (CrashReportCallable) new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
}

View File

@ -1,19 +1,11 @@
--- a/net/minecraft/server/CustomFunction.java
+++ b/net/minecraft/server/CustomFunction.java
@@ -122,7 +122,15 @@
}
@@ -45,7 +45,7 @@
}
public void a(CustomFunctionData customfunctiondata, ICommandListener icommandlistener, ArrayDeque<CustomFunctionData.a> arraydeque, int i) {
- customfunctiondata.a().a(icommandlistener, this.a);
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender;
+ if (icommandlistener instanceof CustomFunctionData.CustomFunctionListener) {
+ sender = ((CustomFunctionData.CustomFunctionListener) icommandlistener).sender;
+ } else {
+ sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener);
+ }
+ CommandBlockListenerAbstract.executeSafely(icommandlistener, sender, this.a);
+ // CraftBukkit end
}
try {
- ParseResults parseresults = customfunctiondata.a().getCommandDispatcher().a().parse(s, customfunctiondata.f());
+ ParseResults parseresults = customfunctiondata.d().parse(s, customfunctiondata.f()); // CraftBukkit
public String toString() {
if (parseresults.getReader().canRead()) {
if (parseresults.getExceptions().size() == 1) {

View File

@ -1,45 +1,38 @@
--- a/net/minecraft/server/CustomFunctionData.java
+++ b/net/minecraft/server/CustomFunctionData.java
@@ -23,7 +23,14 @@
private CustomFunction f;
private final ArrayDeque<CustomFunctionData.a> g = new ArrayDeque();
private boolean h = false;
- private final ICommandListener i = new ICommandListener() {
+ // CraftBukkit start
+ private final ICommandListener i = new CustomFunctionListener();
+
+ public class CustomFunctionListener implements ICommandListener {
+
+ protected org.bukkit.command.CommandSender sender = new org.bukkit.craftbukkit.command.CraftFunctionCommandSender(this);
+ // CraftBukkit end
+
public String getName() {
return CustomFunctionData.this.e;
}
@@ -33,7 +40,7 @@
}
@@ -32,14 +32,16 @@
private final Map<MinecraftKey, CustomFunction> g = Maps.newHashMap();
private final ArrayDeque<CustomFunctionData.a> h = new ArrayDeque();
private boolean i;
- private final Tags<CustomFunction> j = new Tags((minecraftkey) -> {
+ private final Tags<CustomFunction> j = new Tags<>((minecraftkey) -> { // CraftBukkit - decompile error
return this.a(minecraftkey) != null;
}, this::a, "tags/functions", true, "function");
private final List<CustomFunction> k = Lists.newArrayList();
private boolean l;
+ private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher; // CraftBukkit
public World getWorld() {
- return CustomFunctionData.this.c.worldServer[0];
+ return CustomFunctionData.this.c.worlds.get(0); // CraftBukkit
}
public MinecraftServer C_() {
@@ -57,7 +64,7 @@
public CustomFunctionData(MinecraftServer minecraftserver) {
this.f = minecraftserver;
+ this.dispatcher = this.f.getCommandDispatcher().a(); // CraftBukkit
}
public int c() {
- return this.c.worldServer[0].getGameRules().c("maxCommandChainLength");
+ return this.c.worlds.get(0).getGameRules().c("maxCommandChainLength"); // CraftBukkit
@Nullable
@@ -60,7 +62,7 @@
}
public Map<MinecraftKey, CustomFunction> d() {
@@ -65,7 +72,7 @@
public com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> d() {
- return this.f.getCommandDispatcher().a();
+ return dispatcher; // CraftBukkit
}
public void e() {
- String s = this.c.worldServer[0].getGameRules().get("gameLoopFunction");
+ String s = this.c.worlds.get(0).getGameRules().get("gameLoopFunction"); // CraftBukkit
if (!s.equals(this.e)) {
this.e = s;
public void X_() {
@@ -164,7 +166,7 @@
arraylist.add(CompletableFuture.supplyAsync(() -> {
return a(iresourcemanager, minecraftkey);
}, Resource.a).thenApplyAsync((list) -> {
- return CustomFunction.a(minecraftkey, this, list);
+ return CustomFunction.a(minecraftkey1, this, list); // CraftBukkit - decompile error
}).handle((customfunction, throwable) -> {
return this.a(customfunction, throwable, minecraftkey);
}));

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