Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -0,0 +1,46 @@
--- a/net/minecraft/world/level/block/AzaleaBlock.java
+++ b/net/minecraft/world/level/block/AzaleaBlock.java
@@ -12,6 +12,13 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
+
public class AzaleaBlock extends BlockPlant implements IBlockFragilePlantElement {
private static final AzaleaTreeGrower TREE_GROWER = new AzaleaTreeGrower();
@@ -43,6 +50,29 @@
@Override
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {
+ // CraftBukkit start
+ worldserver.captureTreeGeneration = true;
+ // CraftBukkit end
AzaleaBlock.TREE_GROWER.a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), blockposition, iblockdata, random);
+ // CraftBukkit start
+ worldserver.captureTreeGeneration = false;
+ if (worldserver.capturedBlockStates.size() > 0) {
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
+ worldserver.capturedBlockStates.clear();
+ StructureGrowEvent event = null;
+ if (treeType != null) {
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event == null || !event.isCancelled()) {
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true);
+ }
+ }
+ }
+ // CraftBukkit end
}
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -248,7 +248,13 @@
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
@@ -354,7 +354,13 @@
EntityItem entityitem = (EntityItem) supplier.get();
entityitem.defaultPickupDelay();
- world.addEntity(entityitem);
@@ -15,7 +15,7 @@
}
}
@@ -279,7 +285,7 @@
@@ -380,7 +386,7 @@
public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) {
entityhuman.b(StatisticList.BLOCK_MINED.b(this));
@@ -24,8 +24,8 @@
dropItems(iblockdata, world, blockposition, tileentity, entityhuman, itemstack);
}
@@ -375,6 +381,12 @@
return this;
@@ -514,6 +520,12 @@
return (ImmutableMap) this.stateDefinition.a().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function));
}
+ // CraftBukkit start
@@ -36,4 +36,4 @@
+
public static final class a {
private final IBlockData a;
private final IBlockData first;

View File

@@ -1,27 +1,27 @@
--- a/net/minecraft/world/level/block/BlockBamboo.java
+++ b/net/minecraft/world/level/block/BlockBamboo.java
@@ -174,7 +174,7 @@
@@ -187,7 +187,7 @@
BlockPosition blockposition1 = blockposition.up(i);
IBlockData iblockdata1 = worldserver.getType(blockposition1);
- if (k >= 16 || (Integer) iblockdata1.get(BlockBamboo.f) == 1 || !worldserver.isEmpty(blockposition1.up())) {
+ if (k >= 16 || !iblockdata1.a(Blocks.BAMBOO) || (Integer) iblockdata1.get(BlockBamboo.f) == 1 || !worldserver.isEmpty(blockposition1.up())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here
- if (k >= 16 || (Integer) iblockdata1.get(BlockBamboo.STAGE) == 1 || !worldserver.isEmpty(blockposition1.up())) {
+ if (k >= 16 || !iblockdata1.a(Blocks.BAMBOO) || (Integer) iblockdata1.get(BlockBamboo.STAGE) == 1 || !worldserver.isEmpty(blockposition1.up())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here
return;
}
@@ -195,14 +195,18 @@
@@ -208,14 +208,18 @@
BlockPosition blockposition1 = blockposition.down(2);
IBlockData iblockdata2 = world.getType(blockposition1);
BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE;
+ boolean shouldUpdateOthers = false; // CraftBukkit
if (i >= 1) {
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) {
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) {
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) {
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) {
blockpropertybamboosize = BlockPropertyBambooSize.LARGE;
if (iblockdata2.a(Blocks.BAMBOO)) {
- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
+ // CraftBukkit start - moved down
+ // world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
+ // world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
@@ -30,16 +30,16 @@
}
}
} else {
@@ -213,7 +217,14 @@
int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1;
@@ -226,7 +230,14 @@
int j = (Integer) iblockdata.get(BlockBamboo.AGE) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1;
int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1;
- world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3);
- world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.AGE, j)).set(BlockBamboo.LEAVES, blockpropertybamboosize)).set(BlockBamboo.STAGE, k), 3);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3)) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.AGE, j)).set(BlockBamboo.LEAVES, blockpropertybamboosize)).set(BlockBamboo.STAGE, k), 3)) {
+ if (shouldUpdateOthers) {
+ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
+ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
+ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
+ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
+ }
+ }
+ // CraftBukkit end

View File

