3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00

Update to Minecraft 1.14-pre5

Dieser Commit ist enthalten in:
md_5 2019-04-23 12:00:00 +10:00
Ursprung a46fdbc62c
Commit a2d787f6eb
560 geänderte Dateien mit 10642 neuen und 10867 gelöschten Zeilen

Datei anzeigen

@ -8,7 +8,7 @@
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 @@
@@ -210,7 +211,7 @@
}
public Advancement b(MinecraftKey minecraftkey) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -158,7 +158,11 @@
@@ -160,7 +160,11 @@
Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey());
if (advancement == null) {
@ -13,7 +13,7 @@
} else {
this.a(advancement, (AdvancementProgress) entry.getValue());
}
@@ -227,6 +231,7 @@
@@ -275,6 +279,7 @@
this.i.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {

Datei anzeigen

@ -18,7 +18,7 @@
if (t0 instanceof Integer) {
suggestionsbuilder.suggest((Integer) t0);
@@ -488,7 +488,7 @@
@@ -486,7 +486,7 @@
Optional<T> optional = iblockstate.b(s);
if (optional.isPresent()) {
@ -27,7 +27,7 @@
this.k.put(iblockstate, optional.get());
} else {
this.i.setCursor(i);
@@ -526,7 +526,7 @@
@@ -520,7 +520,7 @@
private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.a());
stringbuilder.append('=');

Datei anzeigen

@ -12,8 +12,8 @@
+ // CraftBukkit end
boolean flag = false;
ArgumentParserSelector argumentparserselector = new ArgumentParserSelector(stringreader);
- EntitySelector entityselector = argumentparserselector.s();
+ EntitySelector entityselector = argumentparserselector.s(overridePermissions); // CraftBukkit
- EntitySelector entityselector = argumentparserselector.parse();
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
if (entityselector.a() > 1 && this.h) {
if (this.i) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ArgumentParserSelector.java
+++ b/net/minecraft/server/ArgumentParserSelector.java
@@ -126,7 +126,7 @@
@@ -127,7 +127,7 @@
axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x);
}
@ -9,38 +9,38 @@
if (this.s == null && this.t == null && this.u == null) {
function = (vec3d) -> {
@@ -187,8 +187,10 @@
@@ -188,8 +188,10 @@
};
}
- protected void b() throws CommandSyntaxException {
- this.T = true;
- protected void parseSelector() throws CommandSyntaxException {
- this.checkPermissions = true;
+ // CraftBukkit start
+ protected void b(boolean overridePermissions) throws CommandSyntaxException {
+ this.T = !overridePermissions;
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
+ this.checkPermissions = !overridePermissions;
+ // CraftBukkit end
this.G = this::d;
if (!this.l.canRead()) {
throw ArgumentParserSelector.d.createWithContext(this.l);
@@ -431,6 +433,12 @@
@@ -443,6 +445,12 @@
}
public EntitySelector s() throws CommandSyntaxException {
public EntitySelector parse() throws CommandSyntaxException {
+ // CraftBukkit start
+ return s(false);
+ return parse(false);
+ }
+
+ public EntitySelector s(boolean overridePermissions) throws CommandSyntaxException {
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
+ // CraftBukkit end
this.E = this.l.getCursor();
this.G = this::b;
if (this.l.canRead() && this.l.peek() == '@') {
@@ -439,7 +447,7 @@
@@ -451,7 +459,7 @@
}
this.l.skip();
- this.b();
+ this.b(overridePermissions); // CraftBukkit
- this.parseSelector();
+ this.parseSelector(overridePermissions); // CraftBukkit
} else {
this.c();
}

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/AttributeRanged.java
+++ b/net/minecraft/server/AttributeRanged.java
@@ -31,6 +31,8 @@
}
@@ -32,6 +32,8 @@
@Override
public double a(double d0) {
+ if (d0 != d0) return getDefault(); // CraftBukkit
+

Datei anzeigen

@ -0,0 +1,68 @@
--- a/net/minecraft/server/BehaviorFarm.java
+++ b/net/minecraft/server/BehaviorFarm.java
@@ -31,7 +31,7 @@
} else if (entityvillager.getVillagerData().getProfession() != VillagerProfession.FARMER) {
return false;
} else {
- Set<BlockPosition> set = (Set) ((List) entityvillager.getBehaviorController().c(MemoryModuleType.SECONDARY_JOB_SITE).get()).stream().map(GlobalPos::b).collect(Collectors.toSet());
+ Set<BlockPosition> set = (Set) (entityvillager.getBehaviorController().c(MemoryModuleType.SECONDARY_JOB_SITE).get()).stream().map(GlobalPos::b).collect(Collectors.toSet()); // CraftBukkit - decompile error
BlockPosition blockposition = new BlockPosition(entityvillager);
Stream stream = ImmutableList.of(blockposition.down(), blockposition.south(), blockposition.north(), blockposition.east(), blockposition.west()).stream();
@@ -61,8 +61,8 @@
protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.d && this.a != null) {
- entityvillager.getBehaviorController().a(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.a)));
- entityvillager.getBehaviorController().a(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1)));
+ entityvillager.getBehaviorController().a(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.a))); // CraftBukkit - decompile error
+ entityvillager.getBehaviorController().a(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); // CraftBukkit - decompile error
}
}
@@ -80,7 +80,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) && this.c) {
- worldserver.b(this.a, true);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, Blocks.AIR.getBlockData()).isCancelled()) {
+ worldserver.b(this.a, true);
+ }
+ // CraftBukkit end
} else if (iblockdata.isAir() && this.b) {
InventorySubcontainer inventorysubcontainer = entityvillager.getInventory();
@@ -89,19 +93,28 @@
boolean flag = false;
if (!itemstack.isEmpty()) {
+ // CraftBukkit start
+ Block planted = null;
if (itemstack.getItem() == Items.WHEAT_SEEDS) {
- worldserver.setTypeAndData(this.a, Blocks.WHEAT.getBlockData(), 3);
+ planted = Blocks.WHEAT;
flag = true;
} else if (itemstack.getItem() == Items.POTATO) {
- worldserver.setTypeAndData(this.a, Blocks.POTATOES.getBlockData(), 3);
+ planted = Blocks.POTATOES;
flag = true;
} else if (itemstack.getItem() == Items.CARROT) {
- worldserver.setTypeAndData(this.a, Blocks.CARROTS.getBlockData(), 3);
+ planted = Blocks.CARROTS;
flag = true;
} else if (itemstack.getItem() == Items.BEETROOT_SEEDS) {
- worldserver.setTypeAndData(this.a, Blocks.BEETROOTS.getBlockData(), 3);
+ planted = Blocks.BEETROOTS;
flag = true;
}
+
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, planted.getBlockData()).isCancelled()) {
+ worldserver.setTypeAndData(this.a, planted.getBlockData(), 3);
+ } else {
+ flag = false;
+ }
+ // CraftBukkit end
}
if (flag) {

Datei anzeigen

@ -0,0 +1,33 @@
--- a/net/minecraft/server/BehaviorInteractDoor.java
+++ b/net/minecraft/server/BehaviorInteractDoor.java
@@ -27,7 +27,7 @@
Set<BlockPosition> set = this.a(worldserver, list, list1);
int j = pathentity.f() - 1;
- this.a(worldserver, list1, set, j);
+ this.a(worldserver, list1, set, j, entityliving); // CraftBukkit - add entity
}
private Set<BlockPosition> a(WorldServer worldserver, List<GlobalPos> list, List<BlockPosition> list1) {
@@ -39,13 +39,20 @@
return (Set) stream.filter(list1::contains).collect(Collectors.toSet());
}
- private void a(WorldServer worldserver, List<BlockPosition> list, Set<BlockPosition> set, int i) {
+ private void a(WorldServer worldserver, List<BlockPosition> list, Set<BlockPosition> set, int i, EntityLiving entityliving) { // CraftBukkit - add entity
set.forEach((blockposition) -> {
int j = list.indexOf(blockposition);
IBlockData iblockdata = worldserver.getType(blockposition);
Block block = iblockdata.getBlock();
if (TagsBlock.WOODEN_DOORS.isTagged(block) && block instanceof BlockDoor) {
+ // CraftBukkit start - entities opening doors
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition));
+ entityliving.world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CaftBukkit end
((BlockDoor) block).setDoor(worldserver, blockposition, j >= i);
}

Datei anzeigen

@ -0,0 +1,31 @@
--- a/net/minecraft/server/BehaviorMakeLove.java
+++ b/net/minecraft/server/BehaviorMakeLove.java
@@ -100,6 +100,11 @@
private Optional<EntityVillager> a(EntityVillager entityvillager, EntityVillager entityvillager1) {
EntityVillager entityvillager2 = entityvillager.createChild(entityvillager1);
+ // CraftBukkit start - call EntityBreedEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
+ return Optional.empty();
+ }
+ // CraftBukkit end
if (entityvillager2 == null) {
return Optional.empty();
@@ -108,7 +113,7 @@
entityvillager1.setAgeRaw(6000);
entityvillager2.setAgeRaw(-24000);
entityvillager2.setPositionRotation(entityvillager.locX, entityvillager.locY, entityvillager.locZ, 0.0F, 0.0F);
- entityvillager.world.addEntity(entityvillager2);
+ entityvillager.world.addEntity(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
entityvillager.world.broadcastEntityEffect(entityvillager2, (byte) 12);
return Optional.of(entityvillager2);
}
@@ -117,6 +122,6 @@
private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
GlobalPos globalpos = GlobalPos.a(worldserver.getWorldProvider().getDimensionManager(), blockposition);
- entityvillager.getBehaviorController().a(MemoryModuleType.HOME, (Object) globalpos);
+ entityvillager.getBehaviorController().a(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error
}
}

Datei anzeigen

@ -1,19 +1,19 @@
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
@@ -405,7 +405,8 @@
int j = this.getDropCount(iblockdata, i, world, blockposition, world.random);
@@ -427,7 +427,8 @@
}
for (int k = 0; k < j; ++k) {
- if (f >= 1.0F || world.random.nextFloat() <= f) {
+ // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions
+ if (f >= 1.0F || world.random.nextFloat() < f) {
Item item = this.getDropType(iblockdata, world, blockposition, i).getItem();
public static List<ItemStack> getDrops(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, @Nullable TileEntity tileentity, Entity entity, ItemStack itemstack) {
- LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).a(worldserver.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, itemstack).set(LootContextParameters.THIS_ENTITY, entity).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
+ // CraftBukkit - make entity optional
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).a(worldserver.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, itemstack).setOptional(LootContextParameters.THIS_ENTITY, entity).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
if (item != Items.AIR) {
@@ -426,7 +427,13 @@
return iblockdata.a(loottableinfo_builder);
}
@@ -481,7 +482,13 @@
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
entityitem.n();
entityitem.defaultPickupDelay();
- world.addEntity(entityitem);
+ // CraftBukkit start
+ if (world.captureDrops != null) {
@ -25,19 +25,16 @@
}
}
@@ -1394,8 +1401,14 @@
@@ -678,6 +685,12 @@
return block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL;
}
+ // CraftBukkit start
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
+ return 0;
+ }
+ // CraftBukkit end
+
private static void a(MinecraftKey minecraftkey, Block block) {
- IRegistry.BLOCK.a(minecraftkey, (Object) block);
+ IRegistry.BLOCK.a(minecraftkey, block); // CraftBukkit - decompile error
}
public static enum EnumRandomOffset {
private static void a(String s, Block block) {
NONE, XZ, XYZ;

Datei anzeigen

@ -1,19 +0,0 @@
--- a/net/minecraft/server/BlockBeacon.java
+++ b/net/minecraft/server/BlockBeacon.java
@@ -49,7 +49,7 @@
}
public static void a(World world, BlockPosition blockposition) {
- HttpUtilities.a.submit(() -> {
+ // HttpUtilities.a.submit(() -> { // CraftBukkit - dangerously threaded
Chunk chunk = world.getChunkAtWorldCoords(blockposition);
for (int i = blockposition.getY() - 1; i >= 0; --i) {
@@ -74,6 +74,6 @@
}
}
- });
+ // }); // CraftBukkit
}
}

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockBed.java
+++ b/net/minecraft/server/BlockBed.java
@@ -32,7 +32,8 @@
@@ -41,20 +41,37 @@
}
}
@ -8,18 +8,24 @@
+ // CraftBukkit - moved world and biome check into EntityHuman
+ if (true || world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) {
if ((Boolean) iblockdata.get(BlockBed.OCCUPIED)) {
EntityHuman entityhuman1 = this.a(world, blockposition);
@@ -59,10 +60,22 @@
} else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.TOO_FAR_AWAY) {
entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.too_far_away", new Object[0])), true);
}
+ // CraftBukkit start - handling bed explosion from below here
+ else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) {
+ this.explodeBed(iblockdata, world, blockposition);
+ }
entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.occupied", new Object[0])), true);
return true;
} else {
+ // CraftBukkit start
+ IBlockData finaliblockdata = iblockdata;
+ BlockPosition finalblockposition = blockposition;
+ // CraftBukkit end
entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> {
if (entityhuman_enumbedresult != null) {
entityhuman.a(entityhuman_enumbedresult.a(), true);
}
+ // CraftBukkit start - handling bed explosion from below here
+ else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) {
+ this.explodeBed(finaliblockdata, world, finalblockposition);
+ }
+ // CraftBukkit end
});
return true;
}
+ // CraftBukkit start - moved bed explosion into separate method
@ -30,16 +36,16 @@
+ }
+
+ private boolean explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) {
world.setAir(blockposition);
world.a(blockposition, false);
BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite());
@@ -72,8 +85,7 @@
@@ -64,8 +81,7 @@
world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, true);
world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY);
return true;
- }
- }
+ // CraftBukkit end
}
@Nullable
@Override

