Crystals!

This commit is contained in:
Ellpeck 2015-11-09 18:05:52 +01:00
parent 1c99053f8d
commit 0540dadfc5
6 changed files with 234 additions and 1 deletions

View file

@ -0,0 +1,113 @@
/*
* This file ("BlockCrystal.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
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.ItemBlockBase;
import ellpeck.actuallyadditions.items.metalists.TheCrystals;
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
import ellpeck.actuallyadditions.util.ModUtil;
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 net.minecraft.world.IBlockAccess;
import java.util.List;
public class BlockCrystal extends Block implements IActAddItemOrBlock{
public static final TheCrystals[] allCrystals = TheCrystals.values();
public BlockCrystal(){
super(Material.rock);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setHarvestLevel("pickaxe", 1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta){
return meta >= allCrystals.length ? super.getRenderColor(meta) : allCrystals[meta].color;
}
@Override
public int damageDropped(int meta){
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z){
return this.getRenderColor(world.getBlockMetadata(x, y, z));
}
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for(int j = 0; j < allCrystals.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
}
@Override
public String getName(){
return "blockCrystal";
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allCrystals.length ? EnumRarity.common : allCrystals[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){
return this.getUnlocalizedName()+(stack.getItemDamage() >= allCrystals.length ? " ERROR!" : allCrystals[stack.getItemDamage()].name);
}
@Override
public int getMetadata(int damage){
return damage;
}
@Override
public EnumRarity getRarity(ItemStack stack){
EnumRarity rarity = ((IActAddItemOrBlock)this.field_150939_a).getRarity(stack);
return rarity == null ? EnumRarity.common : rarity;
}
}
}

View file

@ -101,10 +101,14 @@ public class InitBlocks{
public static Block blockLaserRelay; public static Block blockLaserRelay;
public static Block blockBlackLotus; public static Block blockBlackLotus;
public static Block blockCrystal;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Blocks..."); ModUtil.LOGGER.info("Initializing Blocks...");
blockCrystal = new BlockCrystal();
BlockUtil.register(blockCrystal, BlockCrystal.TheItemBlock.class);
blockBlackLotus = new BlockBlackLotus(); blockBlackLotus = new BlockBlackLotus();
BlockUtil.register(blockBlackLotus); BlockUtil.register(blockBlackLotus);

View file

@ -10,6 +10,8 @@
package ellpeck.actuallyadditions.blocks.metalists; package ellpeck.actuallyadditions.blocks.metalists;
import ellpeck.actuallyadditions.util.StringUtil;
public enum TheColoredLampColors{ public enum TheColoredLampColors{
WHITE("White"), WHITE("White"),
@ -39,7 +41,7 @@ public enum TheColoredLampColors{
if(color.substring(0, 3).equals("dye")){ if(color.substring(0, 3).equals("dye")){
String actualName = color.substring(3); String actualName = color.substring(3);
for(int i = 0; i < values().length; i++){ for(int i = 0; i < values().length; i++){
if(values()[i].name.equals(actualName)){ if(StringUtil.equalsToLowerCase(values()[i].name, actualName)){
return values()[i]; return values()[i];
} }
} }

View file

@ -128,10 +128,14 @@ public class InitItems{
public static Item itemChestToCrateUpgrade; public static Item itemChestToCrateUpgrade;
public static Item itemLaserWrench; public static Item itemLaserWrench;
public static Item itemCrystal;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Items..."); ModUtil.LOGGER.info("Initializing Items...");
itemCrystal = new ItemCrystal();
ItemUtil.register(itemCrystal);
itemLaserWrench = new ItemLaserWrench(); itemLaserWrench = new ItemLaserWrench();
ItemUtil.register(itemLaserWrench); ItemUtil.register(itemLaserWrench);

View file

@ -0,0 +1,79 @@
/*
* This file ("ItemCrystal.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
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.BlockCrystal;
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
import ellpeck.actuallyadditions.util.ModUtil;
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 ItemCrystal extends Item implements IActAddItemOrBlock{
public ItemCrystal(){
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public int getMetadata(int damage){
return damage;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName()+(stack.getItemDamage() >= BlockCrystal.allCrystals.length ? " ERROR!" : BlockCrystal.allCrystals[stack.getItemDamage()].name);
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass){
return stack.getItemDamage() >= BlockCrystal.allCrystals.length ? super.getColorFromItemStack(stack, pass) : BlockCrystal.allCrystals[stack.getItemDamage()].color;
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= BlockCrystal.allCrystals.length ? EnumRarity.common : BlockCrystal.allCrystals[stack.getItemDamage()].rarity;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int pass){
return this.itemIcon;
}
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
for(int j = 0; j < BlockCrystal.allCrystals.length; j++){
list.add(new ItemStack(this, 1, j));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
}
@Override
public String getName(){
return "itemCrystal";
}
}

View file

@ -0,0 +1,31 @@
/*
* This file ("TheCrystals.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
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.metalists;
import net.minecraft.item.EnumRarity;
public enum TheCrystals{
REDSTONE("Red", EnumRarity.rare, 12595250),
LAPIS("Blue", EnumRarity.uncommon, 24983),
DIAMOND("LightBlue", EnumRarity.epic, 40140),
COAL("Black", EnumRarity.uncommon, 2500135);
public final String name;
public final EnumRarity rarity;
public final int color;
TheCrystals(String name, EnumRarity rarity, int color){
this.name = name;
this.rarity = rarity;
this.color = color;
}
}