@@ -1,10 +1,10 @@
--- a/net/minecraft/world/level/block/BlockBambooSapling.java
+++ b/net/minecraft/world/level/block/BlockBambooSapling.java
@@ -86,6 +86,6 @@
@@ -94,6 +94,6 @@
}
protected void a(World world, BlockPosition blockposition) {
- world.setTypeAndData(blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent
- world.setTypeAndData(blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockBed.java
+++ b/net/minecraft/world/level/block/BlockBed.java
@@ -78,7 +78,8 @@
@@ -88,7 +88,8 @@
}
}
@@ -10,7 +10,7 @@
world.a(blockposition, false);
BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite());
@@ -95,7 +96,16 @@
@@ -105,7 +106,16 @@
return EnumInteractionResult.SUCCESS;
} else {
@@ -27,7 +27,7 @@
if (entityhuman_enumbedresult != null) {
entityhuman.a(entityhuman_enumbedresult.a(), true);
}
@@ -106,8 +116,27 @@
@@ -116,8 +126,27 @@
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockBeehive.java
+++ b/net/minecraft/world/level/block/BlockBeehive.java
@@ -97,7 +97,7 @@
@@ -108,7 +108,7 @@
EntityBee entitybee = (EntityBee) iterator.next();
if (entitybee.getGoalTarget() == null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockButtonAbstract.java
+++ b/net/minecraft/world/level/block/BlockButtonAbstract.java
@@ -26,6 +26,11 @@
@@ -27,6 +27,11 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -11,8 +11,8 @@
+
public abstract class BlockButtonAbstract extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -92,6 +97,19 @@
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -97,6 +102,19 @@
if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) {
return EnumInteractionResult.CONSUME;
} else {
@@ -31,10 +31,10 @@
+ // CraftBukkit end
this.d(iblockdata, world, blockposition);
this.a(entityhuman, world, blockposition, true);
return EnumInteractionResult.a(world.isClientSide);
@@ -142,6 +160,16 @@
if (this.v) {
this.e(iblockdata, (World) worldserver, blockposition);
world.a((Entity) entityhuman, GameEvent.BLOCK_PRESS, blockposition);
@@ -148,6 +166,16 @@
if (this.sensitive) {
this.e(iblockdata, worldserver, blockposition);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@@ -49,7 +49,7 @@
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3);
this.f(iblockdata, (World) worldserver, blockposition);
this.a((EntityHuman) null, worldserver, blockposition, false);
@@ -162,7 +190,44 @@
@@ -169,11 +197,48 @@
boolean flag = !list.isEmpty();
boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED);
@@ -94,3 +94,8 @@
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3);
this.f(iblockdata, world, blockposition);
this.a((EntityHuman) null, world, blockposition, flag);
- world.a((Entity) list.stream().findFirst().orElse((Object) null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition);
+ world.a((Entity) list.stream().findFirst().orElse(null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); // CraftBukkit - decompile error
}
if (flag) {

View File

@@ -8,8 +8,8 @@
+
public class BlockCactus extends Block {
public static final BlockStateInteger AGE = BlockProperties.aj;
@@ -57,7 +59,7 @@
public static final BlockStateInteger AGE = BlockProperties.AGE_15;
@@ -59,7 +61,7 @@
int j = (Integer) iblockdata.get(BlockCactus.AGE);
if (j == 15) {
@@ -18,7 +18,7 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0);
worldserver.setTypeAndData(blockposition, iblockdata1, 4);
@@ -114,7 +116,9 @@
@@ -116,7 +118,9 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockCake.java
+++ b/net/minecraft/world/level/block/BlockCake.java
@@ -58,7 +58,18 @@
@@ -86,7 +86,18 @@
return EnumInteractionResult.PASS;
} else {
entityhuman.a(StatisticList.EAT_CAKE_SLICE);
@@ -19,4 +19,4 @@
+ // CraftBukkit end
int i = (Integer) iblockdata.get(BlockCake.BITES);
if (i < 6) {
generatoraccess.a((Entity) entityhuman, GameEvent.EAT, blockposition);

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockCampfire.java
+++ b/net/minecraft/world/level/block/BlockCampfire.java
@@ -186,6 +186,11 @@
if (flag && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(BlockCampfire.d)) {
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
@@ -202,6 +202,11 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11);
}
if (!world.isClientSide && iprojectile.isBurning() && iprojectile.a(world, blockposition) && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(BlockCampfire.WATERLOGGED)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true), 11);
}

View File

@@ -1,176 +0,0 @@
--- a/net/minecraft/world/level/block/BlockCauldron.java
+++ b/net/minecraft/world/level/block/BlockCauldron.java
@@ -34,6 +34,8 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
+
public class BlockCauldron extends Block {
public static final BlockStateInteger LEVEL = BlockProperties.ar;
@@ -61,8 +63,13 @@
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.locY() <= (double) f) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
+ return;
+ }
entity.extinguish();
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
}
@@ -79,18 +86,27 @@
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, 3, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
+ return EnumInteractionResult.SUCCESS;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
}
entityhuman.a(StatisticList.FILL_CAULDRON);
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return EnumInteractionResult.a(world.isClientSide);
} else if (item == Items.BUCKET) {
if (i == 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, 0, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
+ return EnumInteractionResult.SUCCESS;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -101,7 +117,8 @@
}
entityhuman.a(StatisticList.USE_CAULDRON);
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -111,6 +128,10 @@
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
+ return EnumInteractionResult.SUCCESS;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER);
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -125,12 +146,17 @@
}
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
return EnumInteractionResult.a(world.isClientSide);
} else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.WATER) {
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
+ return EnumInteractionResult.SUCCESS;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
entityhuman.a(StatisticList.USE_CAULDRON);
@@ -141,7 +167,8 @@
}
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i + 1);
+ // this.a(world, blockposition, iblockdata, i + 1);
+ // CraftBukkit end
}
return EnumInteractionResult.a(world.isClientSide);
@@ -150,8 +177,13 @@
IDyeable idyeable = (IDyeable) item;
if (idyeable.a(itemstack) && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return EnumInteractionResult.SUCCESS;
+ }
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 EnumInteractionResult.SUCCESS;
}
@@ -159,13 +191,18 @@
if (i > 0 && item instanceof ItemBanner) {
if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
+ return EnumInteractionResult.SUCCESS;
+ }
itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
TileEntityBanner.c(itemstack1);
entityhuman.a(StatisticList.CLEAN_BANNER);
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
if (itemstack.isEmpty()) {
@@ -203,9 +240,25 @@
}
}
+ // CraftBukkit start
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, MathHelper.clamp(i, 0, 3)), 2);
+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
+ }
+
+ private boolean changeLevel(World world, BlockPosition blockposition, IBlockData iblockdata, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
+ int newLevel = Integer.valueOf(MathHelper.clamp(i, 0, 3));
+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
+ (entity == null) ? null : entity.getBukkitEntity(), reason, iblockdata.get(BlockCauldron.LEVEL), newLevel
+ );
+ world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
world.updateAdjacentComparators(blockposition, this);
+ return true;
+ // CraftBukkit end
}
@Override
@@ -217,7 +270,7 @@
IBlockData iblockdata = world.getType(blockposition);
if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) {
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
+ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockChest.java
+++ b/net/minecraft/world/level/block/BlockChest.java
@@ -79,24 +79,7 @@
@@ -88,24 +88,7 @@
public Optional<ITileInventory> a(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) {
final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1);
@@ -8,10 +8,10 @@
- @Nullable
- @Override
- public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
- if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) {
- tileentitychest.d(playerinventory.player);
- tileentitychest1.d(playerinventory.player);
- return ContainerChest.b(i, playerinventory, inventorylargechest);
- if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) {
- tileentitychest.e(playerinventory.player);
- tileentitychest1.e(playerinventory.player);
- return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest);
- } else {
- return null;
- }
@@ -26,7 +26,7 @@
}
public Optional<ITileInventory> a(TileEntityChest tileentitychest) {
@@ -109,6 +92,38 @@
@@ -118,6 +101,38 @@
}
};
@@ -46,10 +46,10 @@
+ @Nullable
+ @Override
+ public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
+ if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) {
+ tileentitychest.d(playerinventory.player);
+ tileentitychest1.d(playerinventory.player);
+ return ContainerChest.b(i, playerinventory, inventorylargechest);
+ if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) {
+ tileentitychest.e(playerinventory.player);
+ tileentitychest1.e(playerinventory.player);
+ return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest);
+ } else {
+ return null;
+ }
@@ -64,10 +64,10 @@
+
protected BlockChest(BlockBase.Info blockbase_info, Supplier<TileEntityTypes<? extends TileEntityChest>> supplier) {
super(blockbase_info, supplier);
this.j((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.c, BlockPropertyChestType.SINGLE)).set(BlockChest.d, false));
@@ -262,7 +277,7 @@
}
this.k((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.TYPE, BlockPropertyChestType.SINGLE)).set(BlockChest.WATERLOGGED, false));
@@ -276,7 +291,7 @@
@Override
public DoubleBlockFinder.Result<? extends TileEntityChest> a(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) {
- BiPredicate bipredicate;
+ BiPredicate<GeneratorAccess, BlockPosition> bipredicate; // CraftBukkit - decompile error

View File

@@ -8,16 +8,16 @@
+
public class BlockChorusFlower extends Block {
public static final BlockStateInteger AGE = BlockProperties.ah;
public static final int DEAD_AGE = 5;
@@ -84,8 +86,12 @@
}
if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) {
- worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
- worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2);
- this.a(worldserver, blockposition1, i);
+ // CraftBukkit start - add event
+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) {
+ worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
+ worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2);
+ this.a(worldserver, blockposition1, i);
+ }
+ // CraftBukkit end
@@ -40,7 +40,7 @@
}
if (flag2) {
worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2);
} else {
- this.a((World) worldserver, blockposition);
+ // CraftBukkit - add event

View File

@@ -8,8 +8,8 @@
+
public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.af;
@@ -45,7 +47,7 @@
public static final int MAX_AGE = 2;
@@ -55,7 +57,7 @@
int i = (Integer) iblockdata.get(BlockCocoa.AGE);
if (i < 2) {
@@ -18,7 +18,7 @@
}
}
@@ -115,7 +117,7 @@
@@ -125,7 +127,7 @@
@Override
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/level/block/BlockCommand.java
+++ b/net/minecraft/world/level/block/BlockCommand.java
@@ -27,6 +27,8 @@
@@ -26,6 +26,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockCommand extends BlockTileEntity {
public class BlockCommand extends BlockTileEntity implements GameMasterBlock {
private static final Logger LOGGER = LogManager.getLogger();
@@ -55,6 +57,15 @@
@@ -56,6 +58,15 @@
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
boolean flag2 = tileentitycommand.f();
@@ -24,4 +24,4 @@
+ // CraftBukkit end
tileentitycommand.a(flag1);
if (!flag2 && !tileentitycommand.g() && tileentitycommand.m() != TileEntityCommand.Type.SEQUENCE) {
if (!flag2 && !tileentitycommand.g() && tileentitycommand.t() != TileEntityCommand.Type.SEQUENCE) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockComposter.java
+++ b/net/minecraft/world/level/block/BlockComposter.java
@@ -36,12 +36,18 @@
@@ -38,6 +38,12 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -12,15 +12,17 @@
+
public class BlockComposter extends Block implements IInventoryHolder {
public static final BlockStateInteger a = BlockProperties.as;
public static final Object2FloatMap<IMaterial> b = new Object2FloatOpenHashMap();
private 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
public static final int READY = 8;
@@ -47,7 +53,7 @@
public static final Object2FloatMap<IMaterial> COMPOSTABLES = new Object2FloatOpenHashMap();
private static final int AABB_SIDE_THICKNESS = 2;
private static final VoxelShape OUTER_SHAPE = VoxelShapes.b();
- private static final VoxelShape[] SHAPES = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> {
+ private static final VoxelShape[] SHAPES = (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);
avoxelshape[i] = VoxelShapes.a(BlockComposter.OUTER_SHAPE, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
}
@@ -187,18 +193,25 @@
@@ -225,18 +231,25 @@
return EnumInteractionResult.a(world.isClientSide);
} else if (i == 8) {
@@ -34,22 +36,22 @@
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
int i = (Integer) iblockdata.get(BlockComposter.a);
int i = (Integer) iblockdata.get(BlockComposter.LEVEL);
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) {
- IBlockData iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
+ // CraftBukkit start
+ double rand = worldserver.getRandom().nextDouble();
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
+ IBlockData iblockdata1 = a(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
+ return iblockdata;
+ }
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
+ iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
+ // CraftBukkit end
itemstack.subtract(1);
return iblockdata1;
@@ -207,7 +220,15 @@
@@ -245,7 +258,15 @@
}
}
@@ -57,7 +59,7 @@
+ // CraftBukkit start
+ public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ if (entity != null) {
+ IBlockData iblockdata1 = d(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
+ IBlockData iblockdata1 = c(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
+ return iblockdata;
+ }
@@ -66,69 +68,71 @@
if (!world.isClientSide) {
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D;
@@ -233,10 +254,16 @@
@@ -271,10 +292,16 @@
}
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
+ // CraftBukkit start
+ return b(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
+ return a(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
+ }
+
+ private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
+ static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
+ // CraftBukkit end
int i = (Integer) iblockdata.get(BlockComposter.a);
float f = BlockComposter.b.getFloat(itemstack.getItem());
int i = (Integer) iblockdata.get(BlockComposter.LEVEL);
float f = BlockComposter.COMPOSTABLES.getFloat(itemstack.getItem());
- if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) {
+ if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
return iblockdata;
} else {
int j = i + 1;
@@ -284,7 +311,8 @@
@@ -322,7 +349,8 @@
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
int i = (Integer) iblockdata.get(BlockComposter.a);
int i = (Integer) iblockdata.get(BlockComposter.LEVEL);
- 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 {
@@ -296,6 +324,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;
@@ -348,6 +377,7 @@
this.blockData = iblockdata;
this.generatorAccess = generatoraccess;
this.blockPosition = blockposition;
private static class ContainerOutput extends InventorySubcontainer implements IWorldInventory {
@@ -337,6 +365,7 @@
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
}
@Override
@@ -372,15 +402,23 @@
@@ -361,8 +390,15 @@
@Override
public void update() {
- BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
- this.emptied = true;
- BlockComposter.c(this.state, this.level, this.pos);
- this.changed = true;
+ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
+ if (this.isEmpty()) {
+ BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
+ this.emptied = true;
+ BlockComposter.c(this.state, this.level, this.pos);
+ this.changed = true;
+ } else {
+ this.generatorAccess.setTypeAndData(this.blockPosition, this.blockData, 3);
+ this.emptied = false;
+ this.level.setTypeAndData(this.pos, this.state, 3);
+ this.changed = false;
+ }
+ // CraftBukkit end
}
}
static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
@@ -375,6 +411,7 @@
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
super(1);
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
@@ -417,8 +454,9 @@
private static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
- public ContainerEmpty() {
+ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit

View File

@@ -11,13 +11,13 @@
+
public class BlockConcretePowder extends BlockFalling {
private final IBlockData a;
private final IBlockData concrete;
@@ -25,7 +30,7 @@
@Override
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
if (canHarden(world, blockposition, iblockdata1)) {
- world.setTypeAndData(blockposition, this.a, 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit
- world.setTypeAndData(blockposition, this.concrete, 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete, 3); // CraftBukkit
}
}
@@ -25,7 +25,7 @@
BlockPosition blockposition = blockactioncontext.getClickPosition();
IBlockData iblockdata = world.getType(blockposition);
- return canHarden(world, blockposition, iblockdata) ? this.a : super.getPlacedState(blockactioncontext);
- return canHarden(world, blockposition, iblockdata) ? this.concrete : super.getPlacedState(blockactioncontext);
+ // CraftBukkit start
+ if (!canHarden(world, blockposition, iblockdata)) {
+ return super.getPlacedState(blockactioncontext);
@@ -33,7 +33,7 @@
+
+ // TODO: An event factory call for methods like this
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
+ blockState.setData(this.a);
+ blockState.setData(this.concrete);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ world.getMinecraftServer().server.getPluginManager().callEvent(event);
@@ -47,19 +47,19 @@
}
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
@@ -72,6 +94,24 @@
@@ -72,7 +94,25 @@
@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);
- return a((IBlockAccess) generatoraccess, blockposition) ? this.concrete : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit start
+ if (a((IBlockAccess) generatoraccess, blockposition)) {
+ // Suppress during worldgen
+ if (!(generatoraccess instanceof World)) {
+ return this.a;
+ return this.concrete;
+ }
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(this.a);
+ blockState.setData(this.concrete);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ ((World) generatoraccess).getServer().getPluginManager().callEvent(event);
@@ -72,4 +72,5 @@
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit end
}
}
@Override

View File

@@ -5,10 +5,10 @@
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!this.a((IBlockAccess) worldserver, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData()).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, this.a.getBlockData(), 2);
worldserver.setTypeAndData(blockposition, this.deadBlock.getBlockData(), 2);
}

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockCoralFan.java
+++ b/net/minecraft/world/level/block/BlockCoralFan.java
@@ -29,6 +29,11 @@
@@ -28,6 +28,11 @@
@Override
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
if (!e(iblockdata, worldserver, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) this.a.getBlockData().set(BlockCoralFan.b, false), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false), 2);
}

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockCoralFanWall.java
+++ b/net/minecraft/world/level/block/BlockCoralFanWall.java
@@ -29,6 +29,11 @@
@@ -28,6 +28,11 @@
@Override
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
if (!e(iblockdata, worldserver, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false).set(BlockCoralFanWall.FACING, iblockdata.get(BlockCoralFanWall.FACING))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.c.getBlockData().set(BlockCoralFanWall.b, false)).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a)), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false)).set(BlockCoralFanWall.FACING, (EnumDirection) iblockdata.get(BlockCoralFanWall.FACING)), 2);
}

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockCoralPlant.java
+++ b/net/minecraft/world/level/block/BlockCoralPlant.java
@@ -32,6 +32,11 @@
@@ -33,6 +33,11 @@
@Override
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
if (!e(iblockdata, worldserver, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) this.c.getBlockData().set(BlockCoralPlant.b, false), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false), 2);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockCrops.java
+++ b/net/minecraft/world/level/block/BlockCrops.java
@@ -18,6 +18,8 @@
@@ -21,6 +21,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,8 +8,8 @@
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.ai;
@@ -72,7 +74,7 @@
public static final int MAX_AGE = 7;
@@ -76,7 +78,7 @@
float f = a((Block) this, (IBlockAccess) worldserver, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
@@ -18,7 +18,7 @@
}
}
}
@@ -87,7 +89,7 @@
@@ -91,7 +93,7 @@
i = j;
}
@@ -27,12 +27,12 @@
}
protected int a(World world) {
@@ -145,7 +147,7 @@
@@ -149,7 +151,7 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { // CraftBukkit
- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit
world.a(blockposition, true, entity);
}

View File

@@ -1,10 +1,10 @@
--- a/net/minecraft/world/level/block/BlockDaylightDetector.java
+++ b/net/minecraft/world/level/block/BlockDaylightDetector.java
@@ -65,6 +65,7 @@
@@ -67,6 +67,7 @@
i = MathHelper.clamp(i, 0, 15);
if ((Integer) iblockdata.get(BlockDaylightDetector.POWER) != i) {
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, i), 3);
}
i = MathHelper.clamp(i, 0, 15);
if ((Integer) iblockdata.get(BlockDaylightDetector.POWER) != i) {
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, i), 3);
}

View File