Datei anzeigen

@ -11,8 +11,8 @@
+
public abstract class BlockButtonAbstract extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -72,6 +77,19 @@
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -71,6 +76,19 @@
if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) {
return true;
} else {
@ -31,10 +31,10 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, true), 3);
this.a(entityhuman, world, blockposition, true);
this.c(iblockdata, world, blockposition);
@@ -113,6 +131,16 @@
if (this.E) {
this.b(iblockdata, world, blockposition);
this.e(iblockdata, world, blockposition);
@@ -117,6 +135,16 @@
if (this.D) {
this.d(iblockdata, world, blockposition);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@ -47,9 +47,9 @@
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3);
this.c(iblockdata, world, blockposition);
this.e(iblockdata, world, blockposition);
this.a((EntityHuman) null, world, blockposition, false);
@@ -132,7 +160,44 @@
@@ -137,7 +165,44 @@
boolean flag = !list.isEmpty();
boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED);
@ -92,5 +92,5 @@
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3);
this.c(iblockdata, world, blockposition);
this.e(iblockdata, world, blockposition);
this.a((EntityHuman) null, world, blockposition, flag);

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockCactus extends Block {
public static final BlockStateInteger AGE = BlockProperties.X;
@@ -31,7 +33,7 @@
public static final BlockStateInteger AGE = BlockProperties.ad;
@@ -32,7 +34,7 @@
int j = (Integer) iblockdata.get(BlockCactus.AGE);
if (j == 15) {
@ -18,13 +18,13 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0);
world.setTypeAndData(blockposition, iblockdata1, 4);
@@ -92,7 +94,9 @@
}
@@ -95,7 +97,9 @@
@Override
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 TextureType c() {
@Override

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockCake.java
+++ b/net/minecraft/server/BlockCake.java
@@ -33,7 +33,18 @@
@@ -31,7 +31,18 @@
return false;
} else {
entityhuman.a(StatisticList.EAT_CAKE_SLICE);

Datei anzeigen

@ -7,7 +7,7 @@
+
public class BlockCauldron extends Block {
public static final BlockStateInteger LEVEL = BlockProperties.af;
public static final BlockStateInteger LEVEL = BlockProperties.al;
@@ -32,8 +34,13 @@
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
@ -23,7 +23,7 @@
}
}
@@ -49,18 +56,27 @@
@@ -50,18 +57,27 @@
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
@ -52,7 +52,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -71,7 +87,8 @@
@@ -72,7 +88,8 @@
}
entityhuman.a(StatisticList.USE_CAULDRON);
@ -62,7 +62,7 @@
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -81,6 +98,10 @@
@@ -82,6 +99,10 @@
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
@ -73,7 +73,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -95,12 +116,17 @@
@@ -96,12 +117,17 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
@ -92,7 +92,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -111,7 +137,8 @@
@@ -112,7 +138,8 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
@ -102,22 +102,22 @@
}
return true;
@@ -120,8 +147,13 @@
ItemArmorColorable itemarmorcolorable = (ItemArmorColorable) item;
@@ -121,8 +148,13 @@
IDyeable idyeable = (IDyeable) item;
if (itemarmorcolorable.e(itemstack) && !world.isClientSide) {
if (idyeable.a(itemstack) && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return true;
+ }
itemarmorcolorable.g(itemstack);
idyeable.c(itemstack);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
entityhuman.a(StatisticList.CLEAN_ARMOR);
return true;
}
@@ -129,13 +161,18 @@
@@ -130,13 +162,18 @@
if (i > 0 && item instanceof ItemBanner) {
if (TileEntityBanner.a(itemstack) > 0 && !world.isClientSide) {
@ -137,7 +137,7 @@
}
if (itemstack.isEmpty()) {
@@ -172,9 +209,25 @@
@@ -173,9 +210,25 @@
}
}
@ -163,8 +163,8 @@
+ // CraftBukkit end
}
public void c(World world, BlockPosition blockposition) {
@@ -185,7 +238,7 @@
@Override
@@ -187,7 +240,7 @@
IBlockData iblockdata = world.getType(blockposition);
if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) {

Datei anzeigen

@ -8,11 +8,11 @@
+
public class BlockChorusFlower extends Block {
public static final BlockStateInteger AGE = BlockProperties.V;
@@ -61,8 +63,12 @@
public static final BlockStateInteger AGE = BlockProperties.ab;
@@ -58,8 +60,12 @@
}
if (flag && a((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
if (flag && b((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
@ -24,10 +24,10 @@
} else if (i < 4) {
j = random.nextInt(4);
if (flag1) {
@@ -76,18 +82,30 @@
@@ -73,18 +79,30 @@
BlockPosition blockposition2 = blockposition.shift(enumdirection);
if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a((IWorldReader) world, blockposition2, enumdirection.opposite())) {
if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && b((IWorldReader) world, blockposition2, enumdirection.opposite())) {
- this.b(world, blockposition2, i + 1);
- flag2 = true;
+ // CraftBukkit start - add event

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.T;
@@ -21,7 +23,7 @@
public static final BlockStateInteger AGE = BlockProperties.Z;
@@ -22,7 +24,7 @@
int i = (Integer) iblockdata.get(BlockCocoa.AGE);
if (i < 2) {
@ -18,12 +18,12 @@
}
}
@@ -106,7 +108,7 @@
}
@@ -92,7 +94,7 @@
@Override
public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); // CraftBukkit
}
public TextureType c() {
@Override

Datei anzeigen

@ -9,19 +9,19 @@
public class BlockCommand extends BlockTileEntity {
private static final Logger c = LogManager.getLogger();
@@ -30,6 +32,15 @@
@@ -32,6 +34,15 @@
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
boolean flag = world.isBlockIndirectlyPowered(blockposition);
boolean flag1 = tileentitycommand.d();
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
boolean flag2 = tileentitycommand.d();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = flag1 ? 15 : 0;
+ int current = flag ? 15 : 0;
+ int old = flag2 ? 15 : 0;
+ int current = flag1 ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ flag = eventRedstone.getNewCurrent() > 0;
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
tileentitycommand.a(flag);
if (!flag1 && !tileentitycommand.e() && tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE) {
tileentitycommand.a(flag1);
if (!flag2 && !tileentitycommand.f() && tileentitycommand.t() != TileEntityCommand.Type.SEQUENCE) {

Datei anzeigen

@ -0,0 +1,55 @@
--- a/net/minecraft/server/BlockComposter.java
+++ b/net/minecraft/server/BlockComposter.java
@@ -4,13 +4,14 @@
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder; // CraftBukkit
public class BlockComposter extends Block implements IInventoryHolder {
public static final BlockStateInteger a = BlockProperties.am;
public static final Object2FloatMap<IMaterial> b = new Object2FloatOpenHashMap();
public static final VoxelShape c = VoxelShapes.b();
- private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> {
+ private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error
for (int i = 0; i < 8; ++i) {
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
}
@@ -220,7 +221,8 @@
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
int i = (Integer) iblockdata.get(BlockComposter.a);
- return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty()));
+ // CraftBukkit - empty generatoraccess, blockposition
+ return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition)));
}
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
@@ -232,6 +234,7 @@
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
super(1);
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
this.a = iblockdata;
this.b = generatoraccess;
this.c = blockposition;
@@ -282,6 +285,7 @@
this.a = iblockdata;
this.b = generatoraccess;
this.c = blockposition;
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
}
@Override
@@ -313,8 +317,9 @@
static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
- public ContainerEmpty() {
+ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit
super(0);
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
}
@Override

Datei anzeigen

@ -11,22 +11,22 @@
public class BlockConcretePowder extends BlockFalling {
private final IBlockData a;
@@ -11,7 +16,7 @@
@@ -12,7 +17,7 @@
@Override
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {
if (x(iblockdata1)) {
if (canHarden(iblockdata1)) {
- world.setTypeAndData(blockposition, this.a, 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit
}
}
@@ -20,7 +25,24 @@
@@ -22,7 +27,24 @@
World world = blockactioncontext.getWorld();
BlockPosition blockposition = blockactioncontext.getClickPosition();
- return !x(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a;
- return !canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a;
+ // CraftBukkit start
+ if (!x(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition)) {
+ if (!canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition)) {
+ return super.getPlacedState(blockactioncontext);
+ }
+
@ -46,9 +46,9 @@
}
private static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) {
@@ -51,6 +73,20 @@
}
@@ -54,6 +76,20 @@
@Override
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

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockCoral.java
+++ b/net/minecraft/server/BlockCoral.java
@@ -14,6 +14,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -15,6 +15,11 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!this.a((IBlockAccess) world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.a.getBlockData()).isCancelled()) {

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockCoralFan.java
+++ b/net/minecraft/server/BlockCoralFan.java
@@ -17,6 +17,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -19,6 +19,11 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!b_(iblockdata, world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) {

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockCoralFanWall.java
+++ b/net/minecraft/server/BlockCoralFanWall.java
@@ -17,6 +17,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -19,6 +19,11 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!b_(iblockdata, world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) {

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockCoralPlant.java
+++ b/net/minecraft/server/BlockCoralPlant.java
@@ -18,6 +18,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -20,6 +20,11 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!b_(iblockdata, world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) {

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.W;
@@ -49,7 +51,7 @@
public static final BlockStateInteger AGE = BlockProperties.ac;
@@ -52,7 +54,7 @@
float f = a((Block) this, (IBlockAccess) world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
@ -18,7 +18,7 @@
}
}
}
@@ -64,7 +66,7 @@
@@ -67,7 +69,7 @@
i = j;
}

Datei anzeigen

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

Datei anzeigen

@ -9,7 +9,7 @@
public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
@@ -29,8 +31,18 @@
@@ -28,8 +30,18 @@
boolean flag1 = this.a(world, blockposition, iblockdata);
if (flag && !flag1) {
@ -27,4 +27,4 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, true), 2);
if (!flag1) {
world.getBlockTickList().a(blockposition, this, this.k(iblockdata), TickListPriority.HIGH);
world.getBlockTickList().a(blockposition, this, this.j(iblockdata), TickListPriority.HIGH);

Datei anzeigen

@ -1,23 +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) {
@@ -31,6 +31,11 @@
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!world.isClientSide) {
if (!a((IWorldReader) world, blockposition)) {
if (!b(iblockdata, (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 {
} else if (world.getLightLevel(blockposition.up()) >= 4) {
if (world.getLightLevel(blockposition.up()) >= 9) {
@@ -34,7 +39,7 @@
}
@@ -40,7 +45,7 @@
BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
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
if (world.getType(blockposition1).getBlock() == Blocks.DIRT && c(iblockdata1, (IWorldReader) world, blockposition1)) {
- world.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, world.getType(blockposition1.up()).getBlock() == Blocks.SNOW));
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, world.getType(blockposition1.up()).getBlock() == Blocks.SNOW)); // CraftBukkit
}
}
}

Datei anzeigen

@ -3,7 +3,7 @@
@@ -8,9 +8,10 @@
public static final BlockStateDirection FACING = BlockDirectional.FACING;
public static final BlockStateBoolean TRIGGERED = BlockProperties.w;
public static final BlockStateBoolean TRIGGERED = BlockProperties.A;
- public static final Map<Item, IDispenseBehavior> REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> {
+ public static final Map<Item, IDispenseBehavior> REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem());
@ -12,7 +12,7 @@
public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
BlockDispenser.REGISTRY.put(imaterial.getItem(), idispensebehavior);
@@ -56,6 +57,7 @@
@@ -58,6 +59,7 @@
IDispenseBehavior idispensebehavior = this.a(itemstack);
if (idispensebehavior != IDispenseBehavior.NONE) {

Datei anzeigen

@ -9,11 +9,11 @@
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -163,9 +165,24 @@
}
@@ -171,9 +173,24 @@
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));
@Override
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
- boolean flag1 = 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);
+
@ -30,9 +30,9 @@
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
- if (block != this && flag != (Boolean) iblockdata.get(BlockDoor.POWERED)) {
+ boolean flag = eventRedstone.getNewCurrent() > 0;
- if (block != this && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) {
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
if (flag != (Boolean) iblockdata.get(BlockDoor.OPEN)) {
this.b(world, blockposition, flag);
if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) {
this.b(world, blockposition, flag1);
}

Datei anzeigen

@ -8,8 +8,8 @@
public class BlockDragonEgg extends BlockFalling {
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));
@@ -29,6 +31,18 @@
BlockPosition blockposition1 = blockposition.b(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).isAir()) {
+ // CraftBukkit start

Datei anzeigen

@ -11,7 +11,7 @@
public class BlockDropper extends BlockDispenser {
private static final IDispenseBehavior c = new DispenseBehaviorItem();
@@ -34,8 +39,25 @@
@@ -37,8 +42,25 @@
if (iinventory == null) {
itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack);
} else {

Datei anzeigen

@ -1,22 +1,21 @@
--- a/net/minecraft/server/BlockEnderPortal.java
+++ b/net/minecraft/server/BlockEnderPortal.java
@@ -2,6 +2,8 @@
import java.util.Random;
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockEnderPortal extends BlockTileEntity {
protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
@@ -28,6 +30,10 @@
@@ -21,6 +23,10 @@
@Override
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.getShape(world, blockposition), OperatorBoolean.AND)) {
if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(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.a(DimensionManager.THE_END);
entity.a(world.worldProvider.getDimensionManager() == DimensionManager.THE_END ? DimensionManager.OVERWORLD : DimensionManager.THE_END);
}

Datei anzeigen

@ -1,11 +1,10 @@
--- a/net/minecraft/server/BlockFire.java
+++ b/net/minecraft/server/BlockFire.java
@@ -7,6 +7,16 @@
@@ -7,6 +7,15 @@
import java.util.Map.Entry;
import javax.annotation.Nullable;
+// CraftBukkit start
+
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -16,10 +15,10 @@
+
public class BlockFire extends Block {
public static final BlockStateInteger AGE = BlockProperties.X;
@@ -31,7 +41,20 @@
}
public static final BlockStateInteger AGE = BlockProperties.ad;
@@ -33,7 +42,20 @@
@Override
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
@ -39,43 +38,43 @@
}
@Nullable
@@ -81,7 +104,7 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -82,7 +104,7 @@
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (world.getGameRules().getBoolean("doFireTick")) {
if (!iblockdata.canPlace(world, blockposition)) {
- world.setAir(blockposition);
- world.a(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit - invalid place location
}
Block block = world.getType(blockposition.down()).getBlock();
@@ -89,7 +112,7 @@
@@ -90,7 +112,7 @@
int i = (Integer) iblockdata.get(BlockFire.AGE);
if (!flag && world.isRaining() && this.a(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
- world.setAir(blockposition);
- world.a(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
} else {
int j = Math.min(15, i + random.nextInt(3) / 2);
@@ -102,14 +125,14 @@
world.getBlockTickList().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);
@@ -105,14 +127,14 @@
BlockPosition blockposition1 = blockposition.down();
if (!Block.d(world.getType(blockposition1), world, blockposition1, EnumDirection.UP) || i > 3) {
- world.a(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit
}
return;
}
if (i == 15 && random.nextInt(4) == 0 && !this.k(world.getType(blockposition.down()))) {
- world.setAir(blockposition);
if (i == 15 && random.nextInt(4) == 0 && !this.j(world.getType(blockposition.down()))) {
- world.a(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit
return;
}
}
@@ -117,12 +140,14 @@
boolean flag1 = world.x(blockposition);
@@ -120,12 +142,14 @@
boolean flag1 = world.t(blockposition);
int k = flag1 ? -50 : 0;
- this.a(world, blockposition.east(), 300 + k, random, i);
@ -95,13 +94,13 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
for (int l = -1; l <= 1; ++l) {
@@ -148,7 +173,15 @@
@@ -151,7 +175,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(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, j2), 3);
+ // CraftBukkit start - Call to stop spread of fire
+ if (world.getType(blockposition_mutableblockposition) != Blocks.FIRE) {
+ if (world.getType(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) {
+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition_mutableblockposition, blockposition).isCancelled()) {
+ continue;
+ }
@ -112,13 +111,13 @@
}
}
}
@@ -172,12 +205,24 @@
return this.flameChances.getInt(block);
@@ -175,12 +207,24 @@
return iblockdata.b((IBlockState) BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock());
}
- 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.f(world.getType(blockposition).getBlock());
int k = this.q(world.getType(blockposition));
if (random.nextInt(i) < k) {
IBlockData iblockdata = world.getType(blockposition);
@ -138,24 +137,24 @@
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
int l = Math.min(j + random.nextInt(5) / 4, 15);
@@ -240,7 +285,7 @@
@@ -243,7 +287,7 @@
if (iblockdata1.getBlock() != iblockdata.getBlock()) {
if (world.worldProvider.getDimensionManager() != DimensionManager.OVERWORLD && world.worldProvider.getDimensionManager() != DimensionManager.NETHER || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) {
if (!iblockdata.canPlace(world, blockposition)) {
- world.setAir(blockposition);
- world.a(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
} else {
world.getBlockTickList().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10));
}
@@ -386,4 +431,12 @@
blockfire.a(Blocks.BLACK_CARPET, 60, 20);
blockfire.a(Blocks.DRIED_KELP_BLOCK, 30, 60);
@@ -395,4 +439,12 @@
blockfire.a(Blocks.COMPOSTER, 5, 20);
blockfire.a(Blocks.SWEET_BERRY_BUSH, 60, 100);
}
+
+ // CraftBukkit start
+ private void fireExtinguished(GeneratorAccess world, BlockPosition position) {
+ if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.setAir(position);
+ world.a(position, false);
+ }
+ }
+ // CraftBukkit end

Datei anzeigen

@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockFluids.java
+++ b/net/minecraft/server/BlockFluids.java
@@ -116,14 +116,20 @@
@@ -111,14 +111,20 @@
Fluid fluid = world.getFluid(blockposition);
if (fluid.d()) {
if (fluid.isSource()) {
- world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
@ -14,7 +14,7 @@
return false;
}
if (fluid.getHeight() >= 0.44444445F) {
if (fluid.getHeight(world, blockposition) >= 0.44444445F) {
- world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockGrass.java
+++ b/net/minecraft/server/BlockGrass.java
@@ -58,7 +58,7 @@
@@ -61,7 +61,7 @@
}
if (iblockdata3.canPlace(world, blockposition2)) {

Datei anzeigen

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockIce.java
+++ b/net/minecraft/server/BlockIce.java
@@ -52,6 +52,11 @@
@@ -41,6 +41,11 @@
}
protected void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ 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.isNether()) {
world.setAir(blockposition);
world.a(blockposition, false);
} else {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockJukeBox.java
+++ b/net/minecraft/server/BlockJukeBox.java
@@ -24,7 +24,13 @@
@@ -25,7 +25,13 @@
TileEntity tileentity = generatoraccess.getTileEntity(blockposition);
if (tileentity instanceof TileEntityJukeBox) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockKelp.java
+++ b/net/minecraft/server/BlockKelp.java
@@ -52,7 +52,7 @@
@@ -49,7 +49,7 @@
IBlockData iblockdata1 = world.getType(blockposition1);
if (iblockdata1.getBlock() == Blocks.WATER && (Integer) iblockdata.get(BlockKelp.a) < 25 && random.nextDouble() < 0.14D) {

Datei anzeigen

@ -1,17 +1,17 @@
--- a/net/minecraft/server/BlockLeaves.java
+++ b/net/minecraft/server/BlockLeaves.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public class BlockLeaves extends Block {
public static final BlockStateInteger DISTANCE = BlockProperties.ab;
@@ -20,6 +22,14 @@
public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
public static final BlockStateInteger DISTANCE = BlockProperties.ah;
@@ -21,6 +23,14 @@
@Override
public void c(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
@ -21,6 +21,6 @@
+ return;
+ }
+ // CraftBukkit end
iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
c(iblockdata, world, blockposition);
world.a(blockposition, false);
}

Datei anzeigen

@ -7,8 +7,8 @@
+
public class BlockLever extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -66,6 +68,20 @@
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -64,6 +66,20 @@
return true;
} else {
@ -27,5 +27,5 @@
+ // CraftBukkit end
+
world.setTypeAndData(blockposition, iblockdata, 3);
float f3 = flag ? 0.6F : 0.5F;
float f = flag ? 0.6F : 0.5F;

Datei anzeigen

@ -1,7 +1,7 @@
--- a/net/minecraft/server/BlockMagma.java
+++ b/net/minecraft/server/BlockMagma.java
@@ -10,7 +10,9 @@
@@ -11,7 +11,9 @@
@Override
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.S;
@@ -55,6 +57,17 @@
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.X;
@@ -61,6 +63,17 @@
flag1 = true;
}

Datei anzeigen

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

Datei anzeigen

@ -1,16 +1,16 @@
--- a/net/minecraft/server/BlockMonsterEggs.java
+++ b/net/minecraft/server/BlockMonsterEggs.java
@@ -4,6 +4,8 @@
@@ -3,6 +3,8 @@
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Random;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
+
public class BlockMonsterEggs extends Block {
private final Block a;
@@ -36,7 +38,7 @@
EntitySilverfish entitysilverfish = new EntitySilverfish(world);
@@ -29,7 +31,7 @@
EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a(world);
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);
- world.addEntity(entitysilverfish);

Datei anzeigen

@ -11,7 +11,7 @@
public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement {
protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D);
@@ -43,7 +47,7 @@
@@ -45,7 +49,7 @@
}
if (world.isEmpty(blockposition2) && iblockdata.canPlace(world, blockposition2)) {
@ -20,14 +20,14 @@
}
}
@@ -66,8 +70,10 @@
@@ -70,8 +74,10 @@
WorldGenerator<WorldGenFeatureEmptyConfiguration> worldgenerator = null;
if (this == Blocks.BROWN_MUSHROOM) {
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenerator = WorldGenerator.U;
worldgenerator = WorldGenerator.HUGE_BROWN_MUSHROOM;
} else if (this == Blocks.RED_MUSHROOM) {
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenerator = WorldGenerator.T;
worldgenerator = WorldGenerator.HUGE_RED_MUSHROOM;
}

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockNetherWart.java
+++ b/net/minecraft/server/BlockNetherWart.java
@@ -25,7 +25,7 @@
@@ -28,7 +28,7 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1);
@ -8,4 +8,4 @@
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
}
super.a(iblockdata, world, blockposition, random);
super.tick(iblockdata, world, blockposition, random);

Datei anzeigen

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockNote.java
+++ b/net/minecraft/server/BlockNote.java
@@ -24,7 +24,7 @@
@@ -27,7 +27,7 @@
if (flag != (Boolean) iblockdata.get(BlockNote.POWERED)) {
if (flag) {
if (flag1 != (Boolean) iblockdata.get(BlockNote.POWERED)) {
if (flag1) {
- this.play(world, blockposition);
+ this.play(world, blockposition, iblockdata); // CraftBukkit
}
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag), 3);
@@ -32,9 +32,14 @@
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag1), 3);
@@ -35,9 +35,14 @@
}
@ -26,7 +26,7 @@
}
}
@@ -45,7 +50,7 @@
@@ -49,7 +54,7 @@
} else {
iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE);
world.setTypeAndData(blockposition, iblockdata, 3);
@ -35,8 +35,8 @@
entityhuman.a(StatisticList.TUNE_NOTEBLOCK);
return true;
}
@@ -53,7 +58,7 @@
@@ -58,7 +63,7 @@
@Override
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
if (!world.isClientSide) {
- this.play(world, blockposition);

Datei anzeigen

@ -8,10 +8,10 @@
+
public class BlockObserver extends BlockDirectional {
public static final BlockStateBoolean b = BlockProperties.t;
@@ -25,8 +27,18 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
public static final BlockStateBoolean b = BlockProperties.w;
@@ -29,8 +31,18 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if ((Boolean) iblockdata.get(BlockObserver.b)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {

Datei anzeigen

@ -1,45 +1,32 @@
--- a/net/minecraft/server/BlockOre.java
+++ b/net/minecraft/server/BlockOre.java
@@ -32,6 +32,7 @@
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
super.dropNaturally(iblockdata, world, blockposition, f, i);
@@ -15,6 +15,7 @@
@Override
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
super.dropNaturally(iblockdata, world, blockposition, itemstack);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 0;
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
int i = this.a(world.random);
@@ -49,9 +50,34 @@
this.dropExperience(world, blockposition, j);
@@ -22,6 +23,21 @@
this.dropExperience(world, blockposition, i);
}
}
+ // */
}
+
+ @Override
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
+ int j = 0;
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
+ int i = this.a(world.random);
+
+ if (this == Blocks.COAL_ORE) {
+ j = MathHelper.nextInt(world.random, 0, 2);
+ } else if (this == Blocks.DIAMOND_ORE) {
+ j = MathHelper.nextInt(world.random, 3, 7);
+ } else if (this == Blocks.EMERALD_ORE) {
+ j = MathHelper.nextInt(world.random, 3, 7);
+ } else if (this == Blocks.LAPIS_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ } else if (this == Blocks.NETHER_QUARTZ_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ if (i > 0) {
+ return i;
+ }
+
+ return j;
+ }
+
+ return 0;
+ // CraftBukkit end
+ }
+
public ItemStack a(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
return new ItemStack(this);
}
}

Datei anzeigen

@ -18,8 +18,8 @@
+
public class BlockPiston extends BlockDirectional {
public static final BlockStateBoolean EXTENDED = BlockProperties.f;
@@ -105,6 +117,18 @@
public static final BlockStateBoolean EXTENDED = BlockProperties.g;
@@ -112,6 +124,18 @@
}
}
@ -38,7 +38,7 @@
world.playBlockAction(blockposition, this, b0, enumdirection.a());
}
@@ -277,6 +301,48 @@
@@ -281,6 +305,48 @@
IBlockData[] aiblockdata = new IBlockData[j];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
Set<BlockPosition> set = Sets.newHashSet(list);

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockPlant.java
+++ b/net/minecraft/server/BlockPlant.java
@@ -13,7 +13,14 @@
}
@@ -14,7 +14,14 @@
@Override
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
@ -15,4 +15,4 @@
+ // CraftBukkit end
}
public boolean canPlace(IBlockData iblockdata, IWorldReader iworldreader, BlockPosition blockposition) {
@Override

Datei anzeigen

@ -12,18 +12,18 @@
+
public class BlockPortal extends Block {
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.z;
@@ -36,7 +42,8 @@
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.D;
@@ -34,7 +40,8 @@
}
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);
if (world.getType(blockposition).a((IBlockAccess) world, blockposition, EntityTypes.ZOMBIE_PIGMAN)) {
- Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false);
+ // CraftBukkit - set spawn reason to 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);
+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
entity.portalCooldown = entity.aQ();
@@ -54,8 +61,10 @@
entity.portalCooldown = entity.aW();
@@ -48,8 +55,10 @@
BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
if (blockportal_shape != null) {
@ -36,18 +36,18 @@
} else {
return false;
}
@@ -92,6 +101,10 @@
@@ -85,6 +94,10 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
+ // 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.e(blockposition);
entity.c(blockposition);
}
@@ -189,6 +202,7 @@
@@ -177,6 +190,7 @@
private BlockPosition position;
private int height;
private int width;
@ -55,7 +55,7 @@
public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = generatoraccess;
@@ -247,6 +261,9 @@
@@ -235,6 +249,9 @@
}
protected int c() {
@ -65,7 +65,7 @@
int i;
label56:
@@ -269,11 +286,21 @@
@@ -257,11 +274,21 @@
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
@ -87,7 +87,7 @@
}
}
}
@@ -283,6 +310,11 @@
@@ -271,6 +298,11 @@
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
break;
@ -99,7 +99,7 @@
}
}
@@ -306,7 +338,27 @@
@@ -294,7 +326,27 @@
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
@ -128,7 +128,7 @@
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
@@ -315,6 +367,7 @@
@@ -303,6 +355,7 @@
}
}

