2015-04-17 01:15:33 +02:00
|
|
|
package techreborn.blocks;
|
|
|
|
|
2017-01-05 22:14:24 +01:00
|
|
|
import com.google.common.base.CaseFormat;
|
2015-04-17 01:15:33 +02:00
|
|
|
import net.minecraft.block.material.Material;
|
2015-11-26 18:35:31 +01:00
|
|
|
import net.minecraft.block.properties.PropertyInteger;
|
2016-03-13 17:08:30 +01:00
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
2015-11-23 20:51:40 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-04-17 01:15:33 +02:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-04-17 18:42:57 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-11-19 15:41:00 +01:00
|
|
|
import net.minecraft.util.NonNullList;
|
2015-04-17 18:42:57 +02:00
|
|
|
import net.minecraft.world.World;
|
2015-11-23 20:19:18 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-11-08 13:15:45 +01:00
|
|
|
import reborncore.common.multiblock.BlockMultiblockBase;
|
2015-04-17 18:42:57 +02:00
|
|
|
import techreborn.client.TechRebornCreativeTab;
|
2017-01-05 22:14:24 +01:00
|
|
|
import techreborn.init.ModBlocks;
|
2015-04-17 18:42:57 +02:00
|
|
|
import techreborn.tiles.TileMachineCasing;
|
2015-07-02 20:51:24 +02:00
|
|
|
|
2017-01-05 22:14:24 +01:00
|
|
|
import java.security.InvalidParameterException;
|
2016-10-08 21:46:16 +02:00
|
|
|
import java.util.Random;
|
|
|
|
|
2016-12-05 11:48:21 +01:00
|
|
|
public class BlockMachineCasing extends BlockMultiblockBase {
|
2016-03-25 10:47:34 +01:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public static final String[] types = new String[] { "standard", "reinforced", "advanced" };
|
2016-07-23 20:10:37 +02:00
|
|
|
public static final PropertyInteger METADATA = PropertyInteger.create("type", 0, types.length);
|
2016-03-25 10:47:34 +01:00
|
|
|
|
2016-07-23 20:10:37 +02:00
|
|
|
public BlockMachineCasing(Material material) {
|
2016-03-25 10:47:34 +01:00
|
|
|
super(material);
|
|
|
|
setCreativeTab(TechRebornCreativeTab.instance);
|
|
|
|
setUnlocalizedName("techreborn.machineCasing");
|
|
|
|
setHardness(2F);
|
|
|
|
this.setDefaultState(this.getDefaultState().withProperty(METADATA, 0));
|
|
|
|
}
|
|
|
|
|
2017-01-05 22:14:24 +01:00
|
|
|
public static ItemStack getStackByName(String name, int count) {
|
|
|
|
name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
|
|
|
|
for (int i = 0; i < types.length; i++) {
|
|
|
|
if (types[i].equalsIgnoreCase(name)) {
|
|
|
|
return new ItemStack(ModBlocks.MACHINE_CASINGS, count, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new InvalidParameterException("The machine casing " + name + " could not be found.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getStackByName(String name) {
|
|
|
|
return getStackByName(name, 1);
|
|
|
|
}
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
@Override
|
2016-07-23 20:10:37 +02:00
|
|
|
public IBlockState getStateFromMeta(int meta) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return this.getDefaultState().withProperty(METADATA, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-07-23 20:10:37 +02:00
|
|
|
public int getMetaFromState(IBlockState state) {
|
2016-04-03 15:34:39 +02:00
|
|
|
return state.getValue(METADATA);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
|
2016-07-23 20:10:37 +02:00
|
|
|
protected BlockStateContainer createBlockState() {
|
2016-03-25 10:47:34 +01:00
|
|
|
return new BlockStateContainer(this, METADATA);
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:10:37 +02:00
|
|
|
public int getHeatFromState(IBlockState state) {
|
|
|
|
switch (getMetaFromState(state)) {
|
2016-03-25 10:47:34 +01:00
|
|
|
case 0:
|
|
|
|
return 1020 / 25;
|
|
|
|
case 1:
|
|
|
|
return 1700 / 25;
|
|
|
|
case 2:
|
|
|
|
return 2380 / 25;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-07-23 20:10:37 +02:00
|
|
|
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return Item.getItemFromBlock(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-11-19 15:41:00 +01:00
|
|
|
public void getSubBlocks(Item item, CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
|
2016-07-23 20:10:37 +02:00
|
|
|
for (int meta = 0; meta < types.length; meta++) {
|
2016-03-25 10:47:34 +01:00
|
|
|
list.add(new ItemStack(item, 1, meta));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-07-23 20:10:37 +02:00
|
|
|
public int damageDropped(IBlockState state) {
|
|
|
|
return getMetaFromState(state);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-07-23 20:10:37 +02:00
|
|
|
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return new TileMachineCasing();
|
|
|
|
}
|
|
|
|
|
2015-04-17 01:15:33 +02:00
|
|
|
}
|