@@ -8,7 +8,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);
protected static final VoxelShape SHAPE = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
@@ -46,8 +48,18 @@
boolean flag1 = this.a((World) worldserver, blockposition, iblockdata);
@@ -18,13 +18,13 @@
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, false), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.POWERED, false), 2);
} else if (!flag) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, true), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.POWERED, true), 2);
if (!flag1) {
worldserver.getBlockTickList().a(blockposition, this, this.g(iblockdata), TickListPriority.VERY_HIGH);

View File

@@ -13,11 +13,11 @@
} else {
if (worldserver.getLightLevel(blockposition.up()) >= 9) {
@@ -51,7 +56,7 @@
BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
BlockPosition blockposition1 = blockposition.c(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
if (worldserver.getType(blockposition1).a(Blocks.DIRT) && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) {
- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW)));
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit
- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.SNOWY, worldserver.getType(blockposition1.up()).a(Blocks.SNOW)));
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.SNOWY, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit
}
}
}

View File

@@ -1,21 +1,22 @@
--- a/net/minecraft/world/level/block/BlockDispenser.java
+++ b/net/minecraft/world/level/block/BlockDispenser.java
@@ -41,9 +41,10 @@
@@ -41,10 +41,11 @@
public static final BlockStateDirection FACING = BlockDirectional.FACING;
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
public static final BlockStateBoolean TRIGGERED = BlockProperties.TRIGGERED;
- public static final Map<Item, IDispenseBehavior> DISPENSER_REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> {
+ public static final Map<Item, IDispenseBehavior> DISPENSER_REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem());
});
private static final int TRIGGER_DURATION = 4;
+ public static boolean eventFired = false; // CraftBukkit
public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
BlockDispenser.REGISTRY.put(imaterial.getItem(), idispensebehavior);
@@ -86,6 +87,7 @@
BlockDispenser.DISPENSER_REGISTRY.put(imaterial.getItem(), idispensebehavior);
@@ -88,6 +89,7 @@
IDispenseBehavior idispensebehavior = this.a(itemstack);
if (idispensebehavior != IDispenseBehavior.NONE) {
if (idispensebehavior != IDispenseBehavior.NOOP) {
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockDoor.java
+++ b/net/minecraft/world/level/block/BlockDoor.java
@@ -31,6 +31,8 @@
@@ -34,6 +34,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -9,7 +9,7 @@
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -186,9 +188,24 @@
@@ -192,9 +194,24 @@
@Override
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
@@ -30,9 +30,9 @@
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
- if (block != this && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) {
- if (!this.getBlockData().a(block) && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) {
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) {
this.a(world, blockposition, flag1);
}
world.a(flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockposition);

View File

@@ -8,9 +8,9 @@
+
public class BlockDragonEgg extends BlockFalling {
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
protected static final VoxelShape SHAPE = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
@@ -44,6 +46,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));
BlockPosition blockposition1 = blockposition.c(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

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/BlockDropper.java
+++ b/net/minecraft/world/level/block/BlockDropper.java
@@ -16,6 +16,12 @@
import net.minecraft.world.level.block.entity.TileEntityHopper;
import net.minecraft.world.level.block.state.BlockBase;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import net.minecraft.world.InventoryLargeChest;
@@ -12,10 +12,10 @@
+
public class BlockDropper extends BlockDispenser {
private static final IDispenseBehavior c = new DispenseBehaviorItem();
private static final IDispenseBehavior DISPENSE_BEHAVIOUR = new DispenseBehaviorItem();
@@ -53,8 +59,25 @@
if (iinventory == null) {
itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack);
itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
} else {
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
- if (itemstack1.isEmpty()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockEnderPortal.java
+++ b/net/minecraft/world/level/block/BlockEnderPortal.java
@@ -16,6 +16,13 @@
@@ -19,6 +19,13 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -13,13 +13,13 @@
+
public class BlockEnderPortal extends BlockTileEntity {
protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
@@ -37,13 +44,22 @@
protected static final VoxelShape SHAPE = Block.a(0.0D, 6.0D, 0.0D, 16.0D, 12.0D, 16.0D);
@@ -40,13 +47,22 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (world instanceof WorldServer && !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)) {
- ResourceKey<World> resourcekey = world.getDimensionKey() == World.THE_END ? World.OVERWORLD : World.THE_END;
+ ResourceKey<World> resourcekey = world.getTypeKey() == DimensionManager.THE_END ? World.OVERWORLD : World.THE_END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
- ResourceKey<World> resourcekey = world.getDimensionKey() == World.END ? World.OVERWORLD : World.END;
+ ResourceKey<World> resourcekey = world.getTypeKey() == DimensionManager.END_LOCATION ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
WorldServer worldserver = ((WorldServer) world).getMinecraftServer().getWorldServer(resourcekey);
if (worldserver == null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockFenceGate.java
+++ b/net/minecraft/world/level/block/BlockFenceGate.java
@@ -125,6 +125,17 @@
@@ -130,6 +130,17 @@
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
if (!world.isClientSide) {
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);

View File

@@ -13,8 +13,8 @@
+
public class BlockFire extends BlockFireAbstract {
public static final BlockStateInteger AGE = BlockProperties.aj;
@@ -84,7 +91,24 @@
public static final int MAX_AGE = 15;
@@ -93,7 +100,24 @@
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
@@ -40,16 +40,16 @@
}
@Override
@@ -133,7 +157,7 @@
@@ -142,7 +166,7 @@
worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random));
if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) {
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
if (!iblockdata.canPlace(worldserver, blockposition)) {
- worldserver.a(blockposition, false);
+ fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location
}
IBlockData iblockdata1 = worldserver.getType(blockposition.down());
@@ -141,7 +165,7 @@
@@ -150,7 +174,7 @@
int i = (Integer) iblockdata.get(BlockFire.AGE);
if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
@@ -58,7 +58,7 @@
} else {
int j = Math.min(15, i + random.nextInt(3) / 2);
@@ -155,14 +179,14 @@
@@ -164,14 +188,14 @@
BlockPosition blockposition1 = blockposition.down();
if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
@@ -69,13 +69,13 @@
return;
}
if (i == 15 && random.nextInt(4) == 0 && !this.e(worldserver.getType(blockposition.down()))) {
if (i == 15 && random.nextInt(4) == 0 && !this.f(worldserver.getType(blockposition.down()))) {
- worldserver.a(blockposition, false);
+ fireExtinguished(worldserver, blockposition); // CraftBukkit
return;
}
}
@@ -170,12 +194,14 @@
@@ -179,12 +203,14 @@
boolean flag1 = worldserver.u(blockposition);
int k = flag1 ? -50 : 0;
@@ -96,7 +96,7 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
for (int l = -1; l <= 1; ++l) {
@@ -201,7 +227,15 @@
@@ -210,7 +236,15 @@
if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) {
int j2 = Math.min(15, i + random.nextInt(5) / 4);
@@ -113,8 +113,8 @@
}
}
}
@@ -225,12 +259,24 @@
return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock());
@@ -234,12 +268,24 @@
return iblockdata.b(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.get(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock());
}
- private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockFireAbstract.java
+++ b/net/minecraft/world/level/block/BlockFireAbstract.java
@@ -50,7 +50,14 @@
@@ -125,7 +125,14 @@
if (!entity.isFireProof()) {
entity.setFireTicks(entity.getFireTicks() + 1);
if (entity.getFireTicks() == 0) {
@@ -15,8 +15,8 @@
+ // CraftBukkit end
}
entity.damageEntity(DamageSource.FIRE, this.b);
@@ -72,14 +79,14 @@
entity.damageEntity(DamageSource.IN_FIRE, this.fireDamage);
@@ -147,14 +154,14 @@
}
if (!iblockdata.canPlace(world, blockposition)) {
@@ -28,12 +28,12 @@
}
private static boolean a(World world) {
- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.THE_NETHER;
+ return world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.OVERWORLD || world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.THE_NETHER; // CraftBukkit - getTypeKey()
- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.NETHER;
+ return world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.OVERWORLD_LOCATION || world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.NETHER_LOCATION; // CraftBukkit - getTypeKey()
}
@Override
@@ -123,4 +130,12 @@
@@ -202,4 +209,12 @@
}
}
}

View File

@@ -1,27 +1,27 @@
--- a/net/minecraft/world/level/block/BlockFluids.java
+++ b/net/minecraft/world/level/block/BlockFluids.java
@@ -137,14 +137,20 @@
if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) {
Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE;
@@ -143,14 +143,20 @@
if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) {
Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE;
- world.setTypeUpdate(blockposition, block.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return false;
}
if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) {
- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return false;
}
- world.setTypeUpdate(blockposition, block.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return false;
}
if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) {
- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
return false;
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockFungi.java
+++ b/net/minecraft/world/level/block/BlockFungi.java
@@ -50,6 +50,13 @@
@@ -51,6 +51,13 @@
@Override
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {
@@ -11,6 +11,6 @@
+ BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS;
+ }
+ // CraftBukkit end
((WorldGenFeatureConfigured) this.b.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition);
((WorldGenFeatureConfigured) this.feature.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition);
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockGrass.java
+++ b/net/minecraft/world/level/block/BlockGrass.java
@@ -72,7 +72,7 @@
@@ -70,7 +70,7 @@
}
if (iblockdata3.canPlace(worldserver, blockposition2)) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/level/block/BlockGrowingTop.java
+++ b/net/minecraft/world/level/block/BlockGrowingTop.java
@@ -44,7 +44,7 @@
BlockPosition blockposition1 = blockposition.shift(this.a);
@@ -45,7 +45,7 @@
BlockPosition blockposition1 = blockposition.shift(this.growthDirection);
if (this.h(worldserver.getType(blockposition1))) {
- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d));
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); // CraftBukkit
if (this.g(worldserver.getType(blockposition1))) {
- worldserver.setTypeUpdate(blockposition1, this.a(iblockdata, worldserver.random));
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.a(iblockdata, worldserver.random)); // CraftBukkit
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockJukeBox.java
+++ b/net/minecraft/world/level/block/BlockJukeBox.java
@@ -63,7 +63,13 @@
@@ -62,7 +62,13 @@
TileEntity tileentity = generatoraccess.getTileEntity(blockposition);
if (tileentity instanceof TileEntityJukeBox) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockLeaves.java
+++ b/net/minecraft/world/level/block/BlockLeaves.java
@@ -19,6 +19,8 @@
@@ -21,6 +21,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -8,8 +8,8 @@
+
public class BlockLeaves extends Block {
public static final BlockStateInteger DISTANCE = BlockProperties.an;
@@ -42,6 +44,14 @@
public static final int DECAY_DISTANCE = 7;
@@ -46,6 +48,14 @@
@Override
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockLectern.java
+++ b/net/minecraft/world/level/block/BlockLectern.java
@@ -196,12 +196,13 @@
@@ -199,12 +199,13 @@
}
private void d(IBlockData iblockdata, World world, BlockPosition blockposition) {
@@ -9,7 +9,7 @@
if (tileentity instanceof TileEntityLectern) {
TileEntityLectern tileentitylectern = (TileEntityLectern) tileentity;
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.a);
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.FACING);
ItemStack itemstack = tileentitylectern.getBook().cloneItemStack();
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500
float f = 0.25F * (float) enumdirection.getAdjacentX();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockLever.java
+++ b/net/minecraft/world/level/block/BlockLever.java
@@ -22,6 +22,8 @@
@@ -25,6 +25,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,8 +8,8 @@
+
public class BlockLever extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -86,6 +88,20 @@
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -92,6 +94,20 @@
return EnumInteractionResult.SUCCESS;
} else {

View File

@@ -1,12 +1,12 @@
--- a/net/minecraft/world/level/block/BlockMagma.java
+++ b/net/minecraft/world/level/block/BlockMagma.java
@@ -28,7 +28,9 @@
@@ -30,7 +30,9 @@
@Override
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, 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
entity.damageEntity(DamageSource.HOT_FLOOR, 1.0F);
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit
}
super.stepOn(world, blockposition, entity);
super.stepOn(world, blockposition, iblockdata, entity);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockMinecartDetector.java
+++ b/net/minecraft/world/level/block/BlockMinecartDetector.java
@@ -26,6 +26,8 @@
@@ -25,6 +25,8 @@
import net.minecraft.world.level.block.state.properties.IBlockState;
import net.minecraft.world.phys.AxisAlignedBB;
@@ -8,8 +8,8 @@
+
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.ad;
@@ -78,6 +80,16 @@
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.RAIL_SHAPE_STRAIGHT;
@@ -80,6 +82,16 @@
}
IBlockData iblockdata1;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockMobSpawner.java
+++ b/net/minecraft/world/level/block/BlockMobSpawner.java
@@ -23,9 +23,19 @@
@@ -33,9 +33,19 @@
@Override
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/level/block/BlockMonsterEggs.java
+++ b/net/minecraft/world/level/block/BlockMonsterEggs.java
@@ -15,6 +15,8 @@
import net.minecraft.world.level.block.state.BlockBase;
@@ -18,6 +18,8 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.properties.IBlockState;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
+
public class BlockMonsterEggs extends Block {
private final Block a;
@@ -38,7 +40,7 @@
private final Block hostBlock;
@@ -43,7 +45,7 @@
EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a((World) worldserver);
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);

View File

@@ -10,8 +10,8 @@
+
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);
@@ -58,7 +62,7 @@
protected static final float AABB_OFFSET = 3.0F;
@@ -61,7 +65,7 @@
}
if (worldserver.isEmpty(blockposition2) && iblockdata.canPlace(worldserver, blockposition2)) {
@@ -21,18 +21,10 @@
}
@@ -82,6 +86,7 @@
WorldGenFeatureConfigured worldgenfeatureconfigured;
if (this == Blocks.BROWN_MUSHROOM) {
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM;
public boolean a(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, Random random) {
worldserver.a(blockposition, false);
+ BlockSapling.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit
if (((WorldGenFeatureConfigured) this.featureSupplier.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition)) {
return true;
} else {
if (this != Blocks.RED_MUSHROOM) {
@@ -89,6 +94,7 @@
return false;
}
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_RED_MUSHROOM;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockNetherWart.java
+++ b/net/minecraft/world/level/block/BlockNetherWart.java
@@ -43,7 +43,7 @@
@@ -46,7 +46,7 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1);

View File

@@ -8,23 +8,23 @@
+
public class BlockObserver extends BlockDirectional {
public static final BlockStateBoolean b = BlockProperties.w;
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -41,8 +43,18 @@
@Override
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if ((Boolean) iblockdata.get(BlockObserver.b)) {
if ((Boolean) iblockdata.get(BlockObserver.POWERED)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, false), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.POWERED, false), 2);
} else {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, true), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.POWERED, true), 2);
worldserver.getBlockTickList().a(blockposition, this, 2);
}

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockOre.java
+++ b/net/minecraft/world/level/block/BlockOre.java
@@ -23,6 +23,7 @@
@@ -25,6 +25,7 @@
@Override
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);
+ /* CraftBukkit start - Delegated to getExpDrop
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
int i = this.a(worldserver.random);
int i = this.xpRange.a(worldserver.random);
@@ -30,6 +31,21 @@
@@ -32,6 +33,21 @@
this.dropExperience(worldserver, blockposition, i);
}
}
@@ -19,7 +19,7 @@
+ @Override
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
+ int i = this.a(worldserver.random);
+ int i = this.xpRange.a(worldserver.random);
+
+ if (i > 0) {
+ return i;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockPlant.java
+++ b/net/minecraft/world/level/block/BlockPlant.java
@@ -21,7 +21,14 @@
@@ -23,7 +23,14 @@
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockPortal.java
+++ b/net/minecraft/world/level/block/BlockPortal.java
@@ -23,6 +23,10 @@
@@ -27,6 +27,10 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -10,8 +10,8 @@
+
public class BlockPortal extends Block {
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.E;
@@ -53,7 +57,8 @@
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.HORIZONTAL_AXIS;
@@ -58,7 +62,8 @@
}
if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) {
@@ -21,7 +21,7 @@
if (entity != null) {
entity.resetPortalCooldown();
@@ -75,6 +80,10 @@
@@ -80,6 +85,10 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {

View File

@@ -8,7 +8,7 @@
+
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.ad;
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.RAIL_SHAPE_STRAIGHT;
@@ -113,6 +115,13 @@
boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0);
@@ -22,4 +22,4 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, flag1), 3);
world.applyPhysics(blockposition.down(), this);
if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {
if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).b()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockPressurePlateAbstract.java
+++ b/net/minecraft/world/level/block/BlockPressurePlateAbstract.java
@@ -16,6 +16,8 @@
@@ -18,6 +18,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,8 +8,8 @@
+
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);
@@ -79,6 +81,19 @@
protected static final VoxelShape PRESSED_AABB = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D);
@@ -81,6 +83,19 @@
boolean flag = i > 0;
boolean flag1 = j > 0;

View File

@@ -8,7 +8,7 @@
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockProperties.w;
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -81,6 +83,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

View File

@@ -8,16 +8,16 @@
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockProperties.az;
public static final BlockStateInteger POWER = BlockProperties.POWER;
@@ -27,7 +29,31 @@
@Override
protected int b(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).size(), this.maxWeight);
+ // CraftBukkit start
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ int i = 0;
+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).iterator();
+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
@@ -37,8 +37,8 @@
+ }
+ }
+
+ i = Math.min(i, this.weight);
+ i = Math.min(i, this.maxWeight);
+ // CraftBukkit end
if (i > 0) {
float f = (float) Math.min(this.weight, i) / (float) this.weight;
float f = (float) Math.min(this.maxWeight, i) / (float) this.maxWeight;

View File

@@ -11,7 +11,7 @@
+
public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable {
public static final BlockStateDirection a = BlockFacingHorizontal.FACING;
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -64,19 +69,28 @@
EntityPlayer entityplayer;
int j;

View File

@@ -8,8 +8,8 @@
+
public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity {
public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.aG;
@@ -91,7 +93,8 @@
public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.MODE_COMPARATOR;
@@ -99,7 +101,8 @@
@Nullable
private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) {
@@ -19,8 +19,8 @@
return entityitemframe != null && entityitemframe.getDirection() == enumdirection;
});
@@ -146,8 +149,18 @@
boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c);
@@ -154,8 +157,18 @@
boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.POWERED);
if (flag1 && !flag) {
+ // CraftBukkit start
@@ -28,13 +28,13 @@
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, false), 2);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.POWERED, false), 2);
} else if (!flag1 && flag) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, true), 2);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.POWERED, true), 2);
}

View File

@@ -8,7 +8,7 @@
+
public class BlockRedstoneLamp extends Block {
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT;
@@ -36,6 +38,11 @@
if (flag1) {
world.getBlockTickList().a(blockposition, this, 4);
@@ -18,18 +18,18 @@
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2);
}
}
@@ -46,6 +53,11 @@
@Override
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !worldserver.isBlockIndirectlyPowered(blockposition)) {
if ((Boolean) iblockdata.get(BlockRedstoneLamp.LIT) && !worldserver.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2);
}

View File

@@ -11,7 +11,7 @@
+
public class BlockRedstoneOre extends Block {
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT;
@@ -32,14 +37,30 @@
@Override
@@ -22,24 +22,24 @@
}
@Override
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
- interact(world.getType(blockposition), world, blockposition);
- super.stepOn(world, blockposition, entity);
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- interact(iblockdata, world, blockposition);
- super.stepOn(world, blockposition, iblockdata, entity);
+ // CraftBukkit start
+ // interact(world.getType(blockposition), world, blockposition);
+ // super.stepOn(world, blockposition, entity);
+ // interact(iblockdata, world, blockposition);
+ // super.stepOn(world, blockposition, iblockdata, entity);
+ if (entity instanceof EntityHuman) {
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ if (!event.isCancelled()) {
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(world, blockposition, entity);
+ super.stepOn(world, blockposition, iblockdata, entity);
+ }
+ } else {
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(world, blockposition, entity);
+ super.stepOn(world, blockposition, iblockdata, entity);
+ }
+ }
+ // CraftBukkit end
@@ -62,25 +62,25 @@
- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
playEffect(world, blockposition);
if (!(Boolean) iblockdata.get(BlockRedstoneOre.a)) {
if (!(Boolean) iblockdata.get(BlockRedstoneOre.LIT)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, true)).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.LIT, true)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.LIT, true), 3);
}
@@ -71,6 +97,11 @@
@Override
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) {
if ((Boolean) iblockdata.get(BlockRedstoneOre.LIT)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) {
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.LIT, false)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3);
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.LIT, false), 3);
}
@@ -79,12 +110,25 @@
@@ -108,4 +108,4 @@
+ // CraftBukkit end
}
private static void playEffect(World world, BlockPosition blockposition) {
@Override

View File

@@ -8,8 +8,8 @@
+
public class BlockRedstoneTorch extends BlockTorch {
public static final BlockStateBoolean LIT = BlockProperties.r;
@@ -73,8 +75,24 @@
public static final BlockStateBoolean LIT = BlockProperties.LIT;
@@ -77,8 +79,24 @@
list.remove(0);
}
@@ -34,7 +34,7 @@
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3);
if (a(worldserver, blockposition, true)) {
worldserver.triggerEffect(1502, blockposition, 0);
@@ -82,6 +100,15 @@
@@ -86,6 +104,15 @@
}
}
} else if (!flag && !a(worldserver, blockposition, false)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockRedstoneWire.java
+++ b/net/minecraft/world/level/block/BlockRedstoneWire.java
@@ -34,6 +34,8 @@
@@ -38,6 +38,8 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -8,8 +8,17 @@
+
public class BlockRedstoneWire extends Block {
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.X;
@@ -238,7 +240,16 @@
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.NORTH_REDSTONE;
@@ -55,7 +57,7 @@
private static final Map<EnumDirection, VoxelShape> SHAPES_FLOOR = Maps.newEnumMap(ImmutableMap.of(EnumDirection.NORTH, Block.a(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), EnumDirection.SOUTH, Block.a(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), EnumDirection.EAST, Block.a(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), EnumDirection.WEST, Block.a(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D)));
private static final Map<EnumDirection, VoxelShape> SHAPES_UP = Maps.newEnumMap(ImmutableMap.of(EnumDirection.NORTH, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.NORTH), Block.a(3.0D, 0.0D, 0.0D, 13.0D, 16.0D, 1.0D)), EnumDirection.SOUTH, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.SOUTH), Block.a(3.0D, 0.0D, 15.0D, 13.0D, 16.0D, 16.0D)), EnumDirection.EAST, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.EAST), Block.a(15.0D, 0.0D, 3.0D, 16.0D, 16.0D, 13.0D)), EnumDirection.WEST, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.WEST), Block.a(0.0D, 0.0D, 3.0D, 1.0D, 16.0D, 13.0D))));
private static final Map<IBlockData, VoxelShape> SHAPES_CACHE = Maps.newHashMap();
- private static final Vec3D[] COLORS = (Vec3D[]) SystemUtils.a((Object) (new Vec3D[16]), (avec3d) -> {
+ private static final Vec3D[] COLORS = (Vec3D[]) SystemUtils.a((new Vec3D[16]), (avec3d) -> { // CraftBukkit - decompile error
for (int i = 0; i <= 15; ++i) {
float f = (float) i / 15.0F;
float f1 = f * 0.6F + (f > 0.0F ? 0.4F : 0.3F);
@@ -258,7 +260,16 @@
private void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.a(world, blockposition);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockReed.java
+++ b/net/minecraft/world/level/block/BlockReed.java
@@ -55,7 +55,7 @@
@@ -57,7 +57,7 @@
int j = (Integer) iblockdata.get(BlockReed.AGE);
if (j == 15) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockSapling.java
+++ b/net/minecraft/world/level/block/BlockSapling.java
@@ -15,11 +15,19 @@
@@ -15,12 +15,20 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -13,14 +13,15 @@
+
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger STAGE = BlockProperties.aA;
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 final BlockStateInteger STAGE = BlockProperties.STAGE;
protected static final float AABB_OFFSET = 6.0F;
protected static final VoxelShape SHAPE = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
private final WorldGenTreeProvider treeGrower;
+ public static TreeType treeType; // CraftBukkit
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
super(blockbase_info);
@@ -35,7 +43,30 @@
@@ -36,7 +44,30 @@
@Override
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/level/block/BlockScaffolding.java
+++ b/net/minecraft/world/level/block/BlockScaffolding.java
@@ -94,7 +94,7 @@
@@ -96,7 +96,7 @@
int i = a((IBlockAccess) worldserver, blockposition);
IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.a, i)).set(BlockScaffolding.c, this.a(worldserver, blockposition, i));
IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.DISTANCE, i)).set(BlockScaffolding.BOTTOM, this.a(worldserver, blockposition, i));
- if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7) {
+ if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - BlockFadeEvent
if ((Integer) iblockdata.get(BlockScaffolding.a) == 7) {
worldserver.addEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.set(BlockScaffolding.b, false)));
- if ((Integer) iblockdata1.get(BlockScaffolding.DISTANCE) == 7) {
+ if ((Integer) iblockdata1.get(BlockScaffolding.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - BlockFadeEvent
if ((Integer) iblockdata.get(BlockScaffolding.DISTANCE) == 7) {
worldserver.addEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.set(BlockScaffolding.WATERLOGGED, false)));
} else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockSnow.java
+++ b/net/minecraft/world/level/block/BlockSnow.java
@@ -85,6 +85,11 @@
@@ -87,6 +87,11 @@
@Override
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) {

View File

@@ -11,8 +11,8 @@
+
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockProperties.aw;
@@ -81,26 +86,49 @@
public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE;
@@ -82,26 +87,49 @@
if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) {
if (i > 0) {
@@ -29,9 +29,9 @@
}
@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(GameRules.MOB_GRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) {
public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) {
+ super.fallOn(world, iblockdata, 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(GameRules.RULE_MOBGRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) {
+ // CraftBukkit start - Interact soil
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
@@ -49,11 +49,11 @@
+ return;
+ }
+ // CraftBukkit end
fade(world.getType(blockposition), world, blockposition);
fade(iblockdata, world, blockposition);
}
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
- super.fallOn(world, iblockdata, blockposition, entity, f);
+ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up
}
public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/BlockSponge.java
+++ b/net/minecraft/world/level/block/BlockSponge.java
@@ -16,6 +16,13 @@
import net.minecraft.world.level.material.FluidTypes;
@@ -15,6 +15,13 @@
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Material;
+// CraftBukkit start
@@ -13,8 +13,8 @@
+
public class BlockSponge extends Block {
protected BlockSponge(BlockBase.Info blockbase_info) {
@@ -48,6 +55,7 @@
public static final int MAX_DEPTH = 6;
@@ -50,6 +57,7 @@
queue.add(new Tuple<>(blockposition, 0));
int i = 0;
@@ -22,7 +22,7 @@
while (!queue.isEmpty()) {
Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll();
@@ -59,27 +67,31 @@
@@ -61,27 +69,31 @@
for (int l = 0; l < k; ++l) {
EnumDirection enumdirection = aenumdirection[l];
BlockPosition blockposition2 = blockposition1.shift(enumdirection);
@@ -35,8 +35,8 @@
Material material = iblockdata.getMaterial();
if (fluid.a((Tag) TagsFluid.WATER)) {
- if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata) != FluidTypes.EMPTY) {
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { // CraftBukkit
- if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata).isEmpty()) {
+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata).isEmpty()) { // CraftBukkit
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
@@ -49,9 +49,9 @@
queue.add(new Tuple<>(blockposition2, j + 1));
}
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
- TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null;
+ // CraftBukkit start
+ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+ // TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null;
- a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity);
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
@@ -61,7 +61,7 @@
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
@@ -92,6 +104,39 @@
@@ -94,6 +106,39 @@
break;
}
}
@@ -84,12 +84,12 @@
+ Material material = iblockdata.getMaterial();
+
+ if (fluid.a(TagsFluid.WATER)) {
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) {
+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata).isEmpty()) {
+ // NOP
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
+ // NOP
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
+ TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+ TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null;
+
+ a(iblockdata, world, blockposition2, tileentity);
+ }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockStem.java
+++ b/net/minecraft/world/level/block/BlockStem.java
@@ -15,6 +15,8 @@
@@ -21,6 +21,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,8 +8,8 @@
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockProperties.ai;
@@ -47,14 +49,18 @@
public static final int MAX_AGE = 7;
@@ -57,14 +59,18 @@
if (i < 7) {
iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1);
@@ -20,17 +20,17 @@
BlockPosition blockposition1 = blockposition.shift(enumdirection);
IBlockData iblockdata1 = worldserver.getType(blockposition1.down());
if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a(Blocks.DIRT) || iblockdata1.a(Blocks.COARSE_DIRT) || iblockdata1.a(Blocks.PODZOL) || iblockdata1.a(Blocks.GRASS_BLOCK))) {
- worldserver.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a((Tag) TagsBlock.DIRT))) {
- worldserver.setTypeUpdate(blockposition1, this.fruit.getBlockData());
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.blockFruit.getBlockData())) {
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.getBlockData())) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
worldserver.setTypeUpdate(blockposition, (IBlockData) this.fruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
}
}
@@ -78,7 +84,7 @@
@@ -93,7 +99,7 @@
int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5));
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i);

View File

@@ -14,18 +14,18 @@
+
public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger a = BlockProperties.ag;
@@ -52,7 +60,7 @@
int i = (Integer) iblockdata.get(BlockSweetBerryBush.a);
private static final float HURT_SPEED_THRESHOLD = 0.003F;
@@ -59,7 +67,7 @@
int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE);
if (i < 3 && random.nextInt(5) == 0 && worldserver.getLightLevel(blockposition.up(), 0) >= 9) {
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); // CraftBukkit
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2); // CraftBukkit
}
}
@@ -66,7 +74,9 @@
double d1 = Math.abs(entity.locZ() - entity.F);
@@ -73,7 +81,9 @@
double d1 = Math.abs(entity.locZ() - entity.zOld);
if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit
@@ -34,7 +34,7 @@
}
}
@@ -83,7 +93,15 @@
@@ -90,7 +100,15 @@
} else if (i > 1) {
int j = 1 + world.random.nextInt(2);
@@ -48,6 +48,6 @@
+ a(world, blockposition, CraftItemStack.asNMSCopy(itemStack));
+ }
+ // CraftBukkit end
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_SWEET_BERRIES_PICK_FROM_BUSH, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, 1), 2);
world.playSound((EntityHuman) null, blockposition, SoundEffects.SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, 1), 2);
return EnumInteractionResult.a(world.isClientSide);

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/BlockTNT.java
+++ b/net/minecraft/world/level/block/BlockTNT.java
@@ -115,6 +115,11 @@
@@ -121,6 +121,11 @@
Entity entity = iprojectile.getShooter();
if (iprojectile.isBurning()) {
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
if (iprojectile.isBurning() && iprojectile.a(world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
a(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null);
world.a(blockposition, false);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockTallPlant.java
+++ b/net/minecraft/world/level/block/BlockTallPlant.java
@@ -82,6 +82,11 @@
@@ -84,6 +84,11 @@
}
protected static void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockTrapdoor.java
+++ b/net/minecraft/world/level/block/BlockTrapdoor.java
@@ -27,6 +27,8 @@
@@ -29,6 +29,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,11 +8,11 @@
+
public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged {
public static final BlockStateBoolean OPEN = BlockProperties.u;
@@ -113,6 +115,19 @@
public static final BlockStateBoolean OPEN = BlockProperties.OPEN;
@@ -117,6 +119,19 @@
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.c)) {
if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.POWERED)) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockTripwire.java
+++ b/net/minecraft/world/level/block/BlockTripwire.java
@@ -23,6 +23,8 @@
@@ -24,6 +24,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,8 +8,8 @@
+
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockProperties.w;
@@ -150,6 +152,40 @@
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -153,6 +155,40 @@
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockTripwireHook.java
+++ b/net/minecraft/world/level/block/BlockTripwireHook.java
@@ -25,6 +25,8 @@
@@ -26,6 +26,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -9,7 +9,7 @@
public class BlockTripwireHook extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -155,6 +157,17 @@
@@ -160,6 +162,17 @@
this.a(world, blockposition1, flag4, flag5, flag2, flag3);
}

View File

@@ -12,38 +12,38 @@
+
public class BlockTurtleEgg extends Block {
private static final VoxelShape c = Block.a(3.0D, 0.0D, 3.0D, 12.0D, 7.0D, 12.0D);
public static final int MAX_HATCH_LEVEL = 2;
@@ -62,6 +68,19 @@
IBlockData iblockdata = world.getType(blockposition);
if (iblockdata.a(Blocks.TURTLE_EGG)) {
+ // CraftBukkit start - Step on eggs
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
private void a(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) {
if (this.a(world, entity)) {
if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.a(Blocks.TURTLE_EGG)) {
+ // CraftBukkit start - Step on eggs
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ if (cancellable.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.a(world, blockposition, iblockdata);
}
}
@@ -88,9 +107,19 @@
int i = (Integer) iblockdata.get(BlockTurtleEgg.a);
if (i < 2) {
+ // CraftBukkit start - Call BlockGrowEvent
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(BlockTurtleEgg.a, i + 1), 2)) {
+ if (cancellable.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2);
this.a(world, blockposition, iblockdata);
}
@@ -87,9 +106,19 @@
int i = (Integer) iblockdata.get(BlockTurtleEgg.HATCH);
if (i < 2) {
+ // CraftBukkit start - Call BlockGrowEvent
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(BlockTurtleEgg.HATCH, i + 1), 2)) {
+ return;
+ }
+ // CraftBukkit end
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.HATCH, i + 1), 2);
+ // worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2); // CraftBukkit - handled above
} else {
+ // CraftBukkit start - Call BlockFadeEvent
@@ -51,10 +51,10 @@
+ return;
+ }
+ // CraftBukkit end
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
worldserver.a(blockposition, false);
@@ -101,7 +130,7 @@
@@ -100,7 +129,7 @@
entityturtle.setAgeRaw(-24000);
entityturtle.setHomePos(blockposition);
entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F);

View File

@@ -8,8 +8,8 @@
+
public class BlockVine extends Block {
public static final BlockStateBoolean UP = BlockSprawling.e;
@@ -190,20 +192,24 @@
public static final BlockStateBoolean UP = BlockSprawling.UP;
@@ -196,20 +198,24 @@
BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
@@ -31,7 +31,7 @@
} else if (flag1 && worldserver.isEmpty(blockposition4) && a((IBlockAccess) worldserver, blockposition.shift(enumdirection2), enumdirection3)) {
- worldserver.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
} else if ((double) worldserver.random.nextFloat() < 0.05D && a((IBlockAccess) worldserver, blockposition2.up(), EnumDirection.UP)) {
} else if ((double) random.nextFloat() < 0.05D && a((IBlockAccess) worldserver, blockposition2.up(), EnumDirection.UP)) {
- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
}
@@ -39,7 +39,7 @@
}
} else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) {
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2);
@@ -233,7 +239,7 @@
@@ -239,7 +245,7 @@
}
if (this.canSpread(iblockdata2)) {
@@ -48,7 +48,7 @@
}
return;
@@ -248,7 +254,7 @@
@@ -254,7 +260,7 @@
IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random);
if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockWitherRose.java
+++ b/net/minecraft/world/level/block/BlockWitherRose.java
@@ -31,7 +31,7 @@
@@ -51,7 +51,7 @@
EntityLiving entityliving = (EntityLiving) entity;
if (!entityliving.isInvulnerable(DamageSource.WITHER)) {

View File

@@ -39,7 +39,7 @@
@@ -74,6 +82,15 @@
entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
entitywither.aA = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
entitywither.yBodyRot = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
entitywither.beginSpawnSequence();
+ // CraftBukkit start
+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
@@ -54,7 +54,7 @@
while (iterator.hasNext()) {
@@ -82,7 +99,7 @@
CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
CriterionTriggers.SUMMONED_ENTITY.a(entityplayer, (Entity) entitywither);
}
- world.addEntity(entitywither);

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/BuddingAmethystBlock.java
+++ b/net/minecraft/world/level/block/BuddingAmethystBlock.java
@@ -44,7 +44,7 @@
if (block != null) {
IBlockData iblockdata2 = (IBlockData) ((IBlockData) block.getBlockData().set(AmethystClusterBlock.FACING, enumdirection)).set(AmethystClusterBlock.WATERLOGGED, iblockdata1.getFluid().getType() == FluidTypes.WATER);
- worldserver.setTypeUpdate(blockposition1, iblockdata2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2); // CraftBukkit
}
}

View File

@@ -0,0 +1,48 @@
--- a/net/minecraft/world/level/block/CaveVines.java
+++ b/net/minecraft/world/level/block/CaveVines.java
@@ -15,17 +15,43 @@
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
+import java.util.Collections;
+import net.minecraft.world.entity.Entity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerHarvestBlockEvent;
+// CraftBukkit end
+
public interface CaveVines {
VoxelShape SHAPE = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
BlockStateBoolean BERRIES = BlockProperties.BERRIES;
- static EnumInteractionResult harvest(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ static EnumInteractionResult harvest(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if ((Boolean) iblockdata.get(CaveVines.BERRIES)) {
- Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
+ // CraftBukkit start
+ if (entity instanceof EntityHuman) {
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
+ if (event.isCancelled()) {
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
+ }
+ for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) {
+ Block.a(world, blockposition, CraftItemStack.asNMSCopy(itemStack));
+ }
+ } else {
+ Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
+ }
+ // CraftBukkit end
+
float f = MathHelper.b(world.random, 0.8F, 1.2F);
world.playSound((EntityHuman) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f);
+ // CraftBukkit start - call EntityChangeBlockEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false)).isCancelled()) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false), 2);
return EnumInteractionResult.a(world.isClientSide);
} else {

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/CaveVinesBlock.java
+++ b/net/minecraft/world/level/block/CaveVinesBlock.java
@@ -57,7 +57,7 @@
@Override
public EnumInteractionResult interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
- return CaveVines.harvest(iblockdata, world, blockposition);
+ return CaveVines.harvest(iblockdata, world, blockposition, entityhuman); // CraftBukkit
}
@Override

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/CaveVinesPlantBlock.java
+++ b/net/minecraft/world/level/block/CaveVinesPlantBlock.java
@@ -40,7 +40,7 @@
@Override
public EnumInteractionResult interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
- return CaveVines.harvest(iblockdata, world, blockposition);
+ return CaveVines.harvest(iblockdata, world, blockposition, entityhuman); // CraftBukkit
}
@Override

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/ChangeOverTimeBlock.java
+++ b/net/minecraft/world/level/block/ChangeOverTimeBlock.java
@@ -69,7 +69,7 @@
if (random.nextFloat() < f1) {
this.a(iblockdata).ifPresent((iblockdata2) -> {
- worldserver.setTypeUpdate(blockposition, iblockdata2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, iblockdata2); // CraftBukkit
});
}

View File

@@ -0,0 +1,85 @@
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
@@ -17,6 +17,11 @@
import net.minecraft.world.level.material.FluidType;
import net.minecraft.world.level.material.FluidTypes;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.event.block.CauldronLevelChangeEvent;
+// CraftBukkit end
+
public class LayeredCauldronBlock extends AbstractCauldronBlock {
public static final int MIN_FILL_LEVEL = 1;
@@ -56,10 +61,14 @@
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!world.isClientSide && entity.isBurning() && this.a(iblockdata, blockposition, entity)) {
- entity.extinguish();
+ // CraftBukkit start
if (entity.a(world, blockposition)) {
- this.d(iblockdata, world, blockposition);
+ if (!decreaseLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
+ return;
+ }
}
+ entity.extinguish();
+ // CraftBukkit end
}
}
@@ -69,15 +78,38 @@
}
public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ decreaseLevel(iblockdata, world, blockposition, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
+ }
+
+ public static boolean decreaseLevel(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
int i = (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) - 1;
- world.setTypeUpdate(blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, i));
+ return changeLevel(iblockdata, world, blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : iblockdata.set(LayeredCauldronBlock.LEVEL, i), entity, reason);
}
+ // CraftBukkit start
+ public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
+ CraftBlockState newState = CraftBlockState.getBlockState(world, blockposition);
+ newState.setData(newBlock);
+
+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
+ (entity == null) ? null : entity.getBukkitEntity(), reason, newState
+ );
+ world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
+ newState.update(true);
+ return true;
+ }
+ // CraftBukkit end
+
@Override
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) {
if (BlockCauldron.a(world) && (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) != 3 && this.fillPredicate.test(biomebase_precipitation)) {
- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL));
+ changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
}
}
@@ -94,7 +126,11 @@
@Override
protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) {
if (!this.c(iblockdata)) {
- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1));
+ // CraftBukkit start
+ if (!changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
+ return;
+ }
+ // CraftBukkit end
world.triggerEffect(1047, blockposition, 0);
}
}

View File

@@ -0,0 +1,42 @@
--- a/net/minecraft/world/level/block/LightningRodBlock.java
+++ b/net/minecraft/world/level/block/LightningRodBlock.java
@@ -33,6 +33,11 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockRedstoneEvent;
+// CraftBukkit end
+
public class LightningRodBlock extends RodBlock implements IBlockWaterlogged {
public static final BlockStateBoolean WATERLOGGED = BlockProperties.WATERLOGGED;
@@ -79,6 +84,18 @@
}
public void d(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ boolean powered = iblockdata.get(LightningRodBlock.POWERED);
+ int old = (powered) ? 15 : 0;
+ int current = (!powered) ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() <= 0) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(LightningRodBlock.POWERED, true), 3);
this.e(iblockdata, world, blockposition);
world.getBlockTickList().a(blockposition, this, 8);
@@ -135,7 +152,7 @@
Entity entity = iprojectile.getShooter();
entitylightning.b(entity instanceof EntityPlayer ? (EntityPlayer) entity : null);
- world.addEntity(entitylightning);
+ ((WorldServer) world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.TRIDENT_THUNDER, SoundCategory.WEATHER, 5.0F, 1.0F);
}
}

View File

@@ -0,0 +1,47 @@
--- a/net/minecraft/world/level/block/MultifaceBlock.java
+++ b/net/minecraft/world/level/block/MultifaceBlock.java
@@ -45,7 +45,7 @@
private static final VoxelShape NORTH_AABB = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 1.0D);
private static final VoxelShape SOUTH_AABB = Block.a(0.0D, 0.0D, 15.0D, 16.0D, 16.0D, 16.0D);
private static final Map<EnumDirection, BlockStateBoolean> PROPERTY_BY_DIRECTION = BlockSprawling.PROPERTY_BY_DIRECTION;
- private static final Map<EnumDirection, VoxelShape> SHAPE_BY_DIRECTION = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumDirection.class), (enummap) -> {
+ private static final Map<EnumDirection, VoxelShape> SHAPE_BY_DIRECTION = (Map) SystemUtils.a(Maps.newEnumMap(EnumDirection.class), (enummap) -> { // CraftBukkit - decompile error
enummap.put(EnumDirection.NORTH, MultifaceBlock.NORTH_AABB);
enummap.put(EnumDirection.EAST, MultifaceBlock.EAST_AABB);
enummap.put(EnumDirection.SOUTH, MultifaceBlock.SOUTH_AABB);
@@ -134,7 +134,7 @@
return (IBlockData) Arrays.stream(blockactioncontext.f()).map((enumdirection) -> {
return this.c(iblockdata, (IBlockAccess) world, blockposition, enumdirection);
- }).filter(Objects::nonNull).findFirst().orElse((Object) null);
+ }).filter(Objects::nonNull).findFirst().orElse(null); // CraftBukkit - decompile error
}
@Nullable
@@ -226,7 +226,7 @@
if (optional.isPresent()) {
Pair<BlockPosition, EnumDirection> pair = (Pair) optional.get();
- return this.a(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag);
+ return this.a(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag, blockposition); // CraftBukkit
} else {
return false;
}
@@ -271,7 +271,7 @@
}
}
- private boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag) {
+ private boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag, BlockPosition source) { // CraftBukkit
IBlockData iblockdata = generatoraccess.getType(blockposition);
IBlockData iblockdata1 = this.c(iblockdata, (IBlockAccess) generatoraccess, blockposition, enumdirection);
@@ -280,7 +280,7 @@
generatoraccess.A(blockposition).e(blockposition);
}
- return generatoraccess.setTypeAndData(blockposition, iblockdata1, 2);
+ return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, source, blockposition, iblockdata1, 2); // CraftBukkit
} else {
return false;
}

View File

@@ -0,0 +1,90 @@
--- a/net/minecraft/world/level/block/PointedDripstoneBlock.java
+++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java
@@ -43,6 +43,11 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class PointedDripstoneBlock extends Block implements Fallable, IBlockWaterlogged {
public static final BlockStateDirection TIP_DIRECTION = BlockProperties.VERTICAL_DIRECTION;
@@ -125,6 +130,11 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
if (!world.isClientSide && iprojectile.a(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getMot().f() > 0.6D) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.b(blockposition, true);
}
@@ -133,7 +143,9 @@
@Override
public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) {
if (iblockdata.get(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.get(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) {
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit
entity.a(f + 2.0F, 2.0F, DamageSource.STALAGMITE);
+ CraftEventFactory.blockDamage = null; // CraftBukkit
} else {
super.fallOn(world, iblockdata, blockposition, entity, f);
}
@@ -397,15 +409,15 @@
if (a(iblockdata, enumdirection.opposite())) {
c(iblockdata, (GeneratorAccess) worldserver, blockposition1);
} else if (iblockdata.isAir() || iblockdata.a(Blocks.WATER)) {
- a((GeneratorAccess) worldserver, blockposition1, enumdirection, DripstoneThickness.TIP);
+ a((GeneratorAccess) worldserver, blockposition1, enumdirection, DripstoneThickness.TIP, blockposition); // CraftBukkit
}
}
- private static void a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness) {
+ private static void a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness, BlockPosition source) {
IBlockData iblockdata = (IBlockData) ((IBlockData) ((IBlockData) Blocks.POINTED_DRIPSTONE.getBlockData().set(PointedDripstoneBlock.TIP_DIRECTION, enumdirection)).set(PointedDripstoneBlock.THICKNESS, dripstonethickness)).set(PointedDripstoneBlock.WATERLOGGED, generatoraccess.getFluid(blockposition).getType() == FluidTypes.WATER);
- generatoraccess.setTypeAndData(blockposition, iblockdata, 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, source, blockposition, iblockdata, 3); // CraftBukkit
}
private static void c(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
@@ -420,8 +432,8 @@
blockposition1 = blockposition.down();
}
- a(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE);
- a(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE);
+ a(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit
+ a(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit
}
public static void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
@@ -454,7 +466,7 @@
return (BlockPosition) a(generatoraccess, blockposition, enumdirection.e(), predicate, (iblockdata1) -> {
return a(iblockdata1, flag);
- }, i).orElse((Object) null);
+ }, i).orElse(null); // CraftBukkit - decompile error
}
}
@@ -567,12 +579,12 @@
return iblockdata.getBlock() instanceof AbstractCauldronBlock && ((AbstractCauldronBlock) iblockdata.getBlock()).a(fluidtype);
};
- return (BlockPosition) a(world, blockposition, EnumDirection.DOWN.e(), BlockBase.BlockData::isAir, predicate, 11).orElse((Object) null);
+ return (BlockPosition) a(world, blockposition, EnumDirection.DOWN.e(), BlockBase.BlockData::isAir, predicate, 11).orElse(null); // CraftBukkit - decompile error
}
@Nullable
public static BlockPosition a(World world, BlockPosition blockposition) {
- return (BlockPosition) a(world, blockposition, EnumDirection.UP.e(), BlockBase.BlockData::isAir, PointedDripstoneBlock::h, 11).orElse((Object) null);
+ return (BlockPosition) a(world, blockposition, EnumDirection.UP.e(), BlockBase.BlockData::isAir, PointedDripstoneBlock::h, 11).orElse(null); // CraftBukkit - decompile error
}
public static FluidType b(World world, BlockPosition blockposition) {

View File

@@ -0,0 +1,16 @@
--- a/net/minecraft/world/level/block/PowderSnowBlock.java
+++ b/net/minecraft/world/level/block/PowderSnowBlock.java
@@ -68,7 +68,12 @@
entity.o(true);
if (!world.isClientSide) {
- if (entity.isBurning() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.a(world, blockposition)) {
+ // CraftBukkit start
+ if (entity.isBurning() && entity.a(world, blockposition)) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.b(blockposition, false);
}

View File

@@ -0,0 +1,10 @@
--- a/net/minecraft/world/level/block/RootedDirtBlock.java
+++ b/net/minecraft/world/level/block/RootedDirtBlock.java
@@ -26,6 +26,6 @@
@Override
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {
- worldserver.setTypeUpdate(blockposition.down(), Blocks.HANGING_ROOTS.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition.down(), Blocks.HANGING_ROOTS.getBlockData()); // CraftBukkit
}
}

View File

@@ -0,0 +1,52 @@
--- a/net/minecraft/world/level/block/SculkSensorBlock.java
+++ b/net/minecraft/world/level/block/SculkSensorBlock.java
@@ -38,11 +38,16 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockRedstoneEvent;
+// CraftBukkit end
+
public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged {
public static final int ACTIVE_TICKS = 40;
public static final int COOLDOWN_TICKS = 1;
- public static final Object2IntMap<GameEvent> VIBRATION_STRENGTH_FOR_EVENT = Object2IntMaps.unmodifiable((Object2IntMap) SystemUtils.a((Object) (new Object2IntOpenHashMap()), (object2intopenhashmap) -> {
+ public static final Object2IntMap<GameEvent> VIBRATION_STRENGTH_FOR_EVENT = Object2IntMaps.unmodifiable((Object2IntMap) SystemUtils.a((new Object2IntOpenHashMap()), (object2intopenhashmap) -> { // CraftBukkit - decompile error
object2intopenhashmap.put(GameEvent.STEP, 1);
object2intopenhashmap.put(GameEvent.FLAP, 2);
object2intopenhashmap.put(GameEvent.SWIM, 3);
@@ -216,6 +221,15 @@
}
public static void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ // CraftBukkit start
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), 0);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0) {
+ world.setTypeAndData(blockposition, iblockdata.set(SculkSensorBlock.POWER, eventRedstone.getNewCurrent()), 3);
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).set(SculkSensorBlock.POWER, 0), 3);
world.getBlockTickList().a(new BlockPosition(blockposition), iblockdata.getBlock(), 1);
if (!(Boolean) iblockdata.get(SculkSensorBlock.WATERLOGGED)) {
@@ -226,6 +240,15 @@
}
public static void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
+ // CraftBukkit start
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), i);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() <= 0) {
+ return;
+ }
+ i = eventRedstone.getNewCurrent();
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).set(SculkSensorBlock.POWER, i), 3);
world.getBlockTickList().a(new BlockPosition(blockposition), iblockdata.getBlock(), 40);
a(world, blockposition);

View File

@@ -0,0 +1,58 @@
--- a/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
+++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
@@ -13,6 +13,7 @@
private static final int CHECK_TICK_DELAY = 5;
private int openCount;
+ public boolean opened; // CraftBukkit
public ContainerOpenersCounter() {}
@@ -25,8 +26,19 @@
protected abstract boolean a(EntityHuman entityhuman);
public void a(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
+ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added
int i = this.openCount++;
+ // CraftBukkit start - Call redstone event
+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
+
if (i == 0) {
this.a(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
@@ -37,8 +49,19 @@
}
public void b(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
+ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added
int i = this.openCount--;
+ // CraftBukkit start - Call redstone event
+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
+
if (this.openCount == 0) {
this.b(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
@@ -59,6 +82,7 @@
public void c(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.a(world, blockposition);
+ if (opened) i++; // CraftBukkit - add dummy count from API
int j = this.openCount;
if (j != i) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/entity/TileEntity.java
+++ b/net/minecraft/world/level/block/entity/TileEntity.java
@@ -15,8 +15,18 @@
@@ -12,8 +12,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Supplier;
+// CraftBukkit start
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
@@ -17,27 +17,30 @@
+ public CraftPersistentDataContainer persistentDataContainer;
+ // CraftBukkit end
private static final Logger LOGGER = LogManager.getLogger();
private final TileEntityTypes<?> tileType;
private final TileEntityTypes<?> type;
@Nullable
@@ -48,6 +58,14 @@
@@ -41,7 +51,16 @@
return this.level != null;
}
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
+ // CraftBukkit start - read container
- public void load(NBTTagCompound nbttagcompound) {}
+ // CraftBukkit start - read container
+ public void load(NBTTagCompound nbttagcompound) {
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
+
+ net.minecraft.nbt.NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues");
+ if (persistentDataTag instanceof NBTTagCompound) {
+ this.persistentDataContainer.putAll((NBTTagCompound) persistentDataTag);
+ }
+ // CraftBukkit end
}
+ }
+ // CraftBukkit end
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
@@ -64,6 +82,11 @@
nbttagcompound.setInt("x", this.position.getX());
nbttagcompound.setInt("y", this.position.getY());
nbttagcompound.setInt("z", this.position.getZ());
return this.c(nbttagcompound);
@@ -57,6 +76,11 @@
nbttagcompound.setInt("x", this.worldPosition.getX());
nbttagcompound.setInt("y", this.worldPosition.getY());
nbttagcompound.setInt("z", this.worldPosition.getZ());
+ // CraftBukkit start - store container
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
@@ -46,15 +49,15 @@
return nbttagcompound;
}
}
@@ -179,4 +202,13 @@
}, this::getPosition});
}
@@ -164,4 +188,13 @@
public void b(IBlockData iblockdata) {
this.blockState = iblockdata;
}
+
+ // CraftBukkit start - add method
+ public InventoryHolder getOwner() {
+ if (world == null) return null;
+ org.bukkit.block.BlockState state = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState();
+ if (level == null) return null;
+ org.bukkit.block.BlockState state = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()).getState();
+ if (state instanceof InventoryHolder) return (InventoryHolder) state;
+ return null;
+ }

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBanner.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java
@@ -80,6 +80,11 @@
@@ -99,6 +99,11 @@
}
this.patterns = nbttagcompound.getList("Patterns", 10);
this.itemPatterns = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (this.patterns.size() > 20) {
+ this.patterns.remove(20);
+ while (this.itemPatterns.size() > 20) {
+ this.itemPatterns.remove(20);
+ }
+ // CraftBukkit end
this.h = null;
this.g = true;
this.patterns = null;
this.receivedData = true;
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBarrel.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBarrel.java
@@ -19,8 +19,50 @@
import net.minecraft.world.level.block.Blocks;
@@ -21,8 +21,49 @@
import net.minecraft.world.level.block.BlockBarrel;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
@@ -16,7 +16,6 @@
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new ArrayList<>();
+ private int maxStack = MAX_STACK;
+ public boolean opened;
+
+ @Override
+ public List<ItemStack> getContents() {
@@ -49,14 +48,5 @@
+ }
+ // CraftBukkit end
private NonNullList<ItemStack> items;
private int b;
public ContainerOpenersCounter openersCounter;
@@ -119,7 +161,7 @@
return;
}
- boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN);
+ boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API.
if (flag) {
this.playOpenSound(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java
@@ -38,6 +38,11 @@
@@ -40,6 +40,11 @@
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.phys.AxisAlignedBB;
@@ -9,38 +9,38 @@
+import org.bukkit.potion.PotionEffect;
+// CraftBukkit end
+
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
public class TileEntityBeacon extends TileEntity implements ITileInventory {
public static final MobEffectList[][] a = new MobEffectList[][]{{MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, {MobEffects.RESISTANCE, MobEffects.JUMP}, {MobEffects.INCREASE_DAMAGE}, {MobEffects.REGENERATION}};
@@ -54,6 +59,15 @@
public IChatBaseComponent customName;
public ChestLock chestLock;
private final IContainerProperties containerProperties;
private static final int MAX_LEVELS = 4;
@@ -62,6 +67,15 @@
public IChatBaseComponent name;
public ChestLock lockKey;
private final IContainerProperties dataAccess;
+ // CraftBukkit start - add fields and methods
+ public PotionEffect getPrimaryEffect() {
+ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null;
+ return (this.primaryPower != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null;
+ }
+
+ public PotionEffect getSecondaryEffect() {
+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null;
+ return (hasSecondaryEffect(levels, primaryPower, secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null;
+ }
+ // CraftBukkit end
public TileEntityBeacon() {
super(TileEntityTypes.BEACON);
@@ -222,39 +236,78 @@
super.al_();
public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEACON, blockposition, iblockdata);
@@ -230,39 +244,78 @@
super.aa_();
}
- private void applyEffects() {
- if (!this.world.isClientSide && this.primaryEffect != null) {
- double d0 = (double) (this.levels * 10 + 10);
- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
- if (!world.isClientSide && mobeffectlist != null) {
- double d0 = (double) (i * 10 + 10);
+ // CraftBukkit start - split into components
+ private byte getAmplification() {
+ private static byte getAmplification(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ {
byte b0 = 0;
if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) {
if (i >= 4 && mobeffectlist == mobeffectlist1) {
b0 = 1;
}
@@ -48,25 +48,25 @@
+ }
+ }
+
+ private int getLevel() {
+ private static int getLevel(int i) {
+ {
int i = (9 + this.levels * 2) * 20;
+ return i;
int j = (9 + i * 2) * 20;
+ return j;
+ }
+ }
+
+ public List getHumansInRange() {
+ public static List getHumansInRange(World world, BlockPosition blockposition, int i) {
+ {
+ double d0 = (double) (this.levels * 10 + 10);
+ double d0 = (double) (i * 10 + 10);
+
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getBuildHeight(), 0.0D);
List<EntityHuman> list = this.world.a(EntityHuman.class, axisalignedbb);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).g(d0).b(0.0D, (double) world.getHeight(), 0.0D);
List<EntityHuman> list = world.a(EntityHuman.class, axisalignedbb);
+
+ return list;
+ }
+ }
+
+ private void applyEffect(List list, MobEffectList effects, int i, int b0) {
+ private static void applyEffect(List list, MobEffectList mobeffectlist, int j, int b0) {
+ {
Iterator iterator = list.iterator();
@@ -74,20 +74,20 @@
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.primaryEffect, i, b0, true, true));
+ entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
- entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true));
+ entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
}
+ }
+ }
+ private boolean hasSecondaryEffect() {
+ private static boolean hasSecondaryEffect(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ {
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) {
if (i >= 4 && mobeffectlist != mobeffectlist1 && mobeffectlist1 != null) {
- iterator = list.iterator();
-
- while (iterator.hasNext()) {
- entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true));
- entityhuman.addEffect(new MobEffect(mobeffectlist1, j, 0, true, true));
- }
+ return true;
}
@@ -96,38 +96,38 @@
}
}
+ private void applyEffects() {
+ if (!this.world.isClientSide && this.primaryEffect != null) {
+ double d0 = (double) (this.levels * 10 + 10);
+ byte b0 = getAmplification();
+ private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ if (!world.isClientSide && mobeffectlist != null) {
+ double d0 = (double) (i * 10 + 10);
+ byte b0 = getAmplification(i, mobeffectlist, mobeffectlist1);
+
+ int i = getLevel();
+ List list = getHumansInRange();
+ int j = getLevel(i);
+ List list = getHumansInRange(world, blockposition, i);
+
+ applyEffect(list, this.primaryEffect, i, b0);
+ applyEffect(list, mobeffectlist, j, b0);
+
+ if (hasSecondaryEffect()) {
+ applyEffect(list, this.secondaryEffect, i, 0);
+ if (hasSecondaryEffect(i, mobeffectlist, mobeffectlist1)) {
+ applyEffect(list, mobeffectlist1, j, 0);
+ }
+ }
+
+ }
+ // CraftBukkit end
+
public void a(SoundEffect soundeffect) {
this.world.playSound((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
public static void a(World world, BlockPosition blockposition, SoundEffect soundeffect) {
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -284,8 +337,11 @@
@@ -292,8 +345,11 @@
@Override
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
super.load(iblockdata, nbttagcompound);
- this.primaryEffect = b(nbttagcompound.getInt("Primary"));
- this.secondaryEffect = b(nbttagcompound.getInt("Secondary"));
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
- this.primaryPower = a(nbttagcompound.getInt("Primary"));
- this.secondaryPower = a(nbttagcompound.getInt("Secondary"));
+ // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
+ this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
+ this.primaryPower = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryPower = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
+ this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available
+ // CraftBukkit end
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
this.name = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
}

View File

@@ -1,23 +1,23 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java
@@ -29,6 +29,7 @@
private final List<TileEntityBeehive.HiveBee> bees = Lists.newArrayList();
@@ -43,6 +43,7 @@
private final List<TileEntityBeehive.HiveBee> stored = Lists.newArrayList();
@Nullable
public BlockPosition flowerPos = null;
public BlockPosition savedFlowerPos;
+ public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold
public TileEntityBeehive() {
super(TileEntityTypes.BEEHIVE);
@@ -68,7 +69,7 @@
public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEEHIVE, blockposition, iblockdata);
@@ -82,7 +83,7 @@
}
public boolean isFull() {
- return this.bees.size() == 3;
+ return this.bees.size() == this.maxBees; // CraftBukkit
- return this.stored.size() == 3;
+ return this.stored.size() == this.maxBees; // CraftBukkit
}
public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -85,7 +86,7 @@
@@ -99,7 +100,7 @@
if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) {
if (!this.isSedated()) {
@@ -26,7 +26,7 @@
} else {
entitybee.setCannotEnterHiveTicks(400);
}
@@ -97,10 +98,16 @@
@@ -111,10 +112,16 @@
}
private List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -37,22 +37,22 @@
+ public List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
List<Entity> list = Lists.newArrayList();
this.bees.removeIf((tileentitybeehive_hivebee) -> {
- return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus);
+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, force);
this.stored.removeIf((tileentitybeehive_hivebee) -> {
- return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos);
+ return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
+ // CraftBukkit end
});
return list;
}
@@ -126,7 +133,19 @@
@@ -138,7 +145,19 @@
}
public void a(Entity entity, boolean flag, int i) {
- if (this.bees.size() < 3) {
+ if (this.bees.size() < this.maxBees) { // CraftBukkit
- if (this.stored.size() < 3) {
+ if (this.stored.size() < this.maxBees) { // CraftBukkit
+ // CraftBukkit start
+ if (this.world != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, getPosition()));
+ if (this.level != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getPosition()));
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (entity instanceof EntityBee) {
@@ -65,22 +65,22 @@
entity.stopRiding();
entity.ejectPassengers();
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -152,7 +171,13 @@
@@ -168,7 +187,13 @@
}
private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) {
- if ((world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
+ return releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false);
+ return releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, blockposition1, false);
+ }
+
+ private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
+ if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1, boolean force) {
+ if (!force && (world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit end
return false;
} else {
BlockPosition blockposition = this.getPosition();
@@ -176,6 +201,18 @@
NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData;
@@ -191,6 +216,18 @@
if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) {
return false;
} else {
@@ -92,14 +92,14 @@
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F);
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
+
+ entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
+ entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ }
+ if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ if (!world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ // CraftBukkit end
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
@@ -205,6 +242,7 @@
@@ -220,6 +257,7 @@
list.add(entitybee);
}
@@ -107,22 +107,22 @@
float f = entity.getWidth();
double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
@@ -212,10 +250,11 @@
@@ -227,10 +265,11 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ */ // CraftBukkit end
}
this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
- return this.world.addEntity(entity);
world.playSound((EntityHuman) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
- return world.addEntity(entity);
+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
}
} else {
return false;
@@ -253,6 +292,10 @@
@@ -276,6 +315,10 @@
if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) {
if (releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
iterator.remove();
+ // CraftBukkit start
+ } else {
@@ -131,8 +131,8 @@
}
}
}
@@ -295,6 +338,11 @@
this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
@@ -313,6 +356,11 @@
this.savedFlowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
}
+ // CraftBukkit start
@@ -143,9 +143,9 @@
}
@Override
@@ -304,6 +352,7 @@
if (this.x()) {
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos));
@@ -322,6 +370,7 @@
if (this.s()) {
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.savedFlowerPos));
}
+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
@@ -24,6 +24,17 @@
@@ -25,6 +25,18 @@
import net.minecraft.world.level.block.BlockBrewingStand;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import java.util.List;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
@@ -15,13 +16,13 @@
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable {
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory {
private static final int[] b = new int[]{3};
@@ -35,6 +46,36 @@
private Item k;
public int fuelLevel;
protected final IContainerProperties a;
private static final int INGREDIENT_SLOT = 3;
@@ -42,6 +54,36 @@
private Item ingredient;
public int fuel;
protected final IContainerProperties dataAccess;
+ // CraftBukkit start - add fields and methods
+ private int lastTick = MinecraftServer.currentTick;
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -53,55 +54,62 @@
+ }
+ // CraftBukkit end
public TileEntityBrewingStand() {
super(TileEntityTypes.BREWING_STAND);
@@ -103,8 +144,19 @@
ItemStack itemstack = (ItemStack) this.items.get(4);
public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata);
@@ -109,8 +151,19 @@
ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4);
if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) {
- this.fuelLevel = 20;
if (tileentitybrewingstand.fuel <= 0 && itemstack.a(Items.BLAZE_POWDER)) {
- tileentitybrewingstand.fuel = 20;
- itemstack.subtract(1);
+ // CraftBukkit start
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), CraftItemStack.asCraftMirror(itemstack), 20);
+ this.world.getServer().getPluginManager().callEvent(event);
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(CraftBlock.at(world, blockposition), CraftItemStack.asCraftMirror(itemstack), 20);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ this.fuelLevel = event.getFuelPower();
+ if (this.fuelLevel > 0 && event.isConsuming()) {
+ tileentitybrewingstand.fuel = event.getFuelPower();
+ if (tileentitybrewingstand.fuel > 0 && event.isConsuming()) {
+ itemstack.subtract(1);
+ }
+ // CraftBukkit end
this.update();
a(world, blockposition, iblockdata);
}
@@ -112,9 +164,14 @@
boolean flag1 = this.brewTime > 0;
ItemStack itemstack1 = (ItemStack) this.items.get(3);
@@ -118,12 +171,17 @@
boolean flag1 = tileentitybrewingstand.brewTime > 0;
ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3);
+ // CraftBukkit start - Use wall time instead of ticks for brewing
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ int elapsedTicks = MinecraftServer.currentTick - tileentitybrewingstand.lastTick;
+ tileentitybrewingstand.lastTick = MinecraftServer.currentTick;
+
if (flag1) {
- --this.brewTime;
- boolean flag2 = this.brewTime == 0;
+ this.brewTime -= elapsedTicks;
+ boolean flag2 = this.brewTime <= 0; // == -> <=
- --tileentitybrewingstand.brewTime;
- boolean flag2 = tileentitybrewingstand.brewTime == 0;
+ tileentitybrewingstand.brewTime -= elapsedTicks;
+ boolean flag2 = tileentitybrewingstand.brewTime <= 0; // == -> <=
+ // CraftBukkit end
if (flag2 && flag) {
this.j();
@@ -188,6 +245,16 @@
- a(world, blockposition, tileentitybrewingstand.items);
+ a(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit
a(world, blockposition, iblockdata);
} else if (!flag || !itemstack1.a(tileentitybrewingstand.ingredient)) {
tileentitybrewingstand.brewTime = 0;
@@ -187,8 +245,18 @@
}
}
private void j() {
ItemStack itemstack = (ItemStack) this.items.get(3);
+ // CraftBukkit start
+ InventoryHolder owner = this.getOwner();
- private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) {
+ // CraftBukkit start
+ private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) {
ItemStack itemstack = (ItemStack) nonnulllist.get(3);
+ InventoryHolder owner = tileentitybrewingstand.getOwner();
+ if (owner != null) {
+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), this.fuelLevel);
+ BrewEvent event = new BrewEvent(CraftBlock.at(world, blockposition), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), tileentitybrewingstand.fuel);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
@@ -110,4 +118,4 @@
+ // CraftBukkit end
for (int i = 0; i < 3; ++i) {
this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i)));
nonnulllist.set(i, PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i)));

