Delegate to blocktype for obtaining a BlockState's material

This commit is contained in:
dordsor21 2021-01-14 12:45:11 +00:00
parent ac73478827
commit 5e1289494e
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -26,10 +26,8 @@ import com.boydti.fawe.util.StringMan;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.extent.OutputExtent;
@ -58,7 +56,6 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
private final int ordinal;
private final char ordinalChar;
private final BlockType blockType;
private BlockMaterial material;
private final BaseBlock emptyBaseBlock;
private CompoundInput compoundInput = CompoundInput.NULL;
@ -75,7 +72,6 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
* @deprecated Magic Numbers
* @return BlockState
*/
@Deprecated
public static BlockState getFromInternalId(int combinedId) throws InputParseException {
return BlockTypes.getFromStateId(combinedId).withStateId(combinedId);
@ -366,16 +362,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
@Override
public BlockMaterial getMaterial() {
if (this.material == null) {
if (blockType == BlockTypes.__RESERVED__) {
return this.material = blockType.getMaterial();
}
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
if (this.material.hasContainer()) {
this.compoundInput = CompoundInput.CONTAINER;
}
}
return material;
return blockType.getMaterial();
}
@Override
@ -408,11 +395,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
}
public boolean isAir() {
try {
return material.isAir();
} catch (NullPointerException ignored) {
return getMaterial().isAir();
}
return blockType.getMaterial().isAir();
}
@Override