2015-10-21 20:47:13 -04:00
|
|
|
package gregtech.common.blocks;
|
|
|
|
|
2016-03-20 16:47:17 +01:00
|
|
|
import cpw.mods.fml.common.Loader;
|
2015-10-21 20:47:13 -04:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2016-03-20 16:47:17 +01:00
|
|
|
import gregtech.GT_Mod;
|
2015-10-21 20:47:13 -04:00
|
|
|
import gregtech.api.GregTech_API;
|
|
|
|
import gregtech.api.enums.Materials;
|
|
|
|
import gregtech.api.enums.OrePrefixes;
|
|
|
|
import gregtech.api.items.GT_Generic_Block;
|
|
|
|
import gregtech.api.util.GT_LanguageManager;
|
|
|
|
import gregtech.api.util.GT_ModHandler;
|
|
|
|
import gregtech.api.util.GT_OreDictUnificator;
|
|
|
|
import gregtech.common.render.GT_Renderer_Block;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.ITileEntityProvider;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.boss.EntityDragon;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-10-21 22:06:25 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-10-21 20:47:13 -04:00
|
|
|
public class GT_Block_Ores
|
2015-10-21 22:06:25 -04:00
|
|
|
extends GT_Generic_Block
|
|
|
|
implements ITileEntityProvider {
|
|
|
|
public static ThreadLocal<GT_TileEntity_Ores> mTemporaryTileEntity = new ThreadLocal();
|
|
|
|
public static boolean FUCKING_LOCK = false;
|
|
|
|
|
|
|
|
public GT_Block_Ores() {
|
|
|
|
super(GT_Item_Ores.class, "gt.blockores", Material.rock);
|
|
|
|
this.isBlockContainer = true;
|
|
|
|
setStepSound(soundTypeStone);
|
|
|
|
setCreativeTab(GregTech_API.TAB_GREGTECH_ORES);
|
2016-03-20 16:47:17 +01:00
|
|
|
boolean tHideOres = Loader.isModLoaded("NotEnoughItems") && GT_Mod.gregtechproxy.mHideUnusedOres;
|
2015-10-21 22:06:25 -04:00
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
GT_ModHandler.addValuableOre(this, i, 1);
|
|
|
|
}
|
|
|
|
for (int i = 1; i < GregTech_API.sGeneratedMaterials.length; i++) {
|
|
|
|
if (GregTech_API.sGeneratedMaterials[i] != null) {
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 1000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 2000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 3000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 4000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
2016-07-16 23:48:25 +01:00
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 5000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
2015-10-21 22:06:25 -04:00
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 16000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 17000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 18000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 19000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 20000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
2016-07-16 23:48:25 +01:00
|
|
|
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 21000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
//GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 30000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
//GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 50000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i]));
|
|
|
|
|
2015-10-21 22:06:25 -04:00
|
|
|
if ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x8) != 0) {
|
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.ore.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i));
|
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.oreNetherrack.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 1000));
|
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.oreEndstone.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 2000));
|
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.oreBlackgranite.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 3000));
|
2016-07-16 23:48:25 +01:00
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.oreRedgranite.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 4000));
|
|
|
|
GT_OreDictUnificator.registerOre(OrePrefixes.oreMarble.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 5000));
|
|
|
|
GT_OreDictUnificator.registerOre("oreIgneousStone", new ItemStack(this, 1, i + 21000));
|
|
|
|
//GT_OreDictUnificator.registerOre("oreMetamorphicStone", new ItemStack(this, 1, i + 40000));
|
|
|
|
//GT_OreDictUnificator.registerOre("oreSedimentaryStone", new ItemStack(this, 1, i + 50000));
|
2016-03-20 16:47:17 +01:00
|
|
|
if (tHideOres) {
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 1000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 2000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 3000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 4000));
|
2016-07-16 23:48:25 +01:00
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 5000));
|
2016-03-20 16:47:17 +01:00
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 16000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 17000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 18000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 19000));
|
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 20000));
|
2016-07-16 23:48:25 +01:00
|
|
|
codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 21000));
|
|
|
|
//codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 40000));
|
|
|
|
//codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + 50000));
|
2015-10-21 22:06:25 -04:00
|
|
|
}
|
2016-03-20 16:47:17 +01:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
}
|
|
|
|
}
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) {
|
|
|
|
if (!FUCKING_LOCK) {
|
|
|
|
FUCKING_LOCK = true;
|
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
|
|
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
|
|
|
|
((GT_TileEntity_Ores) tTileEntity).onUpdated();
|
|
|
|
}
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
FUCKING_LOCK = false;
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) {
|
|
|
|
if (!FUCKING_LOCK) {
|
|
|
|
FUCKING_LOCK = true;
|
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
|
|
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
|
|
|
|
((GT_TileEntity_Ores) tTileEntity).onUpdated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FUCKING_LOCK = false;
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public String getLocalizedName(Materials aMaterial) {
|
|
|
|
switch (aMaterial) {
|
|
|
|
case InfusedAir:
|
|
|
|
case InfusedDull:
|
|
|
|
case InfusedEarth:
|
|
|
|
case InfusedEntropy:
|
|
|
|
case InfusedFire:
|
|
|
|
case InfusedOrder:
|
|
|
|
case InfusedVis:
|
|
|
|
case InfusedWater:
|
|
|
|
return aMaterial.mDefaultLocalName + " Infused Stone";
|
|
|
|
case Vermiculite:
|
|
|
|
case Bentonite:
|
|
|
|
case Kaolinite:
|
|
|
|
case Talc:
|
|
|
|
case BasalticMineralSand:
|
|
|
|
case GraniticMineralSand:
|
|
|
|
case GlauconiteSand:
|
|
|
|
case CassiteriteSand:
|
|
|
|
case GarnetSand:
|
|
|
|
case QuartzSand:
|
|
|
|
case Pitchblende:
|
|
|
|
case FullersEarth:
|
|
|
|
return aMaterial.mDefaultLocalName;
|
|
|
|
default:
|
|
|
|
return aMaterial.mDefaultLocalName + OrePrefixes.ore.mLocalizedMaterialPost;
|
|
|
|
}
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) {
|
|
|
|
super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_);
|
|
|
|
TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_);
|
|
|
|
return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false;
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
|
|
|
|
return (!(entity instanceof EntityDragon)) && (super.canEntityDestroy(world, x, y, z, entity));
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public String getHarvestTool(int aMeta) {
|
|
|
|
return aMeta < 8 ? "pickaxe" : "shovel";
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public int getHarvestLevel(int aMeta) {
|
|
|
|
return aMeta % 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
|
|
|
|
return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) {
|
|
|
|
return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean canSilkHarvest() {
|
|
|
|
return false;
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 22:06:25 -04:00
|
|
|
|
|
|
|
public String getUnlocalizedName() {
|
|
|
|
return "gt.blockores";
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getLocalizedName() {
|
|
|
|
return StatCollector.translateToLocal(getUnlocalizedName() + ".name");
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRenderType() {
|
|
|
|
if (GT_Renderer_Block.INSTANCE == null) {
|
|
|
|
return super.getRenderType();
|
|
|
|
}
|
|
|
|
return GT_Renderer_Block.INSTANCE.mRenderID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasTileEntity(int aMeta) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean renderAsNormalBlock() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOpaqueCube() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity createNewTileEntity(World aWorld, int aMeta) {
|
|
|
|
return createTileEntity(aWorld, aMeta);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) {
|
|
|
|
return Blocks.stone.getIcon(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IIcon getIcon(int aSide, int aMeta) {
|
|
|
|
return Blocks.stone.getIcon(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister aIconRegister) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDamageValue(World aWorld, int aX, int aY, int aZ) {
|
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
|
|
if ((tTileEntity != null) && ((tTileEntity instanceof GT_TileEntity_Ores))) {
|
|
|
|
return ((GT_TileEntity_Ores) tTileEntity).getMetaData();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) {
|
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
|
|
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
|
|
|
|
mTemporaryTileEntity.set((GT_TileEntity_Ores) tTileEntity);
|
|
|
|
}
|
|
|
|
super.breakBlock(aWorld, aX, aY, aZ, par5, par6);
|
|
|
|
aWorld.removeTileEntity(aX, aY, aZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) {
|
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
|
|
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
|
|
|
|
return ((GT_TileEntity_Ores) tTileEntity).getDrops(aFortune);
|
|
|
|
}
|
|
|
|
return mTemporaryTileEntity.get() == null ? new ArrayList() : ((GT_TileEntity_Ores) mTemporaryTileEntity.get()).getDrops(aFortune);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity createTileEntity(World aWorld, int aMeta) {
|
|
|
|
return new GT_TileEntity_Ores();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) {
|
|
|
|
for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) {
|
|
|
|
Materials tMaterial = GregTech_API.sGeneratedMaterials[i];
|
|
|
|
if ((tMaterial != null) && ((tMaterial.mTypes & 0x8) != 0)) {
|
|
|
|
aList.add(new ItemStack(aItem, 1, i));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 1000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 2000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 3000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 4000));
|
2016-07-16 23:48:25 +01:00
|
|
|
aList.add(new ItemStack(aItem, 1, i + 5000));
|
2015-10-21 22:06:25 -04:00
|
|
|
aList.add(new ItemStack(aItem, 1, i + 16000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 17000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 18000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 19000));
|
|
|
|
aList.add(new ItemStack(aItem, 1, i + 20000));
|
2016-07-16 23:48:25 +01:00
|
|
|
aList.add(new ItemStack(aItem, 1, i + 21000));
|
|
|
|
//aList.add(new ItemStack(aItem, 1, i + 40000));
|
|
|
|
//aList.add(new ItemStack(aItem, 1, i + 50000));
|
2015-10-21 22:06:25 -04:00
|
|
|
}
|
|
|
|
}
|
2015-10-21 20:47:13 -04:00
|
|
|
}
|
2015-10-21 21:00:04 -04:00
|
|
|
}
|