View File

@@ -10,19 +10,19 @@
+import org.bukkit.event.block.BlockCookEvent;
+// CraftBukkit end
+
public class TileEntityCampfire extends TileEntity implements Clearable, ITickable {
public class TileEntityCampfire extends TileEntity implements Clearable {
private final NonNullList<ItemStack> items;
@@ -72,6 +78,20 @@
private static final int BURN_COOL_SPEED = 2;
@@ -52,6 +58,20 @@
return recipecampfire.a(inventorysubcontainer);
}).orElse(itemstack);
BlockPosition blockposition = this.getPosition();
+ // CraftBukkit start - fire BlockCookEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.world, this.position), source, result);
+ this.world.getServer().getPluginManager().callEvent(blockCookEvent);
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result);
+ world.getServer().getPluginManager().callEvent(blockCookEvent);
+
+ if (blockCookEvent.isCancelled()) {
+ return;
@@ -31,6 +31,6 @@
+ result = blockCookEvent.getResult();
+ itemstack1 = CraftItemStack.asNMSCopy(result);
+ // CraftBukkit end
InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
this.items.set(i, ItemStack.b);
this.k();
InventoryUtils.dropItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
world.notify(blockposition, iblockdata, iblockdata, 3);

View File

@@ -1,26 +1,25 @@
--- a/net/minecraft/world/level/block/entity/TileEntityChest.java
+++ b/net/minecraft/world/level/block/entity/TileEntityChest.java
@@ -27,6 +27,12 @@
@@ -24,6 +24,12 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.properties.BlockPropertyChestType;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.world.level.block.Blocks;
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityChest extends TileEntityLootable implements ITickable {
public class TileEntityChest extends TileEntityLootable implements LidBlockEntity {
private NonNullList<ItemStack> items;
@@ -35,6 +41,37 @@
public int viewingCount;
private int j;
private static final int EVENT_SET_OPEN_COUNT = 1;
@@ -31,6 +37,36 @@
public final ContainerOpenersCounter openersCounter;
private final ChestLidController chestLidController;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+ public boolean opened;
+
+ public List<ItemStack> getContents() {
+ return this.items;
@@ -48,75 +47,12 @@
+ }
+ // CraftBukkit end
+
protected TileEntityChest(TileEntityTypes<?> tileentitytypes) {
super(tileentitytypes);
this.items = NonNullList.a(27, ItemStack.b);
@@ -85,6 +122,13 @@
this.b = this.a;
float f = 0.1F;
protected TileEntityChest(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.a(27, ItemStack.EMPTY);
@@ -200,4 +236,11 @@
+ // CraftBukkit start - If chest is forced open by API, remove a viewer due to playBlockAction() call and don't tick to prevent sound effects.
+ if (opened) {
+ this.viewingCount--;
+ return;
+ }
+ // CraftBukkit end
+
if (this.viewingCount > 0 && this.a == 0.0F) {
this.playOpenSound(SoundEffects.BLOCK_CHEST_OPEN);
}
@@ -179,8 +223,20 @@
if (this.viewingCount < 0) {
this.viewingCount = 0;
}
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
++this.viewingCount;
+ if (this.world == null) return; // CraftBukkit
+
+ // CraftBukkit start - Call redstone event
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
this.onOpen();
}
@@ -189,7 +245,18 @@
@Override
public void closeContainer(EntityHuman entityhuman) {
if (!entityhuman.isSpectator()) {
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
--this.viewingCount;
+
+ // CraftBukkit start - Call redstone event
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
this.onOpen();
}
@@ -199,7 +266,7 @@
Block block = this.getBlock().getBlock();
if (block instanceof BlockChest) {
- this.world.playBlockAction(this.position, block, 1, this.viewingCount);
+ if (!opened) this.world.playBlockAction(this.position, block, 1, this.viewingCount); // CraftBukkit
this.world.applyPhysics(this.position, block);
}
@@ -240,4 +307,11 @@
protected Container createContainer(int i, PlayerInventory playerinventory) {
return ContainerChest.a(i, playerinventory, this);
world.playBlockAction(blockposition, block, 1, j);
}
+
+ // CraftBukkit start

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCommand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCommand.java
@@ -24,6 +24,13 @@
private boolean c;
private boolean g;
private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() {
private boolean conditionMet;
private boolean sendToClient;
private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() {
+ // CraftBukkit start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {

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