diff --git a/patches/net/minecraft/entity/Entity.java.patch b/patches/net/minecraft/entity/Entity.java.patch index 28bf0c6..113c3ed 100644 --- a/patches/net/minecraft/entity/Entity.java.patch +++ b/patches/net/minecraft/entity/Entity.java.patch @@ -80,7 +80,7 @@ private static final String __OBFID = "CL_00001533"; /** Forge: Used to store custom data for each entity. */ private NBTTagCompound customEntityData; -@@ -135,7 +175,17 @@ +@@ -135,7 +175,16 @@ public ArrayList capturedDrops = new ArrayList(); private UUID persistentID; @@ -94,11 +94,10 @@ + // Spigot end protected HashMap extendedProperties; + public String spawnReason; // Cauldron - used to handle CraftBukkit's SpawnReason with CustomSpawners -+ public boolean markedForRemoval = false; public int getEntityId() { -@@ -159,7 +209,7 @@ +@@ -159,7 +208,7 @@ this.rand = new Random(); this.fireResistance = 1; this.firstUpdate = true; @@ -107,7 +106,7 @@ this.myEntitySize = Entity.EnumEntitySize.SIZE_2; this.worldObj = p_i1582_1_; this.setPosition(0.0D, 0.0D, 0.0D); -@@ -167,8 +217,15 @@ +@@ -167,8 +216,15 @@ if (p_i1582_1_ != null) { this.dimension = p_i1582_1_.provider.dimensionId; @@ -123,7 +122,7 @@ this.dataWatcher = new DataWatcher(this); this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); this.dataWatcher.addObject(1, Short.valueOf((short)300)); -@@ -277,6 +334,41 @@ +@@ -277,6 +333,41 @@ protected void setRotation(float p_70101_1_, float p_70101_2_) { @@ -165,7 +164,7 @@ this.rotationYaw = p_70101_1_ % 360.0F; this.rotationPitch = p_70101_2_ % 360.0F; } -@@ -343,7 +435,7 @@ +@@ -343,7 +434,7 @@ if (this.inPortal) { @@ -174,7 +173,7 @@ { if (this.ridingEntity == null && this.portalCounter++ >= i) { -@@ -457,7 +549,35 @@ +@@ -457,7 +548,35 @@ { if (!this.isImmuneToFire) { @@ -211,7 +210,7 @@ this.setFire(15); } } -@@ -492,6 +612,30 @@ +@@ -492,6 +611,30 @@ public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_) { @@ -242,7 +241,7 @@ if (this.noClip) { this.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_); -@@ -756,6 +900,34 @@ +@@ -756,6 +899,34 @@ d10 = this.posY - d4; d11 = this.posZ - d5; @@ -277,7 +276,7 @@ if (this.canTriggerWalking() && !flag && this.ridingEntity == null) { int j1 = MathHelper.floor_double(this.posX); -@@ -798,6 +970,8 @@ +@@ -798,6 +969,8 @@ } } @@ -286,7 +285,7 @@ try { this.func_145775_I(); -@@ -809,7 +983,8 @@ +@@ -809,7 +982,8 @@ this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } @@ -296,7 +295,7 @@ boolean flag2 = this.isWet(); if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D))) -@@ -820,8 +995,20 @@ +@@ -820,8 +994,20 @@ { ++this.fire; @@ -318,7 +317,7 @@ this.setFire(8); } } -@@ -839,6 +1026,8 @@ +@@ -839,6 +1025,8 @@ this.worldObj.theProfiler.endSection(); } @@ -327,7 +326,7 @@ } protected String getSwimSound() -@@ -867,7 +1056,18 @@ +@@ -867,7 +1055,18 @@ try { @@ -347,7 +346,7 @@ } catch (Throwable throwable) { -@@ -928,6 +1128,7 @@ +@@ -928,6 +1127,7 @@ return null; } @@ -355,7 +354,7 @@ protected void dealFireDamage(int p_70081_1_) { if (!this.isImmuneToFire) -@@ -935,7 +1136,16 @@ +@@ -935,7 +1135,16 @@ this.attackEntityFrom(DamageSource.inFire, (float)p_70081_1_); } } @@ -372,7 +371,7 @@ public final boolean isImmuneToFire() { return this.isImmuneToFire; -@@ -1184,6 +1394,8 @@ +@@ -1184,6 +1393,8 @@ public void onCollideWithPlayer(EntityPlayer p_70100_1_) {} @@ -381,7 +380,7 @@ public void applyEntityCollision(Entity p_70108_1_) { if (p_70108_1_.riddenByEntity != this && p_70108_1_.ridingEntity != this) -@@ -1310,6 +1522,20 @@ +@@ -1310,6 +1521,20 @@ { p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ})); p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); @@ -402,7 +401,7 @@ p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch})); p_70109_1_.setFloat("FallDistance", this.fallDistance); p_70109_1_.setShort("Fire", (short)this.fire); -@@ -1320,6 +1546,12 @@ +@@ -1320,6 +1545,12 @@ p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal); p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); @@ -415,7 +414,7 @@ if (customEntityData != null) { p_70109_1_.setTag("ForgeData", customEntityData); -@@ -1370,7 +1602,7 @@ +@@ -1370,7 +1601,7 @@ this.motionX = nbttaglist1.func_150309_d(0); this.motionY = nbttaglist1.func_150309_d(1); this.motionZ = nbttaglist1.func_150309_d(2); @@ -424,7 +423,7 @@ if (Math.abs(this.motionX) > 10.0D) { this.motionX = 0.0D; -@@ -1385,7 +1617,7 @@ +@@ -1385,7 +1616,7 @@ { this.motionZ = 0.0D; } @@ -433,7 +432,7 @@ this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0); this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1); this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2); -@@ -1436,6 +1668,76 @@ +@@ -1436,6 +1667,76 @@ { this.setPosition(this.posX, this.posY, this.posZ); } @@ -510,7 +509,7 @@ } catch (Throwable throwable) { -@@ -1653,6 +1955,31 @@ +@@ -1653,6 +1954,31 @@ public void mountEntity(Entity p_70078_1_) { @@ -542,7 +541,7 @@ this.entityRiderPitchDelta = 0.0D; this.entityRiderYawDelta = 0.0D; -@@ -1660,6 +1987,20 @@ +@@ -1660,6 +1986,20 @@ { if (this.ridingEntity != null) { @@ -563,7 +562,7 @@ this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch); this.ridingEntity.riddenByEntity = null; } -@@ -1668,22 +2009,61 @@ +@@ -1668,22 +2008,61 @@ } else { @@ -632,7 +631,7 @@ this.ridingEntity = p_70078_1_; p_70078_1_.riddenByEntity = this; } -@@ -1860,12 +2240,59 @@ +@@ -1860,12 +2239,59 @@ public void onStruckByLightning(EntityLightningBolt p_70077_1_) { @@ -694,7 +693,7 @@ } } -@@ -2038,36 +2465,62 @@ +@@ -2038,36 +2464,62 @@ { this.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); @@ -773,7 +772,7 @@ } this.isDead = true; -@@ -2077,7 +2530,6 @@ +@@ -2077,7 +2529,6 @@ this.worldObj.theProfiler.endSection(); } } @@ -781,7 +780,7 @@ public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) { return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, posX, posY + getEyeHeight(), posZ); -@@ -2474,4 +2926,14 @@ +@@ -2474,4 +2925,14 @@ } } } diff --git a/patches/net/minecraft/entity/EntityLivingBase.java.patch b/patches/net/minecraft/entity/EntityLivingBase.java.patch index 7792d5e..4c8d45c 100644 --- a/patches/net/minecraft/entity/EntityLivingBase.java.patch +++ b/patches/net/minecraft/entity/EntityLivingBase.java.patch @@ -1,9 +1,7 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java +++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java -@@ -1,13 +1,16 @@ - package net.minecraft.entity; +@@ -2,12 +2,14 @@ -+import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + @@ -17,7 +15,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.EnchantmentHelper; -@@ -50,14 +53,30 @@ +@@ -50,14 +52,30 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.ForgeHooks; @@ -50,7 +48,7 @@ private final ItemStack[] previousEquipment = new ItemStack[5]; public boolean isSwingInProgress; public int swingProgressInt; -@@ -83,7 +102,7 @@ +@@ -83,7 +101,7 @@ public float rotationYawHead; public float prevRotationYawHead; public float jumpMovementFactor = 0.02F; @@ -59,7 +57,7 @@ protected int recentlyHit; protected boolean dead; protected int entityAge; -@@ -93,7 +112,7 @@ +@@ -93,7 +111,7 @@ protected float field_70763_ax; protected float field_70741_aB; protected int scoreValue; @@ -68,7 +66,7 @@ protected boolean isJumping; public float moveStrafing; public float moveForward; -@@ -104,21 +123,26 @@ +@@ -104,21 +122,26 @@ protected double newPosZ; protected double newRotationYaw; protected double newRotationPitch; @@ -98,7 +96,7 @@ this.preventEntitySpawning = true; this.field_70770_ap = (float)(Math.random() + 1.0D) * 0.01F; this.setPosition(this.posX, this.posY, this.posZ); -@@ -173,7 +197,18 @@ +@@ -173,7 +196,18 @@ } else if (!this.worldObj.isRemote && this.fallDistance > 3.0F) { @@ -118,7 +116,7 @@ } block.onFallenUpon(this.worldObj, i, j, k, this, this.fallDistance); -@@ -234,7 +269,12 @@ +@@ -234,7 +268,12 @@ } else { @@ -132,7 +130,7 @@ } if (this.isEntityAlive() && this.isWet()) -@@ -299,6 +339,22 @@ +@@ -299,6 +338,22 @@ this.worldObj.theProfiler.endSection(); } @@ -155,7 +153,7 @@ public boolean isChild() { return false; -@@ -308,22 +364,21 @@ +@@ -308,22 +363,21 @@ { ++this.deathTime; @@ -187,7 +185,7 @@ this.setDead(); for (i = 0; i < 20; ++i) -@@ -485,6 +540,22 @@ +@@ -485,6 +539,22 @@ } } @@ -210,7 +208,7 @@ if (p_70037_1_.hasKey("HealF", 99)) { this.setHealth(p_70037_1_.getFloat("HealF")); -@@ -614,12 +685,14 @@ +@@ -614,12 +684,14 @@ public boolean isPotionActive(int p_82165_1_) { @@ -227,7 +225,7 @@ } public PotionEffect getActivePotionEffect(Potion p_70660_1_) -@@ -710,25 +783,66 @@ +@@ -710,25 +782,66 @@ } } @@ -295,7 +293,7 @@ this.dataWatcher.updateObject(6, Float.valueOf(MathHelper.clamp_float(p_70606_1_, 0.0F, this.getMaxHealth()))); } -@@ -757,7 +871,8 @@ +@@ -757,7 +870,8 @@ } else { @@ -305,7 +303,7 @@ { this.getEquipmentInSlot(4).damageItem((int)(p_70097_2_ * 4.0F + this.rand.nextFloat() * p_70097_2_ * 2.0F), this); p_70097_2_ *= 0.75F; -@@ -773,16 +888,27 @@ +@@ -773,16 +887,27 @@ return false; } @@ -336,7 +334,7 @@ this.hurtTime = this.maxHurtTime = 10; } -@@ -938,6 +1064,22 @@ +@@ -938,6 +1063,22 @@ if (!ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, recentlyHit > 0, j)) { @@ -359,7 +357,7 @@ for (EntityItem item : capturedDrops) { worldObj.spawnEntityInWorld(item); -@@ -1010,8 +1152,17 @@ +@@ -1010,8 +1151,17 @@ if (i > 0) { @@ -378,7 +376,7 @@ int j = MathHelper.floor_double(this.posX); int k = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); int l = MathHelper.floor_double(this.posZ); -@@ -1065,7 +1216,7 @@ +@@ -1065,7 +1215,7 @@ { int i = 25 - this.getTotalArmorValue(); float f1 = p_70655_2_ * (float)i; @@ -387,7 +385,7 @@ p_70655_2_ = f1 / 25.0F; } -@@ -1089,7 +1240,8 @@ +@@ -1089,7 +1239,8 @@ int j; float f1; @@ -397,7 +395,7 @@ { i = (this.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5; j = 25 - i; -@@ -1122,26 +1274,160 @@ +@@ -1122,26 +1273,161 @@ } } @@ -422,6 +420,7 @@ - p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F); - this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - p_70665_2_)); + final boolean human = this instanceof EntityPlayer; ++ float originalDamage = f; + // Cauldron start - apply forge damage hook + f = ForgeHooks.onLivingHurt(this, damagesource, f); + if (f <= 0) return true; @@ -513,7 +512,7 @@ + }; + float absorptionModifier = absorption.apply((double) f).floatValue(); + -+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, f, hardHatModifier, blockingModifier, ++ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, + armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); + if (event.isCancelled()) { diff --git a/patches/net/minecraft/entity/item/EntityItemFrame.java.patch b/patches/net/minecraft/entity/item/EntityItemFrame.java.patch index 3f12c3e..2edbf57 100644 --- a/patches/net/minecraft/entity/item/EntityItemFrame.java.patch +++ b/patches/net/minecraft/entity/item/EntityItemFrame.java.patch @@ -14,15 +14,6 @@ this.func_146065_b(p_70097_1_.getEntity(), false); this.setDisplayedItem((ItemStack)null); } -@@ -115,7 +122,7 @@ - if (p_110131_1_.getItem() == Items.filled_map) - { - MapData mapdata = ((ItemMap)p_110131_1_.getItem()).getMapData(p_110131_1_, this.worldObj); -- mapdata.playersVisibleOnMap.remove("frame-" + this.getEntityId()); -+ mapdata.playersVisibleOnMap.remove(java.util.UUID.nameUUIDFromBytes(("frame-" + this.getEntityId()).getBytes(org.apache.commons.codec.Charsets.US_ASCII))); - } - - p_110131_1_.setItemFrame((EntityItemFrame)null); @@ -203,4 +210,11 @@ return true; diff --git a/patches/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/net/minecraft/entity/player/EntityPlayer.java.patch index 74bc616..279978c 100644 --- a/patches/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/net/minecraft/entity/player/EntityPlayer.java.patch @@ -62,24 +62,6 @@ public int experienceLevel; public int experienceTotal; public float experience; -@@ -254,7 +281,7 @@ - --this.xpCooldown; - } - -- if (this.isPlayerSleeping()) -+ /*if (this.isPlayerSleeping()) KCauldron - moved into EntityPlayerMP - { - ++this.sleepTimer; - -@@ -283,7 +310,7 @@ - { - this.sleepTimer = 0; - } -- } -+ }*/ - - super.onUpdate(); - @@ -416,6 +443,42 @@ { this.updateItemUse(this.itemInUse, 16); @@ -503,15 +485,6 @@ if (p_70999_1_) { this.sleepTimer = 0; -@@ -1491,7 +1712,7 @@ - } - } - -- private boolean isInBed() -+ protected boolean isInBed() // KCauldron - private -> protected - { - return this.worldObj.getBlock(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ).isBed(worldObj, playerLocation.posX, playerLocation.posY, playerLocation.posZ, this); - } @@ -1606,11 +1827,13 @@ { this.spawnChunk = new ChunkCoordinates(p_71063_1_); diff --git a/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch b/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch index 505b884..2f72840 100644 --- a/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch +++ b/patches/net/minecraft/entity/player/EntityPlayerMP.java.patch @@ -190,46 +190,7 @@ iterator1.remove(); } } -@@ -286,6 +384,38 @@ - } - } - } -+ // KCauldron start -+ if (this.isPlayerSleeping()) -+ { -+ ++this.sleepTimer; -+ -+ if (this.sleepTimer > 100) -+ { -+ this.sleepTimer = 100; -+ } -+ -+ if (!this.worldObj.isRemote) -+ { -+ if (!this.isInBed()) -+ { -+ this.wakeUpPlayer(true, true, false); -+ } -+ else if (this.worldObj.isDaytime()) -+ { -+ this.wakeUpPlayer(false, true, true); -+ } -+ } -+ } -+ else if (this.sleepTimer > 0) -+ { -+ ++this.sleepTimer; -+ -+ if (this.sleepTimer >= 110) -+ { -+ this.sleepTimer = 0; -+ } -+ } -+ // KCauldron end - } - - public void onUpdateEntity() -@@ -309,9 +439,10 @@ +@@ -309,9 +407,10 @@ } } @@ -241,7 +202,7 @@ this.lastHealth = this.getHealth(); this.lastFoodLevel = this.foodStats.getFoodLevel(); this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; -@@ -320,16 +451,18 @@ +@@ -320,16 +419,18 @@ if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO) { this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount(); @@ -267,7 +228,7 @@ if (this.experienceTotal != this.lastExperience) { this.lastExperience = this.experienceTotal; -@@ -340,6 +473,20 @@ +@@ -340,6 +441,20 @@ { this.func_147098_j(); } @@ -288,7 +249,7 @@ } catch (Throwable throwable) { -@@ -402,34 +549,74 @@ +@@ -402,34 +517,74 @@ public void onDeath(DamageSource p_70645_1_) { @@ -372,7 +333,7 @@ score.func_96648_a(); } -@@ -495,7 +682,8 @@ +@@ -495,7 +650,8 @@ public boolean canAttackPlayer(EntityPlayer p_96122_1_) { @@ -382,7 +343,7 @@ } public void travelToDimension(int p_71027_1_) -@@ -526,7 +714,10 @@ +@@ -526,7 +682,10 @@ this.triggerAchievement(AchievementList.portal); } @@ -394,7 +355,7 @@ this.lastExperience = -1; this.lastHealth = -1.0F; this.lastFoodLevel = -1; -@@ -569,6 +760,11 @@ +@@ -569,6 +728,11 @@ public void wakeUpPlayer(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_) { @@ -406,7 +367,7 @@ if (this.isPlayerSleeping()) { this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 2)); -@@ -584,11 +780,27 @@ +@@ -584,11 +748,27 @@ public void mountEntity(Entity p_70078_1_) { @@ -437,7 +398,7 @@ protected void updateFallState(double p_70064_1_, boolean p_70064_3_) {} public void handleFalling(double p_71122_1_, boolean p_71122_3_) -@@ -610,29 +822,64 @@ +@@ -610,29 +790,64 @@ this.currentWindowId = this.currentWindowId % 100 + 1; } @@ -505,7 +466,7 @@ this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); } -@@ -644,71 +891,150 @@ +@@ -644,71 +859,150 @@ this.closeScreen(); } @@ -664,7 +625,7 @@ this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); -@@ -725,7 +1051,7 @@ +@@ -725,7 +1019,7 @@ merchantrecipelist.func_151391_a(packetbuffer); this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer)); } @@ -673,7 +634,7 @@ { logger.error("Couldn\'t send trade list", ioexception); } -@@ -738,6 +1064,17 @@ +@@ -738,6 +1032,17 @@ public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_) { @@ -691,7 +652,7 @@ if (this.openContainer != this.inventoryContainer) { this.closeScreen(); -@@ -745,7 +1082,7 @@ +@@ -745,7 +1050,7 @@ this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 11, p_110298_2_.getInventoryName(), p_110298_2_.getSizeInventory(), p_110298_2_.hasCustomInventoryName(), p_110298_1_.getEntityId())); @@ -700,7 +661,7 @@ this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); } -@@ -770,6 +1107,15 @@ +@@ -770,6 +1075,15 @@ { this.playerNetServerHandler.sendPacket(new S30PacketWindowItems(p_71110_1_.windowId, p_71110_2_)); this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack())); @@ -716,7 +677,7 @@ } public void sendProgressBarUpdate(Container p_71112_1_, int p_71112_2_, int p_71112_3_) -@@ -779,6 +1125,7 @@ +@@ -779,6 +1093,7 @@ public void closeScreen() { @@ -724,7 +685,7 @@ this.playerNetServerHandler.sendPacket(new S2EPacketCloseWindow(this.openContainer.windowId)); this.closeContainer(); } -@@ -853,8 +1200,19 @@ +@@ -853,8 +1168,19 @@ public void setPlayerHealthUpdated() { this.lastHealth = -1.0E8F; @@ -744,7 +705,7 @@ public void addChatComponentMessage(IChatComponent p_146105_1_) { this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); -@@ -1037,6 +1395,114 @@ +@@ -1037,6 +1363,114 @@ return this.field_143005_bX; } diff --git a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch index 9e3bea5..4574b47 100644 --- a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -24,7 +24,7 @@ import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.network.play.server.S2FPacketSetSlot; import net.minecraft.network.play.server.S32PacketConfirmTransaction; -@@ -81,19 +84,77 @@ +@@ -81,19 +84,75 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.IntHashMap; import net.minecraft.util.ReportedException; @@ -53,8 +53,6 @@ +import net.minecraft.init.Blocks; +import net.minecraft.network.play.server.S05PacketSpawnPosition; +import net.minecraft.network.play.server.S09PacketHeldItemChange; -+import net.minecraft.network.play.server.S0APacketUseBed; -+import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S33PacketUpdateSign; +import net.minecraft.util.MathHelper; @@ -104,7 +102,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer { private static final Logger logger = LogManager.getLogger(); -@@ -107,13 +168,12 @@ +@@ -107,13 +166,12 @@ private long field_147379_i; private static Random field_147376_j = new Random(); private long field_147377_k; @@ -122,7 +120,7 @@ private static final String __OBFID = "CL_00001452"; public NetHandlerPlayServer(MinecraftServer p_i1530_1_, NetworkManager p_i1530_2_, EntityPlayerMP p_i1530_3_) -@@ -123,8 +183,41 @@ +@@ -123,8 +181,41 @@ p_i1530_2_.setNetHandler(this); this.playerEntity = p_i1530_3_; p_i1530_3_.playerNetServerHandler = this; @@ -164,7 +162,7 @@ public void onNetworkTick() { this.field_147366_g = false; -@@ -139,10 +232,16 @@ +@@ -139,10 +230,16 @@ this.sendPacket(new S00PacketKeepAlive(this.field_147378_h)); } @@ -181,7 +179,7 @@ if (this.field_147375_m > 0) { -@@ -162,6 +261,24 @@ +@@ -162,6 +259,24 @@ public void kickPlayerFromServer(String p_147360_1_) { @@ -206,7 +204,7 @@ final ChatComponentText chatcomponenttext = new ChatComponentText(p_147360_1_); this.netManager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener() { -@@ -170,8 +287,8 @@ +@@ -170,8 +285,8 @@ { NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext); } @@ -217,7 +215,7 @@ this.netManager.disableAutoRead(); } -@@ -182,6 +299,15 @@ +@@ -182,6 +297,15 @@ public void processPlayer(C03PacketPlayer p_147347_1_) { @@ -233,7 +231,7 @@ WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); this.field_147366_g = true; -@@ -199,8 +325,79 @@ +@@ -199,8 +323,70 @@ } } @@ -242,19 +240,10 @@ + Player player = this.getPlayerB(); + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. + Location to = player.getLocation().clone(); // Start off the To location as the Players current location. -+ -+ // KCauldron start -+ if (this.playerEntity.isPlayerSleeping()) - { -+ this.playerEntity.playerNetServerHandler.sendPacket(new S08PacketPlayerPosLook(playerEntity.posX, playerEntity.posY, playerEntity.posZ, playerEntity.rotationYaw, playerEntity.rotationPitch, false)); -+ this.playerEntity.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player.getEntityId(), 0, 0, 0)); -+ return; -+ } -+ // KCauldron end + + // If the packet contains movement information then we update the To location with the correct XYZ. + if (p_147347_1_.field_149480_h && !(p_147347_1_.field_149480_h && p_147347_1_.field_149477_b == -999.0D && p_147347_1_.field_149475_d == -999.0D)) -+ { + { + to.setX(p_147347_1_.field_149479_a); + to.setY(p_147347_1_.field_149477_b); + to.setZ(p_147347_1_.field_149478_c); @@ -314,23 +303,7 @@ double d1; double d2; double d3; -@@ -248,13 +445,13 @@ - return; - } - -- if (this.playerEntity.isPlayerSleeping()) -+ /*if (this.playerEntity.isPlayerSleeping()) // KCauldron - moved up - { - this.playerEntity.onUpdateEntity(); - this.playerEntity.setPositionAndRotation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); - worldserver.updateEntity(this.playerEntity); - return; -- } -+ }*/ - - d0 = this.playerEntity.posY; - this.lastPosX = this.playerEntity.posX; -@@ -280,13 +477,6 @@ +@@ -280,13 +466,6 @@ d3 = p_147347_1_.func_149472_e(); d4 = p_147347_1_.func_149471_f() - p_147347_1_.func_149467_d(); @@ -344,7 +317,7 @@ if (Math.abs(p_147347_1_.func_149464_c()) > 3.2E7D || Math.abs(p_147347_1_.func_149472_e()) > 3.2E7D) { this.kickPlayerFromServer("Illegal position"); -@@ -318,7 +508,7 @@ +@@ -318,7 +497,7 @@ double d9 = Math.max(Math.abs(d6), Math.abs(this.playerEntity.motionZ)); double d10 = d7 * d7 + d8 * d8 + d9 * d9; @@ -353,7 +326,7 @@ { logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); -@@ -413,21 +603,85 @@ +@@ -413,21 +592,85 @@ public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) { @@ -444,7 +417,7 @@ this.playerEntity.dropOneItem(false); } else if (p_147345_1_.func_149506_g() == 3) -@@ -490,7 +744,17 @@ +@@ -490,7 +733,17 @@ } else { @@ -462,7 +435,7 @@ } } else if (p_147345_1_.func_149506_g() == 2) -@@ -517,6 +781,34 @@ +@@ -517,6 +770,34 @@ public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_) { WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); @@ -497,7 +470,7 @@ ItemStack itemstack = this.playerEntity.inventory.getCurrentItem(); boolean flag = false; boolean placeResult = true; -@@ -533,11 +825,21 @@ +@@ -533,11 +814,21 @@ return; } @@ -521,7 +494,7 @@ } else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit())) { -@@ -548,17 +850,24 @@ +@@ -548,17 +839,24 @@ } else { @@ -554,7 +527,7 @@ flag = true; } -@@ -615,7 +924,7 @@ +@@ -615,7 +913,7 @@ this.playerEntity.openContainer.detectAndSendChanges(); this.playerEntity.isChangingQuantityOnly = false; @@ -563,7 +536,7 @@ { this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem())); } -@@ -624,14 +933,34 @@ +@@ -624,14 +922,34 @@ public void onDisconnect(IChatComponent p_147231_1_) { @@ -603,12 +576,12 @@ if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) { logger.info("Stopping singleplayer server as player logged out"); -@@ -657,6 +986,18 @@ +@@ -657,6 +975,18 @@ } } + // CraftBukkit start -+ if (p_147359_1_ == null || this.processedDisconnect) // KCauldron ++ if (p_147359_1_ == null) + { + return; + } @@ -622,7 +595,7 @@ try { this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]); -@@ -679,20 +1020,37 @@ +@@ -679,20 +1009,37 @@ public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_) { @@ -661,7 +634,7 @@ { ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]); chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); -@@ -708,51 +1066,385 @@ +@@ -708,51 +1055,385 @@ { if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) { @@ -1059,7 +1032,7 @@ if (p_147357_1_.func_149513_d() == 1) { this.playerEntity.setSneaking(true); -@@ -772,7 +1464,7 @@ +@@ -772,7 +1453,7 @@ else if (p_147357_1_.func_149513_d() == 3) { this.playerEntity.wakeUpPlayer(false, true, true); @@ -1068,7 +1041,7 @@ } else if (p_147357_1_.func_149513_d() == 6) { -@@ -789,8 +1481,20 @@ +@@ -789,8 +1470,20 @@ public void processUseEntity(C02PacketUseEntity p_147340_1_) { @@ -1090,7 +1063,7 @@ this.playerEntity.func_143004_u(); if (entity != null) -@@ -805,9 +1509,53 @@ +@@ -805,9 +1498,53 @@ if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { @@ -1144,7 +1117,7 @@ } else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK) { -@@ -819,6 +1567,13 @@ +@@ -819,6 +1556,13 @@ } this.playerEntity.attackTargetEntityWithCurrentItem(entity); @@ -1158,7 +1131,7 @@ } } } -@@ -834,8 +1589,19 @@ +@@ -834,8 +1578,19 @@ case 1: if (this.playerEntity.playerConqueredTheEnd) { @@ -1179,7 +1152,7 @@ else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) { if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) -@@ -871,17 +1637,461 @@ +@@ -871,17 +1626,461 @@ public void processCloseWindow(C0DPacketCloseWindow p_147356_1_) { @@ -1642,7 +1615,7 @@ if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack)) { this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true)); -@@ -903,6 +2113,12 @@ +@@ -903,6 +2102,12 @@ } this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist); @@ -1655,7 +1628,7 @@ } } } -@@ -925,9 +2141,61 @@ +@@ -925,9 +2130,61 @@ boolean flag = p_147344_1_.func_149627_c() < 0; ItemStack itemstack = p_147344_1_.func_149625_d(); boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize(); @@ -1718,7 +1691,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) -@@ -956,6 +2224,11 @@ +@@ -956,6 +2213,11 @@ public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_) { @@ -1730,7 +1703,7 @@ Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId); if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) -@@ -966,6 +2239,11 @@ +@@ -966,6 +2228,11 @@ public void processUpdateSign(C12PacketUpdateSign p_147343_1_) { @@ -1742,7 +1715,7 @@ this.playerEntity.func_143004_u(); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); -@@ -980,6 +2258,7 @@ +@@ -980,6 +2247,7 @@ if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity) { this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign"); @@ -1750,7 +1723,7 @@ return; } } -@@ -990,6 +2269,7 @@ +@@ -990,6 +2258,7 @@ for (j = 0; j < 4; ++j) { boolean flag = true; @@ -1758,7 +1731,7 @@ if (p_147343_1_.func_149589_f()[j].length() > 15) { -@@ -1018,7 +2298,29 @@ +@@ -1018,7 +2287,29 @@ int k = p_147343_1_.func_149586_d(); i = p_147343_1_.func_149585_e(); TileEntitySign tileentitysign1 = (TileEntitySign)tileentity; @@ -1789,7 +1762,7 @@ tileentitysign1.markDirty(); worldserver.markBlockForUpdate(j, k, i); } -@@ -1041,7 +2343,22 @@ +@@ -1041,7 +2332,22 @@ public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_) { @@ -1813,7 +1786,7 @@ } public void processTabComplete(C14PacketTabComplete p_147341_1_) -@@ -1068,7 +2385,6 @@ +@@ -1068,7 +2374,6 @@ PacketBuffer packetbuffer; ItemStack itemstack; ItemStack itemstack1; @@ -1821,7 +1794,7 @@ if ("MC|BEdit".equals(p_147349_1_.func_149559_c())) { packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e())); -@@ -1093,16 +2409,18 @@ +@@ -1093,16 +2398,18 @@ { if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem()) { @@ -1844,7 +1817,7 @@ } finally { -@@ -1135,19 +2453,18 @@ +@@ -1135,19 +2442,18 @@ if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book) { @@ -1870,7 +1843,7 @@ } finally { -@@ -1174,9 +2491,12 @@ +@@ -1174,9 +2480,12 @@ ((ContainerMerchant)container).setCurrentRecipeIndex(i); } } @@ -1884,7 +1857,7 @@ } } else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c())) -@@ -1222,9 +2542,12 @@ +@@ -1222,9 +2531,12 @@ this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1})); } } @@ -1899,7 +1872,7 @@ } finally { -@@ -1257,9 +2580,12 @@ +@@ -1257,9 +2569,12 @@ tileentitybeacon.markDirty(); } } @@ -1914,7 +1887,7 @@ } } } -@@ -1281,6 +2607,13 @@ +@@ -1281,6 +2596,13 @@ containerrepair.updateItemName(""); } } @@ -1928,7 +1901,7 @@ } } -@@ -1292,6 +2625,21 @@ +@@ -1292,6 +2614,21 @@ } } diff --git a/patches/net/minecraft/network/NetworkManager.java.patch b/patches/net/minecraft/network/NetworkManager.java.patch index d33a717..98f6fce 100644 --- a/patches/net/minecraft/network/NetworkManager.java.patch +++ b/patches/net/minecraft/network/NetworkManager.java.patch @@ -77,7 +77,7 @@ packet.processPacket(this.netHandler); } -@@ -225,8 +257,11 @@ +@@ -225,6 +257,8 @@ public void closeChannel(IChatComponent p_150718_1_) { @@ -85,11 +85,8 @@ + if (this.channel.isOpen()) { -+ this.outboundPacketsQueue.clear(); // KCauldron this.channel.close(); - this.terminationReason = p_150718_1_; - } -@@ -254,7 +289,7 @@ +@@ -254,7 +288,7 @@ { ; } @@ -98,7 +95,7 @@ try { p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false)); -@@ -322,6 +357,13 @@ +@@ -322,6 +356,13 @@ return channel; } diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index f07120c..aea23c9 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -35,7 +35,7 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@@ -80,28 +86,64 @@ +@@ -80,18 +86,54 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.WorldEvent; @@ -93,19 +93,7 @@ private final ServerStatusResponse field_147147_p = new ServerStatusResponse(); private final Random field_147146_q = new Random(); @SideOnly(Side.SERVER) - private String hostname; - private int serverPort = -1; - public WorldServer[] worldServers = new WorldServer[0]; -- private ServerConfigurationManager serverConfigManager; -+ public ServerConfigurationManager serverConfigManager; - private boolean serverRunning = true; - private boolean serverStopped; -- private int tickCounter; -+ public int tickCounter; - protected final Proxy serverProxy; - public String currentTask; - public int percentDone; -@@ -135,8 +177,41 @@ +@@ -135,8 +177,40 @@ private long field_147142_T = 0L; private final GameProfileRepository field_152365_W; private final PlayerProfileCache field_152366_X; @@ -127,7 +115,6 @@ + public final double[] recentTps = new double[ 3 ]; + // Spigot end + // Cauldron start -+ public kcauldron.KCauldronWorldSaveThread saveThread; + public static CauldronConfig cauldronConfig; + public static KCauldronConfig kcauldronConfig; + public static TileEntityConfig tileEntityConfig; @@ -147,7 +134,7 @@ public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_) { this.field_152366_X = new PlayerProfileCache(this, field_152367_a); -@@ -149,10 +224,70 @@ +@@ -149,10 +223,70 @@ this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString()); this.field_147143_S = this.field_152364_T.createMinecraftSessionService(); this.field_152365_W = this.field_152364_T.createProfileRepository(); @@ -219,7 +206,7 @@ protected void convertMapIfNeeded(String p_71237_1_) { if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_)) -@@ -172,6 +307,7 @@ +@@ -172,6 +306,7 @@ MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%"); } } @@ -227,7 +214,7 @@ @SideOnly(Side.CLIENT) public void resetProgressAndMessage(String p_73721_1_) {} @SideOnly(Side.CLIENT) -@@ -195,10 +331,17 @@ +@@ -195,10 +330,17 @@ protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_) { @@ -247,7 +234,7 @@ WorldSettings worldsettings; if (worldinfo == null) -@@ -215,11 +358,79 @@ +@@ -215,11 +357,79 @@ { worldsettings.enableBonusChest(); } @@ -330,7 +317,7 @@ world.addWorldAccess(new WorldManager(this, world)); if (!this.isSinglePlayer()) -@@ -227,12 +438,14 @@ +@@ -227,12 +437,14 @@ world.getWorldInfo().setGameType(this.getGameType()); } @@ -348,7 +335,7 @@ } protected void initialWorldChunkLoad() -@@ -244,9 +457,12 @@ +@@ -244,9 +456,12 @@ int i = 0; this.setUserMessage("menu.generatingTerrain"); byte b0 = 0; @@ -361,7 +348,7 @@ long j = getSystemTimeMillis(); for (int k = -192; k <= 192 && this.isServerRunning(); k += 16) -@@ -265,7 +481,8 @@ +@@ -265,7 +480,8 @@ worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4); } } @@ -371,7 +358,7 @@ this.clearCurrentTask(); } -@@ -292,19 +509,17 @@ +@@ -292,19 +508,17 @@ { this.currentTask = null; this.percentDone = 0; @@ -379,7 +366,7 @@ } - protected void saveAllWorlds(boolean p_71267_1_) -+ public void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws ++ protected void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws { if (!this.worldIsBeingDeleted) { @@ -396,7 +383,7 @@ if (worldserver != null) { -@@ -313,25 +528,42 @@ +@@ -313,25 +527,41 @@ logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName()); } @@ -428,7 +415,6 @@ - public void stopServer() + public void stopServer() throws MinecraftException // CraftBukkit - added throws { -+ if (saveThread != null) saveThread.stopServer(); if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED) && !serverStopped) // make sure the save is valid and we don't save twice { logger.info("Stopping server"); @@ -444,7 +430,7 @@ if (this.func_147137_ag() != null) { this.func_147137_ag().terminateEndpoints(); -@@ -347,7 +579,14 @@ +@@ -347,7 +577,14 @@ if (this.worldServers != null) { logger.info("Saving worlds"); @@ -460,7 +446,7 @@ for (int i = 0; i < this.worldServers.length; ++i) { -@@ -380,6 +619,13 @@ +@@ -380,6 +617,13 @@ this.serverRunning = false; } @@ -474,7 +460,7 @@ public void run() { try -@@ -392,45 +638,41 @@ +@@ -392,45 +636,41 @@ this.field_147147_p.func_151315_a(new ChatComponentText(this.motd)); this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5)); this.func_147138_a(this.field_147147_p); @@ -541,7 +527,7 @@ FMLCommonHandler.instance().handleServerStopping(); FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions } -@@ -448,6 +690,14 @@ +@@ -448,6 +688,14 @@ catch (Throwable throwable1) { logger.error("Encountered an unexpected exception", throwable1); @@ -556,7 +542,7 @@ CrashReport crashreport = null; if (throwable1 instanceof ReportedException) -@@ -477,6 +727,7 @@ +@@ -477,6 +725,7 @@ { try { @@ -564,7 +550,7 @@ this.stopServer(); this.serverStopped = true; } -@@ -486,6 +737,16 @@ +@@ -486,6 +735,16 @@ } finally { @@ -581,7 +567,7 @@ FMLCommonHandler.instance().handleServerStopped(); this.serverStopped = true; this.systemExitNow(); -@@ -532,8 +793,11 @@ +@@ -532,8 +791,11 @@ public void tick() { @@ -593,20 +579,31 @@ ++this.tickCounter; if (this.startProfiling) -@@ -562,38 +826,62 @@ +@@ -562,12 +824,21 @@ this.field_147147_p.func_151318_b().func_151330_a(agameprofile); } - if (this.tickCounter % 900 == 0) -- { -- this.theProfiler.startSection("save"); -- this.serverConfigManager.saveAllPlayerData(); ++ if ((this.autosavePeriod > 0) && ((this.tickCounter % this.autosavePeriod) == 0)) // CraftBukkit + { ++ SpigotTimings.worldSaveTimer.startTiming(); // Spigot + this.theProfiler.startSection("save"); + this.serverConfigManager.saveAllPlayerData(); - this.saveAllWorlds(true); -- this.theProfiler.endSection(); -- } -- ++ try ++ { ++ this.saveAllWorlds(true); ++ } ++ catch (MinecraftException e) ++ { ++ e.printStackTrace(); ++ } + this.theProfiler.endSection(); ++ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot + } + this.theProfiler.startSection("tallying"); - this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i; +@@ -575,25 +846,57 @@ this.theProfiler.endSection(); this.theProfiler.startSection("snooper"); @@ -666,7 +663,7 @@ int i; Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0); -@@ -602,19 +890,21 @@ +@@ -602,19 +905,21 @@ int id = ids[x]; long j = System.nanoTime(); @@ -691,7 +688,7 @@ this.theProfiler.startSection("tick"); FMLCommonHandler.instance().onPreWorldTick(worldserver); -@@ -622,22 +912,46 @@ +@@ -622,22 +927,46 @@ try { @@ -740,7 +737,7 @@ worldserver.addWorldInfoToCrashReport(crashreport); throw new ReportedException(crashreport); } -@@ -645,10 +959,12 @@ +@@ -645,10 +974,12 @@ FMLCommonHandler.instance().onPostWorldTick(worldserver); this.theProfiler.endSection(); this.theProfiler.startSection("tracker"); @@ -754,7 +751,7 @@ worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j; } -@@ -656,15 +972,21 @@ +@@ -656,15 +987,21 @@ this.theProfiler.endStartSection("dim_unloading"); DimensionManager.unloadWorlds(worldTickTimes); this.theProfiler.endStartSection("connection"); @@ -776,7 +773,7 @@ this.theProfiler.endSection(); } -@@ -699,6 +1021,13 @@ +@@ -699,6 +1036,13 @@ public WorldServer worldServerForDimension(int p_71218_1_) { @@ -790,7 +787,7 @@ WorldServer ret = DimensionManager.getWorld(p_71218_1_); if (ret == null) { -@@ -784,13 +1113,14 @@ +@@ -784,13 +1128,14 @@ public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_) { @@ -809,7 +806,7 @@ if (list != null) { -@@ -798,40 +1128,25 @@ +@@ -798,40 +1143,25 @@ while (iterator.hasNext()) { @@ -858,7 +855,7 @@ } public static MinecraftServer getServer() -@@ -1034,7 +1349,7 @@ +@@ -1034,7 +1364,7 @@ public boolean isServerInOnlineMode() { @@ -867,7 +864,7 @@ } public void setOnlineMode(boolean p_71229_1_) -@@ -1124,7 +1439,7 @@ +@@ -1124,7 +1454,7 @@ public NetworkSystem func_147137_ag() { @@ -876,7 +873,7 @@ } @SideOnly(Side.CLIENT) -@@ -1259,8 +1574,11 @@ +@@ -1259,8 +1589,11 @@ { Bootstrap.func_151354_b(); @@ -888,7 +885,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -1356,16 +1674,34 @@ +@@ -1356,16 +1689,34 @@ { dedicatedserver.setGuiEnabled(); } @@ -929,7 +926,7 @@ } catch (Exception exception) { -@@ -1400,15 +1736,70 @@ +@@ -1400,15 +1751,70 @@ @SideOnly(Side.SERVER) public String getPlugins() { @@ -1005,7 +1002,7 @@ } @SideOnly(Side.SERVER) -@@ -1455,9 +1846,226 @@ +@@ -1455,9 +1861,213 @@ return this.serverStopped; } @@ -1218,17 +1215,4 @@ + return logger; + } + // CraftBukkit end -+ -+ public void invalidateWorldSaver() { -+ if (saveThread != null) { -+ saveThread.interrupt(); -+ saveThread = null; -+ } -+ if (autosavePeriod > 0) { -+ saveThread = new kcauldron.KCauldronWorldSaveThread(this); -+ saveThread.start(); -+ } else { -+ kcauldron.KLog.get().info("No valid autosave period is setted, assumed plugin-induved world saving!"); -+ } -+ } } diff --git a/patches/net/minecraft/server/management/PlayerManager.java.patch b/patches/net/minecraft/server/management/PlayerManager.java.patch index 2834a9c..fde6e37 100644 --- a/patches/net/minecraft/server/management/PlayerManager.java.patch +++ b/patches/net/minecraft/server/management/PlayerManager.java.patch @@ -73,7 +73,7 @@ if (this.players.isEmpty()) { -+ if (this.theWorldServer.loadedEntityList_KC.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap_KC.size() == 0) ++ if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap_KC.size() == 0) + { + return; // CraftBukkit - Only do unload when we go from non-empty to empty + } diff --git a/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch b/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch index 9418b51..74fd628 100644 --- a/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch +++ b/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch @@ -58,13 +58,12 @@ protected int maxPlayers; private int viewDistance; private WorldSettings.GameType gameType; -@@ -91,8 +115,18 @@ +@@ -91,8 +115,17 @@ private int playerPingIndex; private static final String __OBFID = "CL_00001423"; + // CraftBukkit start + private CraftServer cserver; -+ private final Map playersByName = new org.spigotmc.CaseInsensitiveMap(); // KCauldron + public ServerConfigurationManager(MinecraftServer p_i1500_1_) { @@ -77,7 +76,7 @@ this.bannedPlayers = new UserListBans(field_152613_a); this.bannedIPs = new BanList(field_152614_b); this.ops = new UserListOps(field_152615_c); -@@ -131,12 +165,32 @@ +@@ -131,12 +164,32 @@ s1 = p_72355_1_.getSocketAddress().toString(); } @@ -112,7 +111,7 @@ nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8))); nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ)); nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities)); -@@ -145,6 +199,7 @@ +@@ -145,6 +198,7 @@ p_72355_2_.func_147099_x().func_150884_b(p_72355_2_); this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_); this.mcServer.func_147132_au(); @@ -120,7 +119,7 @@ ChatComponentTranslation chatcomponenttranslation; if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s)) -@@ -158,6 +213,7 @@ +@@ -158,6 +212,7 @@ chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW); this.sendChatMsg(chatcomponenttranslation); @@ -128,7 +127,7 @@ this.playerLoggedIn(p_72355_2_); nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch); this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver); -@@ -192,7 +248,7 @@ +@@ -192,7 +247,7 @@ } } @@ -137,7 +136,7 @@ { HashSet hashset = new HashSet(); Iterator iterator = p_96456_1_.getTeams().iterator(); -@@ -225,6 +281,7 @@ +@@ -225,6 +280,7 @@ public void setPlayerManager(WorldServer[] p_72364_1_) { @@ -145,7 +144,7 @@ this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler(); } -@@ -248,7 +305,7 @@ +@@ -248,7 +304,7 @@ public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_) { @@ -154,7 +153,7 @@ NBTTagCompound nbttagcompound1; if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null) -@@ -294,18 +351,62 @@ +@@ -294,18 +350,61 @@ public void playerLoggedIn(EntityPlayerMP p_72377_1_) { @@ -162,7 +161,6 @@ + cserver.detectListNameConflict(p_72377_1_); // CraftBukkit + // this.sendPacketToAllPlayers(new S38PacketPlayerListItem(p_72377_1_.getCommandSenderName(), true, 1000)); // CraftBukkit - replaced with loop below this.playerEntityList.add(p_72377_1_); -+ this.playersByName.put(p_72377_1_.getCommandSenderName(), p_72377_1_); WorldServer worldserver = this.mcServer.worldServerForDimension(p_72377_1_.dimension); + // CraftBukkit start + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(p_72377_1_), "\u00A7e" + p_72377_1_.getCommandSenderName() @@ -221,7 +219,7 @@ } public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_) -@@ -313,14 +414,33 @@ +@@ -313,14 +412,33 @@ p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_); } @@ -257,14 +255,13 @@ { worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity); logger.debug("removing player mount"); -@@ -329,9 +449,36 @@ +@@ -329,9 +447,35 @@ worldserver.removeEntity(p_72367_1_); worldserver.getPlayerManager().removePlayer(p_72367_1_); this.playerEntityList.remove(p_72367_1_); - this.field_148547_k.remove(p_72367_1_.getUniqueID()); - net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount()); - this.sendPacketToAllPlayers(new S38PacketPlayerListItem(p_72367_1_.getCommandSenderName(), false, 9999)); -+ this.playersByName.remove(p_72367_1_.getCommandSenderName()); + this.field_148547_k.remove(p_72367_1_.getCommandSenderName()); + ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount()); // CraftBukkit + // CraftBukkit start - .name -> .listName, replace sendAll with loop @@ -297,7 +294,7 @@ } public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) -@@ -372,6 +519,71 @@ +@@ -372,6 +516,71 @@ } } @@ -369,7 +366,7 @@ public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_) { UUID uuid = EntityPlayer.func_146094_a(p_148545_1_); -@@ -410,80 +622,201 @@ +@@ -410,80 +619,199 @@ return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); } @@ -485,7 +482,6 @@ + // par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removeEntityFromAllTrackingPlayers(par1EntityPlayerMP); // CraftBukkit + par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP); + this.playerEntityList.remove(par1EntityPlayerMP); -+ this.playersByName.remove(par1EntityPlayerMP.getCommandSenderName()); + this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension).removePlayerEntityDangerously(par1EntityPlayerMP); + + // Phase 4 - handle bed spawn @@ -598,7 +594,6 @@ + targetWorld.getPlayerManager().addPlayer(entityplayermp1); + targetWorld.spawnEntityInWorld(entityplayermp1); this.playerEntityList.add(entityplayermp1); -+ this.playersByName.put(entityplayermp1.getCommandSenderName(), entityplayermp1); entityplayermp1.addSelfToInternalCraftingInventory(); entityplayermp1.setHealth(entityplayermp1.getHealth()); - FMLCommonHandler.instance().firePlayerRespawnEvent(entityplayermp1); @@ -611,7 +606,7 @@ return entityplayermp1; } -@@ -492,34 +825,112 @@ +@@ -492,34 +820,112 @@ transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter()); } @@ -743,7 +738,7 @@ } public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter) -@@ -605,6 +1016,109 @@ +@@ -605,6 +1011,109 @@ p_82448_1_.setWorld(p_82448_4_); } @@ -853,7 +848,7 @@ public void sendPlayerInfoToAllPlayers() { if (++this.playerPingIndex > 600) -@@ -612,11 +1126,13 @@ +@@ -612,11 +1121,13 @@ this.playerPingIndex = 0; } @@ -867,26 +862,7 @@ } public void sendPacketToAllPlayers(Packet p_148540_1_) -@@ -719,7 +1235,7 @@ - - public EntityPlayerMP func_152612_a(String p_152612_1_) - { -- Iterator iterator = this.playerEntityList.iterator(); -+ /*Iterator iterator = this.playerEntityList.iterator(); // KCauldron - EntityPlayerMP entityplayermp; - - do -@@ -733,7 +1249,8 @@ - } - while (!entityplayermp.getCommandSenderName().equalsIgnoreCase(p_152612_1_)); - -- return entityplayermp; -+ return entityplayermp;*/ // KCauldron -+ return playersByName.get(p_152612_1_); - } - - public List findPlayers(ChunkCoordinates p_82449_1_, int p_82449_2_, int p_82449_3_, int p_82449_4_, int p_82449_5_, int p_82449_6_, int p_82449_7_, Map p_82449_8_, String p_82449_9_, String p_82449_10_, World p_82449_11_) -@@ -877,13 +1394,24 @@ +@@ -877,13 +1388,24 @@ for (int j = 0; j < this.playerEntityList.size(); ++j) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); @@ -913,7 +889,7 @@ if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) { entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); -@@ -941,13 +1469,16 @@ +@@ -941,13 +1463,16 @@ p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F)); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, p_72354_2_.getRainStrength(1.0F))); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F))); @@ -931,7 +907,7 @@ p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem)); } -@@ -961,9 +1492,17 @@ +@@ -961,9 +1486,17 @@ return this.maxPlayers; } @@ -950,7 +926,7 @@ } public void setWhiteListEnabled(boolean p_72371_1_) -@@ -1032,12 +1571,30 @@ +@@ -1032,12 +1565,30 @@ public void removeAllPlayers() { diff --git a/patches/net/minecraft/tileentity/TileEntity.java.patch b/patches/net/minecraft/tileentity/TileEntity.java.patch index 6659b6a..8b36b9b 100644 --- a/patches/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/net/minecraft/tileentity/TileEntity.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java -@@ -22,18 +22,23 @@ +@@ -22,18 +22,22 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,11 +22,10 @@ public int blockMetadata = -1; public Block blockType; + public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot -+ public boolean markedForRemoval = false; private static final String __OBFID = "CL_00000340"; public static void addMapping(Class p_145826_0_, String p_145826_1_) -@@ -106,7 +111,11 @@ +@@ -106,7 +110,11 @@ } catch (Exception exception) { @@ -39,7 +38,7 @@ } if (tileentity != null) -@@ -282,6 +291,20 @@ +@@ -282,6 +290,20 @@ addMapping(TileEntityFlowerPot.class, "FlowerPot"); } diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index 2192f86..25d5987 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/World.java +++ ../src-work/minecraft/net/minecraft/world/World.java -@@ -2,16 +2,21 @@ +@@ -2,6 +2,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -8,21 +8,15 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; - import java.util.HashSet; - import java.util.Iterator; -+import java.util.LinkedList; - import java.util.List; -+import java.util.Queue; - import java.util.Random; +@@ -12,6 +13,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.Callable; -+import java.util.concurrent.ConcurrentLinkedQueue; + import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.block.BlockLiquid; -@@ -23,9 +28,11 @@ +@@ -23,9 +25,11 @@ import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; @@ -34,7 +28,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; -@@ -51,7 +58,6 @@ +@@ -51,7 +55,6 @@ import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldInfo; @@ -42,7 +36,7 @@ import cpw.mods.fml.common.FMLLog; import com.google.common.collect.ImmutableSetMultimap; -@@ -70,6 +76,55 @@ +@@ -70,6 +73,55 @@ import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraft.entity.EnumCreatureType; @@ -98,22 +92,16 @@ public abstract class World implements IBlockAccess { /** -@@ -82,16 +137,17 @@ - public final MapStorage perWorldStorage; +@@ -83,15 +135,14 @@ public boolean scheduledUpdatesAreImmediate; -- public List loadedEntityList = new ArrayList(); + public List loadedEntityList = new ArrayList(); - protected List unloadedEntityList = new ArrayList(); -- public List loadedTileEntityList = new ArrayList(); -- private List addedTileEntityList = new ArrayList(); ++ public List unloadedEntityList = new ArrayList(); // Cauldron + public List loadedTileEntityList = new ArrayList(); + private List addedTileEntityList = new ArrayList(); - private List field_147483_b = new ArrayList(); -+ public Queue loadedEntityList_KC = new kcauldron.wrapper.ProcessingQueue(new ConcurrentLinkedQueue()); // KCauldron -+ public List loadedEntityList = new kcauldron.wrapper.QueueToList(((kcauldron.wrapper.ProcessingQueue)loadedEntityList_KC).unwrap()); // KCauldron -+ public List unloadedEntityList = com.google.common.collect.ImmutableList.of(); // KCauldron -+ public Queue loadedTileEntityList_KC = new kcauldron.wrapper.ProcessingQueue(new ConcurrentLinkedQueue()); // KCauldron -+ public List loadedTileEntityList = new kcauldron.wrapper.QueueToList(((kcauldron.wrapper.ProcessingQueue)loadedTileEntityList_KC).unwrap()); // KCauldron -+ private List addedTileEntityList = new ArrayList(); // KCauldron -+ public List field_147483_b = com.google.common.collect.ImmutableList.of(); // KCauldron ++ public List field_147483_b = new ArrayList(); // Cauldron public List playerEntities = new ArrayList(); public List weatherEffects = new ArrayList(); private long cloudColour = 16777215L; @@ -122,7 +110,7 @@ protected final int DIST_HASH_MAGIC = 1013904223; public float prevRainingStrength; public float rainingStrength; -@@ -100,26 +156,87 @@ +@@ -100,26 +151,88 @@ public int lastLightningBolt; public EnumDifficulty difficultySetting; public Random rand = new Random(); @@ -152,6 +140,7 @@ + public long ticksPerAnimalSpawns; + public long ticksPerMonsterSpawns; + public boolean populating; ++ private int tickPosition; + // CraftBukkit end + public Set activeChunkSet = new HashSet(); // Cauldron - protected -> public private int ambientTickCountdown; @@ -193,7 +182,7 @@ + // Spigot start + + /** Positions to update */ -+ public final gnu.trove.map.hash.TLongShortHashMap activeChunkSet_CB; ++ protected final gnu.trove.map.hash.TLongShortHashMap activeChunkSet_CB; + public float growthOdds = 100; + protected float modifiedOdds = 100; + @@ -217,7 +206,7 @@ private static final String __OBFID = "CL_00000140"; public boolean restoringBlockSnapshots = false; public boolean captureBlockSnapshots = false; -@@ -166,6 +283,26 @@ +@@ -166,6 +279,27 @@ return this.provider.worldChunkMgr; } @@ -230,6 +219,7 @@ + public final SpigotTimings.WorldTimingsHandler timings; // Spigot + private org.spigotmc.TickLimiter entityLimiter; // Spigot + private org.spigotmc.TickLimiter tileLimiter; // Spigot ++ private int tileTickPosition; // Spigot + + public CraftWorld getWorld() + { @@ -244,7 +234,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 +316,12 @@ +@@ -179,6 +313,12 @@ this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_); this.provider = p_i45368_3_; perWorldStorage = new MapStorage((ISaveHandler)null); @@ -257,7 +247,7 @@ } // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes -@@ -207,8 +350,175 @@ +@@ -207,8 +347,175 @@ this.calculateInitialWeather(); } @@ -433,7 +423,7 @@ this.ambientTickCountdown = this.rand.nextInt(12000); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; -@@ -216,7 +526,6 @@ +@@ -216,7 +523,6 @@ this.lightUpdateBlockList = new int[32768]; this.saveHandler = p_i45369_1_; this.theProfiler = p_i45369_5_; @@ -441,7 +431,7 @@ this.worldInfo = p_i45369_1_.loadWorldInfo(); if (p_i45369_4_ != null) -@@ -235,13 +544,26 @@ +@@ -235,13 +541,26 @@ if (this.worldInfo == null) { this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_); @@ -468,17 +458,15 @@ this.chunkProvider = this.createChunkProvider(); if (this instanceof WorldServer) -@@ -293,7 +615,9 @@ - +@@ -294,6 +613,7 @@ this.calculateInitialSkylight(); this.calculateInitialWeather(); -+ if (getServer() != null && world != null) getServer().addWorld(world); // CraftBukkit } + // Cauldron end private static MapStorage s_mapStorage; private static ISaveHandler s_savehandler; -@@ -336,6 +660,18 @@ +@@ -336,6 +656,18 @@ public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { @@ -497,7 +485,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 +740,7 @@ +@@ -404,7 +736,7 @@ } } @@ -506,7 +494,7 @@ { return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_); } -@@ -421,6 +757,27 @@ +@@ -421,6 +753,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_) { @@ -534,7 +522,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 +805,22 @@ +@@ -448,8 +801,22 @@ this.capturedBlockSnapshots.add(blockSnapshot); } @@ -557,7 +545,7 @@ if (!flag && blockSnapshot != null) { this.capturedBlockSnapshots.remove(blockSnapshot); -@@ -460,6 +831,7 @@ +@@ -460,6 +827,7 @@ this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_); this.theProfiler.endSection(); @@ -565,7 +553,7 @@ if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates { // Modularize client and physic updates -@@ -496,6 +868,19 @@ +@@ -496,6 +864,19 @@ public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { @@ -585,7 +573,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 +896,7 @@ +@@ -511,7 +892,7 @@ Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4); p_72805_1_ &= 15; p_72805_3_ &= 15; @@ -594,7 +582,7 @@ } } else -@@ -610,6 +995,12 @@ +@@ -610,6 +991,12 @@ public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_) { @@ -607,7 +595,7 @@ this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_); } -@@ -694,6 +1085,21 @@ +@@ -694,6 +1081,21 @@ try { @@ -629,7 +617,7 @@ block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); } catch (Throwable throwable1) -@@ -1307,6 +1713,13 @@ +@@ -1307,6 +1709,13 @@ public boolean spawnEntityInWorld(Entity p_72838_1_) { @@ -643,7 +631,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 +1732,99 @@ +@@ -1319,23 +1728,99 @@ flag = true; } @@ -739,14 +727,13 @@ - if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false; - this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_); -- this.loadedEntityList.add(p_72838_1_); -+ this.loadedEntityList_KC.add(p_72838_1_); + this.loadedEntityList.add(p_72838_1_); this.onEntityAdded(p_72838_1_); + net.minecraftforge.cauldron.CauldronHooks.logEntitySpawn(this, p_72838_1_, spawnReason); return true; } } -@@ -1346,6 +1835,8 @@ +@@ -1346,6 +1831,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); } @@ -755,7 +742,7 @@ } public void onEntityRemoved(Entity p_72847_1_) -@@ -1354,6 +1845,8 @@ +@@ -1354,6 +1841,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); } @@ -764,16 +751,27 @@ } public void removeEntity(Entity p_72900_1_) -@@ -1396,7 +1889,7 @@ - this.getChunkFromChunkCoords(i, j).removeEntity(p_72973_1_); +@@ -1397,6 +1886,19 @@ } -- this.loadedEntityList.remove(p_72973_1_); -+ this.loadedEntityList_KC.remove(p_72973_1_); + this.loadedEntityList.remove(p_72973_1_); ++ // CraftBukkit start - Decrement loop variable field if we've already ticked this entity ++ int index = this.loadedEntityList.indexOf(p_72973_1_); ++ ++ if (index != -1) ++ { ++ if (index <= this.tickPosition) ++ { ++ this.tickPosition--; ++ } ++ ++ this.loadedEntityList.remove(index); ++ } ++ // CraftBukkit end this.onEntityRemoved(p_72973_1_); } -@@ -1408,40 +1901,58 @@ +@@ -1408,40 +1910,58 @@ public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_) { this.collidingBoundingBoxes.clear(); @@ -846,7 +844,7 @@ for (int j2 = 0; j2 < list.size(); ++j2) { -@@ -1797,11 +2308,22 @@ +@@ -1797,11 +2317,22 @@ Entity entity; CrashReport crashreport; CrashReportCategory crashreportcategory; @@ -869,60 +867,25 @@ try { ++entity.ticksExisted; -@@ -1838,35 +2360,26 @@ - } - } +@@ -1862,10 +2393,14 @@ -- this.theProfiler.endStartSection("remove"); -- this.loadedEntityList.removeAll(this.unloadedEntityList); -- int j; -- int l; -+ this.theProfiler.endStartSection("regular"); + this.unloadedEntityList.clear(); + this.theProfiler.endStartSection("regular"); + org.spigotmc.ActivationRange.activateEntities(this); // Spigot + timings.entityTick.startTiming(); // Spigot -- for (i = 0; i < this.unloadedEntityList.size(); ++i) -- { -- entity = (Entity)this.unloadedEntityList.get(i); -- j = entity.chunkCoordX; -- l = entity.chunkCoordZ; -- -- if (entity.addedToChunk && this.chunkExists(j, l)) -- { -- this.getChunkFromChunkCoords(j, l).removeEntity(entity); -+ Iterator entityIterator = loadedEntityList_KC.iterator(); -+ for (entityLimiter.initTick(); entityIterator.hasNext() && entityLimiter.shouldContinue();) { -+ entity = entityIterator.next(); -+ -+ if (entity.markedForRemoval || entity.isDead) { -+ theProfiler.startSection("remove"); -+ int x = entity.chunkCoordX; -+ int y = entity.chunkCoordZ; -+ if (entity.addedToChunk && chunkExists(x, y)) -+ getChunkFromChunkCoords(x, y).removeEntity(entity); -+ onEntityRemoved(entity); -+ entityIterator.remove(); -+ theProfiler.endSection(); -+ continue; - } -- } - -- for (i = 0; i < this.unloadedEntityList.size(); ++i) -- { -- this.onEntityRemoved((Entity)this.unloadedEntityList.get(i)); -- } -- -- this.unloadedEntityList.clear(); -- this.theProfiler.endStartSection("regular"); -- - for (i = 0; i < this.loadedEntityList.size(); ++i) - { - entity = (Entity)this.loadedEntityList.get(i); -- ++ int entitiesThisCycle = 0; ++ if (tickPosition < 0) tickPosition = 0; ++ for (entityLimiter.initTick(); entitiesThisCycle < loadedEntityList.size() && (entitiesThisCycle % 10 == 0 || entityLimiter.shouldContinue()); tickPosition++, entitiesThisCycle++) { ++ tickPosition = (tickPosition < loadedEntityList.size()) ? tickPosition : 0; ++ entity = (Entity)this.loadedEntityList.get(this.tickPosition); + if (entity.ridingEntity != null) { - if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity) -@@ -1884,7 +2397,9 @@ +@@ -1884,7 +2419,9 @@ { try { @@ -932,27 +895,19 @@ } catch (Throwable throwable1) { -@@ -1905,41 +2420,56 @@ +@@ -1916,30 +2453,69 @@ + { + this.getChunkFromChunkCoords(j, l).removeEntity(entity); + } +- +- this.loadedEntityList.remove(i--); ++ if (this.tickPosition < this.loadedEntityList.size()) // KCauldron ++ this.loadedEntityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable ++ else kcauldron.KLog.get().warning("Entity removal desync! " + entity); // KCauldron + this.onEntityRemoved(entity); } this.theProfiler.endSection(); -- this.theProfiler.startSection("remove"); -- -- if (entity.isDead) -- { -- j = entity.chunkCoordX; -- l = entity.chunkCoordZ; -- -- if (entity.addedToChunk && this.chunkExists(j, l)) -- { -- this.getChunkFromChunkCoords(j, l).removeEntity(entity); -- } -- -- this.loadedEntityList.remove(i--); -- this.onEntityRemoved(entity); -- } -- -- this.theProfiler.endSection(); } + timings.entityTick.stopTiming(); // Spigot @@ -960,44 +915,50 @@ + timings.tileEntityTick.startTiming(); // Spigot this.field_147481_N = true; - Iterator iterator = this.loadedTileEntityList.iterator(); - +- - while (iterator.hasNext()) -- { ++ // CraftBukkit start - From below, clean up tile entities before ticking them ++ if (!this.field_147483_b.isEmpty()) + { - TileEntity tileentity = (TileEntity)iterator.next(); -+ Iterator tileEntityIterator = loadedTileEntityList_KC.iterator(); -+ for (tileLimiter.initTick(); tileEntityIterator.hasNext() && tileLimiter.shouldContinue();) { -+ TileEntity tileentity = tileEntityIterator.next(); ++ for (Object tile : field_147483_b) ++ { ++ ((TileEntity) tile).onChunkUnload(); ++ } ++ this.loadedTileEntityList.removeAll(this.field_147483_b); ++ 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; ++ TileEntity tileentity = (TileEntity) this.loadedTileEntityList.get(tileTickPosition); + + // Spigot start + if (tileentity == null) -+ { + { + getServer().getLogger().severe("Cauldron has detected a null entity and has removed it, preventing a crash"); -+ tileEntityIterator.remove(); ++ tilesThisCycle--; ++ this.loadedTileEntityList.remove(tileTickPosition--); + continue; + } + // Spigot end + -+ // KCauldron start -+ if (tileentity.markedForRemoval) { -+ tileentity.onChunkUnload(); -+ tileEntityIterator.remove(); -+ continue; -+ } -+ // KCauldron end -+ + if (tileentity.isInvalid()) { -+ tileEntityIterator.remove(); ++ tilesThisCycle--; ++ this.loadedTileEntityList.remove(tileTickPosition--); + if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) { + Chunk chunk = this.getChunkFromChunkCoords(tileentity.xCoord >> 4, tileentity.zCoord >> 4); + if (chunk != null) chunk.removeInvalidTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15); + } + 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 @@ -1011,7 +972,7 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1955,23 +2485,13 @@ +@@ -1955,23 +2531,13 @@ } } } @@ -1031,16 +992,16 @@ - } - } } -+ this.field_147481_N = false; + timings.tileEntityTick.stopTiming(); // Spigot + timings.tileEntityPending.startTiming(); // Spigot ++ this.field_147481_N = false; + + /* CraftBukkit start - Moved up if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2501,7 @@ +@@ -1981,6 +2547,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -1048,19 +1009,7 @@ this.field_147481_N = false; -@@ -1994,9 +2515,9 @@ - - if (!tileentity1.isInvalid()) - { -- if (!this.loadedTileEntityList.contains(tileentity1)) -+ if (!this.loadedTileEntityList_KC.contains(tileentity1)) - { -- this.loadedTileEntityList.add(tileentity1); -+ this.loadedTileEntityList_KC.add(tileentity1); - } - } - else -@@ -2016,17 +2537,23 @@ +@@ -2016,17 +2583,23 @@ this.addedTileEntityList.clear(); } @@ -1074,7 +1023,7 @@ - List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; - for(TileEntity entity : (Collection)p_147448_1_) + // Cauldron start -+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList_KC; // List -> Collection for CB loadedTileEntityList type change ++ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; // List -> Collection for CB loadedTileEntityList type change + for(Object entity : p_147448_1_) { - if(entity.canUpdate()) dest.add(entity); @@ -1087,7 +1036,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2036,21 +2563,33 @@ +@@ -2036,21 +2609,33 @@ public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) { @@ -1122,7 +1071,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 +2673,7 @@ +@@ -2134,6 +2719,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1130,16 +1079,7 @@ } } -@@ -2500,7 +3040,7 @@ - @SideOnly(Side.CLIENT) - public String getDebugLoadedEntities() - { -- return "All: " + this.loadedEntityList.size(); -+ return "All: " + this.loadedEntityList_KC.size(); - } - - @SideOnly(Side.CLIENT) -@@ -2570,7 +3110,7 @@ +@@ -2570,7 +3156,7 @@ return; } @@ -1148,35 +1088,7 @@ { if (this.field_147481_N) { -@@ -2591,7 +3131,7 @@ - } - else - { -- this.loadedTileEntityList.add(p_147455_4_); -+ this.loadedTileEntityList_KC.add(p_147455_4_); - } - } - Chunk chunk = this.getChunkFromChunkCoords(p_147455_1_ >> 4, p_147455_3_ >> 4); -@@ -2612,7 +3152,7 @@ - - public void func_147457_a(TileEntity p_147457_1_) - { -- this.field_147483_b.add(p_147457_1_); -+ p_147457_1_.markedForRemoval = true; - } - - public boolean func_147469_q(int p_147469_1_, int p_147469_2_, int p_147469_3_) -@@ -2666,7 +3206,9 @@ - - public void tick() - { -+ timings.weatherUpdate.startTiming(); // KCauldron - this.updateWeather(); -+ timings.weatherUpdate.stopTiming(); // KCauldron - } - - private void calculateInitialWeather() -@@ -2718,7 +3260,15 @@ +@@ -2718,7 +3304,15 @@ if (i <= 0) { @@ -1193,7 +1105,7 @@ } } -@@ -2754,7 +3304,15 @@ +@@ -2754,7 +3348,15 @@ if (j <= 0) { @@ -1210,7 +1122,7 @@ } } -@@ -2777,8 +3335,41 @@ +@@ -2777,8 +3379,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1253,7 +1165,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3379,28 @@ +@@ -2788,17 +3423,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1288,7 +1200,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3412,7 @@ +@@ -2810,7 +3456,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1297,20 +1209,16 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3280,12 +3882,23 @@ - { - int i = 0; - -- for (int j = 0; j < this.loadedEntityList.size(); ++j) -+ for (Entity entity : loadedEntityList_KC) +@@ -3284,8 +3930,21 @@ { -- Entity entity = (Entity)this.loadedEntityList.get(j); -+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs -+ if (entity instanceof EntityLiving) -+ { -+ EntityLiving entityliving = (EntityLiving) entity; + 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()) + { + continue; @@ -1318,34 +1226,21 @@ + } + + if (p_72907_1_.isAssignableFrom(entity.getClass())) - { ++ { + // if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass())) + // CraftBukkit end ++i; } } -@@ -3298,9 +3911,10 @@ +@@ -3298,6 +3957,7 @@ for (int i = 0; i < p_72868_1_.size(); ++i) { Entity entity = (Entity)p_72868_1_.get(i); + if (!entity.entityAllowedToSpawn()) continue; if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) { -- loadedEntityList.add(entity); -+ loadedEntityList_KC.add(entity); - this.onEntityAdded(entity); - } - } -@@ -3308,14 +3922,25 @@ - - public void unloadEntities(List p_72828_1_) - { -- this.unloadedEntityList.addAll(p_72828_1_); -+ for (Object o : p_72828_1_) { -+ ((Entity)o).markedForRemoval = true; -+ } - } - + loadedEntityList.add(entity); +@@ -3314,8 +3974,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_); @@ -1364,7 +1259,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 +4089,12 @@ +@@ -3464,6 +4133,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1377,7 +1272,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 +4120,12 @@ +@@ -3489,7 +4164,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1391,21 +1286,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3612,11 +4248,11 @@ - } - } - -- if (!this.loadedEntityList.contains(p_72897_1_)) -+ if (!this.loadedEntityList_KC.contains(p_72897_1_)) - { - if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72897_1_, this))) - { -- this.loadedEntityList.add(p_72897_1_); -+ this.loadedEntityList_KC.add(p_72897_1_); - } - } - } -@@ -3660,6 +4296,18 @@ +@@ -3660,6 +4340,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1424,29 +1305,18 @@ public float getWeightedThunderStrength(float p_72819_1_) { return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); -@@ -3932,8 +4580,8 @@ +@@ -3932,8 +4624,8 @@ */ public void addTileEntity(TileEntity entity) { - List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; - if(entity.canUpdate()) -+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList_KC; // Cauldron - List -> Collection for CB loadedTileEntityList type change ++ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; // Cauldron - List -> Collection for CB loadedTileEntityList type change + if (CauldronHooks.canUpdate(entity)) { dest.add(entity); } -@@ -4020,13 +4668,82 @@ - public int countEntities(EnumCreatureType type, boolean forSpawnCount) - { - int count = 0; -- for (int x = 0; x < loadedEntityList.size(); x++) -+ for (Entity entity : loadedEntityList_KC) - { -- if (((Entity)loadedEntityList.get(x)).isCreatureType(type, forSpawnCount)) -+ if (entity.isCreatureType(type, forSpawnCount)) - { - count++; - } +@@ -4029,4 +4721,73 @@ } return count; } @@ -1464,7 +1334,7 @@ + + public boolean isActiveChunk(int x, int z) + { -+ return activeChunkSet_CB.containsKey(chunkToKey(x, z)) || getPersistentChunks().containsKey(new ChunkCoordIntPair(x, z)); ++ return getPersistentChunks().containsKey(new ChunkCoordIntPair(x, z)) || activeChunkSet_CB.containsKey(chunkToKey(x, z)); + } + + public boolean isActiveChunk(long key) diff --git a/patches/net/minecraft/world/WorldServer.java.patch b/patches/net/minecraft/world/WorldServer.java.patch index 2e09798..1a9dc31 100644 --- a/patches/net/minecraft/world/WorldServer.java.patch +++ b/patches/net/minecraft/world/WorldServer.java.patch @@ -69,22 +69,12 @@ this.mcServer = p_i45284_1_; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerManager(this); -@@ -106,7 +129,7 @@ - - if (this.pendingTickListEntriesHashSet == null) - { -- this.pendingTickListEntriesHashSet = new HashSet(); -+ this.pendingTickListEntriesHashSet = com.google.common.collect.Sets.newConcurrentHashSet(); - } - - if (this.pendingTickListEntriesTreeSet == null) -@@ -124,6 +147,48 @@ +@@ -124,6 +147,47 @@ this.mapStorage.setData("scoreboard", scoreboardsavedata); } + scoreboardsavedata.func_96499_a(this.worldScoreboard); + ((ServerScoreboard) this.worldScoreboard).func_96547_a(scoreboardsavedata); -+ DimensionManager.setWorld(p_i45284_4_, this); + } + + // Add env and gen to constructor @@ -106,7 +96,7 @@ + + if (this.pendingTickListEntriesHashSet == null) + { -+ this.pendingTickListEntriesHashSet = com.google.common.collect.Sets.newConcurrentHashSet(); ++ this.pendingTickListEntriesHashSet = new HashSet(); + } + + if (this.pendingTickListEntriesTreeSet == null) @@ -127,7 +117,7 @@ if (!(this instanceof WorldServerMulti)) //Forge: We fix the global mapStorage, which causes us to share scoreboards early. So don't associate the save data with the temporary scoreboard { scoreboardsavedata.func_96499_a(this.worldScoreboard); -@@ -132,6 +197,31 @@ +@@ -132,6 +196,31 @@ DimensionManager.setWorld(p_i45284_4_, this); } @@ -159,17 +149,7 @@ public void tick() { super.tick(); -@@ -141,7 +231,9 @@ - this.difficultySetting = EnumDifficulty.HARD; - } - -+ timings.cleanupCache.startTiming(); // KCauldron - this.provider.worldChunkMgr.cleanupCache(); -+ timings.cleanupCache.stopTiming(); // KCauldron - - if (this.areAllPlayersAsleep()) - { -@@ -155,12 +247,19 @@ +@@ -155,12 +244,19 @@ } this.theProfiler.startSection("mobSpawner"); @@ -192,7 +172,7 @@ this.theProfiler.endStartSection("chunkSource"); this.chunkProvider.unloadQueuedChunks(); int j = this.calculateSkylightSubtracted(1.0F); -@@ -170,30 +269,47 @@ +@@ -170,30 +266,47 @@ this.skylightSubtracted = j; } @@ -241,7 +221,7 @@ } public BiomeGenBase.SpawnListEntry spawnRandomCreature(EnumCreatureType p_73057_1_, int p_73057_2_, int p_73057_3_, int p_73057_4_) -@@ -212,7 +328,7 @@ +@@ -212,7 +325,7 @@ { EntityPlayer entityplayer = (EntityPlayer)iterator.next(); @@ -250,7 +230,7 @@ { this.allPlayersSleeping = false; break; -@@ -240,7 +356,25 @@ +@@ -240,7 +353,25 @@ private void resetRainAndThunder() { @@ -277,7 +257,7 @@ } public boolean areAllPlayersAsleep() -@@ -248,19 +382,26 @@ +@@ -248,19 +379,26 @@ if (this.allPlayersSleeping && !this.isRemote) { Iterator iterator = this.playerEntities.iterator(); @@ -307,7 +287,7 @@ return false; } else -@@ -302,15 +443,29 @@ +@@ -302,15 +440,29 @@ super.func_147456_g(); int i = 0; int j = 0; @@ -343,7 +323,7 @@ this.func_147467_a(k, l, chunk); this.theProfiler.endStartSection("tickChunk"); chunk.func_150804_b(false); -@@ -346,12 +501,32 @@ +@@ -346,12 +498,32 @@ if (this.isBlockFreezableNaturally(j1 + k, l1 - 1, k1 + l)) { @@ -378,7 +358,7 @@ } if (this.isRaining()) -@@ -388,6 +563,7 @@ +@@ -388,6 +560,7 @@ if (block.getTickRandomly()) { ++i; @@ -386,7 +366,7 @@ block.updateTick(this, j2 + k, l2 + extendedblockstorage.getYLocation(), k2 + l, this.rand); } } -@@ -396,6 +572,13 @@ +@@ -396,6 +569,13 @@ this.theProfiler.endSection(); } @@ -400,23 +380,7 @@ } public boolean isBlockTickScheduledThisTick(int p_147477_1_, int p_147477_2_, int p_147477_3_, Block p_147477_4_) -@@ -450,7 +633,7 @@ - if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) - { - this.pendingTickListEntriesHashSet.add(nextticklistentry); -- this.pendingTickListEntriesTreeSet.add(nextticklistentry); -+ //this.pendingTickListEntriesTreeSet.add(nextticklistentry); // KCauldron - } - } - } -@@ -468,13 +651,13 @@ - if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) - { - this.pendingTickListEntriesHashSet.add(nextticklistentry); -- this.pendingTickListEntriesTreeSet.add(nextticklistentry); -+ //this.pendingTickListEntriesTreeSet.add(nextticklistentry); // KCauldron - } - } +@@ -474,7 +654,7 @@ public void updateEntities() { @@ -425,19 +389,7 @@ { if (this.updateEntityTick++ >= 1200) { -@@ -496,9 +679,9 @@ - - public boolean tickUpdates(boolean p_72955_1_) - { -- int i = this.pendingTickListEntriesTreeSet.size(); -+ int i = this.pendingTickListEntriesHashSet.size(); - -- if (i != this.pendingTickListEntriesHashSet.size()) -+ if (false) // KCauldron - { - throw new IllegalStateException("TickNextTick list out of synch"); - } -@@ -506,22 +689,31 @@ +@@ -506,7 +686,16 @@ { if (i > 1000) { @@ -455,43 +407,7 @@ } this.theProfiler.startSection("cleaning"); - NextTickListEntry nextticklistentry; - -- for (int j = 0; j < i; ++j) -+ for (Iterator iter = pendingTickListEntriesHashSet.iterator(); i >= 0 && iter.hasNext(); i--) - { -- nextticklistentry = (NextTickListEntry)this.pendingTickListEntriesTreeSet.first(); -+ nextticklistentry = (NextTickListEntry) iter.next(); - - if (!p_72955_1_ && nextticklistentry.scheduledTime > this.worldInfo.getWorldTotalTime()) - { - break; - } - -- this.pendingTickListEntriesTreeSet.remove(nextticklistentry); -+ //this.pendingTickListEntriesTreeSet.remove(nextticklistentry); // KCauldron - this.pendingTickListEntriesHashSet.remove(nextticklistentry); - this.pendingTickListEntriesThisTick.add(nextticklistentry); - } -@@ -577,7 +769,7 @@ - - this.theProfiler.endSection(); - this.pendingTickListEntriesThisTick.clear(); -- return !this.pendingTickListEntriesTreeSet.isEmpty(); -+ return !this.pendingTickListEntriesHashSet.isEmpty(); - } - } - -@@ -596,7 +788,7 @@ - - if (i1 == 0) - { -- iterator = this.pendingTickListEntriesTreeSet.iterator(); -+ iterator = this.pendingTickListEntriesHashSet.iterator(); - } - else - { -@@ -651,7 +843,37 @@ +@@ -651,7 +840,37 @@ protected IChunkProvider createChunkProvider() { IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); @@ -530,7 +446,7 @@ return this.theChunkProviderServer; } -@@ -659,29 +881,31 @@ +@@ -659,29 +878,31 @@ { ArrayList arraylist = new ArrayList(); @@ -577,16 +493,7 @@ return arraylist; } -@@ -704,7 +928,7 @@ - - if (this.pendingTickListEntriesHashSet == null) - { -- this.pendingTickListEntriesHashSet = new HashSet(); -+ this.pendingTickListEntriesHashSet = com.google.common.collect.Sets.newConcurrentHashSet(); - } - - if (this.pendingTickListEntriesTreeSet == null) -@@ -733,7 +957,28 @@ +@@ -733,7 +954,28 @@ int i = 0; int j = this.provider.getAverageGroundLevel(); int k = 0; @@ -615,7 +522,7 @@ if (chunkposition != null) { i = chunkposition.chunkPosX; -@@ -876,6 +1121,20 @@ +@@ -876,6 +1118,20 @@ public boolean addWeatherEffect(Entity p_72942_1_) { @@ -636,7 +543,7 @@ if (super.addWeatherEffect(p_72942_1_)) { this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_)); -@@ -894,13 +1153,23 @@ +@@ -894,13 +1150,23 @@ 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_) { @@ -661,7 +568,7 @@ if (!p_72885_10_) { explosion.affectedBlockPositions.clear(); -@@ -977,7 +1246,7 @@ +@@ -977,7 +1243,7 @@ { boolean flag = this.isRaining(); super.updateWeather(); @@ -670,7 +577,7 @@ if (this.prevRainingStrength != this.rainingStrength) { this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); -@@ -988,10 +1257,6 @@ +@@ -988,10 +1254,6 @@ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); } @@ -681,7 +588,7 @@ if (flag != this.isRaining()) { if (flag) -@@ -1006,6 +1271,33 @@ +@@ -1006,6 +1268,33 @@ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); } @@ -715,7 +622,7 @@ } protected int func_152379_p() -@@ -1069,4 +1361,51 @@ +@@ -1069,4 +1358,51 @@ this(); } } diff --git a/patches/net/minecraft/world/chunk/storage/RegionFile.java.patch b/patches/net/minecraft/world/chunk/storage/RegionFile.java.patch deleted file mode 100644 index b234bd8..0000000 --- a/patches/net/minecraft/world/chunk/storage/RegionFile.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java -+++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java -@@ -43,7 +43,8 @@ - - if (this.dataFile.length() < 4096L) - { -- for (i = 0; i < 1024; ++i) -+ // KCauldron start -+ /*for (i = 0; i < 1024; ++i) - { - this.dataFile.writeInt(0); - } -@@ -51,7 +52,10 @@ - for (i = 0; i < 1024; ++i) - { - this.dataFile.writeInt(0); -- } -+ }*/ -+ dataFile.write(emptySector); -+ dataFile.write(emptySector); -+ // KCauldron end - - this.sizeDelta += 8192; - } -@@ -209,7 +213,7 @@ - - public DataOutputStream getChunkDataOutputStream(int p_76710_1_, int p_76710_2_) - { -- return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_))); -+ return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new java.io.BufferedOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_)))); // KCauldron - } - - protected synchronized void write(int p_76706_1_, int p_76706_2_, byte[] p_76706_3_, int p_76706_4_) diff --git a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch index 34ee192..f4b1663 100644 --- a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch +++ b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch @@ -250,9 +250,9 @@ + Chunk chunk = (Chunk) this.loadedChunkHashMap_KC.get(LongHash.toLong(p_73154_1_, p_73154_2_)); + chunk = chunk == null ? (shouldLoadChunk() ? this.loadChunk(p_73154_1_, p_73154_2_) : this.defaultEmptyChunk) : chunk; // Cauldron handle forge server tick events and load the chunk within 5 seconds of the world being loaded (for chunk loaders) + -+ if (chunk == defaultEmptyChunk || chunk == null) ++ if (chunk == this.defaultEmptyChunk) + { -+ return defaultEmptyChunk; ++ return chunk; + } + + if ((p_73154_1_ != chunk.xPosition || p_73154_2_ != chunk.zPosition) && !worldObj.isProfilingWorld()) diff --git a/patches/net/minecraft/world/storage/MapData.java.patch b/patches/net/minecraft/world/storage/MapData.java.patch index 1795440..fb5fc73 100644 --- a/patches/net/minecraft/world/storage/MapData.java.patch +++ b/patches/net/minecraft/world/storage/MapData.java.patch @@ -15,12 +15,10 @@ public class MapData extends WorldSavedData { public int xCenter; -@@ -23,12 +31,22 @@ - public byte[] colors = new byte[16384]; +@@ -24,11 +32,21 @@ public List playersArrayList = new ArrayList(); private Map playersHashMap = new HashMap(); -- public Map playersVisibleOnMap = new LinkedHashMap(); -+ public Map playersVisibleOnMap = new LinkedHashMap(); + public Map playersVisibleOnMap = new LinkedHashMap(); + + // CraftBukkit start + public final CraftMapView mapView; @@ -39,7 +37,7 @@ } public void readFromNBT(NBTTagCompound p_76184_1_) -@@ -107,14 +125,14 @@ +@@ -107,7 +125,7 @@ { if (!this.playersHashMap.containsKey(p_76191_1_)) { @@ -48,41 +46,6 @@ this.playersHashMap.put(p_76191_1_, mapinfo); this.playersArrayList.add(mapinfo); } - - if (!p_76191_1_.inventory.hasItemStack(p_76191_2_)) - { -- this.playersVisibleOnMap.remove(p_76191_1_.getCommandSenderName()); -+ this.playersVisibleOnMap.remove(p_76191_1_.getUniqueID()); - } - - for (int i = 0; i < this.playersArrayList.size(); ++i) -@@ -166,7 +184,7 @@ - { - if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F) - { -- this.playersVisibleOnMap.remove(p_82567_3_); -+ this.playersVisibleOnMap.remove(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII))); - return; - } - -@@ -194,7 +212,7 @@ - } - } - -- this.playersVisibleOnMap.put(p_82567_3_, new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2)); -+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2)); - } - - public byte[] getUpdatePacketData(ItemStack p_76193_1_, World p_76193_2_, EntityPlayer p_76193_3_) -@@ -250,7 +268,7 @@ - byte b3 = p_76192_1_[i * 3 + 2]; - byte b0 = p_76192_1_[i * 3 + 3]; - byte b1 = (byte)(p_76192_1_[i * 3 + 1] & 15); -- this.playersVisibleOnMap.put("icon-" + i, new MapData.MapCoord(b2, b3, b0, b1)); -+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(("icon-" + i).getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord(b2, b3, b0, b1)); - } - } - else if (p_76192_1_[0] == 2) @@ -265,7 +283,7 @@ if (mapinfo == null) diff --git a/patches/net/minecraft/world/storage/ThreadedFileIOBase.java.patch b/patches/net/minecraft/world/storage/ThreadedFileIOBase.java.patch deleted file mode 100644 index 5e6b988..0000000 --- a/patches/net/minecraft/world/storage/ThreadedFileIOBase.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/storage/ThreadedFileIOBase.java -+++ ../src-work/minecraft/net/minecraft/world/storage/ThreadedFileIOBase.java -@@ -39,14 +39,14 @@ - ++this.savedIOCounter; - } - -- try -+ /*try // KCauldron start - { - Thread.sleep(this.isThreadWaiting ? 0L : 10L); - } - catch (InterruptedException interruptedexception1) - { - interruptedexception1.printStackTrace(); -- } -+ }*/ // KCauldron end - } - - if (this.threadedIOQueue.isEmpty()) diff --git a/patches/org/bukkit/command/defaults/StopCommand.java.patch b/patches/org/bukkit/command/defaults/StopCommand.java.patch deleted file mode 100644 index aefcd01..0000000 --- a/patches/org/bukkit/command/defaults/StopCommand.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- ../src-base/minecraft/org/bukkit/command/defaults/StopCommand.java -+++ ../src-work/minecraft/org/bukkit/command/defaults/StopCommand.java -@@ -12,6 +12,8 @@ - - import com.google.common.collect.ImmutableList; - -+import net.minecraft.server.dedicated.DedicatedServer; -+ - public class StopCommand extends VanillaCommand { - public StopCommand() { - super("stop"); -@@ -23,16 +25,19 @@ - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; -+ -+ DedicatedServer.allowPlayerLogins = false; // KCauldron - immediately disable logins - - Command.broadcastCommandMessage(sender, "Stopping the server.."); -- Bukkit.shutdown(); - - String reason = this.createString(args, 0); - if (StringUtils.isNotEmpty(reason)) { -- for (Player player : Bukkit.getOnlinePlayers()) { -+ for (Player player : ImmutableList.copyOf(Bukkit.getOnlinePlayers())) { - player.kickPlayer(reason); - } - } -+ -+ Bukkit.shutdown(); // KCauldron - shutdown server after all players kicked - - return true; - } diff --git a/reformat.sh b/reformat.sh new file mode 100755 index 0000000..989fc15 --- /dev/null +++ b/reformat.sh @@ -0,0 +1,4 @@ +#!/bin/sh +find patches -type f -name '*.java.patch' -exec sed -i "s/\t/ /g" {} \; +find src/main/java -type f -name '*.java' -exec sed -i "s/\t/ /g" {} \; + diff --git a/src/main/java/kcauldron/KCauldron.java b/src/main/java/kcauldron/KCauldron.java index 156cbdd..9430ead 100644 --- a/src/main/java/kcauldron/KCauldron.java +++ b/src/main/java/kcauldron/KCauldron.java @@ -105,13 +105,13 @@ public class KCauldron { private static boolean sLegacy, sOfficial; public static boolean isLegacy() { - parseManifest(); - return sLegacy; + parseManifest(); + return sLegacy; } public static boolean isOfficial() { - parseManifest(); - return sOfficial; + parseManifest(); + return sOfficial; } public static File sNewServerLocation; diff --git a/src/main/java/kcauldron/KCauldronCommand.java b/src/main/java/kcauldron/KCauldronCommand.java index e2d3359..6176151 100644 --- a/src/main/java/kcauldron/KCauldronCommand.java +++ b/src/main/java/kcauldron/KCauldronCommand.java @@ -20,6 +20,7 @@ import kcauldron.updater.KVersionRetriever; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.NextTickListEntry; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; @@ -129,22 +130,22 @@ public class KCauldronCommand extends Command { world.provider.getDimensionName(), world.dimension)); writer.write("Current tick: " + world.worldInfo.getWorldTotalTime() + "\n"); writer.write("\nEntities: "); - writer.write("count - " + world.loadedEntityList_KC.size() + "\n"); - for (Entity entity : world.loadedEntityList_KC) { + writer.write("count - " + world.loadedEntityList.size() + "\n"); + for (Entity entity : (Iterable) world.loadedEntityList) { writer.write(String.format(" %s at (%.4f;%.4f;%.4f)\n", entity.getClass().getName(), entity.posX, entity.posY, entity.posZ)); } writer.write("\nTileEntities: "); - writer.write("count - " + world.loadedTileEntityList_KC.size() + "\n"); - for (TileEntity entity : world.loadedTileEntityList_KC) { + writer.write("count - " + world.loadedTileEntityList.size() + "\n"); + for (TileEntity entity : (Iterable) world.loadedTileEntityList) { writer.write(String.format(" %s at (%d;%d;%d)\n", entity.getClass().getName(), entity.xCoord, entity.yCoord, entity.zCoord)); } writer.write("\nLoaded chunks: "); - writer.write("count - " + world.activeChunkSet_CB.size() + "\n"); - for (long chunkKey : world.activeChunkSet_CB.keys()) { - final int x = WorldServer.keyToX(chunkKey); - final int z = WorldServer.keyToZ(chunkKey); + writer.write("count - " + world.activeChunkSet.size() + "\n"); + for (ChunkCoordIntPair chunkCoords : (Iterable) world.activeChunkSet) { + final int x = chunkCoords.chunkXPos; + final int z = chunkCoords.chunkZPos; Chunk chunk = world.chunkProvider.provideChunk(x, z); if (chunk == null) continue; diff --git a/src/main/java/kcauldron/KCauldronWorldSaveThread.java b/src/main/java/kcauldron/KCauldronWorldSaveThread.java deleted file mode 100644 index 9440253..0000000 --- a/src/main/java/kcauldron/KCauldronWorldSaveThread.java +++ /dev/null @@ -1,57 +0,0 @@ -package kcauldron; - -import org.bukkit.craftbukkit.SpigotTimings; - -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.MinecraftException; - -public class KCauldronWorldSaveThread extends Thread { - private final MinecraftServer mServer; - private int mLastSaveTick = -1; - private int mNextSaveTick = -1; - - public KCauldronWorldSaveThread(MinecraftServer server) { - super(KCauldron.sKCauldronThreadGroup, "KCauldron World Save"); - mServer = server; - setPriority(Thread.MIN_PRIORITY); - setDaemon(true); - } - - @Override - public void run() { - KLog.get().info("Starting KCauldron World Saver thread..."); - try { - while (!isInterrupted()) { - if (mLastSaveTick < 0) { - mLastSaveTick = mServer.tickCounter; - } - mNextSaveTick = mLastSaveTick + mServer.autosavePeriod; - while (mNextSaveTick > mServer.tickCounter) { - try { - sleep((mNextSaveTick - mServer.tickCounter) * 50); - } catch (InterruptedException e) { - return; - } - } - SpigotTimings.worldSaveTimer.startTiming(); - try { - mServer.serverConfigManager.saveAllPlayerData(); - mServer.saveAllWorlds(true); - } catch (MinecraftException e) { - new RuntimeException("Error occurred during save world", e).printStackTrace(); - } - SpigotTimings.worldSaveTimer.stopTiming(); - mLastSaveTick = mServer.tickCounter; - } - } finally { - KLog.get().info("Stopping KCauldron World Saver thread..."); - } - } - - public void stopServer() { - interrupt(); - while(isAlive()) { - Thread.yield(); - } - } -} diff --git a/src/main/java/kcauldron/updater/DefaultUpdateCallback.java b/src/main/java/kcauldron/updater/DefaultUpdateCallback.java index f3442a8..2980c31 100644 --- a/src/main/java/kcauldron/updater/DefaultUpdateCallback.java +++ b/src/main/java/kcauldron/updater/DefaultUpdateCallback.java @@ -21,12 +21,12 @@ public class DefaultUpdateCallback implements IVersionCheckCallback { public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); if (hasPermission(player)) { - if (KCauldron.isLegacy()) { - player.sendMessage(ChatColor.YELLOW + "We're running on legacy version on KCauldron, please update your version"); - } - if (!KCauldron.isOfficial()) { - player.sendMessage(ChatColor.YELLOW + "We're running on non-official version on KCauldron, please update your version"); - } + if (KCauldron.isLegacy()) { + player.sendMessage(ChatColor.YELLOW + "We're running on legacy version on KCauldron, please update your version"); + } + if (!KCauldron.isOfficial()) { + player.sendMessage(ChatColor.YELLOW + "We're running on non-official version on KCauldron, please update your version"); + } if (mHasUpdate) { sendUpdate(player); } diff --git a/src/main/java/kcauldron/wrapper/CollectionWrapper.java b/src/main/java/kcauldron/wrapper/CollectionWrapper.java deleted file mode 100644 index 17a1cf3..0000000 --- a/src/main/java/kcauldron/wrapper/CollectionWrapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package kcauldron.wrapper; - -import java.util.Collection; -import java.util.Iterator; - -public class CollectionWrapper> implements Collection { - protected C mCollection; - - public CollectionWrapper(C collection) { - mCollection = collection; - } - - @Override - public boolean add(T e) { - return mCollection.add(e); - } - - @Override - public boolean addAll(Collection c) { - return mCollection.addAll(c); - } - - @Override - public void clear() { - mCollection.clear(); - } - - @Override - public boolean contains(Object o) { - return mCollection.contains(o); - } - - @Override - public boolean containsAll(Collection c) { - return mCollection.containsAll(c); - } - - @Override - public boolean isEmpty() { - return mCollection.isEmpty(); - } - - @Override - public Iterator iterator() { - return mCollection.iterator(); - } - - @Override - public boolean remove(Object o) { - return mCollection.remove(o); - } - - @Override - public boolean removeAll(Collection c) { - return mCollection.removeAll(c); - } - - @Override - public boolean retainAll(Collection c) { - return mCollection.retainAll(c); - } - - @Override - public int size() { - return mCollection.size(); - } - - @Override - public Object[] toArray() { - return mCollection.toArray(); - } - - @Override - public T[] toArray(T[] a) { - return mCollection.toArray(a); - } - - public C unwrap() { - return mCollection; - } -} diff --git a/src/main/java/kcauldron/wrapper/LinkedHelper.java b/src/main/java/kcauldron/wrapper/LinkedHelper.java deleted file mode 100644 index c4ac9ac..0000000 --- a/src/main/java/kcauldron/wrapper/LinkedHelper.java +++ /dev/null @@ -1,153 +0,0 @@ -package kcauldron.wrapper; - -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import cpw.mods.fml.common.FMLLog; - -public class LinkedHelper { - private final Iterable mIterable; - private volatile Iterator mIndexIterator; - private volatile int mIndex; - private volatile T mIndexValue; - - public LinkedHelper(Iterable iterable) { - mIterable = iterable; - } - - public synchronized T get(int index) { - if (mIndexIterator == null || mIndex > index) { - mIndexIterator = mIterable.iterator(); - mIndex = -1; - } - if (mIndex == index) return mIndexValue; - T value = null; - while (mIndex < index && mIndexIterator.hasNext()) { - value = mIndexIterator.next(); - mIndex++; - } - if (mIndex < index) { - mIndexIterator = mIterable.iterator(); - mIndex = -1; - while (mIndex < index && mIndexIterator.hasNext()) { - value = mIndexIterator.next(); - mIndex++; - } - } - if (mIndex < index) { - FMLLog.bigWarning("LinkedHelper desync, report this to KCauldron tracker!"); - } - return mIndexValue = value; - } - - public int indexOf(Object o) { - int i = 0; - for (T value : mIterable) { - if (o == null ? value == null : o.equals(value)) - return i; - i++; - } - return -1; - } - - public int lastIndexOf(Object o) { - if (!(mIterable instanceof List)) { - throw new UnsupportedOperationException(); - } - ListIterator iterator = ((List) mIterable).listIterator(); - int i = 0; - while (iterator.hasPrevious()) { - T value = iterator.previous(); - if (o == null ? value == null : o.equals(value)) - return i; - i++; - } - return -1; - } - - public ListIterator listIterator() { - if (mIterable instanceof List) { - return ((List) mIterable).listIterator(); - } - return new LinkedListIterator(mIterable.iterator(), 0); - } - - public ListIterator listIterator(int index) { - if (mIterable instanceof List) { - return ((List) mIterable).listIterator(index); - } - Iterator iterator = mIterable.iterator(); - for (int i = 0; i < index; i++) - iterator.next(); - return new LinkedListIterator(iterator, index); - } - - private static final class LinkedListIterator implements ListIterator { - private final Iterator mIterator; - private final ListIterator mListIterator; - private int mNextIndex; - - public LinkedListIterator(Iterator iterator, int index) { - mIterator = iterator; - mListIterator = iterator instanceof ListIterator ? (ListIterator) iterator : null; - mNextIndex = index; - } - - private void ensureListIterator() { - if (mListIterator == null) - throw new UnsupportedOperationException(); - } - - @Override - public void add(T e) { - ensureListIterator(); - mListIterator.add(e); - } - - @Override - public boolean hasNext() { - return mIterator.hasNext(); - } - - @Override - public boolean hasPrevious() { - ensureListIterator(); - return mListIterator.hasPrevious(); - } - - @Override - public T next() { - mNextIndex++; - return mIterator.next(); - } - - @Override - public int nextIndex() { - return mListIterator != null ? mListIterator.nextIndex() : mNextIndex; - } - - @Override - public T previous() { - ensureListIterator(); - return mListIterator.previous(); - } - - @Override - public int previousIndex() { - ensureListIterator(); - return mListIterator.previousIndex(); - } - - @Override - public void remove() { - mIterator.remove(); - } - - @Override - public void set(T e) { - ensureListIterator(); - mListIterator.set(e); - } - } -} diff --git a/src/main/java/kcauldron/wrapper/ProcessingQueue.java b/src/main/java/kcauldron/wrapper/ProcessingQueue.java deleted file mode 100644 index d44885d..0000000 --- a/src/main/java/kcauldron/wrapper/ProcessingQueue.java +++ /dev/null @@ -1,124 +0,0 @@ -package kcauldron.wrapper; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Queue; -import java.util.concurrent.atomic.AtomicInteger; - -public class ProcessingQueue extends QueueWrapper { - public class ProcessingIterator implements Iterator { - private Iterator mRealIterator = mCollection.iterator(); - - @Override - public boolean hasNext() { - return mRealIterator.hasNext(); - } - - @Override - public T next() { - return mRealIterator.next(); - } - - @Override - public void remove() { - mRealIterator.remove(); - mSize.decrementAndGet(); - } - } - - private final AtomicInteger mSize; - - @Override - public boolean add(T e) { - boolean result = super.add(e); - if (result) { - mSize.incrementAndGet(); - } - return result; - }; - - @Override - public boolean offer(T e) { - boolean result = super.offer(e); - if (result) { - mSize.incrementAndGet(); - } - return result; - } - - @Override - public boolean addAll(Collection c) { - boolean result = false; - for (T t : c) { - result |= add(t); - } - return result; - } - - @Override - public T remove() { - T result = super.remove(); - mSize.decrementAndGet(); - return result; - } - - @Override - public boolean remove(Object o) { - boolean result = super.remove(o); - if (result) { - mSize.decrementAndGet(); - } - return result; - } - - @Override - public boolean removeAll(Collection c) { - boolean result = false; - for (Object t : c) { - result |= remove(t); - } - return result; - } - - @Override - public boolean retainAll(Collection c) { - boolean result = super.retainAll(c); - if (result) { - mSize.set(mCollection.size()); - } - return result; - } - - @Override - public T poll() { - T result = super.remove(); - if (result != null) { - mSize.decrementAndGet(); - } - return result; - } - - public ProcessingQueue(Queue collection) { - super(collection); - mSize = new AtomicInteger(collection.size()); - } - - @Override - public ProcessingIterator iterator() { - return new ProcessingIterator(); - } - - @Override - public String toString() { - if (size() == 0) - return "[]"; - StringBuilder builder = new StringBuilder(); - for (T t : this) { - builder.append(','); - builder.append(t == null ? "null" : t.getClass().getSimpleName()); - } - builder.setCharAt(0, '['); - builder.append(']'); - return builder.toString(); - } -} diff --git a/src/main/java/kcauldron/wrapper/QueueToList.java b/src/main/java/kcauldron/wrapper/QueueToList.java deleted file mode 100644 index 6dd9332..0000000 --- a/src/main/java/kcauldron/wrapper/QueueToList.java +++ /dev/null @@ -1,68 +0,0 @@ -package kcauldron.wrapper; - -import java.util.Collection; -import java.util.List; -import java.util.ListIterator; -import java.util.Queue; - -public class QueueToList extends CollectionWrapper> implements List { - private final Queue mQueue; - private final LinkedHelper mHelper; - - public QueueToList(Queue queue) { - super(queue); - mQueue = queue; - mHelper = new LinkedHelper(mQueue); - } - - @Override - public void add(int index, T element) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public T get(int index) { - return mHelper.get(index); - } - - @Override - public int indexOf(Object o) { - return mHelper.indexOf(o); - } - - @Override - public int lastIndexOf(Object o) { - return mHelper.lastIndexOf(o); - } - - @Override - public ListIterator listIterator() { - return mHelper.listIterator(); - } - - @Override - public ListIterator listIterator(int index) { - return mHelper.listIterator(index); - } - - @Override - public T remove(int index) { - T object = mHelper.get(index); - return mQueue.remove(object) ? object : null; - } - - @Override - public T set(int index, T element) { - throw new UnsupportedOperationException(); - } - - @Override - public List subList(int fromIndex, int toIndex) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/kcauldron/wrapper/QueueWrapper.java b/src/main/java/kcauldron/wrapper/QueueWrapper.java deleted file mode 100644 index b65ef73..0000000 --- a/src/main/java/kcauldron/wrapper/QueueWrapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package kcauldron.wrapper; - -import java.util.Queue; - -public class QueueWrapper extends CollectionWrapper> implements Queue{ - public QueueWrapper(Queue collection) { - super(collection); - } - - @Override - public T element() { - return mCollection.element(); - } - - @Override - public boolean offer(T e) { - return mCollection.offer(e); - } - - @Override - public T peek() { - return mCollection.peek(); - } - - @Override - public T poll() { - return mCollection.poll(); - } - - @Override - public T remove() { - return mCollection.remove(); - } -} diff --git a/src/main/java/net/minecraftforge/cauldron/CauldronHooks.java b/src/main/java/net/minecraftforge/cauldron/CauldronHooks.java index 150b7ae..8008d9b 100644 --- a/src/main/java/net/minecraftforge/cauldron/CauldronHooks.java +++ b/src/main/java/net/minecraftforge/cauldron/CauldronHooks.java @@ -334,15 +334,16 @@ public class CauldronHooks writer.name("players").value(world.playerEntities.size()); writer.name("loadedChunks").value(world.theChunkProviderServer.loadedChunkHashMap_KC.size()); writer.name("activeChunks").value(world.activeChunkSet.size()); - writer.name("entities").value(world.loadedEntityList_KC.size()); - writer.name("tiles").value(world.loadedTileEntityList_KC.size()); + writer.name("entities").value(world.loadedEntityList.size()); + writer.name("tiles").value(world.loadedTileEntityList.size()); TObjectIntHashMap chunkEntityCounts = new TObjectIntHashMap(); TObjectIntHashMap classEntityCounts = new TObjectIntHashMap(); TObjectIntHashMap entityCollisionCounts = new TObjectIntHashMap(); Set collidingCoords = new HashSet(); - for (Entity entity : world.loadedEntityList_KC) + for (int i = 0; i < world.loadedEntityList.size(); i++) { + Entity entity = (Entity) world.loadedEntityList.get(i); ChunkCoordIntPair chunkCoords = new ChunkCoordIntPair((int) entity.posX >> 4, (int) entity.posZ >> 4); chunkEntityCounts.adjustOrPutValue(chunkCoords, 1, 1); classEntityCounts.adjustOrPutValue(entity.getClass(), 1, 1); @@ -365,8 +366,9 @@ public class CauldronHooks TObjectIntHashMap chunkTileCounts = new TObjectIntHashMap(); TObjectIntHashMap classTileCounts = new TObjectIntHashMap(); writer.name("tiles").beginArray(); - for (TileEntity tile : world.loadedTileEntityList_KC) + for (int i = 0; i < world.loadedTileEntityList.size(); i++) { + TileEntity tile = (TileEntity) world.loadedTileEntityList.get(i); if (logAll) { writer.beginObject(); diff --git a/src/main/java/net/minecraftforge/cauldron/command/CauldronCommand.java b/src/main/java/net/minecraftforge/cauldron/command/CauldronCommand.java index 6108051..3442f89 100644 --- a/src/main/java/net/minecraftforge/cauldron/command/CauldronCommand.java +++ b/src/main/java/net/minecraftforge/cauldron/command/CauldronCommand.java @@ -7,8 +7,6 @@ import java.util.Date; import java.util.List; import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.WorldServer; import net.minecraftforge.cauldron.CauldronHooks; import net.minecraftforge.cauldron.configuration.BoolSetting; import net.minecraftforge.cauldron.configuration.IntSetting; @@ -114,11 +112,13 @@ public class CauldronCommand extends Command sender.sendMessage(ChatColor.GOLD + "Dimension: " + ChatColor.GRAY + world.provider.dimensionId + ChatColor.GOLD + " Loaded Chunks: " + ChatColor.GRAY + world.theChunkProviderServer.loadedChunkHashMap_KC.size() + ChatColor.GOLD + " Active Chunks: " + ChatColor.GRAY + world.activeChunkSet.size() + - ChatColor.GOLD + " Entities: " + ChatColor.GRAY + world.loadedEntityList_KC.size() + - ChatColor.GOLD + " Tile Entities: " + ChatColor.GRAY + world.loadedTileEntityList_KC.size() + ChatColor.GOLD + " Entities: " + ChatColor.GRAY + world.loadedEntityList.size() + + ChatColor.GOLD + " Tile Entities: " + ChatColor.GRAY + world.loadedTileEntityList.size() ); sender.sendMessage(ChatColor.GOLD + " Entities Last Tick: " + ChatColor.GRAY + world.entitiesTicked + - ChatColor.GOLD + " Tiles Last Tick: " + ChatColor.GRAY + world.tilesTicked + ChatColor.GOLD + " Tiles Last Tick: " + ChatColor.GRAY + world.tilesTicked + + ChatColor.GOLD + " Removed Entities: " + ChatColor.GRAY + world.unloadedEntityList.size() + + ChatColor.GOLD + " Removed Tile Entities: " + ChatColor.GRAY + world.field_147483_b.size() ); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 33a189f..0e45b9f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -263,7 +263,6 @@ public final class CraftServer implements Server { waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); ambientSpawn = configuration.getInt("spawn-limits.ambient"); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); - console.invalidateWorldSaver(); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); loadIcon(); chunkGCEnabled = configuration.getBoolean("chunk-gc.enabled"); // Cauldron @@ -671,7 +670,7 @@ public final class CraftServer implements Server { @Override public List getWorlds() { - return ImmutableList.copyOf(worlds.values()); + return new ArrayList(worlds.values()); } public DedicatedPlayerList getHandle() { @@ -765,7 +764,6 @@ public final class CraftServer implements Server { warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); printSaveWarning = false; console.autosavePeriod = configuration.getInt("ticks-per.autosave"); - console.invalidateWorldSaver(); chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); loadIcon(); @@ -1152,7 +1150,7 @@ public final class CraftServer implements Server { @Override public Map getCommandAliases() { - ConfigurationSection section = commandsConfiguration.getConfigurationSection("aliases"); + ConfigurationSection section = configuration.getConfigurationSection("aliases"); Map result = new LinkedHashMap(); if (section != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 6be5a1f..8e94643 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -683,16 +683,16 @@ public class CraftWorld implements World { public List getEntities() { List list = new ArrayList(); - for (net.minecraft.entity.Entity mcEnt : world.loadedEntityList_KC) { - //if (o instanceof net.minecraft.entity.Entity) { - //net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; + for (Object o : world.loadedEntityList) { + if (o instanceof net.minecraft.entity.Entity) { + net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); // Assuming that bukkitEntity isn't null if (bukkitEntity != null) { list.add(bukkitEntity); } - //} + } } return list; @@ -701,16 +701,16 @@ public class CraftWorld implements World { public List getLivingEntities() { List list = new ArrayList(); - for (net.minecraft.entity.Entity mcEnt : world.loadedEntityList_KC) { - //if (o instanceof net.minecraft.entity.Entity) { - //net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; + for (Object o : world.loadedEntityList) { + if (o instanceof net.minecraft.entity.Entity) { + net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); // Assuming that bukkitEntity isn't null if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) { list.add((LivingEntity) bukkitEntity); } - //} + } } return list; @@ -726,9 +726,9 @@ public class CraftWorld implements World { public Collection getEntitiesByClass(Class clazz) { Collection list = new ArrayList(); - for (net.minecraft.entity.Entity entity : world.loadedEntityList_KC) { - //if (entity instanceof net.minecraft.entity.Entity) { - Entity bukkitEntity = entity.getBukkitEntity(); + for (Object entity: world.loadedEntityList) { + if (entity instanceof net.minecraft.entity.Entity) { + Entity bukkitEntity = ((net.minecraft.entity.Entity) entity).getBukkitEntity(); if (bukkitEntity == null) { continue; @@ -739,7 +739,7 @@ public class CraftWorld implements World { if (clazz.isAssignableFrom(bukkitClass)) { list.add((T) bukkitEntity); } - //} + } } return list; @@ -748,9 +748,9 @@ public class CraftWorld implements World { public Collection getEntitiesByClasses(Class... classes) { Collection list = new ArrayList(); - for (net.minecraft.entity.Entity entity: world.loadedEntityList_KC) { - //if (entity instanceof net.minecraft.entity.Entity) { - Entity bukkitEntity = entity.getBukkitEntity(); + for (Object entity: world.loadedEntityList) { + if (entity instanceof net.minecraft.entity.Entity) { + Entity bukkitEntity = ((net.minecraft.entity.Entity) entity).getBukkitEntity(); if (bukkitEntity == null) { continue; @@ -764,7 +764,7 @@ public class CraftWorld implements World { break; } } - //} + } } return list; @@ -773,15 +773,15 @@ public class CraftWorld implements World { public List getPlayers() { List list = new ArrayList(); - for (net.minecraft.entity.Entity mcEnt : world.loadedEntityList_KC) { - //if (o instanceof net.minecraft.entity.Entity) { - //net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; + for (Object o : world.loadedEntityList) { + if (o instanceof net.minecraft.entity.Entity) { + net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { list.add((Player) bukkitEntity); } - //} + } } return list; diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java index 64b1cc4..dd32404 100644 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java @@ -136,8 +136,6 @@ public class SpigotTimings { public final CustomTimingsHandler tracker; public final CustomTimingsHandler doTick; public final CustomTimingsHandler tickEntities; - public final CustomTimingsHandler weatherUpdate; - public final CustomTimingsHandler cleanupCache; public final CustomTimingsHandler syncChunkLoadTimer; public final CustomTimingsHandler syncChunkLoadDataTimer; @@ -175,8 +173,6 @@ public class SpigotTimings { tracker = new CustomTimingsHandler(name + "tracker"); doTick = new CustomTimingsHandler(name + "doTick"); tickEntities = new CustomTimingsHandler(name + "tickEntities"); - weatherUpdate = new CustomTimingsHandler(name + "weatherUpdate"); - cleanupCache = new CustomTimingsHandler(name + "cleanupCache"); } } } \ No newline at end of file diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4b89cce..5b3e16a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.MapMaker; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index bbe768d..4dbbca5 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -1,9 +1,6 @@ package org.bukkit.craftbukkit.map; -import java.util.Map; -import java.util.UUID; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.map.MapCanvas; @@ -11,8 +8,6 @@ import org.bukkit.map.MapCursorCollection; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; -import net.minecraft.world.storage.MapData; - public class CraftMapRenderer extends MapRenderer { private final net.minecraft.world.storage.MapData worldMap; @@ -37,14 +32,14 @@ public class CraftMapRenderer extends MapRenderer { cursors.removeCursor(cursors.getCursor(0)); } - for (Map.Entry key : worldMap.playersVisibleOnMap.entrySet()) { + for (Object key : worldMap.playersVisibleOnMap.keySet()) { // If this cursor is for a player check visibility with vanish system - Player other = Bukkit.getPlayer(key.getKey()); + Player other = Bukkit.getPlayerExact((String) key); if (other != null && !player.canSee(other)) { continue; } - MapData.MapCoord decoration = key.getValue(); + net.minecraft.world.storage.MapData.MapCoord decoration = (net.minecraft.world.storage.MapData.MapCoord) worldMap.playersVisibleOnMap.get(key); cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize); } } diff --git a/src/main/java/org/spigotmc/CaseInsensitiveHashingStrategy.java b/src/main/java/org/spigotmc/CaseInsensitiveHashingStrategy.java deleted file mode 100644 index 365887f..0000000 --- a/src/main/java/org/spigotmc/CaseInsensitiveHashingStrategy.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.spigotmc; - -import gnu.trove.strategy.HashingStrategy; - -class CaseInsensitiveHashingStrategy implements HashingStrategy { - private static final long serialVersionUID = -9212222772914758878L; - static final CaseInsensitiveHashingStrategy INSTANCE = new CaseInsensitiveHashingStrategy(); - - @Override - public int computeHashCode(String object) { - return object.toLowerCase().hashCode(); - } - - @Override - public boolean equals(String o1, String o2) { - return o1.equalsIgnoreCase(o2); - } -} \ No newline at end of file diff --git a/src/main/java/org/spigotmc/CaseInsensitiveMap.java b/src/main/java/org/spigotmc/CaseInsensitiveMap.java deleted file mode 100644 index e16535a..0000000 --- a/src/main/java/org/spigotmc/CaseInsensitiveMap.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.spigotmc; - -import gnu.trove.map.hash.TCustomHashMap; -import java.util.Map; - -public class CaseInsensitiveMap extends TCustomHashMap { - - public CaseInsensitiveMap() { - super(CaseInsensitiveHashingStrategy.INSTANCE); - } - - public CaseInsensitiveMap(Map map) { - super(CaseInsensitiveHashingStrategy.INSTANCE, map); - } -} \ No newline at end of file diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index b7da4a5..4d7ee7a 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -90,7 +90,7 @@ public class WatchdogThread extends Thread log.log(Level.SEVERE, " Dimension:" + world.provider.dimensionId); log.log(Level.SEVERE, " Loaded Chunks: " + world.theChunkProviderServer.loadedChunkHashMap_KC.size() + " Active Chunks: " + world.activeChunkSet.size() - + " Entities: " + world.loadedEntityList_KC.size() + " Tile Entities: " + world.loadedTileEntityList_KC.size()); + + " Entities: " + world.loadedEntityList.size() + " Tile Entities: " + world.loadedTileEntityList.size()); log.log(Level.SEVERE, " Entities Last Tick: " + world.entitiesTicked); log.log(Level.SEVERE, " Tiles Last Tick: " + world.tilesTicked); } @@ -155,8 +155,8 @@ public class WatchdogThread extends Thread log.log(Level.WARNING, " Dimension:" + world.provider.dimensionId); log.log(Level.WARNING, " Loaded Chunks: " + world.theChunkProviderServer.loadedChunkHashMap_KC.size() + " Active Chunks: " + world.activeChunkSet.size() + - " Entities: " + world.loadedEntityList_KC.size() + - " Tile Entities: " + world.loadedTileEntityList_KC.size()); + " Entities: " + world.loadedEntityList.size() + + " Tile Entities: " + world.loadedTileEntityList.size()); log.log(Level.WARNING, " Entities Last Tick: " + world.entitiesTicked); log.log(Level.WARNING, " Tiles Last Tick: " + world.tilesTicked); }