3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

SPIGOT-4720: Remove now unnecessary tile fixer

Dieser Commit ist enthalten in:
md_5 2019-04-24 10:28:36 +10:00
Ursprung 3ddaf665e2
Commit 331c43929e

Datei anzeigen

@ -57,131 +57,15 @@
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
return block == null || block.getBlockData().isAir();
}, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b);
@@ -85,7 +119,123 @@
@@ -85,6 +119,7 @@
}
this.mobSpawnerTrader = this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null;
+ this.getServer().addWorld(this.getWorld()); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ @Override
+ public TileEntity getTileEntity(BlockPosition pos) {
+ TileEntity result = super.getTileEntity(pos);
+ Block type = getType(pos).getBlock();
+
+ if (type == Blocks.CHEST) {
+ if (!(result instanceof TileEntityChest)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.FURNACE) {
+ if (!(result instanceof TileEntityFurnace)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.DROPPER) {
+ if (!(result instanceof TileEntityDropper)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.DISPENSER) {
+ if (!(result instanceof TileEntityDispenser)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.JUKEBOX) {
+ if (!(result instanceof TileEntityJukeBox)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.SPAWNER) {
+ if (!(result instanceof TileEntityMobSpawner)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (TagsBlock.SIGNS.isTagged(type)) {
+ if (!(result instanceof TileEntitySign)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.ENDER_CHEST) {
+ if (!(result instanceof TileEntityEnderChest)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.BREWING_STAND) {
+ if (!(result instanceof TileEntityBrewingStand)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.BEACON) {
+ if (!(result instanceof TileEntityBeacon)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.HOPPER) {
+ if (!(result instanceof TileEntityHopper)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.ENCHANTING_TABLE) {
+ if (!(result instanceof TileEntityEnchantTable)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.END_PORTAL) {
+ if (!(result instanceof TileEntityEnderPortal)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type instanceof BlockSkullAbstract) {
+ if (!(result instanceof TileEntitySkull)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.DAYLIGHT_DETECTOR) {
+ if (!(result instanceof TileEntityLightDetector)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.COMPARATOR) {
+ if (!(result instanceof TileEntityComparator)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ }else if (type instanceof BlockBannerAbstract) {
+ if (!(result instanceof TileEntityBanner)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.STRUCTURE_BLOCK) {
+ if (!(result instanceof TileEntityStructure)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.END_GATEWAY) {
+ if (!(result instanceof TileEntityEndGateway)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.COMMAND_BLOCK) {
+ if (!(result instanceof TileEntityCommand)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.STRUCTURE_BLOCK) {
+ if (!(result instanceof TileEntityStructure)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type instanceof BlockBed) {
+ if (!(result instanceof TileEntityBed)) {
+ result = fixTileEntity(pos, type, result);
+ }
+ }
+
+ return result;
+ }
+
+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) {
+ this.getServer().getLogger().log(Level.SEVERE, "Block at {0},{1},{2} is {3} but has {4}" + ". "
+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found});
+
+ if (type instanceof ITileEntity) {
+ TileEntity replacement = ((ITileEntity) type).createTile(this);
+ replacement.world = this;
+ this.setTileEntity(pos, replacement);
+ return replacement;
+ } else {
+ this.getServer().getLogger().severe("Don't know how to fix for this type... Can't do anything! :(");
+ return found;
+ }
}
+ // CraftBukkit end
public void doTick(BooleanSupplier booleansupplier) {
GameProfilerFiller gameprofilerfiller = this.getMethodProfiler();
@@ -161,6 +311,7 @@
@@ -161,6 +196,7 @@
this.m = MathHelper.a(this.m, 0.0F, 1.0F);
}
@ -189,7 +73,7 @@
if (this.l != this.m) {
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.m)), this.worldProvider.getDimensionManager());
}
@@ -179,13 +330,34 @@
@@ -179,13 +215,34 @@
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.m));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.o));
}
@ -225,7 +109,7 @@
})) {
this.D = false;
if (this.getGameRules().getBoolean("doDaylightCycle")) {
@@ -226,7 +398,7 @@
@@ -226,7 +283,7 @@
this.ae();
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
@ -234,7 +118,7 @@
if (flag3) {
this.resetEmptyTime();
@@ -240,6 +412,11 @@
@@ -240,6 +297,11 @@
for (i = 0; i < this.globalEntityList.size(); ++i) {
entity = (Entity) this.globalEntityList.get(i);
@ -246,7 +130,7 @@
this.a((entity1) -> {
++entity1.ticksLived;
entity1.tick();
@@ -258,6 +435,7 @@
@@ -258,6 +320,7 @@
Entity entity1 = (Entity) entry.getValue();
Entity entity2 = entity1.getVehicle();
@ -254,7 +138,7 @@
if (!this.server.getSpawnAnimals() && (entity1 instanceof EntityAnimal || entity1 instanceof EntityWaterAnimal)) {
entity1.die();
}
@@ -265,6 +443,7 @@
@@ -265,6 +328,7 @@
if (!this.server.getSpawnNPCs() && entity1 instanceof NPC) {
entity1.die();
}
@ -262,7 +146,7 @@
if (entity2 != null) {
if (!entity2.dead && entity2.w(entity1)) {
@@ -325,10 +504,10 @@
@@ -325,10 +389,10 @@
entityhorseskeleton.r(true);
entityhorseskeleton.setAgeRaw(0);
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -275,7 +159,7 @@
}
}
@@ -339,11 +518,11 @@
@@ -339,11 +403,11 @@
BiomeBase biomebase = this.getBiome(blockposition);
if (biomebase.a((IWorldReader) this, blockposition1)) {
@ -289,7 +173,7 @@
}
if (flag && this.getBiome(blockposition1).b() == BiomeBase.Precipitation.RAIN) {
@@ -390,7 +569,7 @@
@@ -390,7 +454,7 @@
protected BlockPosition a(BlockPosition blockposition) {
BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D);
@ -298,7 +182,7 @@
return entityliving != null && entityliving.isAlive() && this.f(entityliving.getChunkCoordinates());
});
@@ -421,7 +600,7 @@
@@ -421,7 +485,7 @@
if (entityplayer.isSpectator()) {
++i;
@ -307,7 +191,7 @@
++j;
}
}
@@ -437,10 +616,22 @@
@@ -437,10 +501,22 @@
}
private void clearWeather() {
@ -332,7 +216,7 @@
}
public void resetEmptyTime() {
@@ -478,6 +669,7 @@
@@ -478,6 +554,7 @@
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType()).toString();
});
entity.tick();
@ -340,7 +224,7 @@
this.getMethodProfiler().exit();
}
@@ -563,6 +755,22 @@
@@ -563,6 +640,22 @@
BlockPosition blockposition = worldchunkmanager.a(0, 0, 256, list, random);
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
@ -363,7 +247,7 @@
if (blockposition == null) {
WorldServer.v.warn("Unable to find spawn biome");
}
@@ -638,6 +846,7 @@
@@ -638,6 +731,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
if (!flag1) {
@ -371,7 +255,7 @@
if (iprogressupdate != null) {
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
}
@@ -716,8 +925,16 @@
@@ -716,8 +810,16 @@
while (objectiterator.hasNext()) {
Entity entity = (Entity) objectiterator.next();
@ -389,7 +273,7 @@
EnumCreatureType enumcreaturetype = entity.getEntityType().d();
if (enumcreaturetype != EnumCreatureType.MISC) {
@@ -733,11 +950,24 @@
@@ -733,11 +835,24 @@
@Override
public boolean addEntity(Entity entity) {
@ -416,7 +300,7 @@
}
public void addEntityTeleport(Entity entity) {
@@ -787,13 +1017,18 @@
@@ -787,13 +902,18 @@
this.registerEntity(entityplayer);
}
@ -437,7 +321,7 @@
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX / 16.0D), MathHelper.floor(entity.locZ / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
if (!(ichunkaccess instanceof Chunk)) {
@@ -821,7 +1056,7 @@
@@ -821,7 +941,7 @@
if (entity1 == null) {
return false;
} else {
@ -446,7 +330,7 @@
return true;
}
}
@@ -899,6 +1134,7 @@
@@ -899,6 +1019,7 @@
if (entity instanceof EntityInsentient) {
this.I.add(((EntityInsentient) entity).getNavigation());
}
@ -454,7 +338,7 @@
}
}
@@ -929,6 +1165,18 @@
@@ -929,6 +1050,18 @@
}
public void strikeLightning(EntityLightning entitylightning) {
@ -473,7 +357,7 @@
this.globalEntityList.add(entitylightning);
this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning));
}
@@ -937,6 +1185,12 @@
@@ -937,6 +1070,12 @@
public void a(int i, BlockPosition blockposition, int j) {
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
@ -486,7 +370,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -945,6 +1199,12 @@
@@ -945,6 +1084,12 @@
double d1 = (double) blockposition.getY() - entityplayer.locY;
double d2 = (double) blockposition.getZ() - entityplayer.locZ;
@ -499,7 +383,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -955,12 +1215,14 @@
@@ -955,12 +1100,14 @@
@Override
public void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
@ -516,7 +400,7 @@
}
@Override
@@ -970,7 +1232,8 @@
@@ -970,7 +1117,8 @@
@Override
public void a(@Nullable EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
@ -526,7 +410,7 @@
}
@Override
@@ -1005,6 +1268,14 @@
@@ -1005,6 +1153,14 @@
@Override
public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -541,7 +425,7 @@
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect);
if (damagesource != null) {
@@ -1013,6 +1284,8 @@
@@ -1013,6 +1169,8 @@
explosion.a();
explosion.a(false);
@ -550,7 +434,7 @@
if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearBlocks();
}
@@ -1040,7 +1313,8 @@
@@ -1040,7 +1198,8 @@
BlockActionData blockactiondata = (BlockActionData) this.J.removeFirst();
if (this.a(blockactiondata)) {
@ -560,7 +444,7 @@
}
}
@@ -1083,13 +1357,20 @@
@@ -1083,13 +1242,20 @@
}
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -583,7 +467,7 @@
++j;
}
}
@@ -1172,7 +1453,13 @@
@@ -1172,7 +1338,13 @@
@Override
public WorldMap a(String s) {
return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> {