Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Update adapters.
Don't update unchanged blocks, do change NBT, no need to light. Also clean up the forge side a bit.
Dieser Commit ist enthalten in:
Ursprung
c885f70c7b
Commit
678a78a982
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
@ -166,21 +166,19 @@ public class ForgeWorld extends AbstractWorld {
|
||||
boolean successful = successState != null;
|
||||
|
||||
// Create the TileEntity
|
||||
if (successful) {
|
||||
if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) {
|
||||
// Kill the old TileEntity
|
||||
world.removeTileEntity(pos);
|
||||
NBTTagCompound nativeTag = NBTConverter.toNative(((BaseBlock) block).getNbtData());
|
||||
if (successful || old == newState) {
|
||||
if (block instanceof BaseBlock) {
|
||||
CompoundTag tag = ((BaseBlock) block).getNbtData();
|
||||
if (tag != null) {
|
||||
NBTTagCompound nativeTag = NBTConverter.toNative(tag);
|
||||
nativeTag.putString("id", ((BaseBlock) block).getNbtId());
|
||||
TileEntityUtils.setTileEntity(world, position, nativeTag);
|
||||
}
|
||||
}
|
||||
|
||||
if (notifyAndLight) {
|
||||
if (!successful) {
|
||||
newState = old;
|
||||
}
|
||||
world.checkLight(pos);
|
||||
|
||||
if (successful && notifyAndLight) {
|
||||
//world.checkLight(pos);
|
||||
world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@ -46,45 +44,14 @@ final class TileEntityUtils {
|
||||
*
|
||||
* @param tag the tag
|
||||
* @param position the position
|
||||
* @return a tag compound
|
||||
*/
|
||||
private static NBTTagCompound updateForSet(NBTTagCompound tag, BlockVector3 position) {
|
||||
private static void updateForSet(NBTTagCompound tag, BlockVector3 position) {
|
||||
checkNotNull(tag);
|
||||
checkNotNull(position);
|
||||
|
||||
tag.put("x", new NBTTagInt(position.getBlockX()));
|
||||
tag.put("y", new NBTTagInt(position.getBlockY()));
|
||||
tag.put("z", new NBTTagInt(position.getBlockZ()));
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a tile entity at the given location.
|
||||
*
|
||||
* @param world the world
|
||||
* @param position the position
|
||||
* @param clazz the tile entity class
|
||||
* @param tag the tag for the tile entity (may be null to not set NBT data)
|
||||
*/
|
||||
static void setTileEntity(World world, BlockVector3 position, Class<? extends TileEntity> clazz, @Nullable NBTTagCompound tag) {
|
||||
checkNotNull(world);
|
||||
checkNotNull(position);
|
||||
checkNotNull(clazz);
|
||||
|
||||
TileEntity tileEntity = constructTileEntity(world, position, clazz);
|
||||
|
||||
if (tileEntity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tag != null) {
|
||||
// Set X, Y, Z
|
||||
updateForSet(tag, position);
|
||||
tileEntity.read(tag);
|
||||
}
|
||||
|
||||
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,42 +72,6 @@ final class TileEntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a tile entity from the given class.
|
||||
*
|
||||
* @param world the world
|
||||
* @param position the position
|
||||
* @param clazz the class
|
||||
* @return a tile entity (may be null if it failed)
|
||||
*/
|
||||
@Nullable
|
||||
static TileEntity constructTileEntity(World world, BlockVector3 position, Class<? extends TileEntity> clazz) {
|
||||
Constructor<? extends TileEntity> baseConstructor;
|
||||
try {
|
||||
baseConstructor = clazz.getConstructor(); // creates "blank" TE
|
||||
} catch (Throwable e) {
|
||||
return null; // every TE *should* have this constructor, so this isn't necessary
|
||||
}
|
||||
|
||||
TileEntity genericTE;
|
||||
try {
|
||||
genericTE = baseConstructor.newInstance();
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
genericTE.blockType = Block.blocksList[block.getId()];
|
||||
genericTE.blockMetadata = block.getData();
|
||||
genericTE.xCoord = pt.getBlockX();
|
||||
genericTE.yCoord = pt.getBlockY();
|
||||
genericTE.zCoord = pt.getBlockZ();
|
||||
genericTE.worldObj = world;
|
||||
*/ // handled by internal code
|
||||
|
||||
return genericTE;
|
||||
}
|
||||
|
||||
public static NBTTagCompound copyNbtData(TileEntity tile) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tile.write(tag);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren