2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("BlockMisc.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-03-07 12:51:28 +01:00
|
|
|
|
package ellpeck.actuallyadditions.blocks;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-03-07 12:51:28 +01:00
|
|
|
|
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
2015-10-23 16:48:56 +02:00
|
|
|
|
import ellpeck.actuallyadditions.items.ItemBlockBase;
|
2015-10-18 19:56:18 +02:00
|
|
|
|
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
2015-10-01 23:20:31 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
2015-04-06 15:51:59 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
|
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;
|
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2015-10-01 23:20:31 +02:00
|
|
|
|
public class BlockMisc extends Block implements IActAddItemOrBlock{
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
|
|
|
|
public static final TheMiscBlocks[] allMiscBlocks = TheMiscBlocks.values();
|
|
|
|
|
public IIcon[] textures = new IIcon[allMiscBlocks.length];
|
|
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
|
private IIcon stoneCasingSeasonalTop;
|
|
|
|
|
private IIcon stoneCasingSeasonal;
|
|
|
|
|
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public BlockMisc(){
|
|
|
|
|
super(Material.rock);
|
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
|
|
|
|
|
public IIcon getIcon(int side, int metadata){
|
2015-10-18 19:56:18 +02:00
|
|
|
|
if(ClientProxy.jingleAllTheWay && metadata == TheMiscBlocks.STONE_CASING.ordinal() && side != 0){
|
|
|
|
|
return side == 1 ? this.stoneCasingSeasonalTop : this.stoneCasingSeasonal;
|
|
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
|
return metadata >= textures.length ? null : textures[metadata];
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public int damageDropped(int meta){
|
2015-03-07 12:51:28 +01:00
|
|
|
|
return meta;
|
2015-02-20 22:45:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List list){
|
|
|
|
|
for(int j = 0; j < allMiscBlocks.length; j++){
|
|
|
|
|
list.add(new ItemStack(item, 1, j));
|
|
|
|
|
}
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
|
|
|
|
for(int i = 0; i < textures.length; i++){
|
2015-10-23 16:48:56 +02:00
|
|
|
|
textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+allMiscBlocks[i].name);
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
2015-10-18 19:56:18 +02:00
|
|
|
|
|
|
|
|
|
this.stoneCasingSeasonalTop = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockMiscStoneCasingSnowTop");
|
|
|
|
|
this.stoneCasingSeasonal = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockMiscStoneCasingSnow");
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
|
|
|
|
public String getName(){
|
|
|
|
|
return "blockMisc";
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-23 16:48:56 +02:00
|
|
|
|
@Override
|
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
|
return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2015-10-23 16:48:56 +02:00
|
|
|
|
return this.getUnlocalizedName()+(stack.getItemDamage() >= allMiscBlocks.length ? " ERROR!" : allMiscBlocks[stack.getItemDamage()].name);
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public int getMetadata(int damage){
|
|
|
|
|
return damage;
|
|
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
2015-10-23 16:48:56 +02:00
|
|
|
|
EnumRarity rarity = ((IActAddItemOrBlock)this.field_150939_a).getRarity(stack);
|
|
|
|
|
return rarity == null ? EnumRarity.common : rarity;
|
2015-10-03 10:19:40 +02:00
|
|
|
|
}
|
2015-02-17 16:15:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|