Datei anzeigen

@ -7,8 +7,8 @@
+
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.S;
@@ -101,6 +103,13 @@
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.X;
@@ -102,6 +104,13 @@
boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0);
if (flag1 != flag) {

Datei anzeigen

@ -9,7 +9,7 @@
public abstract class BlockPressurePlateAbstract extends Block {
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D);
@@ -65,6 +67,19 @@
@@ -68,6 +70,19 @@
boolean flag = i > 0;
boolean flag1 = j > 0;

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -61,6 +63,26 @@
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -66,6 +68,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

Datei anzeigen

@ -7,10 +7,10 @@
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockProperties.al;
@@ -12,7 +14,31 @@
}
public static final BlockStateInteger POWER = BlockProperties.as;
@@ -13,7 +15,31 @@
@Override
protected int b(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ // CraftBukkit start

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockPumpkinCarved.java
+++ b/net/minecraft/server/BlockPumpkinCarved.java
@@ -3,6 +3,12 @@
import java.util.Iterator;
@@ -4,6 +4,12 @@
import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
@ -13,20 +13,22 @@
public class BlockPumpkinCarved extends BlockFacingHorizontal {
public static final BlockStateDirection a = BlockFacingHorizontal.FACING;
@@ -38,18 +44,24 @@
ShapeDetectorBlock shapedetectorblock;
int k;
@@ -42,19 +48,28 @@
EntityPlayer entityplayer;
int j;
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
if (shapedetector_shapedetectorcollection != null) {
for (i = 0; i < this.e().b(); ++i) {
ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, i, 0);
for (i = 0; i < this.getSnowmanShape().b(); ++i) {
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);
- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
+ blockList.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a()));
+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit
}
EntitySnowman entitysnowman = new EntitySnowman(world);
EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.a(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);
@ -35,21 +37,26 @@
+ if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
+ return;
+ }
+ for (BlockPosition pos : blockList.getBlocks()) {
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
+ }
+ 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.g().c(); ++i) {
for (int l = 0; l < this.g().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
@@ -74,8 +89,8 @@
for (int k = 0; k < this.getIronGolemShape().b(); ++k) {
ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(i, k, 0);
- world.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2);
- world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a()));
+ blockList.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ // world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); // CraftBukkit
}
}
@@ -79,7 +91,12 @@
@@ -84,7 +99,15 @@
entityirongolem.setPlayerCreated(true);
entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
@ -58,6 +65,9 @@
+ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
+ return;
+ }
+ for (BlockPosition pos : blockList.getBlocks()) {
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
+ }
+ blockList.updateList();
+ // CraftBukkit end
iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();

Datei anzeigen

@ -8,7 +8,7 @@
+
public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity {
public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.aq;
public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.ay;
@@ -64,7 +66,8 @@
@Nullable
@ -19,7 +19,7 @@
return entityitemframe != null && entityitemframe.getDirection() == enumdirection;
});
@@ -117,8 +120,18 @@
@@ -119,8 +122,18 @@
boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c);
if (flag1 && !flag) {

Datei anzeigen

@ -9,8 +9,8 @@
public class BlockRedstoneLamp extends Block {
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
@@ -33,6 +35,11 @@
if (flag) {
@@ -37,6 +39,11 @@
if (flag1) {
world.getBlockTickList().a(blockposition, this, 4);
} else {
+ // CraftBukkit start
@ -21,8 +21,8 @@
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) {
@@ -48,6 +55,11 @@
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!world.isClientSide) {
if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !world.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start

Datei anzeigen

@ -12,15 +12,16 @@
public class BlockRedstoneOre extends Block {
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
@@ -16,23 +21,44 @@
}
@@ -18,25 +23,46 @@
@Override
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);
}
@Override
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
- interact(world.getType(blockposition), world, blockposition);
- super.stepOn(world, blockposition, entity);
@ -44,10 +45,11 @@
+ // CraftBukkit end
}
public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
@Override
public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
- interact(iblockdata, world, blockposition);
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2);
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock);
}
- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) {
@ -62,9 +64,9 @@
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3);
}
@@ -40,6 +66,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -45,6 +71,11 @@
@Override
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) {
@ -74,29 +76,31 @@
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3);
}
@@ -59,12 +90,25 @@
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
super.dropNaturally(iblockdata, world, blockposition, f, i);
@@ -53,14 +84,27 @@
@Override
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
super.dropNaturally(iblockdata, world, blockposition, itemstack);
+ /* CraftBukkit start - Delegated to getExpDrop
if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 1 + world.random.nextInt(5);
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
int i = 1 + world.random.nextInt(5);
this.dropExperience(world, blockposition, j);
this.dropExperience(world, blockposition, i);
}
+ // */
+
+ }
}
+ @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);
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
+ int i = 1 + world.random.nextInt(5);
+
+ return j;
+ return i;
+ }
+ return 0;
+ // CraftBukkit end
}
+ }
+
private static void playEffect(World world, BlockPosition blockposition) {
double d0 = 0.5625D;
Random random = world.random;

Datei anzeigen

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockRedstoneTorch.java
+++ b/net/minecraft/server/BlockRedstoneTorch.java
@@ -6,6 +6,8 @@
import java.util.Map;
import java.util.Random;
import java.util.WeakHashMap;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
public static final BlockStateBoolean LIT = BlockProperties.o;
@@ -65,8 +67,24 @@
public static final BlockStateBoolean LIT = BlockProperties.r;
@@ -70,8 +72,24 @@
list.remove(0);
}
@ -33,8 +33,8 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, 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 @@
world.triggerEffect(1502, blockposition, 0);
@@ -79,6 +97,15 @@
}
}
} else if (!flag && !a(world, blockposition, false)) {

Datei anzeigen

@ -8,20 +8,20 @@
+
public class BlockRedstoneWire extends Block {
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.M;
@@ -216,6 +218,15 @@
j = k;
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.R;
@@ -206,6 +208,15 @@
l = j;
}
+ // CraftBukkit start
+ if (i != j) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, j);
+ if (i != l) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, l);
+ world.getServer().getPluginManager().callEvent(event);
+
+ j = event.getNewCurrent();
+ l = event.getNewCurrent();
+ }
+ // CraftBukkit end
+
if (i != j) {
iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, j);
if (i != l) {
iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, l);
if (world.getType(blockposition) == iblockdata1) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockReed.java
+++ b/net/minecraft/server/BlockReed.java
@@ -29,7 +29,7 @@
@@ -33,7 +33,7 @@
int j = (Integer) iblockdata.get(BlockReed.AGE);
if (j == 15) {

Datei anzeigen

@ -15,16 +15,16 @@
+
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger STAGE = BlockProperties.am;
public static final BlockStateInteger STAGE = BlockProperties.at;
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(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);
@@ -23,7 +33,30 @@
public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
super.tick(iblockdata, world, blockposition, random);
if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
+ // CraftBukkit start
+ world.captureTreeGeneration = true;

Datei anzeigen

@ -1,54 +0,0 @@
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
@@ -81,7 +81,31 @@
super.a(world, blockposition, iblockdata, entityhuman);
}
- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {}
+ // CraftBukkit start - override to prevent duplication when dropping
+ @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 (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) {
+ ItemStack itemstack = new ItemStack(this);
+
+ itemstack.getOrCreateTag().set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).g(new NBTTagCompound()));
+ if (tileentityshulkerbox.hasCustomName()) {
+ itemstack.a(tileentityshulkerbox.getCustomName());
+ tileentityshulkerbox.setCustomName((IChatBaseComponent) null);
+ }
+
+ a(world, blockposition, itemstack);
+ }
+ }
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+ }
+ }
+ // CraftBukkit end
public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
if (itemstack.hasName()) {
@@ -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 (!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
super.remove(iblockdata, world, blockposition, iblockdata1, flag);
}

Datei anzeigen

@ -1,45 +0,0 @@
--- 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()) {

Datei anzeigen

@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockSnow.java
+++ b/net/minecraft/server/BlockSnow.java
@@ -85,6 +85,11 @@
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
@@ -58,6 +58,11 @@
@Override
public void tick(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, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
c(iblockdata, world, blockposition);
world.a(blockposition, false);
}

Datei anzeigen

@ -1,14 +0,0 @@
--- a/net/minecraft/server/BlockSnowBlock.java
+++ b/net/minecraft/server/BlockSnowBlock.java
@@ -18,6 +18,11 @@
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, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
}

Datei anzeigen

