3
0

Fix DragonAPI incompatibility (close #99)

This commit is contained in:
Prototik 2015-07-11 01:37:58 +07:00
parent 801f84d461
commit 664666ef68
2 changed files with 11 additions and 27 deletions

View File

@ -17,13 +17,13 @@
if (!this.canPlaceBlockAt(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - invalid place location
+ if (!CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.air).isCancelled()) { p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); } // CraftBukkit - invalid place location
}
if (!flag && p_149674_1_.isRaining() && (p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ - 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ + 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ - 1) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ + 1)))
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - extinguished by rain
+ if (!CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.air).isCancelled()) { p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); } // CraftBukkit - extinguished by rain
}
else
{
@ -32,17 +32,17 @@
if (!World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) || l > 3)
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - burn out of inflammable block
+ if (!CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.air).isCancelled()) { p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); } // CraftBukkit - burn out of inflammable block
}
}
else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0)
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - burn out
+ if (!CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.air).isCancelled()) { p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); } // CraftBukkit - burn out
}
else
{
@@ -186,7 +191,29 @@
@@ -186,7 +191,30 @@
k2 = 15;
}
@ -65,6 +65,7 @@
+
+ if (!spreadEvent.isCancelled())
+ {
+ p_149674_1_.setBlock(i1, k1, j1, ((org.bukkit.craftbukkit.block.CraftBlock)blockState.getBlock()).getNMSBlock(), blockState.getRawData(), 3); // KCauldron - DragonAPI uses this call
+ blockState.update(true);
+ }
+ }
@ -73,7 +74,7 @@
}
}
}
@@ -216,7 +243,18 @@
@@ -216,7 +244,18 @@
if (p_149841_6_.nextInt(p_149841_5_) < j1)
{
boolean flag = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt;
@ -92,12 +93,12 @@
if (p_149841_6_.nextInt(p_149841_7_ + 10) < 5 && !p_149841_1_.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_))
{
int k1 = p_149841_7_ + p_149841_6_.nextInt(5) / 4;
@@ -297,17 +335,17 @@
@@ -297,17 +336,17 @@
{
if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_) && !this.canNeighborBurn(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_))
{
- p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
+ fireExtinguished(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); // CraftBukkit - fuel block gone
+ if (!CraftEventFactory.callBlockFadeEvent(p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_), Blocks.air).isCancelled()) { p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); } // CraftBukkit - fuel block gone
}
}
@ -109,24 +110,7 @@
if (!World.doesBlockHaveSolidTopSurface(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_) && !this.canNeighborBurn(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_))
{
- p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_);
+ fireExtinguished(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); // CraftBukkit - fuel block broke
+ if (!CraftEventFactory.callBlockFadeEvent(p_149726_1_.getWorld().getBlockAt(p_149726_2_, p_149726_3_, p_149726_4_), Blocks.air).isCancelled()) { p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_); } // CraftBukkit - fuel block broke
}
else
{
@@ -398,6 +436,16 @@
}
}
+ // CraftBukkit start
+ private void fireExtinguished(World world, int x, int y, int z)
+ {
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(x, y, z), Blocks.air).isCancelled())
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ }
+ // CraftBukkit end
+
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{

View File

@ -59,7 +59,7 @@ public class CraftBlock implements Block {
this.chunk = chunk;
}
private net.minecraft.block.Block getNMSBlock() {
public net.minecraft.block.Block getNMSBlock() {
return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS
}