Don't construct new BaseBlock

Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-06 01:12:57 +11:00
Ursprung 99db2d557a
Commit 144215c813
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
12 geänderte Dateien mit 15 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -379,8 +379,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
trio.set(x, y, z);
CompoundTag nbt = nbtMap.get(trio);
if (nbt != null) {
BaseBlock block = new BaseBlock(state, nbt);
task.run(x, y, z, block);
task.run(x, y, z, state.toBaseBlock(nbt));
continue;
}
}
@ -411,8 +410,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
trio.set(x, y, z);
CompoundTag nbt = nbtMap.get(trio);
if (nbt != null) {
BaseBlock block = new BaseBlock(state, nbt);
task.run(x, y, z, block);
task.run(x, y, z, state.toBaseBlock(nbt));
continue;
}
}

Datei anzeigen

@ -12,7 +12,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
public class IdDataMaskPattern extends AbstractExtentPattern {
private final Pattern pattern;
private final int bitMask;
private final BaseBlock mutable = new BaseBlock(BlockTypes.AIR);
public IdDataMaskPattern(Extent extent, Pattern parent, int bitMask) {
super(extent);

Datei anzeigen

@ -205,7 +205,7 @@ public class PropertyPattern extends AbstractExtentPattern {
if (newOrdinal != ordinal) {
CompoundTag nbt = block.getNbtData();
BlockState newState = BlockState.getFromOrdinal(newOrdinal);
return nbt != null ? new BaseBlock(newState, nbt) : newState.toBaseBlock();
return newState.toBaseBlock(nbt);
}
return orDefault;
}

Datei anzeigen

@ -122,7 +122,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag nbt = (CompoundTag) blockMap.get("nbt");
if (nbt != null) {
BaseBlock block = new BaseBlock(state, nbt);
BaseBlock block = state.toBaseBlock(nbt);
clipboard.setBlock(x, y, z, block);
continue;
}

Datei anzeigen

@ -153,7 +153,7 @@ public class FakePlayer extends AbstractPlayerActor {
@Override
public BaseBlock getBlockInHand(HandSide ignore) {
return new BaseBlock(BlockTypes.AIR.getDefaultState());
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@Override

Datei anzeigen

@ -341,7 +341,7 @@ public class CuboidClipboard {
public BaseBlock getPoint(BlockVector3 position) throws ArrayIndexOutOfBoundsException {
final BaseBlock block = getBlock(position);
if (block == null) {
return new BaseBlock(BlockTypes.AIR);
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
return block;

Datei anzeigen

@ -271,7 +271,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
}
if (nbt != null) return new BaseBlock(state, nbt);
if (nbt != null) return state.toBaseBlock(nbt);
if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN) {
// Allow special sign text syntax

Datei anzeigen

@ -203,8 +203,8 @@ public class WorldEditBinding {
@BindingMatch(type = {BaseBlock.class, BlockState.class, BlockStateHolder.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1)
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
return new BaseBlock(getBlockState(context));
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
return getBlockState(context).toBaseBlock();
}
/**

Datei anzeigen

@ -153,6 +153,6 @@ public class ServerCUIHandler {
structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId()));
// return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag));
return new BaseBlock(BlockTypes.STRUCTURE_BLOCK.getDefaultState(), new CompoundTag(structureTag));
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag));
}
}

Datei anzeigen

@ -111,7 +111,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
this(getState(id, data));
}
private static final BlockState getState(int id, int data) {
public static final BlockState getState(int id, int data) {
BlockState blockState = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
if (blockState == null) {
blockState = BlockTypes.AIR.getDefaultState();
@ -124,8 +124,8 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
}
@Deprecated
public static BaseBlock getFromInternalId(int id, CompoundTag nbtData) {
return new BaseBlock(id, nbtData);
public static BaseBlock getFromInternalId(int internalId, CompoundTag nbtData) {
return BlockState.getFromInternalId(internalId).toBaseBlock(nbtData);
}
/**

Datei anzeigen

@ -245,7 +245,7 @@ public class AnvilChunk13 implements Chunk {
BlockState state = sectionBlocks != null ? sectionBlocks[(yIndex << 8) | (z << 4) | x] : BlockTypes.AIR.getDefaultState();
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) return new BaseBlock(state, tileEntity);
return state.toBaseBlock(tileEntity);
}
return state.toBaseBlock();

Datei anzeigen

@ -238,7 +238,7 @@ public class LegacyMapper {
}
}else if(plotBlock instanceof LegacyPlotBlock) {
try {
return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData());
return BaseBlock.getState(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData()).toBaseBlock();
}catch(Throwable failed) {
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace();