2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2016-01-09 02:36:43 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2020-09-09 09:58:55 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-02-17 16:15:16 +01:00
|
|
|
import net.minecraft.block.Block;
|
2020-09-08 16:41:52 +02:00
|
|
|
import net.minecraft.block.SoundType;
|
2015-02-17 16:15:16 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2016-11-21 16:23:48 +01:00
|
|
|
import net.minecraft.block.properties.PropertyEnum;
|
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
2016-01-07 23:42:42 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-02-17 16:15:16 +01:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2015-03-07 02:23:31 +01:00
|
|
|
import net.minecraft.item.EnumRarity;
|
2015-02-17 16:15:16 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-11-19 21:11:17 +01:00
|
|
|
import net.minecraft.util.NonNullList;
|
2020-09-08 16:41:52 +02:00
|
|
|
import net.minecraftforge.common.ToolType;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2020-09-08 16:41:52 +02:00
|
|
|
public class BlockMisc extends Block {
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
public static final TheMiscBlocks[] ALL_MISC_BLOCKS = TheMiscBlocks.values();
|
2017-07-28 03:17:50 +02:00
|
|
|
public static final PropertyEnum<TheMiscBlocks> TYPE = PropertyEnum.create("type", TheMiscBlocks.class);
|
2015-10-18 19:56:18 +02:00
|
|
|
|
2020-09-08 16:41:52 +02:00
|
|
|
public BlockMisc() {
|
|
|
|
super(Block.Properties.create(Material.ROCK)
|
|
|
|
.hardnessAndResistance(1.5f, 10.0f)
|
|
|
|
.harvestTool(ToolType.PICKAXE)
|
|
|
|
.sound(SoundType.STONE));
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public int damageDropped(IBlockState state) {
|
2016-01-07 23:42:42 +01:00
|
|
|
return this.getMetaFromState(state);
|
2015-02-20 22:45:33 +01:00
|
|
|
}
|
|
|
|
|
2016-06-10 21:52:37 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
|
|
for (int j = 0; j < ALL_MISC_BLOCKS.length; j++) {
|
2017-06-17 00:48:49 +02:00
|
|
|
list.add(new ItemStack(this, 1, j));
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 20:32:49 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
protected BlockItemBase getItemBlock() {
|
2016-04-20 21:39:03 +02:00
|
|
|
return new TheItemBlock(this);
|
2016-02-01 20:32:49 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 02:36:43 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void registerRendering() {
|
|
|
|
for (int i = 0; i < ALL_MISC_BLOCKS.length; i++) {
|
|
|
|
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_MISC_BLOCKS[i].name);
|
2016-01-09 02:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:56 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public EnumRarity getRarity(ItemStack stack) {
|
2016-05-19 20:05:12 +02:00
|
|
|
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? EnumRarity.COMMON : ALL_MISC_BLOCKS[stack.getItemDamage()].rarity;
|
2015-10-23 16:48:56 +02:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBlockState getStateFromMeta(int meta) {
|
2016-11-21 16:23:48 +01:00
|
|
|
return this.getDefaultState().withProperty(TYPE, TheMiscBlocks.values()[meta]);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public int getMetaFromState(IBlockState state) {
|
2016-11-21 16:23:48 +01:00
|
|
|
return state.getValue(TYPE).ordinal();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected BlockStateContainer createBlockState() {
|
2016-11-21 16:23:48 +01:00
|
|
|
return new BlockStateContainer(this, TYPE);
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
|
|
|
|
2020-09-09 09:58:55 +02:00
|
|
|
public static class TheItemBlock extends BlockItemBase {
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public TheItemBlock(Block block) {
|
2015-02-17 16:15:16 +01:00
|
|
|
super(block);
|
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public String getTranslationKey(ItemStack stack) {
|
|
|
|
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_MISC_BLOCKS[stack.getItemDamage()].name;
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
2017-08-02 14:01:41 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemBurnTime(ItemStack stack) {
|
2019-05-02 09:10:29 +02:00
|
|
|
if (stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000;
|
2019-02-27 19:53:05 +01:00
|
|
|
return super.getItemBurnTime(stack);
|
2017-08-02 14:01:41 +02:00
|
|
|
}
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
}
|