mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-24 01:19:24 +00:00
rename methods
This commit is contained in:
@@ -108,7 +108,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
this.fallingBlockRemoveListener = new FallingBlockRemoveListener();
|
||||
} else this.fallingBlockRemoveListener = null;
|
||||
this.stateId2ImmutableBlockStates = new ImmutableBlockState[customBlockCount];
|
||||
Arrays.fill(this.stateId2ImmutableBlockStates, EmptyBlock.INSTANCE.getDefaultState());
|
||||
Arrays.fill(this.stateId2ImmutableBlockStates, EmptyBlock.INSTANCE.defaultState());
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
this.cachedSuggestions.clear();
|
||||
this.blockStateOverrides.clear();
|
||||
if (EmptyBlock.INSTANCE != null)
|
||||
Arrays.fill(this.stateId2ImmutableBlockStates, EmptyBlock.INSTANCE.getDefaultState());
|
||||
Arrays.fill(this.stateId2ImmutableBlockStates, EmptyBlock.INSTANCE.defaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -595,7 +595,7 @@ public class BukkitInjector {
|
||||
int stateId = BlockStateUtils.blockStateToId(newState);
|
||||
CESection section = holder.ceSection();
|
||||
if (BlockStateUtils.isVanillaBlock(stateId)) {
|
||||
section.setBlockState(x, y, z, EmptyBlock.INSTANCE.getDefaultState());
|
||||
section.setBlockState(x, y, z, EmptyBlock.INSTANCE.defaultState());
|
||||
if (ConfigManager.enableLightSystem() && ConfigManager.forceUpdateLight()) {
|
||||
updateLightIfChanged(holder, previousState, newState, null, y, z, x);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BlockStateParser {
|
||||
return null;
|
||||
}
|
||||
Holder<CustomBlock> holder = optional.get();
|
||||
ImmutableBlockState defaultState = holder.value().getDefaultState();
|
||||
ImmutableBlockState defaultState = holder.value().defaultState();
|
||||
if (reader.canRead() && reader.peek() == '[') {
|
||||
reader.skip();
|
||||
while (reader.canRead() && reader.peek() != ']') {
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.function.BiFunction;
|
||||
|
||||
public abstract class CustomBlock {
|
||||
protected final Holder<CustomBlock> holder;
|
||||
protected Key id;
|
||||
protected ImmutableBlockState defaultState;
|
||||
protected BlockStateVariantProvider variantProvider;
|
||||
protected Map<String, Property<?>> properties;
|
||||
protected BlockBehavior behavior;
|
||||
protected final Key id;
|
||||
protected final BlockStateVariantProvider variantProvider;
|
||||
protected final Map<String, Property<?>> properties;
|
||||
protected final BlockBehavior behavior;
|
||||
protected final List<BiFunction<BlockPlaceContext, ImmutableBlockState, ImmutableBlockState>> placements;
|
||||
protected final ImmutableBlockState defaultState;
|
||||
@Nullable
|
||||
protected LootTable<?> lootTable;
|
||||
protected List<BiFunction<BlockPlaceContext, ImmutableBlockState, ImmutableBlockState>> placements;
|
||||
protected final LootTable<?> lootTable;
|
||||
|
||||
public CustomBlock(
|
||||
@NotNull Key id,
|
||||
@@ -47,7 +47,7 @@ public abstract class CustomBlock {
|
||||
this.properties = properties;
|
||||
this.placements = new ArrayList<>();
|
||||
this.variantProvider = new BlockStateVariantProvider(holder, ImmutableBlockState::new, properties);
|
||||
this.setDefaultState(this.variantProvider.getDefaultState());
|
||||
this.defaultState = this.variantProvider.getDefaultState();
|
||||
this.behavior = BlockBehaviors.fromMap(this, behaviorSettings);
|
||||
for (Map.Entry<String, VariantState> entry : variantMapper.entrySet()) {
|
||||
String nbtString = entry.getKey();
|
||||
@@ -101,7 +101,7 @@ public abstract class CustomBlock {
|
||||
|
||||
private List<ImmutableBlockState> getPossibleStates(CompoundTag nbt) {
|
||||
List<ImmutableBlockState> tempStates = new ArrayList<>();
|
||||
tempStates.add(getDefaultState());
|
||||
tempStates.add(defaultState());
|
||||
for (Property<?> property : variantProvider.getDefaultState().getProperties()) {
|
||||
Tag value = nbt.get(property.name());
|
||||
if (value != null) {
|
||||
@@ -120,9 +120,9 @@ public abstract class CustomBlock {
|
||||
}
|
||||
|
||||
public ImmutableBlockState getBlockState(CompoundTag nbt) {
|
||||
ImmutableBlockState state = getDefaultState();
|
||||
ImmutableBlockState state = defaultState();
|
||||
for (Map.Entry<String, Tag> entry : nbt.tags.entrySet()) {
|
||||
Property<?> property = variantProvider.getProperty(entry.getKey());
|
||||
Property<?> property = this.variantProvider.getProperty(entry.getKey());
|
||||
if (property != null) {
|
||||
try {
|
||||
state = ImmutableBlockState.with(state, property, property.unpack(entry.getValue()));
|
||||
@@ -144,16 +144,12 @@ public abstract class CustomBlock {
|
||||
return this.properties.values();
|
||||
}
|
||||
|
||||
protected final void setDefaultState(ImmutableBlockState state) {
|
||||
this.defaultState = state;
|
||||
}
|
||||
|
||||
public final ImmutableBlockState getDefaultState() {
|
||||
public final ImmutableBlockState defaultState() {
|
||||
return this.defaultState;
|
||||
}
|
||||
|
||||
public ImmutableBlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
ImmutableBlockState state = getDefaultState();
|
||||
ImmutableBlockState state = defaultState();
|
||||
for (BiFunction<BlockPlaceContext, ImmutableBlockState, ImmutableBlockState> placement : this.placements) {
|
||||
state = placement.apply(context, state);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ImmutableBlockState extends BlockStateHolder {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this == EmptyBlock.INSTANCE.getDefaultState();
|
||||
return this == EmptyBlock.INSTANCE.defaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CEChunk {
|
||||
for (int i = 0; i < sections.length; ++i) {
|
||||
if (sections[i] == null) {
|
||||
sections[i] = new CESection(world.worldHeight().getSectionYFromSectionIndex(i),
|
||||
new PalettedContainer<>(null, EmptyBlock.INSTANCE.getDefaultState(), PalettedContainer.PaletteProvider.CUSTOM_BLOCK_STATE));
|
||||
new PalettedContainer<>(null, EmptyBlock.INSTANCE.defaultState(), PalettedContainer.PaletteProvider.CUSTOM_BLOCK_STATE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SectionSerializer {
|
||||
ReadableContainer.Serialized<ImmutableBlockState> serialized = section.statesContainer().serialize(null, PalettedContainer.PaletteProvider.CUSTOM_BLOCK_STATE);
|
||||
ListTag palettes = new ListTag();
|
||||
List<ImmutableBlockState> states = serialized.paletteEntries();
|
||||
if (states.size() == 1 && states.get(0) == EmptyBlock.INSTANCE.getDefaultState()) {
|
||||
if (states.size() == 1 && states.get(0) == EmptyBlock.INSTANCE.defaultState()) {
|
||||
return null;
|
||||
}
|
||||
CompoundTag sectionNbt = new CompoundTag();
|
||||
|
||||
Reference in New Issue
Block a user