Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Some general changes to the handling of blocks
Dieser Commit ist enthalten in:
Ursprung
f74381b93f
Commit
62e6e9de96
@ -1,3 +1,6 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven'
|
||||
|
||||
repositories {
|
||||
maven {url "https://ci.athion.net/job/FAWE-WorldGuard-1.13/lastSuccessfulBuild/artifact/mvn"}
|
||||
}
|
||||
|
@ -83,9 +83,15 @@ public class BaseBlock extends BlockState {
|
||||
public BaseBlock(BlockType blockType) {
|
||||
this(blockType.getDefaultState());
|
||||
}
|
||||
/**
|
||||
* Construct a block with a state.
|
||||
*
|
||||
* @param blockState The blockstate
|
||||
*/
|
||||
|
||||
public BaseBlock(BlockState blockState) {
|
||||
this(blockState, blockState.getNbtData());
|
||||
// this(blockState, blockState.getNbtData());
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +101,7 @@ public class BaseBlock extends BlockState {
|
||||
* @param nbtData NBT data, which must be provided
|
||||
*/
|
||||
public BaseBlock(BlockState state, CompoundTag nbtData) {
|
||||
super(state.getBlockType());
|
||||
// super(state.getBlockType());
|
||||
checkNotNull(nbtData);
|
||||
this.blockState = state;
|
||||
this.nbtData = nbtData;
|
||||
@ -200,7 +206,7 @@ public class BaseBlock extends BlockState {
|
||||
|
||||
@Override
|
||||
public BlockTypes getBlockType() {
|
||||
return blockState.getBlockType();
|
||||
return blockState.getBlockType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,14 +85,17 @@ public abstract class BlockState implements BlockStateHolder<BlockState> {
|
||||
public static BlockState get(@Nullable BlockType type, String state) throws InputParseException {
|
||||
return get(type, state, null);
|
||||
}
|
||||
private BaseBlock emptyBaseBlock;
|
||||
// private BlockTypes blockType;
|
||||
// private BaseBlock emptyBaseBlock;
|
||||
|
||||
// Neighbouring state table.
|
||||
private Table<Property<?>, Object, BlockState> states;
|
||||
|
||||
protected BlockState(BlockType blockType) {
|
||||
this.emptyBaseBlock = new BaseBlock(this);
|
||||
}
|
||||
|
||||
// protected BlockState(BlockTypes blockType) {
|
||||
//// protected BlockState() {
|
||||
// this.blockType = blockType;
|
||||
// this.emptyBaseBlock = new BaseBlock(this);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a temporary BlockState for a given type and string
|
||||
@ -306,13 +309,13 @@ public abstract class BlockState implements BlockStateHolder<BlockState> {
|
||||
return (Map<Property<?>, Object>) map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock() {
|
||||
// if (this.fuzzy) {
|
||||
// throw new IllegalArgumentException("Can't create a BaseBlock from a fuzzy BlockState!");
|
||||
// }
|
||||
return this.emptyBaseBlock;
|
||||
}
|
||||
// @Override
|
||||
// public BaseBlock toBaseBlock() {
|
||||
//// if (this.fuzzy) {
|
||||
//// throw new IllegalArgumentException("Can't create a BaseBlock from a fuzzy BlockState!");
|
||||
//// }
|
||||
// return this.emptyBaseBlock;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
|
||||
@ -321,6 +324,11 @@ public abstract class BlockState implements BlockStateHolder<BlockState> {
|
||||
}
|
||||
return new BaseBlock(this, compoundTag);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public BlockTypes getBlockType() {
|
||||
// return this.blockType;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Deprecated, use masks - not try to this fuzzy/non fuzzy state nonsense
|
||||
|
@ -9,12 +9,14 @@ public class BlockStateImpl extends BlockState {
|
||||
private final int ordinal;
|
||||
private final BlockTypes type;
|
||||
private BlockMaterial material;
|
||||
private BaseBlock baseBlock;
|
||||
|
||||
protected BlockStateImpl(BlockTypes type, int internalId, int ordinal) {
|
||||
super(type);
|
||||
// super(type);
|
||||
this.type = type;
|
||||
this.internalId = internalId;
|
||||
this.ordinal = ordinal;
|
||||
this.baseBlock = new BaseBlock(this);
|
||||
}
|
||||
|
||||
public BlockMaterial getMaterial() {
|
||||
@ -45,4 +47,9 @@ public class BlockStateImpl extends BlockState {
|
||||
public final BlockTypes getBlockType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock() {
|
||||
return this.baseBlock;
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ public enum BlockTypes implements BlockType {
|
||||
String name = (name().indexOf(':') == -1 ? "minecraft:" : "") + name().toLowerCase();
|
||||
ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("id"), this, name);
|
||||
}
|
||||
Settings settings = new Settings((this.getTypeEnum() == BlockTypes.__RESERVED__ ? BlockTypes.AIR : this), id, internalId, states);
|
||||
Settings settings = new Settings(this, id, internalId, states);
|
||||
ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("settings"), this, settings);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -95,6 +95,7 @@ public class LegacyMapper {
|
||||
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
|
||||
try {
|
||||
BlockStateHolder blockState = BlockState.get(null, blockEntry.getValue());
|
||||
// BlockState blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(blockEntry.getValue(), parserContext).toImmutableState();
|
||||
BlockTypes type = blockState.getBlockType();
|
||||
if (type.hasProperty(PropertyKey.WATERLOGGED)) {
|
||||
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren