2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("BlockMisc.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
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;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
|
|
|
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;
|
|
|
|
import net.minecraft.block.material.Material;
|
2016-01-08 15:21:05 +01:00
|
|
|
import net.minecraft.block.properties.PropertyInteger;
|
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.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public class BlockMisc extends BlockBase{
|
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();
|
|
|
|
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_MISC_BLOCKS.length-1);
|
2015-10-18 19:56:18 +02:00
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public BlockMisc(String name){
|
2016-04-20 21:39:03 +02:00
|
|
|
super(Material.ROCK, name);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.setHardness(1.5F);
|
2015-07-07 01:13:39 +02:00
|
|
|
this.setResistance(10.0F);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.setHarvestLevel("pickaxe", 1);
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2016-01-07 23:42:42 +01:00
|
|
|
public int damageDropped(IBlockState state){
|
|
|
|
return this.getMetaFromState(state);
|
2015-02-20 22:45:33 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List list){
|
2016-05-19 20:05:12 +02:00
|
|
|
for(int j = 0; j < ALL_MISC_BLOCKS.length; j++){
|
2016-02-01 17:49:55 +01:00
|
|
|
list.add(new ItemStack(item, 1, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 20:32:49 +01:00
|
|
|
@Override
|
2016-04-20 21:39:03 +02:00
|
|
|
protected ItemBlockBase getItemBlock(){
|
|
|
|
return new TheItemBlock(this);
|
2016-02-01 20:32:49 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 02:36:43 +01:00
|
|
|
@Override
|
|
|
|
protected void registerRendering(){
|
2016-05-19 20:05:12 +02:00
|
|
|
for(int i = 0; i < ALL_MISC_BLOCKS.length; i++){
|
2016-06-01 00:37:28 +02:00
|
|
|
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), META.getName()+"="+i);
|
2016-01-09 02:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:56 +02:00
|
|
|
@Override
|
2015-12-19 10:30:39 +01: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
|
|
|
|
protected PropertyInteger getMetaProperty(){
|
|
|
|
return META;
|
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:56 +02:00
|
|
|
public static class TheItemBlock extends ItemBlockBase{
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
public TheItemBlock(Block block){
|
2015-02-17 16:15:16 +01:00
|
|
|
super(block);
|
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
2016-05-29 23:49:35 +02:00
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2016-05-19 20:05:12 +02:00
|
|
|
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+ALL_MISC_BLOCKS[stack.getItemDamage()].name;
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|