SPIGOT-4192: Fix cancelling dispensers removing water sources

This commit is contained in:
md_5 2018-07-31 09:21:21 +10:00
parent 03c1273b59
commit c79e28e627

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java
@@ -8,6 +8,15 @@
@@ -8,6 +8,16 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -9,6 +9,7 @@
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+import org.bukkit.event.block.BlockDispenseEvent;
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
@ -16,7 +17,7 @@
public class DispenserRegistry {
public static final PrintStream a = System.out;
@@ -70,7 +79,7 @@
@@ -70,7 +80,7 @@
BlockDispenser.a((IMaterial) Items.SPLASH_POTION, new IDispenseBehavior() {
public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) {
return (new DispenseBehaviorProjectile() {
@ -25,7 +26,7 @@
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
}
@@ -87,7 +96,7 @@
@@ -87,7 +97,7 @@
BlockDispenser.a((IMaterial) Items.LINGERING_POTION, new IDispenseBehavior() {
public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) {
return (new DispenseBehaviorProjectile() {
@ -34,7 +35,7 @@
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
}
@@ -106,11 +115,39 @@
@@ -106,11 +116,39 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING);
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag());
@ -75,7 +76,7 @@
return itemstack;
}
};
@@ -128,10 +165,39 @@
@@ -128,10 +166,39 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
@ -117,7 +118,7 @@
return itemstack;
}
@@ -152,8 +218,38 @@
@@ -152,8 +219,38 @@
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
@ -158,7 +159,7 @@
return itemstack;
}
@@ -175,9 +271,52 @@
@@ -175,9 +272,52 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
World world = isourceblock.getWorld();
@ -212,7 +213,15 @@
} else {
return this.a.dispense(isourceblock, itemstack);
}
@@ -207,6 +346,30 @@
@@ -200,13 +340,39 @@
Block block = iblockdata.getBlock();
if (block instanceof IFluidSource) {
- FluidType fluidtype = ((IFluidSource) block).a(world, blockposition, iblockdata);
+ FluidType fluidtype = ((IFluidSource) block).a(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
if (!(fluidtype instanceof FluidTypeFlowing)) {
return super.a(isourceblock, itemstack);
} else {
Item item = fluidtype.b();
@ -238,12 +247,14 @@
+ return itemstack;
+ }
+ }
+
+ fluidtype = ((IFluidSource) block).a(world, blockposition, iblockdata); // From above
+ // CraftBukkit end
+
itemstack.subtract(1);
if (itemstack.isEmpty()) {
return new ItemStack(item);
@@ -227,11 +390,39 @@
@@ -227,11 +393,39 @@
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
@ -284,7 +295,7 @@
} else {
Block block = world.getType(blockposition).getBlock();
@@ -255,12 +446,55 @@
@@ -255,12 +449,55 @@
this.a = true;
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
@ -340,7 +351,7 @@
return itemstack;
}
@@ -269,11 +503,40 @@
@@ -269,11 +506,40 @@
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
@ -383,7 +394,7 @@
return itemstack;
}
}));
@@ -295,6 +558,30 @@
@@ -295,6 +561,30 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
@ -414,7 +425,7 @@
this.a = true;
if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) {
world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, Integer.valueOf(enumdirection.opposite().get2DRotationValue() * 4)), 3);
@@ -318,6 +605,30 @@
@@ -318,6 +608,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
@ -445,7 +456,7 @@
this.a = true;
if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) {
if (!world.isClientSide) {
@@ -379,6 +690,51 @@
@@ -379,6 +693,51 @@
}
d();
@ -497,7 +508,7 @@
}
}
}
@@ -387,7 +743,7 @@
@@ -387,7 +746,7 @@
LocaleLanguage localelanguage = LocaleLanguage.a();
registrymaterials.iterator().forEachRemaining((object) -> {
@ -506,7 +517,7 @@
if (!localelanguage.b(s)) {
DispenserRegistry.c.warn("Missing translation for {}: {} (key: \'{}\')", s1, registrymaterials.b(object), s);
@@ -481,6 +837,30 @@
@@ -481,6 +840,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
@ -537,7 +548,7 @@
this.a = ((ItemBlock) item).a((BlockActionContext) (new DispenserRegistry.b(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS;
if (this.a) {
itemstack.subtract(1);
@@ -534,12 +914,40 @@
@@ -534,12 +917,40 @@
d3 = 0.0D;
}