ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/blocks/BlockMisc.java

110 lines
3.6 KiB
Java
Raw Normal View History

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
2016-01-03 16:05:51 +01:00
* http://ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2015-12-30 22:02:15 +01:00
package de.ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2015-12-30 22:02:15 +01:00
import de.ellpeck.actuallyadditions.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.util.ModUtil;
import de.ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public class BlockMisc extends BlockBase{
public static final TheMiscBlocks[] allMiscBlocks = TheMiscBlocks.values();
2015-10-28 14:46:04 +01:00
@SideOnly(Side.CLIENT)
public IIcon[] textures;
2015-10-28 14:46:04 +01:00
@SideOnly(Side.CLIENT)
2015-12-26 23:48:49 +01:00
private IIcon ironCasingSeasonalTop;
2015-10-29 20:54:10 +01:00
@SideOnly(Side.CLIENT)
private IIcon ironCasingSeasonal;
2015-10-18 19:56:18 +02:00
public BlockMisc(String name){
super(Material.rock, name);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setHarvestLevel("pickaxe", 1);
}
2015-10-03 10:19:40 +02:00
@Override
2015-10-28 14:46:04 +01:00
@SideOnly(Side.CLIENT)
2015-10-03 10:19:40 +02:00
public IIcon getIcon(int side, int metadata){
2015-10-29 20:54:10 +01:00
if(ClientProxy.jingleAllTheWay && side != 0){
2015-12-26 23:48:49 +01:00
if(metadata == TheMiscBlocks.IRON_CASING.ordinal()){
return side == 1 ? this.ironCasingSeasonalTop : this.ironCasingSeasonal;
2015-10-29 20:54:10 +01:00
}
2015-10-18 19:56:18 +02:00
}
2015-10-03 10:19:40 +02:00
return metadata >= textures.length ? null : textures[metadata];
}
@Override
public int damageDropped(int meta){
2015-03-07 12:51:28 +01:00
return meta;
}
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));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
2015-10-28 14:46:04 +01:00
this.textures = new IIcon[allMiscBlocks.length];
for(int i = 0; i < textures.length; i++){
textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+allMiscBlocks[i].name);
}
2015-10-18 19:56:18 +02:00
2015-12-26 23:48:49 +01:00
this.ironCasingSeasonalTop = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockMiscIronCasingSnowTop");
2015-10-29 20:54:10 +01:00
this.ironCasingSeasonal = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockMiscIronCasingSnow");
}
@Override
2015-12-19 10:30:39 +01:00
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
}
@Override
2015-12-19 10:30:39 +01:00
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity;
}
public static class TheItemBlock extends ItemBlockBase{
public TheItemBlock(Block block){
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
2015-11-23 19:06:07 +01:00
return stack.getItemDamage() >= allMiscBlocks.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allMiscBlocks[stack.getItemDamage()].name;
}
}
}