aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2022-08-27 10:19:57 +0100
committerGitHub <noreply@github.com>2022-08-27 11:19:57 +0200
commit6f31720697bcc351421a4d86ba3bf749375dd12c (patch)
tree3adf8f318f22c892d74cd7c9d30b6dd3f11f11bd /src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
parentc3eac50decd33ee2be8703dfb2ecf9cdc31c2b67 (diff)
downloadGT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.tar.gz
GT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.tar.bz2
GT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.zip
Update buildscript & apply spotless (#1306)
* Update dependencies * Update buildscript, apply spotless
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.java157
1 files changed, 111 insertions, 46 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 4885910877..452e9db5d4 100644
--- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
+++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
@@ -1,5 +1,7 @@
package gregtech.common.blocks;
+import static gregtech.api.enums.TextureSet.SET_NONE;
+
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
@@ -11,6 +13,8 @@ import gregtech.api.objects.XSTR;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
+import java.util.ArrayList;
+import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -19,11 +23,6 @@ import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
-import java.util.ArrayList;
-import java.util.Random;
-
-import static gregtech.api.enums.TextureSet.SET_NONE;
-
public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntity {
public short mMetaData = 0;
public boolean mNatural = false;
@@ -31,9 +30,19 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
public static byte getHarvestData(short aMetaData, int aBaseBlockHarvestLevel) {
Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)];
- byte tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1)));
+ byte tByte = aMaterial == null
+ ? 0
+ : (byte) Math.max(
+ aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1)));
if (GT_Mod.gregtechproxy.mChangeHarvestLevels) {
- tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1)));
+ tByte = aMaterial == null
+ ? 0
+ : (byte) Math.max(
+ aBaseBlockHarvestLevel,
+ Math.min(
+ GT_Mod.gregtechproxy.mMaxHarvestLevel,
+ GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID]
+ - (aMetaData < 16000 ? 0 : 1)));
}
return tByte;
}
@@ -42,7 +51,8 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
return setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, true);
}
- public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre, 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));
}
@@ -53,8 +63,8 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
aMetaData += isSmallOre ? 16000 : 0;
if ((aMetaData > 0) && ((tBlock != Blocks.air) || air)) {
if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) {
- //Do nothing, stone background is default background.
- //Do this comparison first since stone is most common
+ // Do nothing, stone background is default background.
+ // Do this comparison first since stone is most common
} else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) {
aMetaData += 1000;
} else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) {
@@ -83,25 +93,33 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
if (GregTech_API.sBlockOresUb1 != null) {
tOreBlock = GregTech_API.sBlockOresUb1;
aMetaData += (BlockMeta * 1000);
- //GT_FML_LOGGER.info("Block changed to UB1");
+ // GT_FML_LOGGER.info("Block changed to UB1");
}
} else if (BlockName.equals("tile.metamorphicStone")) {
if (GregTech_API.sBlockOresUb2 != null) {
tOreBlock = GregTech_API.sBlockOresUb2;
aMetaData += (BlockMeta * 1000);
- //GT_FML_LOGGER.info("Block changed to UB2");
+ // GT_FML_LOGGER.info("Block changed to UB2");
}
} else if (BlockName.equals("tile.sedimentaryStone")) {
if (GregTech_API.sBlockOresUb3 != null) {
tOreBlock = GregTech_API.sBlockOresUb3;
aMetaData += (BlockMeta * 1000);
- //GT_FML_LOGGER.info("Block changed to UB3");
+ // GT_FML_LOGGER.info("Block changed to UB3");
}
} else {
return false;
}
- //GT_FML_LOGGER.info(tOreBlock);
- aWorld.setBlock(aX, aY, aZ, tOreBlock, getHarvestData((short) aMetaData, ((GT_Block_Ores_Abstract) tOreBlock).getBaseBlockHarvestLevel(aMetaData % 16000 / 1000)), 0);
+ // GT_FML_LOGGER.info(tOreBlock);
+ aWorld.setBlock(
+ aX,
+ aY,
+ aZ,
+ tOreBlock,
+ getHarvestData(
+ (short) aMetaData,
+ ((GT_Block_Ores_Abstract) tOreBlock).getBaseBlockHarvestLevel(aMetaData % 16000 / 1000)),
+ 0);
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity instanceof GT_TileEntity_Ores)) {
((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) aMetaData);
@@ -129,22 +147,28 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
public void onUpdated() {
if ((!this.worldObj.isRemote) && (this.mBlocked)) {
this.mBlocked = false;
- GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_Ores(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord);
+ GT_Values.NW.sendPacketToAllPlayersInRange(
+ this.worldObj,
+ new GT_Packet_Ores(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData),
+ this.xCoord,
+ this.zCoord);
}
}
@Override
public Packet getDescriptionPacket() {
if (!this.worldObj.isRemote) {
- if (!(this.mBlocked = (
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord + 1, this.yCoord, this.zCoord) &&
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord - 1, this.yCoord, this.zCoord) &&
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord + 1, this.zCoord) &&
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord - 1, this.zCoord) &&
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord + 1) &&
- GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord - 1)
- ))) {
- GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_Ores(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord);
+ if (!(this.mBlocked = (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord + 1, this.yCoord, this.zCoord)
+ && GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord - 1, this.yCoord, this.zCoord)
+ && GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord + 1, this.zCoord)
+ && GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord - 1, this.zCoord)
+ && GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord + 1)
+ && GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord - 1)))) {
+ GT_Values.NW.sendPacketToAllPlayersInRange(
+ this.worldObj,
+ new GT_Packet_Ores(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData),
+ this.xCoord,
+ this.zCoord);
}
}
return null;
@@ -153,11 +177,14 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) {
if (this.worldObj == null || blockType == null) return;
this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L));
- if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) {
+ 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)) {
+ } 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)) {
+ } 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));
@@ -167,7 +194,8 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
} else {
this.mMetaData = ((short) (this.mMetaData + 3000));
}
- } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, GregTech_API.sBlockStones)) {
+ } 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));
@@ -178,7 +206,14 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
this.mMetaData = ((short) (this.mMetaData + 5000));
}
}
- this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData, ((GT_Block_Ores_Abstract) blockType).getBaseBlockHarvestLevel(mMetaData % 16000 / 1000)), 0);
+ this.worldObj.setBlockMetadataWithNotify(
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ getHarvestData(
+ this.mMetaData,
+ ((GT_Block_Ores_Abstract) blockType).getBaseBlockHarvestLevel(mMetaData % 16000 / 1000)),
+ 0);
}
public void convertOreBlock(World aWorld, int aX, int aY, int aZ) {
@@ -187,7 +222,15 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
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, ((GT_Block_Ores_Abstract) tTileEntity.blockType).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), 0);
+ this.worldObj.setBlockMetadataWithNotify(
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ getHarvestData(
+ aMeta,
+ ((GT_Block_Ores_Abstract) tTileEntity.blockType)
+ .getBaseBlockHarvestLevel(aMeta % 16000 / 1000)),
+ 0);
}
}
@@ -223,13 +266,15 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
Materials aMaterial = aOreMaterial.mOreReplacement;
- ItemStack tStack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L);
+ ItemStack tStack = GT_OreDictUnificator.get(
+ OrePrefixes.gemExquisite, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L);
if (tStack != null) {
for (int i = 0; i < 1; i++) {
tSelector.add(tStack);
}
}
- tStack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L);
+ tStack = GT_OreDictUnificator.get(
+ OrePrefixes.gemFlawless, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L);
if (tStack != null) {
for (int i = 0; i < 2; i++) {
tSelector.add(tStack);
@@ -241,7 +286,8 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
tSelector.add(tStack);
}
}
- tStack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, aMaterial, GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), 1L);
+ tStack = GT_OreDictUnificator.get(
+ OrePrefixes.gemFlawed, aMaterial, GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), 1L);
if (tStack != null) {
for (int i = 0; i < 5; i++) {
tSelector.add(tStack);
@@ -253,7 +299,11 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
tSelector.add(tStack);
}
}
- tStack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, aMaterial, GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L), 1L);
+ tStack = GT_OreDictUnificator.get(
+ OrePrefixes.gemChipped,
+ aMaterial,
+ GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L),
+ 1L);
if (tStack != null) {
for (int i = 0; i < 5; i++) {
tSelector.add(tStack);
@@ -267,14 +317,22 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
}
if (!tSelector.isEmpty()) {
int i = 0;
- for (int j = Math.max(1, aMaterial.mOreMultiplier + (aFortune > 0 ? tRandom.nextInt(1 + aFortune * aMaterial.mOreMultiplier) : 0) / 2); i < j; i++) {
+ for (int j = Math.max(
+ 1,
+ aMaterial.mOreMultiplier
+ + (aFortune > 0 ? tRandom.nextInt(1 + aFortune * aMaterial.mOreMultiplier) : 0)
+ / 2);
+ i < j;
+ i++) {
rList.add(GT_Utility.copyAmount(1L, tSelector.get(tRandom.nextInt(tSelector.size()))));
}
}
if (tRandom.nextInt(3 + aFortune) > 1) {
- Materials dustMat = ((GT_Block_Ores_Abstract) aDroppedOre).getDroppedDusts()[this.mMetaData / 1000 % 16];
+ 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));
+ rList.add(GT_OreDictUnificator.get(
+ tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, dustMat, 1L));
}
}
return rList;
@@ -285,20 +343,27 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)];
if ((aMaterial != null) && (this.mMetaData < 32000)) {
ITexture iTexture = TextureFactory.builder()
- .addIcon(aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ?
- OrePrefixes.ore.mTextureIndex :
- OrePrefixes.oreSmall.mTextureIndex])
+ .addIcon(aMaterial
+ .mIconSet
+ .mTextures[
+ this.mMetaData / 16000 == 0
+ ? OrePrefixes.ore.mTextureIndex
+ : OrePrefixes.oreSmall.mTextureIndex])
.setRGBA(aMaterial.mRGBa)
.stdOrient()
.build();
if (aBlock instanceof GT_Block_Ores_Abstract) {
- return new ITexture[]{
- ((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], iTexture};
+ return new ITexture[] {
+ ((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], iTexture
+ };
}
}
- return new ITexture[]{
- TextureFactory.of(Blocks.stone, 0),
- TextureFactory.builder().addIcon(SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]).stdOrient().build()
+ return new ITexture[] {
+ TextureFactory.of(Blocks.stone, 0),
+ TextureFactory.builder()
+ .addIcon(SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex])
+ .stdOrient()
+ .build()
};
}
}