package WayofTime.bloodmagic.block.base; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; /** * Creates a block that has multiple meta-based states. *
* These states will be numbered 0 through {@code maxMeta}.
*/
public class BlockInteger extends Block {
private final int maxMeta;
private final PropertyInteger property;
private final BlockStateContainer realStateContainer;
public BlockInteger(Material material, int maxMeta, String propName) {
super(material);
this.maxMeta = maxMeta;
this.property = PropertyInteger.create(propName, 0, maxMeta);
this.realStateContainer = createStateContainer();
setDefaultState(getBlockState().getBaseState());
}
public BlockInteger(Material material, int maxMeta) {
this(material, maxMeta, "meta");
}
@Override
protected final BlockStateContainer createBlockState() {
return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes
}
@Override
public final BlockStateContainer getBlockState() {
return realStateContainer;
}
@Override
public BlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(property, meta);
}
@Override
public int getMetaFromState(BlockState state) {
return state.getValue(property);
}
@Override
public int damageDropped(BlockState state) {
return getMetaFromState(state);
}
@Override
public void getSubBlocks(ItemGroup tab, NonNullList