@ -11,15 +11,15 @@
+
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockProperties.ai;
@@ -51,26 +56,49 @@
public static final BlockStateInteger MOISTURE = BlockProperties.ap;
@@ -53,12 +58,12 @@
if (!a((IWorldReader) world, blockposition) && !world.isRainingAt(blockposition.up())) {
if (i > 0) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
} else if (!a((IBlockAccess) world, blockposition)) {
b(iblockdata, world, blockposition);
fade(iblockdata, world, blockposition);
}
} else if (i < 7) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2);
@ -27,11 +27,12 @@
}
}
}
@@ -66,14 +71,37 @@
@Override
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
+ super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) {
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) {
+ // CraftBukkit start - Interact soil
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
@ -49,14 +50,14 @@
+ return;
+ }
+ // CraftBukkit end
b(world.getType(blockposition), world, blockposition);
fade(world.getType(blockposition), world, blockposition);
}
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
public static void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;

Datei anzeigen

@ -13,7 +13,7 @@
public class BlockSponge extends Block {
@@ -33,6 +39,7 @@
@@ -35,6 +41,7 @@
queue.add(new Tuple<>(blockposition, 0));
int i = 0;
@ -21,7 +21,7 @@
while (!queue.isEmpty()) {
Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll();
@@ -49,20 +56,20 @@
@@ -51,22 +58,24 @@
Material material = iblockdata.getMaterial();
if (fluid.a(TagsFluid.WATER)) {
@ -39,14 +39,19 @@
queue.add(new Tuple<>(blockposition2, j + 1));
}
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
- iblockdata.a(world, blockposition2, 0);
- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+ // CraftBukkit start
+ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
- a(iblockdata, world, blockposition2, tileentity);
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
+ // iblockdata.a(world, blockposition2, 0);
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit
+ // a(iblockdata, world, blockposition2, tileentity);
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
+ // CraftBukkit end
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
@@ -75,6 +82,37 @@
@@ -79,6 +88,39 @@
break;
}
}
@ -74,7 +79,9 @@
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
+ // NOP
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
+ iblockdata.a(world, blockposition2, 0);
+ TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+
+ a(iblockdata, world, blockposition2, tileentity);
+ }
+ }
+ world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag());

Datei anzeigen

@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockStem.java
+++ b/net/minecraft/server/BlockStem.java
@@ -3,6 +3,8 @@
@@ -2,6 +2,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.W;
@@ -33,14 +35,18 @@
public static final BlockStateInteger AGE = BlockProperties.ac;
@@ -35,14 +37,18 @@
if (i < 7) {
iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1);
@ -30,7 +30,7 @@
world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.e().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
}
}
@@ -94,7 +100,7 @@
@@ -66,7 +72,7 @@
int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(world.random, 2, 5));
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i);

Datei anzeigen

@ -0,0 +1,32 @@
--- a/net/minecraft/server/BlockSweetBerryBush.java
+++ b/net/minecraft/server/BlockSweetBerryBush.java
@@ -1,6 +1,10 @@
package net.minecraft.server;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement {
@@ -24,7 +28,7 @@
int i = (Integer) iblockdata.get(BlockSweetBerryBush.a);
if (i < 3 && random.nextInt(5) == 0 && world.getLightLevel(blockposition.up(), 0) >= 9) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); // CraftBukkit
}
}
@@ -38,7 +42,9 @@
double d1 = Math.abs(entity.locZ - entity.J);
if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit
entity.damageEntity(DamageSource.SWEET_BERRY_BUSH, 1.0F);
+ CraftEventFactory.blockDamage = null; // CraftBukkit
}
}

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockTNT.java
+++ b/net/minecraft/server/BlockTNT.java
@@ -90,6 +90,11 @@
@@ -92,6 +92,11 @@
Entity entity1 = entityarrow.getShooter();
if (entityarrow.isBurning()) {
@ -9,6 +9,6 @@
+ return;
+ }
+ // CraftBukkit end
this.a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null);
world.setAir(blockposition);
a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null);
world.a(blockposition, false);
}

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockTallPlant.java
+++ b/net/minecraft/server/BlockTallPlant.java
@@ -48,6 +48,11 @@
}
@@ -54,6 +54,11 @@
@Override
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
@ -10,5 +10,5 @@
+ }
+ // CraftBukkit end
BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF);
boolean flag = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER;
BlockPosition blockposition1 = flag ? blockposition.up() : blockposition.down();
BlockPosition blockposition1 = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER ? blockposition.up() : blockposition.down();
IBlockData iblockdata1 = world.getType(blockposition1);

Datei anzeigen

@ -6,12 +6,12 @@
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class BlockTrapdoor extends BlockFacingHorizontal implements IFluidSource, IFluidContainer {
public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged {
@@ -88,6 +89,19 @@
boolean flag = world.isBlockIndirectlyPowered(blockposition);
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
if (flag != (Boolean) iblockdata.get(BlockTrapdoor.c)) {
if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.c)) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@ -22,9 +22,9 @@
+ if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ flag = eventRedstone.getNewCurrent() > 0;
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ }
+ // CraftBukkit end
if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag) {
iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag);
this.a((EntityHuman) null, world, blockposition, flag);
if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag1) {
iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag1);
this.a((EntityHuman) null, world, blockposition, flag1);

Datei anzeigen

@ -8,8 +8,8 @@
+
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -134,6 +136,40 @@
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -139,6 +141,40 @@
}
}

Datei anzeigen

@ -13,7 +13,7 @@
public class BlockTurtleEgg extends Block {
@@ -33,6 +39,19 @@
@@ -35,6 +41,19 @@
super.stepOn(world, blockposition, entity);
} else {
if (!world.isClientSide && world.random.nextInt(i) == 0) {
@ -33,7 +33,7 @@
this.a(world, blockposition, world.getType(blockposition));
}
@@ -57,9 +76,19 @@
@@ -60,9 +79,19 @@
int i = (Integer) iblockdata.get(BlockTurtleEgg.a);
if (i < 2) {
@ -52,9 +52,9 @@
+ }
+ // CraftBukkit end
world.a((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
world.setAir(blockposition);
world.a(blockposition, false);
if (!world.isClientSide) {
@@ -70,7 +99,7 @@
@@ -73,7 +102,7 @@
entityturtle.setAgeRaw(-24000);
entityturtle.g(blockposition);
entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F);

Datei anzeigen

@ -8,50 +8,50 @@
+
public class BlockVine extends Block {
public static final BlockStateBoolean UP = BlockSprawling.p;
@@ -182,20 +184,24 @@
public static final BlockStateBoolean UP = BlockSprawling.e;
@@ -178,20 +180,24 @@
BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ BlockPosition source = blockposition;
+
if (flag && this.b((IBlockAccess) world, blockposition3, enumdirection1)) {
if (flag && a((IBlockAccess) world, blockposition3, enumdirection1)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2);
} else if (flag1 && this.b((IBlockAccess) world, blockposition4, enumdirection2)) {
} else if (flag1 && a((IBlockAccess) world, blockposition4, enumdirection2)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2);
} else {
EnumDirection enumdirection3 = enumdirection.opposite();
if (flag && world.isEmpty(blockposition3) && this.b((IBlockAccess) world, blockposition.shift(enumdirection1), enumdirection3)) {
if (flag && world.isEmpty(blockposition3) && a((IBlockAccess) world, blockposition.shift(enumdirection1), enumdirection3)) {
- world.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
} else if (flag1 && world.isEmpty(blockposition4) && this.b((IBlockAccess) world, blockposition.shift(enumdirection2), enumdirection3)) {
} else if (flag1 && world.isEmpty(blockposition4) && a((IBlockAccess) world, blockposition.shift(enumdirection2), enumdirection3)) {
- world.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
} else if ((double) world.random.nextFloat() < 0.05D && this.b((IBlockAccess) world, blockposition2.up(), EnumDirection.UP)) {
} else if ((double) world.random.nextFloat() < 0.05D && a((IBlockAccess) world, blockposition2.up(), EnumDirection.UP)) {
- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
}
+ // CraftBukkit end
}
} else if (this.b((IBlockAccess) world, blockposition2, enumdirection)) {
} else if (a((IBlockAccess) world, blockposition2, enumdirection)) {
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2);
@@ -225,7 +231,7 @@
@@ -221,7 +227,7 @@
}
if (this.x(iblockdata3)) {
if (this.canSpread(iblockdata3)) {
- world.setTypeAndData(blockposition1, iblockdata3, 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit
}
return;
@@ -240,7 +246,7 @@
@@ -236,7 +242,7 @@
IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random);
if (iblockdata4 != iblockdata5 && this.x(iblockdata5)) {
if (iblockdata4 != iblockdata5 && this.canSpread(iblockdata5)) {
- world.setTypeAndData(blockposition2, iblockdata5, 2);
+ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit
}

Datei anzeigen

@ -1,11 +1,11 @@
--- a/net/minecraft/server/BlockWaterLily.java
+++ b/net/minecraft/server/BlockWaterLily.java
@@ -10,7 +10,7 @@
@@ -11,7 +11,7 @@
@Override
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.getBlockData()).isCancelled()) { // CraftBukkit
world.setAir(new BlockPosition(blockposition), true);
world.b(new BlockPosition(blockposition), true);
}

Datei anzeigen

@ -11,56 +11,54 @@
+
public class BlockWitherSkull extends BlockSkull {
private static ShapeDetector c;
@@ -23,6 +28,7 @@
@Nullable
@@ -26,6 +31,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;
if (!world.isClientSide) {
Block block = tileentityskull.getBlock().getBlock();
boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL;
@@ -35,12 +41,14 @@
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
@@ -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);
for (int i = 0; i < shapedetector.c(); ++i) {
for (int j = 0; j < shapedetector.b(); ++j) {
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, j, 0);
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
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a()));
+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // 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);
@@ -50,6 +58,15 @@
entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
entitywither.aK = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
entitywither.l();
+ // CraftBukkit start
+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ return;
+ }
+ return;
+ }
+ blockList.updateList();
+ // CraftBukkit end
Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
+ for (BlockPosition pos : blockList.getBlocks()) {
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
+ }
+ 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);
}
while (iterator.hasNext()) {
@@ -58,7 +75,7 @@
CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
}
- world.addEntity(entitywither);
+ // world.addEntity(entitywither); // CraftBukkit - moved up
int k;
- world.addEntity(entitywither);
+ // world.addEntity(entitywither); // CraftBukkit - moved up
for (int k = 0; k < shapedetector.c(); ++k) {
for (int l = 0; l < shapedetector.b(); ++l) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Chunk.java
+++ b/net/minecraft/server/Chunk.java
@@ -21,6 +21,13 @@
@@ -22,6 +22,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -13,74 +13,42 @@
+
public class Chunk implements IChunkAccess {
private static final Logger d = LogManager.getLogger();
@@ -56,6 +63,35 @@
private final AtomicInteger E;
private final ChunkCoordIntPair F;
private static final Logger b = LogManager.getLogger();
@@ -91,8 +98,19 @@
}
}
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
+ public long chunkKey;
+
+ public boolean areNeighborsLoaded(final int radius) {
+ switch (radius) {
+ case 2:
+ return this.neighbors == Integer.MAX_VALUE >> 6;
+ case 1:
+ final int mask =
+ // x z offset x z offset x z offset
+ (0x1 << (1 * 5 + 1 + 12)) | (0x1 << (0 * 5 + 1 + 12)) | (0x1 << (-1 * 5 + 1 + 12)) |
+ (0x1 << (1 * 5 + 0 + 12)) | (0x1 << (0 * 5 + 0 + 12)) | (0x1 << (-1 * 5 + 0 + 12)) |
+ (0x1 << (1 * 5 + -1 + 12)) | (0x1 << (0 * 5 + -1 + 12)) | (0x1 << (-1 * 5 + -1 + 12));
+ return (this.neighbors & mask) == mask;
+ default:
+ throw new UnsupportedOperationException(String.valueOf(radius));
+ }
+ }
+
+ public void setNeighborLoaded(final int x, final int z) {
+ this.neighbors |= 0x1 << (x * 5 + 12 + z);
+ }
+
+ public void setNeighborUnloaded(final int x, final int z) {
+ this.neighbors &= ~(0x1 << (x * 5 + 12 + z));
+ }
+ // CraftBukkit end
+
public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long k) {
this.sections = new ChunkSection[16];
this.g = new boolean[256];
@@ -94,8 +130,16 @@
this.s = ticklist;
this.t = ticklist1;
this.z = k;
+ // CraftBukkit start
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
+ this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ);
+ }
+
+ public org.bukkit.Chunk bukkitChunk;
+ public org.bukkit.Chunk getBukkitChunk() {
+ return bukkitChunk;
}
+ public org.bukkit.Chunk bukkitChunk;
+ public boolean mustSave;
+ private boolean needsDecoration;
+ public boolean mustNotSave;
+ public boolean needsDecoration;
+ // CraftBukkit end
+
public Chunk(World world, ProtoChunk protochunk, int i, int j) {
this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.k(), protochunk.l(), protochunk.m());
public Chunk(World world, ProtoChunk protochunk) {
this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.q(), protochunk.getSections(), (Consumer) null);
Iterator iterator = protochunk.y().iterator();
@@ -134,6 +152,7 @@
@@ -143,6 +187,7 @@
this.x = true;
this.a(ChunkStatus.FULLCHUNK);
this.b(protochunk.r());
this.s = true;
+ this.needsDecoration = true; // CraftBukkit
}
public Set<BlockPosition> t() {
@@ -412,8 +457,15 @@
@Override
@@ -224,9 +243,16 @@
}
}
+ // CraftBukkit start
@Nullable
@Override
public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag) {
+ return this.setType(blockposition, iblockdata, flag, true);
+ }
@ -91,17 +59,17 @@
int i = blockposition.getX() & 15;
int j = blockposition.getY();
int k = blockposition.getZ() & 15;
@@ -473,7 +525,8 @@
@@ -278,7 +304,8 @@
}
}
- 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 && doPlace && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
iblockdata.onPlace(this.world, blockposition, iblockdata1);
iblockdata.onPlace(this.world, blockposition, iblockdata1, flag);
}
@@ -653,7 +706,12 @@
@@ -378,7 +405,12 @@
@Nullable
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@ -114,39 +82,27 @@
+ // CraftBukkit end
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.h.remove(blockposition);
@@ -700,6 +758,13 @@
NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition);
@@ -425,6 +457,13 @@
tileentity1.m();
}
tileentity.z();
this.tileEntities.put(blockposition.h(), tileentity);
+ // CraftBukkit start
+ } else {
+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ()
+ + " (" + getType(blockposition) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ System.out.println("Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
@@ -727,11 +792,53 @@
for (int j = 0; j < i; ++j) {
EntitySlice<Entity> entityslice = aentityslice[j];
@@ -453,6 +492,41 @@
+ // CraftBukkit start
+ List<Entity> toRemove = new LinkedList<>();
this.world.a(entityslice.stream().filter((entity) -> {
+ if (this.needsDecoration && !CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { // Only call for new chunks
+ toRemove.add(entity);
+ return false;
+ }
return !(entity instanceof EntityHuman);
}));
+ entityslice.removeAll(toRemove);
+ // CraftBukkit end
}
}
+ // CraftBukkit start
+ // CraftBukkit start
+ public void loadCallback() {
+ org.bukkit.Server server = this.world.getServer();
+ if (server != null) {
+ /*
@ -157,12 +113,11 @@
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
+
+ if (this.needsDecoration) {
+ BlockSand.instaFall = true;
+ java.util.Random random = new java.util.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());
+ random.setSeed((long) this.loc.x * xRand + (long) this.loc.z * zRand ^ world.getSeed());
+
+ org.bukkit.World world = this.world.getWorld();
+ if (world != null) {
@ -175,40 +130,17 @@
+ this.world.populating = false;
+ }
+ }
+ BlockSand.instaFall = false;
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
+ }
+ }
+ // CraftBukkit end
}
public void removeEntities() {
@@ -748,9 +855,21 @@
int i = aentityslice.length;
for (int j = 0; j < i; ++j) {
- EntitySlice<Entity> entityslice = aentityslice[j];
+ // CraftBukkit start
+ List<Entity> newList = Lists.newArrayList(aentityslice[j]);
+ java.util.Iterator<Entity> iter = newList.iterator();
+ while (iter.hasNext()) {
+ Entity entity = iter.next();
+ }
+ // CraftBukkit end
+
+ // Do not pass along players, as doing so can get them stuck outside of time.
+ // (which for example disables inventory icon updates and prevents block breaking)
+ if (entity instanceof EntityPlayer) {
+ iter.remove();
+ }
+ }
- this.world.b((Collection) entityslice);
+ this.world.b((Collection) newList);
+ // CraftBukkit end
}
public void markDirty() {
this.s = true;
}
@@ -810,7 +929,7 @@
Iterator iterator = this.entitySlices[k].c(oclass).iterator();
@@ -527,7 +601,7 @@
Iterator iterator = this.entitySlices[k].a(oclass).iterator();
while (iterator.hasNext()) {
- T t0 = (Entity) iterator.next();
@ -216,19 +148,30 @@
if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) {
list.add(t0);
@@ -1073,13 +1192,13 @@
}
@@ -601,7 +675,7 @@
if (this.s instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.s).a(this.world.getBlockTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<Block>) this.s).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.world.getType(blockposition1).getBlock();
});
}
@Override
public boolean isNeedsSaving() {
- return this.s || this.q && this.world.getTime() != this.lastSaved;
+ return (this.s || this.q && this.world.getTime() != this.lastSaved) && !this.mustNotSave; // CraftBukkit
}
if (this.t instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.t).a(this.world.getFluidTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<FluidType>) this.t).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.world.getFluid(blockposition1).c();
});
}
public void d(boolean flag) {
@@ -691,7 +765,7 @@
}
if (this.o instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<Block>) this.o).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.getType(blockposition1).getBlock();
});
} else if (this.o instanceof TickListChunk) {
@@ -700,7 +774,7 @@
}
if (this.p instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<FluidType>) this.p).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.getFluid(blockposition1).getType();
});
} else if (this.p instanceof TickListChunk) {

Datei anzeigen

@ -1,26 +0,0 @@
--- a/net/minecraft/server/ChunkMap.java
+++ b/net/minecraft/server/ChunkMap.java
@@ -31,6 +31,23 @@
}
}
+ // CraftBukkit start
+ // 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);
+ }
+ }
+ }
+ // CraftBukkit end
+
return chunk1;
}

Datei anzeigen

@ -1,14 +1,23 @@
--- a/net/minecraft/server/ChunkProviderGenerate.java
+++ b/net/minecraft/server/ChunkProviderGenerate.java
@@ -166,6 +166,11 @@
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}
+ // CraftBukkit start - fix MC-54738
+ if (f5 < -1.8F) {
+ f5 = -1.8F;
+ }
+ // CraftBukkit end
@@ -4,7 +4,7 @@
float f7 = this.o[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
public class ChunkProviderGenerate extends ChunkGeneratorAbstract<GeneratorSettingsOverworld> {
- private static final float[] h = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> {
+ private static final float[] h = (float[]) SystemUtils.a((new float[25]), (afloat) -> { // CraftBukkit - decompile error
for (int i = -2; i <= 2; ++i) {
for (int j = -2; j <= 2; ++j) {
float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F);
@@ -81,6 +81,11 @@
f4 = 1.0F + f4 * 2.0F;
f5 = 1.0F + f5 * 4.0F;
}
+ // CraftBukkit start - fix MC-54738
+ if (f4 < -1.8F) {
+ f4 = -1.8F;
+ }
+ // CraftBukkit end
float f6 = ChunkProviderGenerate.h[k + 2 + (l + 2) * 5] / (f4 + 2.0F);

Datei anzeigen

@ -1,109 +1,78 @@
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
@@ -16,6 +16,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -82,7 +82,7 @@
+// CraftBukkit start
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
+import org.bukkit.event.world.ChunkUnloadEvent;
+// CraftBukkit end
+
public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger();
@@ -34,7 +39,7 @@
this.chunkLoader = ichunkloader;
this.chunkGenerator = chunkgenerator;
this.asyncTaskHandler = iasynctaskhandler;
- this.chunkScheduler = new ChunkTaskScheduler(2, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler);
+ this.chunkScheduler = 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.batchScheduler = new SchedulerBatch<>(this.chunkScheduler);
if (flag1) {
completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag);
- this.serverThreadQueue.c(completablefuture::isDone);
+ this.serverThreadQueue.c((BooleanSupplier) completablefuture::isDone); // CraftBukkit - decompile error
} else {
completablefuture = CompletableFuture.supplyAsync(() -> {
return this.getChunkFutureMainThread(i, j, chunkstatus, flag);
@@ -193,6 +193,17 @@
this.playerChunkMap.close();
}
@@ -112,6 +117,25 @@
}
}
+ // CraftBukkit start
+ public Chunk generateChunk(int x, int z) {
+ try {
+ this.batchScheduler.b();
+ ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z);
+ this.chunkScheduler.forcePolluteCache(pos);
+ ((ChunkRegionLoader) this.chunkLoader).blacklist.add(pos.a());
+ this.batchScheduler.a(pos);
+ CompletableFuture<ProtoChunk> completablefuture = this.batchScheduler.c();
+
+ Chunk chunk = (Chunk) completablefuture.thenApply(this::a).join();
+ ((ChunkRegionLoader) this.chunkLoader).blacklist.remove(pos.a());
+ return chunk;
+ } catch (RuntimeException runtimeexception) {
+ throw this.a(x, z, (Throwable) runtimeexception);
+ }
+ // CraftBukkit start - modelled on below
+ public void purgeUnload() {
+ this.world.getMethodProfiler().enter("purge");
+ this.chunkMapDistance.purgeTickets();
+ this.tickDistanceManager();
+ this.world.getMethodProfiler().exitEnter("unload");
+ this.playerChunkMap.unloadChunks(() -> true);
+ this.world.getMethodProfiler().exit();
+ }
+ // CraftBukkit end
+
public IChunkAccess a(int i, int j, boolean flag) {
Chunk chunk = this.getChunkAt(i, j, true, false);
public void tick(BooleanSupplier booleansupplier) {
this.world.getMethodProfiler().enter("purge");
this.chunkMapDistance.purgeTickets();
@@ -211,14 +222,14 @@
this.lastTickTime = i;
WorldData worlddata = this.world.getWorldData();
boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES;
- boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning");
+ boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning") && !world.getPlayers().isEmpty(); // CraftBukkit
@@ -249,10 +273,12 @@
Chunk chunk = (Chunk) this.chunks.get(olong);
if (!flag) {
this.world.getMethodProfiler().enter("pollingChunks");
int k = this.chunkMapDistance.b();
int l = this.world.getGameRules().c("randomTickSpeed");
BlockPosition blockposition = this.world.getSpawn();
- boolean flag2 = worlddata.getTime() % 400L == 0L;
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
Object2IntMap<EnumCreatureType> object2intmap = this.world.l();
ObjectBidirectionalIterator objectbidirectionaliterator = this.playerChunkMap.f();
@@ -244,8 +255,30 @@
for (int j1 = 0; j1 < i1; ++j1) {
EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1];
if (chunk != null) {
- chunk.removeEntities();
- this.saveChunk(chunk);
- this.chunks.remove(olong);
- this.lastChunk = null;
+ // CraftBukkit start - move unload logic to own method
+ if (!unloadChunk(chunk, true)) {
+ continue;
+ }
+ // CraftBukkit end
+ // CraftBukkit start - Use per-world spawn limits
+ int limit = enumcreaturetype.b();
+ switch (enumcreaturetype) {
+ case MONSTER:
+ limit = world.getWorld().getMonsterSpawnLimit();
+ break;
+ case CREATURE:
+ limit = world.getWorld().getAnimalSpawnLimit();
+ break;
+ case WATER_CREATURE:
+ limit = world.getWorld().getWaterAnimalSpawnLimit();
+ break;
+ case AMBIENT:
+ limit = world.getWorld().getAmbientSpawnLimit();
+ break;
+ }
+
++i;
}
}
@@ -265,6 +291,42 @@
return false;
}
+ if (limit == 0) {
+ continue;
+ }
+ // CraftBukkit end
+
if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) {
- int k1 = enumcreaturetype.b() * k / ChunkProviderServer.b;
+ int k1 = limit * k / ChunkProviderServer.b; // CraftBukkit - use per-world limits
+ // CraftBukkit start
+ public boolean unloadChunk(Chunk chunk, boolean save) {
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk, save);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
+ save = event.isSaveChunk();
+
+ // 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.getChunkAt(chunk.locX + x, chunk.locZ + z, false, false);
+ if (neighbor != null) {
+ neighbor.setNeighborUnloaded(-x, -z);
+ chunk.setNeighborUnloaded(x, z);
+ }
+ }
+ }
+ // Moved from unloadChunks above
+ synchronized (this.chunkLoader) {
+ chunk.removeEntities();
+ if (save) {
+ this.saveChunk(chunk);
+ }
+ this.chunks.remove(chunk.chunkKey);
+ this.lastChunk = null;
+ }
+ return true;
+ }
+ // CraftBukkit end
+
public boolean d() {
return !this.world.savingDisabled;
}
if (object2intmap.getInt(enumcreaturetype) <= k1) {
SpawnerCreature.a(enumcreaturetype, (World) this.world, chunk, blockposition);

Datei anzeigen

@ -1,305 +0,0 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
@@ -29,7 +29,8 @@
private final File c;
private final DataFixer d;
private PersistentStructureLegacy e;
- private boolean f;
+ // private boolean f; // CraftBukkit
+ public final LongSet blacklist = new LongOpenHashSet();
public ChunkRegionLoader(File file, DataFixer datafixer) {
this.c = file;
@@ -38,25 +39,69 @@
@Nullable
private NBTTagCompound a(GeneratorAccess generatoraccess, int i, int j) throws IOException {
- return this.a(generatoraccess.o().getDimensionManager(), generatoraccess.h(), i, j);
+ return this.a(generatoraccess.o().getDimensionManager(), generatoraccess.h(), i, j, generatoraccess); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException {
+ if (cps != null) {
+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread");
+ if (cps.isLoaded(x, z)) {
+ return true;
+ }
+ }
+
+ if (this.chunkExists(x, z)) {
+ NBTTagCompound nbt = RegionFileCache.read(this.c, x, z);
+ if (nbt != null) {
+ NBTTagCompound level = nbt.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated")) {
+ return true;
+ }
+
+ ChunkStatus status = ChunkStatus.a(level.getString("Status"));
+ if (status != null && status.a(ChunkStatus.DECORATED)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean chunkExists(int x, int z) {
+ return RegionFileCache.chunkExists(this.c, x, z);
}
@Nullable
- private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j) throws IOException {
+ private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ // CraftBukkit start
+ if (blacklist.contains(ChunkCoordIntPair.a(i, j))) {
+ return null;
+ }
+ // CraftBukkit end
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(new ChunkCoordIntPair(i, j));
if (nbttagcompound != null) {
return nbttagcompound;
} else {
- DataInputStream datainputstream = RegionFileCache.read(this.c, i, j);
+ NBTTagCompound nbttagcompound1 = RegionFileCache.read(this.c, i, j);
- if (datainputstream == null) {
+ if (nbttagcompound1 == null) {
return null;
} else {
- NBTTagCompound nbttagcompound1 = NBTCompressedStreamTools.a(datainputstream);
-
- datainputstream.close();
int k = nbttagcompound1.hasKeyOfType("DataVersion", 99) ? nbttagcompound1.getInt("DataVersion") : -1;
+ // CraftBukkit start
+ if (k < 1466) {
+ NBTTagCompound level = nbttagcompound1.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkProvider();
+ if (check(cps, i - 1, j) && check(cps, i - 1, j - 1) && check(cps, i, j - 1)) {
+ level.setBoolean("LightPopulated", true);
+ }
+ }
+ }
+ // CraftBukkit end
if (k < 1493) {
nbttagcompound1 = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound1, k, 1493);
@@ -84,13 +129,29 @@
}
+ // CraftBukkit start - Add async variant, provide compatibility
@Nullable
public 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];
+ consumer.accept(chunk);
+ this.loadEntities(nbttagcompound.getCompound("Level"), chunk);
+ return chunk;
+ }
+
+ return null;
+ }
+
+ public Object[] loadChunk(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
+ // CraftBukkit end
NBTTagCompound nbttagcompound = this.a(generatoraccess, i, j);
if (nbttagcompound == null) {
return null;
} else {
+ /*
Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
if (chunk != null) {
@@ -99,6 +160,9 @@
}
return chunk;
+ */
+
+ return this.a(generatoraccess, i, j, nbttagcompound);
}
}
@@ -130,7 +194,7 @@
}
@Nullable
- 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);
@@ -149,10 +213,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", i, j, i, j, chunk.locX, 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 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
}
}
} else {
@@ -167,7 +249,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");
@@ -215,10 +297,15 @@
}
public boolean a() {
+ // CraftBukkit start
+ return this.processSaveQueueEntry(false);
+ }
+
+ private boolean processSaveQueueEntry(boolean logCompletion) {
Iterator<Entry<ChunkCoordIntPair, NBTTagCompound>> iterator = this.b.entrySet().iterator();
if (!iterator.hasNext()) {
- if (this.f) {
+ if (logCompletion) { // CraftBukkit
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
}
@@ -234,10 +321,14 @@
return true;
} else {
try {
- DataOutputStream dataoutputstream = RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z);
+ // CraftBukkit start
+ RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ /*
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
dataoutputstream.close();
+ */
+ // CraftBukkit end
if (this.e != null) {
this.e.a(chunkcoordintpair.a());
}
@@ -264,15 +355,16 @@
public void b() {
try {
- this.f = true;
+ // this.f = true; // CraftBukkit
while (true) {
- if (this.a()) {
+ if (this.processSaveQueueEntry(true)) { // CraftBukkit
continue;
}
+ break; // CraftBukkit - Fix infinite loop when saving chunks
}
} finally {
- this.f = false;
+ // this.f = false; // CraftBukkit
}
}
@@ -301,7 +393,7 @@
if (abiomebase != null) {
for (int k = 0; k < abiomebase.length; ++k) {
- aint[k] = IRegistry.BIOME.a((Object) abiomebase[k]);
+ aint[k] = IRegistry.BIOME.a(abiomebase[k]); // CraftBukkit - decompile error
}
}
@@ -383,7 +475,7 @@
int[] aint = new int[abiomebase.length];
for (int i = 0; i < abiomebase.length; ++i) {
- aint[i] = IRegistry.BIOME.a((Object) abiomebase[i]);
+ aint[i] = IRegistry.BIOME.a(abiomebase[i]); // CraftBukkit - decompile error
}
nbttagcompound.setIntArray("Biomes", aint);
@@ -833,17 +925,29 @@
}
@Nullable
+ // CraftBukkit start
public static Entity a(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag) {
+ return spawnEntity(nbttagcompound, world, d0, d1, d2, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ 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
return a(nbttagcompound, world, (entity) -> {
entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch);
- 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
});
}
@@ -857,8 +961,14 @@
}
}
+ // CraftBukkit start
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, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ if (generatoraccess.addEntity(entity, reason) && entity.isVehicle()) {
+ // CraftBukkit end
Iterator iterator = entity.bP().iterator();
while (iterator.hasNext()) {
@@ -874,7 +984,7 @@
boolean flag = false;
try {
- this.a(dimensionmanager, persistentcollection, chunkcoordintpair.x, chunkcoordintpair.z);
+ this.a(dimensionmanager, persistentcollection, chunkcoordintpair.x, chunkcoordintpair.z, null); // CraftBukkit
while (this.a()) {
flag = true;

Datei anzeigen

@ -1,15 +0,0 @@
--- a/net/minecraft/server/ChunkTaskScheduler.java
+++ b/net/minecraft/server/ChunkTaskScheduler.java
@@ -37,6 +37,12 @@
this.f = iasynctaskhandler;
}
+ // CraftBukkit start
+ public void forcePolluteCache(ChunkCoordIntPair chunkcoordintpair) {
+ this.progressCache.put(chunkcoordintpair.a(), new Scheduler.a(chunkcoordintpair, new ProtoChunk(chunkcoordintpair, ChunkConverter.a), ChunkStatus.EMPTY));
+ }
+ // CraftBukkit end
+
@Nullable
protected Scheduler<ChunkCoordIntPair, ChunkStatus, ProtoChunk>.a a(ChunkCoordIntPair chunkcoordintpair, boolean flag) {
IChunkLoader ichunkloader = this.e;

Datei anzeigen

@ -9,9 +9,9 @@
public abstract class CommandBlockListenerAbstract implements ICommandListener {
@@ -15,6 +16,10 @@
private IChatBaseComponent f;
private String g = "";
private IChatBaseComponent h = new ChatComponentText("@");
private IChatBaseComponent lastOutput;
private String command = "";
private IChatBaseComponent customName = new ChatComponentText("@");
+ // CraftBukkit start
+ @Override
+ public abstract CommandSender getBukkitSender(CommandListenerWrapper wrapper);
@ -20,18 +20,18 @@
public CommandBlockListenerAbstract() {}
@@ -102,14 +107,7 @@
if (minecraftserver != null && minecraftserver.D() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.g)) {
if (minecraftserver != null && minecraftserver.E() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.command)) {
try {
this.f = null;
this.lastOutput = null;
- CommandListenerWrapper commandlistenerwrapper = this.getWrapper().a((commandcontext, flag, i) -> {
- if (flag) {
- ++this.d;
- ++this.successCount;
- }
-
- });
-
- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.g);
+ this.d = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.g); // CraftBukkit
- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.command);
+ this.successCount = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.command); // CraftBukkit
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
@ -44,6 +44,6 @@
+ ichatbasecomponent = new ChatComponentText("@");
+ }
+ // CraftBukkit end
this.h = ichatbasecomponent;
this.customName = ichatbasecomponent;
}

Datei anzeigen

@ -1,32 +0,0 @@
--- a/net/minecraft/server/CommandDebug.java
+++ b/net/minecraft/server/CommandDebug.java
@@ -33,6 +33,14 @@
}
private static int a(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;
@@ -46,6 +54,14 @@
}
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;

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/CommandDispatcher.java
+++ b/net/minecraft/server/CommandDispatcher.java
@@ -22,12 +22,21 @@
@@ -17,12 +17,21 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -23,7 +23,7 @@
CommandAdvancement.a(this.b);
CommandExecute.a(this.b);
CommandBossBar.a(this.b);
@@ -95,8 +104,13 @@
@@ -93,14 +102,59 @@
}
this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
@ -38,8 +38,6 @@
this.b.setConsumer((commandcontext, flag1, i) -> {
((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
});
@@ -111,7 +125,47 @@
}
+ // CraftBukkit start
@ -86,7 +84,7 @@
StringReader stringreader = new StringReader(s);
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -123,7 +177,6 @@
@@ -112,7 +166,6 @@
byte b0;
try {
@ -94,7 +92,7 @@
ChatComponentText chatcomponenttext;
try {
@@ -132,52 +185,56 @@
@@ -121,52 +174,56 @@
return i;
} catch (CommandException commandexception) {
commandlistenerwrapper.sendFailureMessage(commandexception.a());
@ -176,9 +174,9 @@
+ return b1;
+ }
} finally {
commandlistenerwrapper.getServer().methodProfiler.exit();
commandlistenerwrapper.getServer().getMethodProfiler().exit();
}
@@ -186,11 +243,36 @@
@@ -175,11 +232,36 @@
}
public void a(EntityPlayer entityplayer) {
@ -216,7 +214,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
}
@@ -201,7 +283,7 @@
@@ -190,7 +272,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@ -225,7 +223,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -224,7 +306,7 @@
@@ -213,7 +295,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

