forked from xjboss/KCauldronX
Apply fixes from binary patches.
This commit is contained in:
@ -22,6 +22,8 @@ import javax.management.MBeanServer;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IEntityMultiPart;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -147,32 +149,36 @@ public class CauldronHooks
|
||||
|
||||
public static boolean checkBoundingBoxSize(Entity entity, AxisAlignedBB aabb)
|
||||
{
|
||||
if (!(entity instanceof EntityLivingBase) || entity instanceof EntityPlayer) return false; // only check living entities that are not players
|
||||
int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue();
|
||||
if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
|
||||
int x = MathHelper.floor_double(aabb.minX);
|
||||
int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
|
||||
int y = MathHelper.floor_double(aabb.minY);
|
||||
int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
|
||||
int z = MathHelper.floor_double(aabb.minZ);
|
||||
int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);
|
||||
|
||||
int size = Math.abs(x1-x) * Math.abs(y1-y) * Math.abs(z1-z);
|
||||
if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
|
||||
if (entity instanceof EntityLivingBase && (!(entity instanceof IBossDisplayData) || !(entity instanceof IEntityMultiPart))
|
||||
&& !(entity instanceof EntityPlayer))
|
||||
{
|
||||
logWarning("Entity being removed for bounding box restrictions");
|
||||
logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength());
|
||||
logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ);
|
||||
logWarning("Calculated bounding box: {0}", aabb);
|
||||
logWarning("Entity bounding box: {0}", entity.getBoundingBox());
|
||||
logWarning("Entity: {0}", entity);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
logWarning("Entity NBT: {0}", tag);
|
||||
logStack();
|
||||
entity.setDead();
|
||||
return true;
|
||||
int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue();
|
||||
if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
|
||||
int x = MathHelper.floor_double(aabb.minX);
|
||||
int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
|
||||
int y = MathHelper.floor_double(aabb.minY);
|
||||
int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
|
||||
int z = MathHelper.floor_double(aabb.minZ);
|
||||
int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);
|
||||
|
||||
int size = Math.abs(x1 - x) * Math.abs(y1 - y) * Math.abs(z1 - z);
|
||||
if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
|
||||
{
|
||||
logWarning("Entity being removed for bounding box restrictions");
|
||||
logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength());
|
||||
logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ);
|
||||
logWarning("Calculated bounding box: {0}", aabb);
|
||||
logWarning("Entity bounding box: {0}", entity.getBoundingBox());
|
||||
logWarning("Entity: {0}", entity);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
logWarning("Entity NBT: {0}", tag);
|
||||
logStack();
|
||||
entity.setDead();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class CauldronWorldConfig extends WorldConfig
|
||||
|
||||
public void init()
|
||||
{
|
||||
entityDespawnImmediate = getBoolean( "entity-despawn-immediate", true);
|
||||
entityDespawnImmediate = getBoolean( "entity-despawn-immediate", false);
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ public class CraftChunk implements Chunk {
|
||||
}
|
||||
|
||||
public net.minecraft.world.chunk.Chunk getHandle() {
|
||||
net.minecraft.world.chunk.Chunk c = weakChunk.get();
|
||||
net.minecraft.world.chunk.Chunk c = null;
|
||||
if (weakChunk != null) {
|
||||
c = weakChunk.get();
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
c = worldServer.getChunkFromChunkCoords(x, z);
|
||||
|
@ -9,9 +9,9 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
@ -504,28 +504,28 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
world.captureTreeGeneration = true;
|
||||
world.captureBlockStates = true;
|
||||
world.captureBlockSnapshots = true;
|
||||
boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
world.captureBlockStates = false;
|
||||
world.captureBlockSnapshots = false;
|
||||
world.captureTreeGeneration = false;
|
||||
if (grownTree) { // Copy block data to delegate
|
||||
for (BlockState blockstate : world.capturedBlockStates) {
|
||||
int x = blockstate.getX();
|
||||
int y = blockstate.getY();
|
||||
int z = blockstate.getZ();
|
||||
for (BlockSnapshot blocksnapshot : world.capturedBlockSnapshots) {
|
||||
int x = blocksnapshot.x;
|
||||
int y = blocksnapshot.y;
|
||||
int z = blocksnapshot.z;
|
||||
net.minecraft.block.Block oldBlock = world.getBlock(x, y, z);
|
||||
int newId = blockstate.getTypeId();
|
||||
int data = blockstate.getRawData();
|
||||
int flag = ((CraftBlockState)blockstate).getFlag();
|
||||
int newId = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
|
||||
int data = blocksnapshot.meta;
|
||||
int flag = blocksnapshot.flag;
|
||||
delegate.setTypeIdAndData(x, y, z, newId, data);
|
||||
net.minecraft.block.Block newBlock = world.getBlock(x, y, z);
|
||||
world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
|
||||
}
|
||||
world.capturedBlockStates.clear();
|
||||
world.capturedBlockSnapshots.clear();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
world.capturedBlockStates.clear();
|
||||
world.capturedBlockSnapshots.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// Cauldron start
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
// Cauldron end
|
||||
|
||||
public class CraftBlockState implements BlockState {
|
||||
@ -57,6 +59,30 @@ public class CraftBlockState implements BlockState {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public CraftBlockState(BlockSnapshot blocksnapshot)
|
||||
{
|
||||
this.world = blocksnapshot.world.getWorld();
|
||||
this.x = blocksnapshot.x;
|
||||
this.y = blocksnapshot.y;
|
||||
this.z = blocksnapshot.z;
|
||||
this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
|
||||
this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
|
||||
this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
|
||||
this.flag = 3;
|
||||
TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
|
||||
if (te != null)
|
||||
{
|
||||
this.nbt = new NBTTagCompound();
|
||||
te.writeToNBT(this.nbt);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.nbt = null;
|
||||
}
|
||||
|
||||
this.createData((byte) blocksnapshot.meta);
|
||||
}
|
||||
|
||||
public static CraftBlockState getBlockState(net.minecraft.world.World world, int x, int y, int z) {
|
||||
return new CraftBlockState(world.getWorld().getBlockAt(x, y, z));
|
||||
}
|
||||
|
@ -949,6 +949,10 @@ public class CraftEventFactory {
|
||||
event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.stats.Achievement) statistic));
|
||||
} else {
|
||||
org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
|
||||
if (stat == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
switch (stat) {
|
||||
case FALL_ONE_CM:
|
||||
case BOAT_ONE_CM:
|
||||
|
@ -371,10 +371,12 @@ public final class CraftItemStack extends ItemStack {
|
||||
return false;
|
||||
}
|
||||
|
||||
net.minecraft.nbt.NBTTagCompound tag = new net.minecraft.nbt.NBTTagCompound();
|
||||
item.setTagCompound(tag);
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.stackTagCompound = item.writeToNBT(new net.minecraft.nbt.NBTTagCompound());
|
||||
}
|
||||
|
||||
((CraftMetaItem) itemMeta).applyToItem(tag);
|
||||
((CraftMetaItem)itemMeta).applyToItem(item.stackTagCompound);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user