forked from xjboss/KCauldronX
Apply fixes from binary patches.
This commit is contained in:
@ -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