Datei anzeigen

@ -1,42 +1,42 @@
--- a/net/minecraft/server/CommandForceload.java
+++ b/net/minecraft/server/CommandForceload.java
@@ -43,7 +43,7 @@
@@ -47,7 +47,7 @@
private static int a(CommandListenerWrapper commandlistenerwrapper, ArgumentVec2I.a argumentvec2i_a) throws CommandSyntaxException {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(argumentvec2i_a.a >> 4, argumentvec2i_a.b >> 4);
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager();
private static int a(CommandListenerWrapper commandlistenerwrapper, BlockPosition2D blockposition2d) throws CommandSyntaxException {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(blockposition2d.a >> 4, blockposition2d.b >> 4);
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager();
+ DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit
boolean flag = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).isForceLoaded(chunkcoordintpair.x, chunkcoordintpair.z);
boolean flag = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).getForceLoadedChunks().contains(chunkcoordintpair.pair());
if (flag) {
@@ -55,7 +55,7 @@
@@ -59,7 +59,7 @@
}
private static int a(CommandListenerWrapper commandlistenerwrapper) {
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager();
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager();
+ DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit
LongSet longset = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).ag();
LongSet longset = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).getForceLoadedChunks();
int i = longset.size();
@@ -75,11 +75,11 @@
@@ -79,11 +79,11 @@
}
private static int b(CommandListenerWrapper commandlistenerwrapper) {
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager();
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager();
+ DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit
WorldServer worldserver = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager);
LongSet longset = worldserver.ag();
LongSet longset = worldserver.getForceLoadedChunks();
- longset.forEach((i) -> {
+ longset.forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error
worldserver.setForceLoaded(ChunkCoordIntPair.a(i), ChunkCoordIntPair.b(i), false);
worldserver.setForceLoaded(ChunkCoordIntPair.getX(i), ChunkCoordIntPair.getZ(i), false);
});
commandlistenerwrapper.sendMessage(new ChatMessage("commands.forceload.removed.all", new Object[] { dimensionmanager}), true);
@@ -102,7 +102,7 @@
@@ -106,7 +106,7 @@
if (i2 > 256L) {
throw CommandForceload.a.create(256, i2);
} else {
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager();
- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager();
+ DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit
WorldServer worldserver = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager);
ChunkCoordIntPair chunkcoordintpair = null;

