mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Crystals!
This commit is contained in:
parent
1c99053f8d
commit
0540dadfc5
6 changed files with 234 additions and 1 deletions
113
src/main/java/ellpeck/actuallyadditions/blocks/BlockCrystal.java
Normal file
113
src/main/java/ellpeck/actuallyadditions/blocks/BlockCrystal.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -101,10 +101,14 @@ public class InitBlocks{
|
|||
public static Block blockLaserRelay;
|
||||
|
||||
public static Block blockBlackLotus;
|
||||
public static Block blockCrystal;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
blockCrystal = new BlockCrystal();
|
||||
BlockUtil.register(blockCrystal, BlockCrystal.TheItemBlock.class);
|
||||
|
||||
blockBlackLotus = new BlockBlackLotus();
|
||||
BlockUtil.register(blockBlackLotus);
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.blocks.metalists;
|
||||
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
|
||||
public enum TheColoredLampColors{
|
||||
|
||||
WHITE("White"),
|
||||
|
@ -39,7 +41,7 @@ public enum TheColoredLampColors{
|
|||
if(color.substring(0, 3).equals("dye")){
|
||||
String actualName = color.substring(3);
|
||||
for(int i = 0; i < values().length; i++){
|
||||
if(values()[i].name.equals(actualName)){
|
||||
if(StringUtil.equalsToLowerCase(values()[i].name, actualName)){
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,10 +128,14 @@ public class InitItems{
|
|||
public static Item itemChestToCrateUpgrade;
|
||||
|
||||
public static Item itemLaserWrench;
|
||||
public static Item itemCrystal;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
||||
itemCrystal = new ItemCrystal();
|
||||
ItemUtil.register(itemCrystal);
|
||||
|
||||
itemLaserWrench = new ItemLaserWrench();
|
||||
ItemUtil.register(itemLaserWrench);
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue