Rewrite ores
This commit is contained in:
parent
3fb1e4ceb8
commit
4c5cf82db4
5 changed files with 118 additions and 94 deletions
|
@ -1,8 +1,8 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -18,8 +18,11 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.common.BaseBlock;
|
||||
import reborncore.common.blocks.PropertyString;
|
||||
import reborncore.common.util.ArrayUtils;
|
||||
import reborncore.common.util.OreDrop;
|
||||
import reborncore.common.util.OreDropSet;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
@ -34,10 +37,11 @@ import java.util.Random;
|
|||
public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvider
|
||||
{
|
||||
|
||||
public static final String[] types = new String[] { "Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite",
|
||||
"Cinnabar", "Sphalerite", "Tungston", "Sheldonite", "Peridot", "Sodalite",
|
||||
"Lead", "Silver" };
|
||||
public PropertyInteger METADATA;
|
||||
public static final String[] ores = new String[] { "galena", "iridium", "ruby", "sapphire", "bauxite", "pyrite",
|
||||
"cinnabar", "sphalerite", "tungston", "sheldonite", "peridot", "sodalite",
|
||||
"lead", "silver" };
|
||||
static List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
|
||||
public PropertyString VARIANTS = new PropertyString("type", oreNamesList);
|
||||
|
||||
public BlockOre(Material material)
|
||||
{
|
||||
|
@ -46,14 +50,14 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
setHardness(2.0f);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(METADATA, 0));
|
||||
this.setDefaultState(this.getStateFromMeta(0));
|
||||
}
|
||||
|
||||
public static ItemStack getOreByName(String name, int count)
|
||||
{
|
||||
for (int i = 0; i < types.length; i++)
|
||||
for (int i = 0; i < ores.length; i++)
|
||||
{
|
||||
if (types[i].equalsIgnoreCase(name))
|
||||
if (ores[i].equalsIgnoreCase(name))
|
||||
{
|
||||
return new ItemStack(ModBlocks.ore, count, i);
|
||||
}
|
||||
|
@ -69,9 +73,9 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
public IBlockState getBlockStateFromName(String name)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < types.length; i++)
|
||||
for (int i = 0; i < ores.length; i++)
|
||||
{
|
||||
if (types[i].equalsIgnoreCase(name))
|
||||
if (ores[i].equalsIgnoreCase(name))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
|
@ -87,10 +91,11 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
@Deprecated
|
||||
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
|
||||
{
|
||||
int metadata = getMetaFromState(state);
|
||||
String variant = state.getValue(VARIANTS);
|
||||
int meta = getMetaFromState(state);
|
||||
Random random = new Random();
|
||||
// Ruby
|
||||
if (metadata == 2)
|
||||
if (variant.equals("Ruby"))
|
||||
{
|
||||
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby"),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -100,7 +105,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
// Sapphire
|
||||
if (metadata == 3)
|
||||
if (variant.equals("Sapphire"))
|
||||
{
|
||||
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire"),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -110,7 +115,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
// Pyrite
|
||||
if (metadata == 5)
|
||||
if (variant.equals("Pyrite"))
|
||||
{
|
||||
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite"),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -119,7 +124,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
// Sodalite
|
||||
if (metadata == 11)
|
||||
if (variant.equals("Sodalite"))
|
||||
{
|
||||
OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", 6),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -129,7 +134,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
// Cinnabar
|
||||
if (metadata == 6)
|
||||
if (variant.equals("Cinnabar"))
|
||||
{
|
||||
OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar"),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -139,7 +144,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
// Sphalerite 1, 1/8 yellow garnet
|
||||
if (metadata == 7)
|
||||
if (variant.equals("Sphalerite"))
|
||||
{
|
||||
OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite"),
|
||||
ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
|
||||
|
@ -149,7 +154,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
}
|
||||
|
||||
ArrayList<ItemStack> block = new ArrayList<>();
|
||||
block.add(new ItemStack(Item.getItemFromBlock(this), 1, metadata));
|
||||
block.add(new ItemStack(Item.getItemFromBlock(this), 1, meta));
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -163,7 +168,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < types.length; meta++)
|
||||
for (int meta = 0; meta < ores.length; meta++)
|
||||
{
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
|
@ -176,57 +181,59 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
|
|||
return new ItemStack(this,1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
int meta = getMetaFromState(state);
|
||||
if (meta == 2)
|
||||
{
|
||||
return 0;
|
||||
} else if (meta == 3)
|
||||
{
|
||||
return 1;
|
||||
} else if (meta == 5)
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
// @Override
|
||||
// public int damageDropped(IBlockState state)
|
||||
// {
|
||||
// int meta = getMetaFromState(state);
|
||||
// if (meta == 2)
|
||||
// {
|
||||
// return 0;
|
||||
// } else if (meta == 3)
|
||||
// {
|
||||
// return 1;
|
||||
// } else if (meta == 5)
|
||||
// {
|
||||
// return 60;
|
||||
// }
|
||||
// return meta;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState BlockStateContainer, EnumFacing facing)
|
||||
{
|
||||
return "techreborn:blocks/ore/ore" + types[getMetaFromState(BlockStateContainer)];
|
||||
return "techreborn:blocks/ore/ore" + StringUtils.toFirstCapital(ores[getMetaFromState(BlockStateContainer)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
return types.length;
|
||||
return ores.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(METADATA, meta);
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(METADATA);
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getBlockState().getBaseState().withProperty(VARIANTS, oreNamesList.get(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return oreNamesList.indexOf(state.getValue(VARIANTS));
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
|
||||
METADATA = PropertyInteger.create("type", 0, types.length - 1);
|
||||
return new BlockStateContainer(this, METADATA);
|
||||
VARIANTS = new PropertyString("type", oreNamesList);
|
||||
return new BlockStateContainer(this, VARIANTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserLoclisedName(IBlockState state)
|
||||
{
|
||||
return types[state.getValue(METADATA)];
|
||||
return StringUtils.toFirstCapital(oreNamesList.get(getMetaFromState(state)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package techreborn.blocks;
|
|||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
|
@ -19,6 +20,9 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.common.BaseBlock;
|
||||
import reborncore.common.blocks.PropertyString;
|
||||
import reborncore.common.util.ArrayUtils;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.world.config.IOreNameProvider;
|
||||
|
@ -26,8 +30,9 @@ import techreborn.world.config.IOreNameProvider;
|
|||
public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProvider
|
||||
{
|
||||
|
||||
public static final String[] types = new String[] { "Copper", "Tin" };
|
||||
public PropertyInteger METADATA;
|
||||
public static final String[] ores = new String[] { "copper", "tin"};
|
||||
static List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
|
||||
public PropertyString VARIANTS = new PropertyString("type", oreNamesList);
|
||||
|
||||
public BlockOre2(Material material)
|
||||
{
|
||||
|
@ -36,14 +41,14 @@ public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProv
|
|||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
setHardness(2.0f);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(METADATA, 0));
|
||||
this.setDefaultState(this.getStateFromMeta(0));
|
||||
}
|
||||
|
||||
public static ItemStack getOreByName(String name, int count)
|
||||
{
|
||||
for (int i = 0; i < types.length; i++)
|
||||
for (int i = 0; i < ores.length; i++)
|
||||
{
|
||||
if (types[i].equalsIgnoreCase(name))
|
||||
if (ores[i].equalsIgnoreCase(name))
|
||||
{
|
||||
return new ItemStack(ModBlocks.ore2, count, i);
|
||||
}
|
||||
|
@ -59,9 +64,9 @@ public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProv
|
|||
public IBlockState getBlockStateFromName(String name)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < types.length; i++)
|
||||
for (int i = 0; i < ores.length; i++)
|
||||
{
|
||||
if (types[i].equalsIgnoreCase(name))
|
||||
if (ores[i].equalsIgnoreCase(name))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
|
@ -69,7 +74,7 @@ public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProv
|
|||
}
|
||||
if (index == -1)
|
||||
{
|
||||
throw new InvalidParameterException("The ore block " + name + " could not be found.");
|
||||
return ModBlocks.ore2.getBlockStateFromName(name);
|
||||
}
|
||||
return getStateFromMeta(index);
|
||||
}
|
||||
|
@ -84,7 +89,7 @@ public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProv
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < types.length; meta++)
|
||||
for (int meta = 0; meta < ores.length; meta++)
|
||||
{
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
|
@ -97,47 +102,59 @@ public class BlockOre2 extends BaseBlock implements ITexturedBlock, IOreNameProv
|
|||
return new ItemStack(this,1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
int meta = getMetaFromState(state);
|
||||
return meta;
|
||||
}
|
||||
// @Override
|
||||
// public int damageDropped(IBlockState state)
|
||||
// {
|
||||
// int meta = getMetaFromState(state);
|
||||
// if (meta == 2)
|
||||
// {
|
||||
// return 0;
|
||||
// } else if (meta == 3)
|
||||
// {
|
||||
// return 1;
|
||||
// } else if (meta == 5)
|
||||
// {
|
||||
// return 60;
|
||||
// }
|
||||
// return meta;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState BlockStateContainer, EnumFacing facing)
|
||||
{
|
||||
return "techreborn:blocks/ore/ore" + types[getMetaFromState(BlockStateContainer)];
|
||||
return "techreborn:blocks/ore/ore" + StringUtils.toFirstCapital(ores[getMetaFromState(BlockStateContainer)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
return types.length;
|
||||
return ores.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(METADATA, meta);
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(METADATA);
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getBlockState().getBaseState().withProperty(VARIANTS, oreNamesList.get(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return oreNamesList.indexOf(state.getValue(VARIANTS));
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
|
||||
METADATA = PropertyInteger.create("type", 0, types.length - 1);
|
||||
return new BlockStateContainer(this, METADATA);
|
||||
VARIANTS = new PropertyString("type", oreNamesList);
|
||||
return new BlockStateContainer(this, VARIANTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserLoclisedName(IBlockState state)
|
||||
{
|
||||
return types[state.getValue(METADATA)];
|
||||
return StringUtils.toFirstCapital(oreNamesList.get(getMetaFromState(state)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class ItemBlockOre extends ItemBlockBase
|
|||
|
||||
public ItemBlockOre(Block block)
|
||||
{
|
||||
super(ModBlocks.ore, ModBlocks.ore, BlockOre.types);
|
||||
super(ModBlocks.ore, ModBlocks.ore, BlockOre.ores);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class ItemBlockOre2 extends ItemBlockBase
|
|||
|
||||
public ItemBlockOre2(Block block)
|
||||
{
|
||||
super(ModBlocks.ore2, ModBlocks.ore2, BlockOre2.types);
|
||||
super(ModBlocks.ore2, ModBlocks.ore2, BlockOre2.ores);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ tile.techreborn.electricfurnace.name=Electric Furnace
|
|||
tile.techreborn.machineFrame.highlyAdvancedMachine.name=Highly Advanced Machine Block
|
||||
tile.techreborn.machineFrame.advancedMachine.name=Advanced Machine Block
|
||||
tile.techreborn.machineFrame.machine.name=Machine Block
|
||||
tile.techreborn.ore2.Copper.name=Copper Ore
|
||||
tile.techreborn.ore2.Tin.name=Tin Ore
|
||||
tile.techreborn.ore2.copper.name=Copper Ore
|
||||
tile.techreborn.ore2.tin.name=Tin Ore
|
||||
tile.techreborn.storage2.copper.name=Copper Block
|
||||
tile.techreborn.storage2.tin.name=Tin Block
|
||||
tile.techreborn.solarpanel.name=Solar Panel
|
||||
|
@ -92,22 +92,22 @@ tile.techreborn.rubbersapling.name=Rubber Sapling
|
|||
tile.techreborn.ironfence.name=Iron Fence
|
||||
|
||||
#Ores
|
||||
tile.techreborn.ore.Galena.name=Galena Ore
|
||||
tile.techreborn.ore.Iridium.name=Iridium Ore
|
||||
tile.techreborn.ore.Ruby.name=Ruby Ore
|
||||
tile.techreborn.ore.Sapphire.name=Sapphire Ore
|
||||
tile.techreborn.ore.Bauxite.name=Bauxite Ore
|
||||
tile.techreborn.ore.Pyrite.name=Pyrite Ore
|
||||
tile.techreborn.ore.Cinnabar.name=Cinnabar Ore
|
||||
tile.techreborn.ore.Sphalerite.name=Sphalerite Ore
|
||||
tile.techreborn.ore.Tungston.name=Tungsten Ore
|
||||
tile.techreborn.ore.Sheldonite.name=Sheldonite Ore
|
||||
tile.techreborn.ore.Peridot.name=Peridot Ore
|
||||
tile.techreborn.ore.Sodalite.name=Sodalite Ore
|
||||
tile.techreborn.ore.Tetrahedrite.name=Tetrahedrite Ore
|
||||
tile.techreborn.ore.Cassiterite.name=Cassiterite Ore
|
||||
tile.techreborn.ore.Lead.name=Lead Ore
|
||||
tile.techreborn.ore.Silver.name=Silver Ore
|
||||
tile.techreborn.ore.galena.name=Galena Ore
|
||||
tile.techreborn.ore.iridium.name=Iridium Ore
|
||||
tile.techreborn.ore.ruby.name=Ruby Ore
|
||||
tile.techreborn.ore.sapphire.name=Sapphire Ore
|
||||
tile.techreborn.ore.bauxite.name=Bauxite Ore
|
||||
tile.techreborn.ore.pyrite.name=Pyrite Ore
|
||||
tile.techreborn.ore.cinnabar.name=Cinnabar Ore
|
||||
tile.techreborn.ore.sphalerite.name=Sphalerite Ore
|
||||
tile.techreborn.ore.tungston.name=Tungsten Ore
|
||||
tile.techreborn.ore.sheldonite.name=Sheldonite Ore
|
||||
tile.techreborn.ore.peridot.name=Peridot Ore
|
||||
tile.techreborn.ore.sodalite.name=Sodalite Ore
|
||||
tile.techreborn.ore.tetrahedrite.name=Tetrahedrite Ore
|
||||
tile.techreborn.ore.cassiterite.name=Cassiterite Ore
|
||||
tile.techreborn.ore.lead.name=Lead Ore
|
||||
tile.techreborn.ore.silver.name=Silver Ore
|
||||
|
||||
#Storage
|
||||
tile.techreborn.storage.silver.name=Block of Silver
|
||||
|
|
Loading…
Reference in a new issue