Datei anzeigen

@ -8,7 +8,7 @@
+ GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getWorld().getGameRules().get(s); // CraftBukkit
gamerules_gamerulevalue.getType().a(commandcontext, "value", gamerules_gamerulevalue);
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[] { s, gamerules_gamerulevalue.a()}), true);
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[] { s, gamerules_gamerulevalue.getValue()}), true);
@@ -35,7 +35,7 @@
}
@ -16,5 +16,5 @@
- GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getServer().getGameRules().get(s);
+ GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getWorld().getGameRules().get(s); // CraftBukkit
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[] { s, gamerules_gamerulevalue.a()}), false);
return gamerules_gamerulevalue.c();
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[] { s, gamerules_gamerulevalue.getValue()}), false);
return gamerules_gamerulevalue.getIntValue();

Datei anzeigen

@ -6,8 +6,8 @@
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import com.mojang.brigadier.tree.CommandNode;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.CompletableFuture;
@@ -31,6 +32,7 @@
private final ResultConsumer<CommandListenerWrapper> l;
private final ArgumentAnchor.Anchor m;
@ -16,9 +16,9 @@
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, j) -> {
@@ -119,9 +121,22 @@
}
@@ -120,9 +122,22 @@
@Override
public boolean hasPermission(int i) {
+ // CraftBukkit start
+ if (currentCommand != null) {
@ -39,7 +39,7 @@
public Vec3D getPosition() {
return this.d;
}
@@ -183,7 +198,7 @@
@@ -184,7 +199,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@ -48,9 +48,9 @@
entityplayer.sendMessage(ichatbasecomponent1);
}
}
@@ -232,4 +247,10 @@
public Collection<ICompletionProvider.a> a(boolean flag) {
return Collections.singleton(ICompletionProvider.a.b);
@@ -234,4 +249,10 @@
public CompletableFuture<Suggestions> a(CommandContext<ICompletionProvider> commandcontext, SuggestionsBuilder suggestionsbuilder) {
return null;
}
+
+ // CraftBukkit start

Datei anzeigen

@ -34,7 +34,7 @@
+
+ // CraftBukkit start - add a version of getType which force loads chunks
+ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
+ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true, true);
+ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true);
+ return iblockaccess.getType(position);
+ }
+ // CraftBukkit end

Datei anzeigen

@ -1,10 +1,11 @@
--- a/net/minecraft/server/Container.java
+++ b/net/minecraft/server/Container.java
@@ -7,6 +7,17 @@
@@ -7,6 +7,18 @@
import java.util.Set;
import javax.annotation.Nullable;
+// CraftBukkit start
+import com.google.common.base.Preconditions;
+import java.util.HashMap;
+import java.util.Map;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
@ -18,9 +19,9 @@
public abstract class Container {
public NonNullList<ItemStack> items = NonNullList.a();
@@ -18,6 +29,18 @@
protected List<ICrafting> listeners = Lists.newArrayList();
private final Set<EntityHuman> i = Sets.newHashSet();
@@ -21,6 +33,27 @@
private final List<ICrafting> listeners = Lists.newArrayList();
private final Set<EntityHuman> k = Sets.newHashSet();
+ // CraftBukkit start
+ public boolean checkReachable = true;
@ -32,20 +33,29 @@
+ ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player);
+ ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player);
+ }
+ private IChatBaseComponent title;
+ public IChatBaseComponent getTitle() {
+ Preconditions.checkState(this.title != null, "Title not set");
+ return this.title;
+ }
+ public void setTitle(IChatBaseComponent title) {
+ Preconditions.checkState(this.title == null, "Title already set");
+ this.title = title;
+ }
+ // CraftBukkit end
+
public Container() {}
protected Slot a(Slot slot) {
@@ -128,6 +151,7 @@
protected Container(@Nullable Containers<?> containers, int i) {
this.e = containers;
this.windowId = i;
@@ -180,6 +213,7 @@
k = playerinventory.getCarried().getCount();
Iterator iterator = this.h.iterator();
Iterator iterator = this.i.iterator();
+ Map<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack)
while (iterator.hasNext()) {
Slot slot1 = (Slot) iterator.next();
ItemStack itemstack3 = playerinventory.getCarried();
@@ -143,12 +167,48 @@
@@ -195,12 +229,48 @@
}
k -= itemstack4.getCount() - j1;
@ -96,8 +106,8 @@
+ // CraftBukkit end
}
this.c();
@@ -165,8 +225,11 @@
this.d();
@@ -217,8 +287,11 @@
if (i == -999) {
if (!playerinventory.getCarried().isEmpty()) {
if (j == 0) {
@ -110,10 +120,10 @@
}
if (j == 1) {
@@ -254,6 +317,15 @@
@@ -306,6 +379,15 @@
}
slot2.f();
slot2.d();
+ // CraftBukkit start - Make sure the client has the right slot contents
+ if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem()));
@ -126,7 +136,7 @@
}
}
} else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) {
@@ -356,8 +428,11 @@
@@ -408,8 +490,11 @@
PlayerInventory playerinventory = entityhuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {
@ -139,11 +149,3 @@
}
}
@@ -565,6 +640,7 @@
if (inventorycraftresult.a(world, entityplayer, irecipe) && irecipe != null) {
itemstack = irecipe.craftItem(iinventory);
}
+ 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));

Datei anzeigen

@ -0,0 +1,42 @@
--- a/net/minecraft/server/ContainerAccess.java
+++ b/net/minecraft/server/ContainerAccess.java
@@ -6,6 +6,20 @@
public interface ContainerAccess {
+ // CraftBukkit start
+ default World getWorld() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ default BlockPosition getPosition() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ default org.bukkit.Location getLocation() {
+ return new org.bukkit.Location(getWorld().getWorld(), getPosition().getX(), getPosition().getY(), getPosition().getZ());
+ }
+ // CraftBukkit end
+
ContainerAccess a = new ContainerAccess() {
@Override
public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) {
@@ -15,6 +29,18 @@
static ContainerAccess at(final World world, final BlockPosition blockposition) {
return new ContainerAccess() {
+ // CraftBukkit start
+ @Override
+ public World getWorld() {
+ return world;
+ }
+
+ @Override
+ public BlockPosition getPosition() {
+ return blockposition;
+ }
+ // CraftBukkit end
+
@Override
public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) {
return Optional.of(bifunction.apply(world, blockposition));

Datei anzeigen

@ -10,9 +10,9 @@
+
public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger();
@@ -22,8 +26,15 @@
private int k;
private static final Logger c = LogManager.getLogger();
@@ -16,6 +20,12 @@
private int h;
public String renameText;
private final EntityHuman player;
+ // CraftBukkit start
@ -22,108 +22,98 @@
+ private PlayerInventory playerInventory;
+ // CraftBukkit end
public ContainerAnvil(PlayerInventory playerinventory, final World world, final BlockPosition blockposition, EntityHuman entityhuman) {
public ContainerAnvil(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.a);
@@ -23,6 +33,7 @@
public ContainerAnvil(int i, PlayerInventory playerinventory, final ContainerAccess containeraccess) {
super(Containers.ANVIL, i);
+ this.playerInventory = playerinventory; // CraftBukkit
this.position = blockposition;
this.world = world;
this.player = entityhuman;
@@ -111,7 +122,7 @@
this.resultInventory = new InventoryCraftResult();
this.repairInventory = new InventorySubcontainer(2) {
@Override
@@ -123,7 +134,7 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
- this.resultInventory.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
this.levelCost.a(0);
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -129,7 +140,7 @@
@@ -141,7 +152,7 @@
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
if (k <= 0) {
- this.resultInventory.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
this.levelCost.a(0);
return;
}
@@ -144,7 +155,7 @@
this.k = i1;
@@ -156,7 +167,7 @@
this.h = i1;
} else {
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
- this.resultInventory.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
this.levelCost.a(0);
return;
}
@@ -234,7 +245,7 @@
@@ -246,7 +257,7 @@
}
if (flag2 && !flag1) {
- this.resultInventory.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
this.levelCost.a(0);
return;
}
@@ -258,11 +269,11 @@
@@ -270,11 +281,11 @@
itemstack1 = ItemStack.a;
}
- if (b1 == i && b1 > 0 && this.levelCost >= 40) {
- this.levelCost = 39;
+ if (b1 == i && b1 > 0 && this.levelCost >= maximumRepairCost) { // CraftBukkit
+ this.levelCost = maximumRepairCost - 1; // CraftBukkit
- if (b1 == i && b1 > 0 && this.levelCost.b() >= 40) {
- this.levelCost.a(39);
+ if (b1 == i && b1 > 0 && this.levelCost.b() >= maximumRepairCost) { // CraftBukkit
+ this.levelCost.a(maximumRepairCost - 1); // CraftBukkit
}
- if (this.levelCost >= 40 && !this.player.abilities.canInstantlyBuild) {
+ if (this.levelCost >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
- if (this.levelCost.b() >= 40 && !this.player.abilities.canInstantlyBuild) {
+ if (this.levelCost.b() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
itemstack1 = ItemStack.a;
}
@@ -281,7 +292,7 @@
@@ -293,7 +304,7 @@
EnchantmentManager.a(map, itemstack1);
}
- this.resultInventory.setItem(0, itemstack1);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
this.b();
this.c();
}
}
@@ -299,6 +310,7 @@
}
@@ -312,6 +323,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return !this.world.getType(this.position).a(TagsBlock.ANVIL) ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
return (Boolean) this.containerAccess.a((world, blockposition) -> {
return !world.getType(blockposition).a(TagsBlock.ANVIL) ? false : entityhuman.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D;
}, true);
@@ -370,4 +382,18 @@
@@ -354,4 +366,33 @@
this.d();
this.e();
}
+
+ // CraftBukkit start
+ @Override
+ public void b() {
+ super.b();
+
+ for (int i = 0; i < this.listeners.size(); ++i) {
+ ICrafting icrafting = (ICrafting) this.listeners.get(i);
+
+ if (this.lastLevelCost != this.levelCost) {
+ icrafting.setContainerData(this, 0, this.levelCost);
+ }
+ }
+
+ this.lastLevelCost = this.levelCost;
+ }
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(
+ new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ()), this.repairInventory, this.resultInventory, this);
+ containerAccess.getLocation(), this.repairInventory, this.resultInventory, this);
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerBeacon.java
+++ b/net/minecraft/server/ContainerBeacon.java
@@ -1,11 +1,18 @@
@@ -1,11 +1,17 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
@ -8,26 +8,33 @@
public class ContainerBeacon extends Container {
private final IInventory beacon;
private final ContainerBeacon.SlotBeacon f;
private final ContainerBeacon.SlotBeacon d;
private final ContainerAccess containerAccess;
private final IContainerProperties containerProperties;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerBeacon(IInventory iinventory, IInventory iinventory1) {
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
this.beacon = iinventory1;
this.f = new ContainerBeacon.SlotBeacon(iinventory1, 0, 136, 110);
this.a((Slot) this.f);
@@ -48,6 +55,7 @@
}
public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.a);
@@ -13,6 +19,7 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i);
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
this.beacon = new InventorySubcontainer(1) {
@Override
public boolean b(int j, ItemStack itemstack) {
@@ -62,6 +69,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.beacon.a(entityhuman);
return a(this.containerAccess, entityhuman, Blocks.BEACON);
}
@@ -113,4 +121,17 @@
@@ -145,4 +153,17 @@
return 1;
}
}
@ -39,7 +46,7 @@
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon((TileEntityBeacon) this.beacon); // TODO - check this
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerBrewingStand.java
+++ b/net/minecraft/server/ContainerBrewingStand.java
@@ -1,5 +1,10 @@
@@ -1,17 +1,28 @@
package net.minecraft.server;
+// CraftBukkit start
@ -11,29 +11,33 @@
public class ContainerBrewingStand extends Container {
private final IInventory brewingStand;
@@ -7,7 +12,13 @@
private int g;
private int h;
private final IContainerProperties d;
private final Slot e;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
+
public ContainerBrewingStand(PlayerInventory playerinventory, IInventory iinventory) {
+ player = playerinventory; // CraftBukkit
this.brewingStand = iinventory;
this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(iinventory, 0, 56, 51)));
this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(iinventory, 1, 79, 58)));
@@ -54,6 +65,7 @@
public ContainerBrewingStand(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(5), new ContainerProperties(2));
}
public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) {
super(Containers.BREWING_STAND, i);
+ player = playerinventory; // CraftBukkit
a(iinventory, 5);
a(icontainerproperties, 2);
this.brewingStand = iinventory;
@@ -39,6 +50,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.brewingStand.a(entityhuman);
}
@@ -178,4 +190,17 @@
@@ -171,4 +183,17 @@
return item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE;
}
}

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