aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java')
-rw-r--r--src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java116
1 files changed, 72 insertions, 44 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
index 787c1bc9f9..6bf6a71395 100644
--- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
+++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
@@ -5,7 +5,6 @@ import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
-import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.ITexturedTileEntity;
import gregtech.api.objects.GT_CopiedBlockTexture;
@@ -23,10 +22,7 @@ import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Random;
-public class GT_TileEntity_Ores
- extends TileEntity
- implements ITexturedTileEntity {
- private static final ITexture[] mStoneTextures = {new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.netherrack, 0, 0), new GT_CopiedBlockTexture(Blocks.end_stone, 0, 0), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_BLACK_STONE), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_RED_STONE), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0)};
+public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntity {
public short mMetaData = 0;
public boolean mNatural = false;
public boolean mBlocked = true;
@@ -35,22 +31,35 @@ public class GT_TileEntity_Ores
Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)];
byte tByte = aMaterial == null ? 0 : (byte) Math.max((aMetaData % 16000 / 1000 == 3) || (aMetaData % 16000 / 1000 == 4) ? 3 : 0, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1)));
if(GT_Mod.gregtechproxy.mChangeHarvestLevels ){
- tByte = aMaterial == null ? 0 : (byte) Math.max((aMetaData % 16000 / 1000 == 3) || (aMetaData % 16000 / 1000 == 4) ? GT_Mod.gregtechproxy.mGraniteHavestLevel : 0, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1)));
+ tByte = aMaterial == null ? 0 : (byte) Math.max((aMetaData % 16000 / 1000 == 3) || (aMetaData % 16000 / 1000 == 4) ? GT_Mod.gregtechproxy.mGraniteHavestLevel : 0, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1)));
}
return tByte;
}
- public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData) {
- return setOreBlock(aWorld, aX, aY, aZ, aMetaData, false);
+ public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) {
+ return setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, false);
}
- public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air) {
+ public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre, boolean air) {
if (!air) {
aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1));
}
Block tBlock = aWorld.getBlock(aX, aY, aZ);
+ Block tOreBlock = GregTech_API.sBlockOres1;
+ int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ);
+ String BlockName = tBlock.getUnlocalizedName();
+ aMetaData += isSmallOre ? 16000 : 0;
if ((aMetaData > 0) && ((tBlock != Blocks.air) || air)) {
- if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) {
+ if (BlockName.equals("tile.igneousStone")) {
+ tOreBlock = GregTech_API.sBlockOresUb1;
+ aMetaData += (BlockMeta * 1000);
+ } else if (BlockName.equals("tile.metamorphicStone")) {
+ tOreBlock = GregTech_API.sBlockOresUb2;
+ aMetaData += (BlockMeta * 1000);
+ } else if (BlockName.equals("tile.sedimentaryStone")) {
+ tOreBlock = GregTech_API.sBlockOresUb3;
+ aMetaData += (BlockMeta * 1000);
+ } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) {
aMetaData += 1000;
} else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) {
aMetaData += 2000;
@@ -64,10 +73,20 @@ public class GT_TileEntity_Ores
} else {
aMetaData += 3000;
}
+ } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockStones)) {
+ if (tBlock == GregTech_API.sBlockStones) {
+ if (aWorld.getBlockMetadata(aX, aY, aZ) < 8) {
+ aMetaData += 5000;
+ } else {
+ aMetaData += 6000;
+ }
+ } else {
+ aMetaData += 5000;
+ }
} else if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) {
return false;
}
- aWorld.setBlock(aX, aY, aZ, GregTech_API.sBlockOres1, getHarvestData((short) aMetaData), 0);
+ aWorld.setBlock(aX, aY, aZ, tOreBlock, getHarvestData((short) aMetaData), 0);
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) aMetaData);
@@ -107,23 +126,43 @@ public class GT_TileEntity_Ores
}
public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) {
- this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L));
- if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) {
- this.mMetaData = ((short) (this.mMetaData + 1000));
- } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.end_stone)) {
- this.mMetaData = ((short) (this.mMetaData + 2000));
- } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, GregTech_API.sBlockGranites)) {
- if (aOverridingStoneBlock == GregTech_API.sBlockGranites) {
- if (aOverridingStoneMeta < 8) {
+ this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L));
+ if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) {
+ this.mMetaData = ((short) (this.mMetaData + 1000));
+ } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.end_stone)) {
+ this.mMetaData = ((short) (this.mMetaData + 2000));
+ } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, GregTech_API.sBlockGranites)) {
+ if (aOverridingStoneBlock == GregTech_API.sBlockGranites) {
+ if (aOverridingStoneMeta < 8) {
+ this.mMetaData = ((short) (this.mMetaData + 3000));
+ } else {
+ this.mMetaData = ((short) (this.mMetaData + 4000));
+ }
+ } else {
this.mMetaData = ((short) (this.mMetaData + 3000));
+ }
+ } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, GregTech_API.sBlockStones)) {
+ if (aOverridingStoneBlock == GregTech_API.sBlockStones) {
+ if (aOverridingStoneMeta < 8) {
+ this.mMetaData = ((short) (this.mMetaData + 5000));
+ } else {
+ this.mMetaData = ((short) (this.mMetaData + 6000));
+ }
} else {
- this.mMetaData = ((short) (this.mMetaData + 4000));
+ this.mMetaData = ((short) (this.mMetaData + 5000));
}
- } else {
- this.mMetaData = ((short) (this.mMetaData + 3000));
}
+ this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData), 0);
+ }
+
+ public void convertOreBlock(World aWorld, int aX, int aY, int aZ) {
+ short aMeta = ((short) (int) (this.mMetaData % 1000 + (this.mMetaData / 16000 * 16000)));
+ aWorld.setBlock(aX, aY, aZ, GregTech_API.sBlockOres1);
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity instanceof GT_TileEntity_Ores) {
+ ((GT_TileEntity_Ores) tTileEntity).mMetaData = aMeta;
+ this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(aMeta), 0);
}
- this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData), 0);
}
public short getMetaData() {
@@ -134,14 +173,14 @@ public class GT_TileEntity_Ores
return false;
}
- public ArrayList<ItemStack> getDrops(int aFortune) {
+ public ArrayList<ItemStack> getDrops(Block aDroppedOre, int aFortune) {
ArrayList<ItemStack> rList = new ArrayList();
if (this.mMetaData <= 0) {
rList.add(new ItemStack(Blocks.cobblestone, 1, 0));
return rList;
}
if (this.mMetaData < 16000) {
- rList.add(new ItemStack(GregTech_API.sBlockOres1, 1, this.mMetaData));
+ rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData));
return rList;
}
Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)];
@@ -202,32 +241,21 @@ public class GT_TileEntity_Ores
}
}
if (tRandom.nextInt(3 + aFortune) > 1) {
- switch (this.mMetaData / 1000 % 16) {
- case 0:
- rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Stone, 1L));
- break;
- case 1:
- rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Netherrack, 1L));
- break;
- case 2:
- rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Endstone, 1L));
- break;
- case 3:
- rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.GraniteBlack, 1L));
- break;
- case 4:
- rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.GraniteRed, 1L));
- }
+ Materials dustMat = ((GT_Block_Ores_Abstract) aDroppedOre).getDroppedDusts()[this.mMetaData / 1000 % 16];
+ if (dustMat != null) rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, dustMat, 1L));
}
}
return rList;
}
- public ITexture[] getTexture(byte aSide) {
+ public ITexture[] getTexture(Block aBlock, byte aSide) {
Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)];
if ((aMaterial != null) && (this.mMetaData < 32000)) {
- return new ITexture[]{mStoneTextures[(this.mMetaData / 1000 % 16)], new GT_RenderedTexture(aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? OrePrefixes.ore.mTextureIndex : OrePrefixes.oreSmall.mTextureIndex], aMaterial.mRGBa)};
+ GT_RenderedTexture aIconSet = new GT_RenderedTexture(aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? OrePrefixes.ore.mTextureIndex : OrePrefixes.oreSmall.mTextureIndex], aMaterial.mRGBa);
+ if (aBlock instanceof GT_Block_Ores_Abstract) {
+ return new ITexture[]{((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], aIconSet};
+ }
}
- return new ITexture[]{mStoneTextures[0], new GT_RenderedTexture(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex])};
+ return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_RenderedTexture(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex])};
}
}