Easier handling of meta blocks
This commit is contained in:
parent
fb94914b91
commit
9035f800e2
16 changed files with 436 additions and 277 deletions
|
@ -3,34 +3,23 @@ package WayofTime.bloodmagic.block;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
|
||||
import WayofTime.bloodmagic.block.base.BlockStringContainer;
|
||||
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockRitualController extends BlockContainer {
|
||||
public class BlockRitualController extends BlockStringContainer {
|
||||
|
||||
public static final String[] names = { "master", "imperfect" };
|
||||
public static final PropertyInteger META = PropertyInteger.create("meta", 0, names.length - 1);
|
||||
|
||||
public BlockRitualController() {
|
||||
super(Material.rock);
|
||||
super(Material.rock, names);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".stone.ritual.");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
|
@ -40,14 +29,6 @@ public class BlockRitualController extends BlockContainer {
|
|||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < names.length; i++)
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
@ -63,36 +44,6 @@ public class BlockRitualController extends BlockContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(META, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return (Integer) state.getValue(META);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState() {
|
||||
return new BlockState(this, META);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return meta == 0 ? new TileMasterRitualStone() : new TileImperfectRitualStone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue