Browse Source

Bukkit Explosion Event takes precedence over Forge Explosion Event

master
Robotia 9 years ago
parent
commit
e35a0ade12
  1. 140
      patches/net/minecraft/world/World.java.patch

140
patches/net/minecraft/world/World.java.patch

@ -36,7 +36,7 @@
import cpw.mods.fml.common.FMLLog;
import com.google.common.collect.ImmutableSetMultimap;
@@ -70,6 +73,55 @@
@@ -70,6 +73,56 @@
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraft.entity.EnumCreatureType;
@ -66,6 +66,7 @@
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+import org.bukkit.event.entity.*;
+import org.bukkit.event.weather.WeatherChangeEvent;
+import org.bukkit.event.weather.ThunderChangeEvent;
+
@ -92,7 +93,7 @@
public abstract class World implements IBlockAccess
{
/**
@@ -83,15 +135,14 @@
@@ -83,15 +136,14 @@
public boolean scheduledUpdatesAreImmediate;
public List loadedEntityList = new ArrayList();
@ -110,7 +111,7 @@
protected final int DIST_HASH_MAGIC = 1013904223;
public float prevRainingStrength;
public float rainingStrength;
@@ -100,26 +151,88 @@
@@ -100,26 +152,88 @@
public int lastLightningBolt;
public EnumDifficulty difficultySetting;
public Random rand = new Random();
@ -206,7 +207,7 @@
private static final String __OBFID = "CL_00000140";
public boolean restoringBlockSnapshots = false;
public boolean captureBlockSnapshots = false;
@@ -166,6 +279,27 @@
@@ -166,6 +280,27 @@
return this.provider.worldChunkMgr;
}
@ -234,7 +235,7 @@
@SideOnly(Side.CLIENT)
public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_)
{
@@ -179,6 +313,12 @@
@@ -179,6 +314,12 @@
this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_);
this.provider = p_i45368_3_;
perWorldStorage = new MapStorage((ISaveHandler)null);
@ -247,7 +248,7 @@
}
// Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
@@ -207,8 +347,175 @@
@@ -207,8 +348,175 @@
this.calculateInitialWeather();
}
@ -423,7 +424,7 @@
this.ambientTickCountdown = this.rand.nextInt(12000);
this.spawnHostileMobs = true;
this.spawnPeacefulMobs = true;
@@ -216,7 +523,6 @@
@@ -216,7 +524,6 @@
this.lightUpdateBlockList = new int[32768];
this.saveHandler = p_i45369_1_;
this.theProfiler = p_i45369_5_;
@ -431,7 +432,7 @@
this.worldInfo = p_i45369_1_.loadWorldInfo();
if (p_i45369_4_ != null)
@@ -235,13 +541,26 @@
@@ -235,13 +542,26 @@
if (this.worldInfo == null)
{
this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_);
@ -458,7 +459,7 @@
this.chunkProvider = this.createChunkProvider();
if (this instanceof WorldServer)
@@ -294,6 +613,7 @@
@@ -294,6 +614,7 @@
this.calculateInitialSkylight();
this.calculateInitialWeather();
}
@ -466,7 +467,7 @@
private static MapStorage s_mapStorage;
private static ISaveHandler s_savehandler;
@@ -336,6 +656,18 @@
@@ -336,6 +657,18 @@
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
{
@ -485,7 +486,7 @@
if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256)
{
Chunk chunk = null;
@@ -404,7 +736,7 @@
@@ -404,7 +737,7 @@
}
}
@ -494,7 +495,7 @@
{
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
}
@@ -421,6 +753,27 @@
@@ -421,6 +754,27 @@
public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_)
{
@ -522,7 +523,7 @@
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
{
if (p_147465_2_ < 0)
@@ -448,8 +801,22 @@
@@ -448,8 +802,22 @@
this.capturedBlockSnapshots.add(blockSnapshot);
}
@ -545,7 +546,7 @@
if (!flag && blockSnapshot != null)
{
this.capturedBlockSnapshots.remove(blockSnapshot);
@@ -460,6 +827,7 @@
@@ -460,6 +828,7 @@
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
this.theProfiler.endSection();
@ -553,7 +554,7 @@
if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
// Modularize client and physic updates
@@ -496,6 +864,19 @@
@@ -496,6 +865,19 @@
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
{
@ -573,7 +574,7 @@
if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000)
{
if (p_72805_2_ < 0)
@@ -511,7 +892,7 @@
@@ -511,7 +893,7 @@
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
p_72805_1_ &= 15;
p_72805_3_ &= 15;
@ -582,7 +583,7 @@
}
}
else
@@ -610,6 +991,12 @@
@@ -610,6 +992,12 @@
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
{
@ -595,7 +596,7 @@
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
}
@@ -694,6 +1081,21 @@
@@ -694,6 +1082,21 @@
try
{
@ -617,7 +618,7 @@
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
}
catch (Throwable throwable1)
@@ -1307,6 +1709,13 @@
@@ -1307,6 +1710,13 @@
public boolean spawnEntityInWorld(Entity p_72838_1_)
{
@ -631,7 +632,7 @@
// do not drop any items while restoring blocksnapshots. Prevents dupes
if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
@@ -1319,23 +1728,99 @@
@@ -1319,23 +1729,99 @@
flag = true;
}
@ -733,7 +734,7 @@
return true;
}
}
@@ -1346,6 +1831,8 @@
@@ -1346,6 +1832,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
}
@ -742,7 +743,7 @@
}
public void onEntityRemoved(Entity p_72847_1_)
@@ -1354,6 +1841,8 @@
@@ -1354,6 +1842,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
}
@ -751,7 +752,7 @@
}
public void removeEntity(Entity p_72900_1_)
@@ -1397,6 +1886,19 @@
@@ -1397,6 +1887,19 @@
}
this.loadedEntityList.remove(p_72973_1_);
@ -771,7 +772,7 @@
this.onEntityRemoved(p_72973_1_);
}
@@ -1408,40 +1910,58 @@
@@ -1408,40 +1911,58 @@
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
{
this.collidingBoundingBoxes.clear();
@ -803,6 +804,10 @@
+ }
- if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000)
- {
- block = this.getBlock(k1, i2, l1);
- }
- else
+ int cz = chunkz << 4;
+ Chunk chunk = this.getChunkFromChunkCoords(chunkx, chunkz);
+ // Compute ranges within chunk
@ -818,10 +823,6 @@
+ {
+ for (int y = ystart; y < l; y++)
{
- block = this.getBlock(k1, i2, l1);
- }
- else
- {
- block = Blocks.stone;
- }
+ Block block = chunk.getBlock(x - cx, y, z - cz);
@ -844,7 +845,7 @@
for (int j2 = 0; j2 < list.size(); ++j2)
{
@@ -1797,11 +2317,22 @@
@@ -1797,11 +2318,22 @@
Entity entity;
CrashReport crashreport;
CrashReportCategory crashreportcategory;
@ -867,7 +868,7 @@
try
{
++entity.ticksExisted;
@@ -1862,10 +2393,14 @@
@@ -1862,10 +2394,14 @@
this.unloadedEntityList.clear();
this.theProfiler.endStartSection("regular");
@ -885,7 +886,7 @@
if (entity.ridingEntity != null)
{
@@ -1884,7 +2419,9 @@
@@ -1884,7 +2420,9 @@
{
try
{
@ -895,7 +896,7 @@
}
catch (Throwable throwable1)
{
@@ -1916,30 +2453,69 @@
@@ -1916,30 +2454,80 @@
{
this.getChunkFromChunkCoords(j, l).removeEntity(entity);
}
@ -940,8 +941,7 @@
+ this.field_147483_b.clear();
+ }
+ // CraftBukkit end
- if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
+
+ int tilesThisCycle = 0;
+ for (tileLimiter.initTick(); tilesThisCycle < loadedTileEntityList.size() && (tilesThisCycle % 10 == 0 || tileLimiter.shouldContinue()); tileTickPosition++, tilesThisCycle++) {
+ tileTickPosition = (tileTickPosition < loadedTileEntityList.size()) ? tileTickPosition : 0;
@ -949,7 +949,7 @@
+
+ // Spigot start
+ if (tileentity == null)
{
+ {
+ getServer().getLogger().severe("Cauldron has detected a null entity and has removed it, preventing a crash");
+ tilesThisCycle--;
+ this.loadedTileEntityList.remove(tileTickPosition--);
@ -966,10 +966,11 @@
+ }
+ continue;
+ }
+
- if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
+ if (tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this)
+ && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
+ {
{
try
{
+ tileentity.tickTimer.startTiming(); // Spigot
@ -983,7 +984,7 @@
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory);
@@ -1955,23 +2531,13 @@
@@ -1955,23 +2543,13 @@
}
}
}
@ -1012,7 +1013,7 @@
if (!this.field_147483_b.isEmpty())
{
for (Object tile : field_147483_b)
@@ -1981,6 +2547,7 @@
@@ -1981,6 +2559,7 @@
this.loadedTileEntityList.removeAll(this.field_147483_b);
this.field_147483_b.clear();
}
@ -1020,7 +1021,7 @@
this.field_147481_N = false;
@@ -2016,17 +2583,23 @@
@@ -2016,17 +2595,23 @@
this.addedTileEntityList.clear();
}
@ -1047,7 +1048,7 @@
}
public void updateEntity(Entity p_72870_1_)
@@ -2036,21 +2609,36 @@
@@ -2036,21 +2621,36 @@
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
@ -1086,7 +1087,7 @@
p_72866_1_.lastTickPosX = p_72866_1_.posX;
p_72866_1_.lastTickPosY = p_72866_1_.posY;
p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
@@ -2134,6 +2722,7 @@
@@ -2134,6 +2734,7 @@
p_72866_1_.riddenByEntity = null;
}
}
@ -1094,7 +1095,18 @@
}
}
@@ -2570,7 +3159,7 @@
@@ -2405,6 +3006,10 @@
public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
+ org.bukkit.craftbukkit.CraftServer server = this.getServer();
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent( org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, p_72885_1_),p_72885_8_,p_72885_10_);
+ server.getPluginManager().callEvent(event);
+ if(event.isCancelled())return null;
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_);
explosion.isFlaming = p_72885_9_;
explosion.isSmoking = p_72885_10_;
@@ -2570,7 +3175,7 @@
return;
}
@ -1103,7 +1115,7 @@
{
if (this.field_147481_N)
{
@@ -2718,7 +3307,15 @@
@@ -2718,7 +3323,15 @@
if (i <= 0)
{
@ -1120,7 +1132,7 @@
}
}
@@ -2754,7 +3351,15 @@
@@ -2754,7 +3367,15 @@
if (j <= 0)
{
@ -1137,7 +1149,7 @@
}
}
@@ -2777,8 +3382,41 @@
@@ -2777,8 +3398,41 @@
protected void setActivePlayerChunksAndCheckLight()
{
this.activeChunkSet.clear();
@ -1180,13 +1192,15 @@
int i;
EntityPlayer entityplayer;
int j;
@@ -2788,17 +3426,28 @@
@@ -2788,17 +3442,28 @@
for (i = 0; i < this.playerEntities.size(); ++i)
{
entityplayer = (EntityPlayer)this.playerEntities.get(i);
- j = MathHelper.floor_double(entityplayer.posX / 16.0D);
- k = MathHelper.floor_double(entityplayer.posZ / 16.0D);
- l = this.func_152379_p();
-
- for (int i1 = -l; i1 <= l; ++i1)
+ int chunkX = MathHelper.floor_double(entityplayer.posX / 16.0D);
+ int chunkZ = MathHelper.floor_double(entityplayer.posZ / 16.0D);
+ // Spigot start - Always update the chunk the player is on
@ -1194,8 +1208,7 @@
+ int existingPlayers = Math.max(0, activeChunkSet_CB.get(key)); //filter out -1's
+ activeChunkSet_CB.put(key, (short) (existingPlayers + 1));
+ activeChunkSet.add(new ChunkCoordIntPair(chunkX, chunkZ)); // Cauldron - vanilla compatibility
- for (int i1 = -l; i1 <= l; ++i1)
+
+ // Check and see if we update the chunks surrounding the player this tick
+ for (int chunk = 0; chunk < chunksPerPlayer; chunk++)
{
@ -1215,7 +1228,7 @@
}
this.theProfiler.endSection();
@@ -2810,7 +3459,7 @@
@@ -2810,7 +3475,7 @@
this.theProfiler.startSection("playerCheckLight");
@ -1224,7 +1237,7 @@
{
i = this.rand.nextInt(this.playerEntities.size());
entityplayer = (EntityPlayer)this.playerEntities.get(i);
@@ -3034,9 +3683,9 @@
@@ -3034,9 +3699,9 @@
}
}
@ -1236,7 +1249,7 @@
{
return false;
}
@@ -3166,6 +3815,16 @@
@@ -3166,6 +3831,16 @@
}
}
@ -1253,14 +1266,14 @@
this.theProfiler.endSection();
return true;
}
@@ -3284,8 +3943,21 @@
@@ -3284,8 +3959,21 @@
{
Entity entity = (Entity)this.loadedEntityList.get(j);
- if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass()))
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
+ if (entity instanceof EntityLiving)
{
+ {
+ EntityLiving entityliving = (EntityLiving) entity;
+
+ if (entityliving.canDespawn_CB() && entityliving.isNoDespawnRequired())
@ -1270,13 +1283,13 @@
+ }
+
+ if (p_72907_1_.isAssignableFrom(entity.getClass()))
+ {
{
+ // if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass()))
+ // CraftBukkit end
++i;
}
}
@@ -3298,6 +3970,7 @@
@@ -3298,6 +3986,7 @@
for (int i = 0; i < p_72868_1_.size(); ++i)
{
Entity entity = (Entity)p_72868_1_.get(i);
@ -1284,7 +1297,7 @@
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
{
loadedEntityList.add(entity);
@@ -3314,8 +3987,17 @@
@@ -3314,8 +4003,17 @@
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
{
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
@ -1303,7 +1316,7 @@
}
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
@@ -3464,6 +4146,12 @@
@@ -3464,6 +4162,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1316,7 +1329,7 @@
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
@@ -3489,7 +4177,12 @@
@@ -3489,7 +4193,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1330,7 +1343,7 @@
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
{
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
@@ -3660,6 +4353,18 @@
@@ -3660,6 +4369,18 @@
public void updateAllPlayersSleepingFlag() {}
@ -1349,7 +1362,7 @@
public float getWeightedThunderStrength(float p_72819_1_)
{
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
@@ -3932,8 +4637,8 @@
@@ -3932,8 +4653,8 @@
*/
public void addTileEntity(TileEntity entity)
{
@ -1360,10 +1373,11 @@
{
dest.add(entity);
}
@@ -4029,4 +4734,122 @@
@@ -4029,4 +4750,122 @@
}
return count;
}
-}
+
+ // Cauldron start
+ public boolean isEmpty(int x, int y, int z) // Required until SS inheritance bug is fixed
@ -1482,4 +1496,4 @@
+ });
+ return true;
+ }
}
+}

Loading…
Cancel
Save