From c40f01930ea256adcdb858e0214deb517989b676 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Wed, 20 Sep 2017 00:29:49 +0800 Subject: [PATCH 01/22] Fix #562 Listen to the BlockEvent of Reinforced Glass and trigger the update check. --- src/main/java/gregtech/common/GT_Proxy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index c0e1134c..09fb87fd 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1888,5 +1888,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } } + @SubscribeEvent + public void onBlockEvent(BlockEvent event) { + if (event.block.getUnlocalizedName().equals("blockAlloyGlass")) + GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); + } -} \ No newline at end of file + +} From 0802fdbd0272c4251c4615026643c8eadcf7fe70 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 21 Sep 2017 20:33:23 +0800 Subject: [PATCH 02/22] Fix Oil Drill logic; rebalance EU cost --- ...MetaTileEntity_ConcreteBackfillerBase.java | 17 ++----- .../multi/GT_MetaTileEntity_DrillerBase.java | 51 ++++++++++++++----- .../multi/GT_MetaTileEntity_OilDrillBase.java | 39 ++++++-------- 3 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index 29b37f6d..2f88d446 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -53,18 +53,9 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi protected void setElectricityStats() { this.mEfficiency = getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; - //T1 = 48; T2 = 192; T3 = 768; T4 = 3072 - this.mEUt = 12 * (1 << (getMinTier() << 1)); - this.mMaxProgresstime = (isPickingPipes ? 240: 80) / (1 << getMinTier()); - - long voltage = getMaxInputVoltage(); - long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1]; - while (this.mEUt <= overclockEu) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - - this.mEUt = -this.mEUt; + int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEUt = -6 * (1 << (tier << 1)); + this.mMaxProgresstime = (workState == STATE_UPWARD ? 240 : 80) / (1 << tier); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } @@ -94,7 +85,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi mLastZOff = 0; return true; } else { - isPickingPipes = false; + workState = STATE_DOWNWARD; stopMachine(); return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 7f1cfafb..aa0bd0f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -39,7 +39,8 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu private ForgeDirection back; private int xDrill, yDrill, zDrill, xPipe, zPipe, yHead; - protected boolean isPickingPipes; + protected int workState; + protected static final int STATE_DOWNWARD = 0, STATE_AT_BOTTOM = 1, STATE_UPWARD = 2; public GT_MetaTileEntity_DrillerBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -57,7 +58,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu int frameId = 4096 + getFrameMaterial().mMetaItemSubID; frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; casingTextureIndex = getCasingTextureIndex(); - isPickingPipes = false; + workState = STATE_DOWNWARD; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -69,13 +70,14 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("isPickingPipe", isPickingPipes); + aNBT.setInteger("workState", workState); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - isPickingPipes = aNBT.getBoolean("isPickingPipes"); + workState = aNBT.getInteger("workState"); + if (aNBT.hasKey("isPickingPipes")) workState = aNBT.getBoolean("isPickingPipes") ? STATE_UPWARD : STATE_DOWNWARD; } protected boolean tryPickPipe() { @@ -90,15 +92,21 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } protected boolean tryLowerPipe() { + return tryLowerPipe(false); + } + + protected boolean tryLowerPipe(boolean isSimulating) { if (!isHasMiningPipes()) return false; if (yHead <= 0) return false; if (!canLowerPipe()) return false; - getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock); - if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock); + if (!isSimulating) { + getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock); + if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock); - getBaseMetaTileEntity().decrStackSize(1, 1); + getBaseMetaTileEntity().decrStackSize(1, 1); + } return true; } @@ -154,18 +162,27 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return false; } - protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){ - if(!tryLowerPipe()) + protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { + if(!tryLowerPipe()) { if(waitForPipes()) return false; - isPickingPipes = true; + workState = STATE_AT_BOTTOM; + } return true; } - + + protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { + if(tryLowerPipe(true)) + workState = STATE_DOWNWARD; + else + workState = STATE_UPWARD; + return true; + } + protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { if (tryPickPipe()) { return true; } else { - isPickingPipes = false; + workState = STATE_DOWNWARD; stopMachine(); return false; } @@ -181,10 +198,16 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return false; } putMiningPipesFromInputsInController(); - if (!isPickingPipes) + switch (workState) { + case STATE_DOWNWARD: return workingDownward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); - else + case STATE_AT_BOTTOM: + return workingAtBottom(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + case STATE_UPWARD: return workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + default: + return false; + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index a4311ee1..7d3b4678 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -78,27 +78,20 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D protected void setElectricityStats() { this.mEfficiency = getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; - //T1 = 24; T2 = 96; T3 = 384 - this.mEUt = 6 * (1 << (getMinTier() << 1)); - //160 per chunk in MV - this.mMaxProgresstime = (isPickingPipes ? 80 : 640 * getRangeInChunks() * getRangeInChunks()) / (1 << getMinTier()); - - long voltage = getMaxInputVoltage(); - long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1]; - while (this.mEUt <= overclockEu) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - - this.mEUt = -this.mEUt; + int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEUt = -3 * (1 << (tier << 1)); + this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? 320 * getRangeInChunks() * getRangeInChunks() : 80) / (1 << tier); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } @Override - protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){ - if (!tryLowerPipe()){ - if (waitForPipes()) return false; - if (tryFillChunkList()) { + protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { + if(tryLowerPipe(true)) { + workState = STATE_DOWNWARD; + setElectricityStats(); + } + else { + if (tryFillChunkList()) { float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; FluidStack tFluid = pumpOil(speed); if (tFluid != null && tFluid.amount > getTotalConfigValue()){ @@ -106,10 +99,9 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D return true; } } - isPickingPipes = true; - return true; - } - return true; + workState = STATE_UPWARD; + } + return true; } private boolean tryFillChunkList(){ @@ -124,11 +116,10 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D if (mOilFieldChunks.isEmpty()) { Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord()); int range = getRangeInChunks(); - int xChunk = (tChunk.xPosition / range) * range, zChunk = (tChunk.zPosition / range) * range; - int xDir = tChunk.xPosition < 0 ? -1 : 1, zDir = tChunk.zPosition < 0 ? -1 : 1; + int xChunk = (tChunk.xPosition / range) * range - (tChunk.xPosition < 0 ? range : 0), zChunk = (tChunk.zPosition / range) * range - (tChunk.zPosition < 0 ? range : 0); for (int i = 0; i < range; i++) { for (int j = 0; j < range; j++) { - tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i * xDir, zChunk + j * zDir); + tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i, zChunk + j); tFluid = undergroundOilReadInformation(tChunk); if (tOil.isFluidEqual(tFluid)) mOilFieldChunks.add(tChunk); From 9d8ac82535b0099ef70e8995bca51f62f39f9f94 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 21 Sep 2017 20:34:38 +0800 Subject: [PATCH 03/22] Fix Ore Drill EU calculation; now Ore Drill is using DrillerBase --- ...T_MetaTileEntity_OreDrillingPlantBase.java | 282 ++---------------- 1 file changed, 30 insertions(+), 252 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index a227ab74..bc523114 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -1,18 +1,15 @@ package gregtech.common.tileentities.machines.multi; -import gregtech.api.GregTech_API; +import static gregtech.api.enums.GT_Values.*; + +import java.util.ArrayList; + import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -22,106 +19,40 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkPosition; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - -import static gregtech.api.enums.GT_Values.*; - -public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_MultiBlockBase { - private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0); - private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0); - private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe); - private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip); - +public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase { + private final ArrayList oreBlockPositions = new ArrayList<>(); - private Block casingBlock; - private int casingMeta; - private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - private int xDrill, yDrill, zDrill, xCenter, zCenter, yHead; - - private boolean isPickingPipes; - public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - initFields(); } public GT_MetaTileEntity_OreDrillingPlantBase(String aName) { super(aName); - initFields(); - } - - private void initFields() { - casingBlock = getCasingBlockItem().getBlock(); - casingMeta = getCasingBlockItem().get(0).getItemDamage(); - int frameId = 4096 + getFrameMaterial().mMetaItemSubID; - frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; - casingTextureIndex = getCasingTextureIndex(); - isPickingPipes = false; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex],new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL)}; - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex]}; } + @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png"); } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("isPickingPipes", isPickingPipes); - } + protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { + if (yHead != oldYHead) oreBlockPositions.clear(); - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - isPickingPipes = aNBT.getBoolean("isPickingPipes"); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - setElectricityStats(); - int oldYHead = yHead; - if (!checkPipesAndSetYHead() || !isEnergyEnough()) { - stopMachine(); - return false; - } - if (yHead != oldYHead) oreBlockPositions.clear(); - if (isPickingPipes) { - if (tryPickPipe()) { - mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)}; - return true; - } else { - isPickingPipes = false; - stopMachine(); - return false; - } - } - - putMiningPipesFromInputsInController(); - if (!tryConsumeDrillingFluid()) return false; - - fillMineListIfEmpty(); + fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); if (oreBlockPositions.isEmpty()) { if (!tryLowerPipe()) { - isPickingPipes = true; + if (waitForPipes()) return false; + workState = STATE_AT_BOTTOM; return true; } //new layer - fill again - fillMineListIfEmpty(); + fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); } ChunkPosition oreBlockPos = null; @@ -132,6 +63,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); } + if (!tryConsumeDrillingFluid()) return false; if (oreBlock != null && oreBlock != Blocks.air) { ArrayList oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); @@ -141,29 +73,19 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile return true; } - private boolean isEnergyEnough() { - long requiredEnergy = 512 + getMaxInputVoltage() * 4; - for (GT_MetaTileEntity_Hatch_Energy energyHatch : mEnergyHatches) { - requiredEnergy -= energyHatch.getEUVar(); - if (requiredEnergy <= 0) return true; - } - return false; + @Override + protected boolean checkHatches(){ + return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mOutputBusses.isEmpty() && !mEnergyHatches.isEmpty(); } - - private boolean tryPickPipe() { - if (yHead == yDrill) return false; - if (checkBlockAndMeta(xCenter, yHead + 1, zCenter, miningPipeBlock, W)) - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead + 1, zCenter, miningPipeTipBlock); - getBaseMetaTileEntity().getWorld().setBlockToAir(xCenter, yHead, zCenter); - return true; - } - - private void setElectricityStats() { + + @Override + protected void setElectricityStats() { this.mEfficiency = getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; - int overclock = 1 << GT_Utility.getTier(getMaxInputVoltage()) - 1; - this.mEUt = -12 * overclock * overclock; - this.mMaxProgresstime = (isPickingPipes ? 80 : getBaseProgressTime()) / overclock; + int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEUt = -3 * (1 << (tier << 1)); + this.mMaxProgresstime = (workState == STATE_DOWNWARD ? getBaseProgressTime() : 80) / (1 < oreBlockDrops) { @@ -216,37 +138,17 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } private boolean tryConsumeDrillingFluid() { - return depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000)); - } - - private void putMiningPipesFromInputsInController() { - int maxPipes = miningPipe.getMaxStackSize(); - if (isHasMiningPipes(maxPipes)) return; - - ItemStack pipes = getStackInSlot(1); - for (ItemStack storedItem : getStoredInputs()) { - if (!storedItem.isItemEqual(miningPipe)) continue; - - if (pipes == null) { - setInventorySlotContents(1, GT_Utility.copy(miningPipe)); - pipes = getStackInSlot(1); - } - - if (pipes.stackSize == maxPipes) break; - - int needPipes = maxPipes - pipes.stackSize; - int transferPipes = storedItem.stackSize < needPipes ? storedItem.stackSize : needPipes; - - pipes.stackSize += transferPipes; - storedItem.stackSize -= transferPipes; + if (!depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000))) { + mMaxProgresstime = 0; + return false; } - updateSlots(); + return true; } - private void fillMineListIfEmpty() { + private void fillMineListIfEmpty(int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead) { if (!oreBlockPositions.isEmpty()) return; - tryAddOreBlockToMineList(xCenter, yHead - 1, zCenter); + tryAddOreBlockToMineList(xPipe, yHead - 1, zPipe); if (yHead == yDrill) return; //skip controller block layer int radius = getRadiusInChunks() << 4; @@ -271,132 +173,8 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } } - private boolean tryLowerPipe() { - if (!isHasMiningPipes()) return false; - - if (yHead <= 0) return false; - if (checkBlockAndMeta(xCenter, yHead - 1, zCenter, Blocks.bedrock, W)) return false; - - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead - 1, zCenter, miningPipeTipBlock); - if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeBlock); - - getBaseMetaTileEntity().decrStackSize(1, 1); - return true; - } - - private boolean isHasMiningPipes() { - return isHasMiningPipes(1); - } - - private boolean isHasMiningPipes(int minCount) { - ItemStack pipe = getStackInSlot(1); - return pipe != null && pipe.stackSize > minCount - 1 && pipe.isItemEqual(miningPipe); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - updateCoordinates(); - //check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) - && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addInputToMachineList(tTileEntity, casingTextureIndex) - && !addOutputToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)) - return false; - } - } - if (mMaintenanceHatches.isEmpty() || mInputHatches.isEmpty() || mOutputBusses.isEmpty() || mEnergyHatches.isEmpty()) return false; - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false; - //check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) - return false; - } - return true; - } - - private void updateCoordinates() { - xDrill = getBaseMetaTileEntity().getXCoord(); - yDrill = getBaseMetaTileEntity().getYCoord(); - zDrill = getBaseMetaTileEntity().getZCoord(); - back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); - xCenter = xDrill + back.offsetX; - zCenter = zDrill + back.offsetZ; - } - - private boolean checkPipesAndSetYHead() { - yHead = yDrill - 1; - while (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeBlock, W)) yHead--; //skip pipes - //is pipe tip OR is controller layer - if (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeTipBlock, W) || ++yHead == yDrill) return true; - //pipe column is broken - try fix - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeTipBlock); - return true; - } - - private boolean checkCasingBlock(int xOff, int yOff, int zOff) { - return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); - } - //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) - private boolean checkFrameBlock(int xOff, int yOff, int zOff) { - return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); - } - - private boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { - return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta); - } - - private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { - return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) - && getBaseMetaTileEntity().getBlock(x, y, z) == block; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - protected abstract ItemList getCasingBlockItem(); - - protected abstract Materials getFrameMaterial(); - - protected abstract int getCasingTextureIndex(); - protected abstract int getRadiusInChunks(); - protected abstract int getMinTier(); - - //returns theoretical progress time for LV energy hatch protected abstract int getBaseProgressTime(); protected String[] getDescriptionInternal(String tierSuffix) { From 7b6bbb6a7c387e8017541c301bc4a27625e22081 Mon Sep 17 00:00:00 2001 From: Usenkov Dmitry Date: Thu, 21 Sep 2017 18:24:43 +0300 Subject: [PATCH 04/22] Glass fiber recipy fix Prevent extruder from consuming wire mold --- .../java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 4cb542b7..54e47070 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -503,7 +503,7 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Plastic, 1), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 2), ItemList.Circuit_Parts_Capacitor.get(2, o), 80, 96); GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 8), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 2),Materials.Plastic.getMolten(72), ItemList.Circuit_Parts_CapacitorSMD.get(32, o), 120, 120); GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.PolyvinylChloride, 8), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 2),Materials.Plastic.getMolten(72), ItemList.Circuit_Parts_CapacitorSMD.get(32, o), 100, 120); - GT_Values.RA.addExtruderRecipe(Materials.BorosilicateGlass.getIngots(1), ItemList.Shape_Extruder_Wire.get(1, new Object[0]), ItemList.Circuit_Parts_GlassFiber.get(8, new Object[0]), 160, 96); + GT_Values.RA.addExtruderRecipe(Materials.BorosilicateGlass.getIngots(1), ItemList.Shape_Extruder_Wire.get(0, new Object[0]), ItemList.Circuit_Parts_GlassFiber.get(8, new Object[0]), 160, 96); GT_Values.RA.addLaserEngraverRecipe(ItemList.Circuit_Silicon_Wafer2.get(1, new Object[0]), GT_Utility.copyAmount(0,GT_OreDictUnificator.get(OrePrefixes.lens, Materials.EnderPearl, 1)), ItemList.Circuit_Wafer_NAND.get(1, new Object[0]), 500, 480, true); GT_Values.RA.addLaserEngraverRecipe(ItemList.Circuit_Silicon_Wafer3.get(1, new Object[0]), GT_Utility.copyAmount(0,GT_OreDictUnificator.get(OrePrefixes.lens, Materials.EnderPearl, 1)), ItemList.Circuit_Wafer_NAND.get(4, new Object[0]), 200, 1920, true); From e725c455b3d9025caeebdbf12cc9d25f238f74bb Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 01:34:10 +0800 Subject: [PATCH 05/22] Adding Fake Player for all drills and pumps --- .../java/gregtech/api/util/GT_Utility.java | 43 +++++++++- .../basic/GT_MetaTileEntity_Miner.java | 13 ++- .../basic/GT_MetaTileEntity_Pump.java | 34 +++++--- ...MetaTileEntity_ConcreteBackfillerBase.java | 13 ++- .../multi/GT_MetaTileEntity_DrillerBase.java | 79 +++++++++++-------- .../multi/GT_MetaTileEntity_OilDrillBase.java | 36 ++++----- ...T_MetaTileEntity_OreDrillingPlantBase.java | 20 +++-- 7 files changed, 159 insertions(+), 79 deletions(-) diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index fb89cbba..996e5fd8 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -54,7 +54,12 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; @@ -67,6 +72,8 @@ import java.text.NumberFormat; import java.util.*; import java.util.Map.Entry; +import com.mojang.authlib.GameProfile; + import static gregtech.api.enums.GT_Values.*; import static gregtech.common.GT_Proxy.GTPOLLUTION; import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; @@ -1981,7 +1988,41 @@ public class GT_Utility { public static ItemStack getIntegratedCircuit(int config){ return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]); } - + + public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlock(aX, aY, aZ).getBlockHardness(aWorld, aX, aY, aZ); + } + + public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) { + return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(null, aBaseMetaTileEntity.getOwnerName())); + } + return null; + } + + public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) { + if (aPlayer == null) return false; + World aWorld = aPlayer.worldObj; + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer); + MinecraftForge.EVENT_BUS.post(event); + if (!event.isCanceled()) { + if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ); + return true; + } + return false; + } + + public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) { + if (aPlayer == null) return false; + World aWorld = aPlayer.worldObj; + BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN); + if (!event.isCanceled()) { + if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3); + return true; + } + return false; + } + public static class ItemNBT { public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) { if (aNBT == null) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 13f16a2b..254daaf8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -17,6 +17,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.FakePlayer; import java.util.ArrayList; @@ -133,7 +134,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { - if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 || aBaseMetaTileEntity.getBlockOffset(0, drillY - 1, 0) == Blocks.bedrock) { + if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), 0, drillY - 1, 0) < 0 || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), 0, drillY - 1, 0, MINING_PIPE_TIP_BLOCK, 0, true)) { isPickingPipes = true; return false; } @@ -166,6 +167,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } public void mineBlock(IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z) { + if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z, true)); ArrayList drops = getBlockDrops(aBaseMetaTileEntity.getBlockOffset(x, y, z), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z); if (drops.size() > 0) mOutputItems[0] = drops.get(0); @@ -196,4 +198,13 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { drillY = aNBT.getInteger("drillY"); drillZ = aNBT.getInteger("drillZ"); } + + private FakePlayer mFakePlayer = null; + + protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { + if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); + return mFakePlayer; + } + } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index c4fa8d73..4b410407 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -15,8 +15,10 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.ChunkPosition; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; @@ -26,6 +28,9 @@ import java.util.Iterator; import static gregtech.api.enums.GT_Values.V; public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { + private static final ItemStack MINING_PIPE = GT_ModHandler.getIC2Item("miningPipe", 0); + private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE); + private static final Block MINING_PIPE_TIP_BLOCK = GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 0)); public ArrayList mPumpList = new ArrayList(); public int mPumpTimer = 0; @@ -171,7 +176,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { private boolean moveOneDown() { if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1) - || (!GT_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L)))) { + || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) { return false; } int yHead = getYOfPumpHead(); @@ -179,14 +184,13 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { return false; } if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getAir(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { - return false; } - if (!(getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))))) { + if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) { return false; } if (yHead != getBaseMetaTileEntity().getYCoord()) { - getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))); + getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK); } getBaseMetaTileEntity().decrStackSize(0, 1); return true; @@ -194,19 +198,16 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { private int getYOfPumpHead() { int y = getBaseMetaTileEntity().getYCoord() - 1; - while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == GT_Utility - .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))) { + while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == MINING_PIPE_BLOCK) { y--; } if (y == getBaseMetaTileEntity().getYCoord() - 1) { - if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility - .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))) { + if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK) { return y + 1; } - } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility - .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)) && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L))) { - getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), - GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))); + } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK + && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE)) { + getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK); getBaseMetaTileEntity().decrStackSize(0, 1); } return y; @@ -281,6 +282,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } private boolean consumeFluid(int aX, int aY, int aZ) { + if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false; Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ); if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock))) { @@ -447,4 +449,12 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),}; } + + private FakePlayer mFakePlayer = null; + + protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { + if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); + return mFakePlayer; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index 2f88d446..a285f136 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.multi; -import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; import gregtech.api.GregTech_API; @@ -92,15 +91,15 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi } private boolean isRefillableBlock(int aX, int aY, int aZ){ - if (getBaseMetaTileEntity().getTileEntity(aX, aY, aZ) != null) return false; - if (getBaseMetaTileEntity().getAir(aX, aY, aZ) || !getBaseMetaTileEntity().getBlock(aX, aY, aZ).getMaterial().isSolid()) - return true; - return false; + IGregTechTileEntity aBaseTile = getBaseMetaTileEntity(); + if (aBaseTile.getTileEntity(aX, aY, aZ) != null) return false; + if (!aBaseTile.getAir(aX, aY, aZ) && aBaseTile.getBlock(aX, aY, aZ).getMaterial().isSolid()) return false; + if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseTile), aX, aY, aZ, GregTech_API.sBlockConcretes, 8, true)) return false; + return true; } private boolean tryRefillBlock(int aX, int aY, int aZ) { - if (!tryConsumeFluid()) - return false; + if (!tryConsumeFluid()) return false; getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, GregTech_API.sBlockConcretes, 8, 3); return true; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index aa0bd0f1..7998d102 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -23,6 +23,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase { @@ -91,23 +92,30 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return false; } - protected boolean tryLowerPipe() { + /** + * @return 0 for succeeded, 1 for invalid block, 2 for not having mining pipes, 3 for event canceled. + */ + protected int tryLowerPipe() { return tryLowerPipe(false); } - protected boolean tryLowerPipe(boolean isSimulating) { - if (!isHasMiningPipes()) return false; - - if (yHead <= 0) return false; - if (!canLowerPipe()) return false; - + /** + * @return 0 for succeeded, 1 for invalid block, 2 for not having mining pipes, 3 for event canceled. + */ + protected int tryLowerPipe(boolean isSimulating) { + if (!isHasMiningPipes()) return 2; + switch (canLowerPipe()) { + case 1: return 1; + case 2: return 3; + } + + if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), xPipe, yHead - 1, zPipe, miningPipeTipBlock, 0, isSimulating)) return 3; if (!isSimulating) { - getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock); if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock); - getBaseMetaTileEntity().decrStackSize(1, 1); } - return true; + + return 0; } private void putMiningPipesFromInputsInController() { @@ -140,8 +148,19 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return true; } - protected boolean canLowerPipe(){ - return yHead > 0 && !checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W); + /** + * @return 0 for available, 1 for invalid block, 2 for event canceled. + */ + protected int canLowerPipe(){ + IGregTechTileEntity aBaseTile = getBaseMetaTileEntity(); + if (yHead > 0 && GT_Utility.getBlockHardnessAt(aBaseTile.getWorld(), xPipe, yHead - 1, zPipe) >= 0) { + return GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseTile), xPipe, yHead - 1, zPipe, true) ? 0 : 2; + } + return 1; + } + + protected boolean reachingVoidOrBedrock() { + return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, 0); } private boolean isHasMiningPipes() { @@ -163,19 +182,19 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { - if(!tryLowerPipe()) { - if(waitForPipes()) return false; - workState = STATE_AT_BOTTOM; + switch (tryLowerPipe()) { + case 2: mMaxProgresstime = 0; return false; + case 3: workState = STATE_UPWARD; return true; + case 1: workState = STATE_AT_BOTTOM; return true; + default: return true; } - return true; } protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { - if(tryLowerPipe(true)) - workState = STATE_DOWNWARD; - else - workState = STATE_UPWARD; - return true; + switch (tryLowerPipe(true)) { + case 0: workState = STATE_DOWNWARD; return true; + default: workState = STATE_UPWARD; return true; + } } protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { @@ -278,13 +297,13 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) && getBaseMetaTileEntity().getBlock(x, y, z) == block; } - - protected boolean waitForPipes(){ - if (canLowerPipe()) { - mMaxProgresstime = 0; - return true; - } - return false; + + private FakePlayer mFakePlayer = null; + + protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { + if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); + return mFakePlayer; } @Override @@ -311,8 +330,6 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } - - public abstract Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity); protected abstract ItemList getCasingBlockItem(); @@ -371,7 +388,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; // TODO return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 7d3b4678..068b09db 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -1,5 +1,11 @@ package gregtech.common.tileentities.machines.multi; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.common.GT_UndergroundOil.undergroundOil; +import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; + +import java.util.ArrayList; + import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; @@ -10,13 +16,6 @@ import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; -import static gregtech.common.GT_UndergroundOil.undergroundOil; -import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; - public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_DrillerBase { private boolean completedCycle = false; @@ -86,21 +85,20 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D @Override protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { - if(tryLowerPipe(true)) { - workState = STATE_DOWNWARD; - setElectricityStats(); + switch (tryLowerPipe(true)) { + case 0: workState = STATE_DOWNWARD; setElectricityStats(); return true; + case 3: workState = STATE_UPWARD; return true; } - else { - if (tryFillChunkList()) { - float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; - FluidStack tFluid = pumpOil(speed); - if (tFluid != null && tFluid.amount > getTotalConfigValue()){ - this.mOutputFluids = new FluidStack[]{tFluid}; - return true; - } + + if (!reachingVoidOrBedrock() && tryFillChunkList()) { + float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; + FluidStack tFluid = pumpOil(speed); + if (tFluid != null && tFluid.amount > getTotalConfigValue()){ + this.mOutputFluids = new FluidStack[]{tFluid}; + return true; } - workState = STATE_UPWARD; } + workState = STATE_UPWARD; return true; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index bc523114..4e963d53 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -1,6 +1,6 @@ package gregtech.common.tileentities.machines.multi; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.VN; import java.util.ArrayList; @@ -46,11 +46,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); if (oreBlockPositions.isEmpty()) { - if (!tryLowerPipe()) { - if (waitForPipes()) return false; - workState = STATE_AT_BOTTOM; - return true; - } + switch (tryLowerPipe()) { + case 2: mMaxProgresstime = 0; return false; + case 3: workState = STATE_UPWARD; return true; + case 1: workState = STATE_AT_BOTTOM; return true; + } //new layer - fill again fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); } @@ -60,10 +60,14 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile while ((oreBlock == null || oreBlock == Blocks.air) && !oreBlockPositions.isEmpty()) { oreBlockPos = oreBlockPositions.remove(0); - oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + if (GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ, true)) + oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); } - if (!tryConsumeDrillingFluid()) return false; + if (!tryConsumeDrillingFluid()) { + oreBlockPositions.add(0, oreBlockPos); + return false; + } if (oreBlock != null && oreBlock != Blocks.air) { ArrayList oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); From 3db38a5c53a771aeb37a8cf2568f79c49bb38c21 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 01:36:28 +0800 Subject: [PATCH 06/22] Update --- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 7998d102..bb0aaaee 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -388,7 +388,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; // TODO + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture((byte) aBaseCasingIndex); return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; From aef60bbf3b6752963b51c9c4e27b6ba03f75ba8c Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 14:06:42 +0800 Subject: [PATCH 07/22] Fix wrong logic. --- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../machines/multi/GT_MetaTileEntity_OilDrillBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index bb0aaaee..9c05c58d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -160,7 +160,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } protected boolean reachingVoidOrBedrock() { - return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, 0); + return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W); } private boolean isHasMiningPipes() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 068b09db..6e7c0f4f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -90,7 +90,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D case 3: workState = STATE_UPWARD; return true; } - if (!reachingVoidOrBedrock() && tryFillChunkList()) { + if (reachingVoidOrBedrock() && tryFillChunkList()) { float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; FluidStack tFluid = pumpOil(speed); if (tFluid != null && tFluid.amount > getTotalConfigValue()){ From 3f0224f55faab43cdebc19015d3132e30b9a766c Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sat, 23 Sep 2017 17:14:15 +0800 Subject: [PATCH 08/22] Register Reinforced Glass as GT machine casing --- .../gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index cf216a17..21df347a 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -722,5 +722,6 @@ public class GT_Loader_Item_Block_And_Fluid FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.NaquadahEnriched.getMolten(1000L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.NaquadahEnriched, 1L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L))); FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.Naquadria.getMolten(1000L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Naquadria, 1L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L))); + GregTech_API.registerMachineBlock(GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("reinforcedGlass", 0)), 0); } } From ef41455fe59f2915c94c204b97cee19aa2ddcd3b Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sun, 24 Sep 2017 11:45:15 +0800 Subject: [PATCH 09/22] Fix wrong coordinate --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 254daaf8..c59790d1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -134,7 +134,9 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { - if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), 0, drillY - 1, 0) < 0 || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), 0, drillY - 1, 0, MINING_PIPE_TIP_BLOCK, 0, true)) { + if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 + || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), 0, aBaseMetaTileEntity.getYCoord() + drillY - 1, 0) < 0 + || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), 0, drillY - 1, 0, MINING_PIPE_TIP_BLOCK, 0, true)) { isPickingPipes = true; return false; } From 32d4998ec6b2a9e6d8b14450748a9ae256d311a1 Mon Sep 17 00:00:00 2001 From: Dimach Date: Mon, 25 Sep 2017 14:01:46 +0300 Subject: [PATCH 10/22] Fixed small bug - basic miner cant work using battery in inner slot. --- .../machines/basic/GT_MetaTileEntity_Miner.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 13f16a2b..71d42fa8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -20,6 +20,8 @@ import net.minecraft.tileentity.TileEntity; import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.V; + public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { private static final ItemStack MINING_PIPE = GT_ModHandler.getIC2Item("miningPipe", 0); private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE); @@ -132,6 +134,11 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } } + @Override + public long maxEUStore() { + return mTier == 1 ? 4096 : V[mTier] * 64; + } + public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 || aBaseMetaTileEntity.getBlockOffset(0, drillY - 1, 0) == Blocks.bedrock) { isPickingPipes = true; From 4372034ff4edc9e58629d63123b84c29e6e0e516 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Mon, 2 Oct 2017 11:31:01 +0800 Subject: [PATCH 11/22] Rebalance EU cost 2 --- .../machines/multi/GT_MetaTileEntity_OilDrillBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 6e7c0f4f..5d760e62 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -79,7 +79,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D this.mEfficiencyIncrease = 10000; int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); this.mEUt = -3 * (1 << (tier << 1)); - this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? 320 * getRangeInChunks() * getRangeInChunks() : 80) / (1 << tier); + this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? (1280 * getRangeInChunks() * getRangeInChunks() / (1 << getMinTier())) : 80) / (1 << tier); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } From 7f68c17736aff5afa1e048525715c6b0608ffc50 Mon Sep 17 00:00:00 2001 From: Sirse Date: Fri, 6 Oct 2017 01:43:50 +0700 Subject: [PATCH 12/22] Added TeleporterUsingEvent. In multiplayer players can teleport to "restricted" areas (like closed dimensions or WorldEdit regions), need to handle it. --- .../api/events/TeleporterUsingEvent.java | 21 +++++++++++++++++++ .../basic/GT_MetaTileEntity_Teleporter.java | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/java/gregtech/api/events/TeleporterUsingEvent.java diff --git a/src/main/java/gregtech/api/events/TeleporterUsingEvent.java b/src/main/java/gregtech/api/events/TeleporterUsingEvent.java new file mode 100644 index 00000000..ab065f63 --- /dev/null +++ b/src/main/java/gregtech/api/events/TeleporterUsingEvent.java @@ -0,0 +1,21 @@ +package gregtech.api.events; + +import net.minecraft.entity.Entity; + +@cpw.mods.fml.common.eventhandler.Cancelable +public class TeleporterUsingEvent extends net.minecraftforge.event.entity.EntityEvent { + + public final Entity mEntity; + public final int mTargetX, mTargetY, mTargetZ, mTargetD; + public final boolean mHasEgg; + + public TeleporterUsingEvent(Entity aEntity, int aTargetX, int aTargetY, int aTargetZ, int aTargetD, boolean aHasEgg) { + super(aEntity); + mEntity = aEntity; + mTargetX = aTargetX; + mTargetY = aTargetY; + mTargetZ = aTargetZ; + mTargetD = aTargetD; + mHasEgg = aHasEgg; + } +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java index 399e798c..9261e1b7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java @@ -3,6 +3,7 @@ package gregtech.common.tileentities.machines.basic; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; +import gregtech.api.events.TeleporterUsingEvent; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -34,6 +35,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidStack; import static gregtech.api.enums.GT_Values.V; @@ -281,7 +283,9 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { if (((tObject instanceof Entity)) && (!((Entity) tObject).isDead)) { Entity tEntity = (Entity) tObject; // System.out.println("teleport"+(Math.pow(tDistance, 1.5))); - if (getBaseMetaTileEntity().decreaseStoredEnergyUnits((int) (Math.pow(tDistance, 1.5) * weightCalculation(tEntity) * sFPowerMultiplyer), false)) { + TeleporterUsingEvent tEvent = new TeleporterUsingEvent(tEntity, mTargetX, mTargetY, mTargetZ, mTargetD, hasEgg); + MinecraftForge.EVENT_BUS.post(tEvent); + if (!tEvent.isCanceled() && getBaseMetaTileEntity().decreaseStoredEnergyUnits((int) (Math.pow(tDistance, 1.5) * weightCalculation(tEntity) * sFPowerMultiplyer), false)) { if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))) { mFluid.amount = mFluid.amount - ((int) Math.min(10, (Math.pow(tDistance, 1.5) * weightCalculation(tEntity) / 8192))); if (mFluid.amount < 1) { From f5abfcefe8d77e2c3c6284bff72de25c0a0ef774 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sun, 8 Oct 2017 02:48:49 +0800 Subject: [PATCH 13/22] The right method to find out whether the machine should break the block. --- .../tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 2 +- .../multi/GT_MetaTileEntity_ConcreteBackfillerBase.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index 4b410407..f91ce480 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -183,7 +183,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { if (yHead <= 0) { return false; } - if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getAir(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { + if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()).isAir(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { return false; } if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index a285f136..73795647 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -92,8 +92,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi private boolean isRefillableBlock(int aX, int aY, int aZ){ IGregTechTileEntity aBaseTile = getBaseMetaTileEntity(); - if (aBaseTile.getTileEntity(aX, aY, aZ) != null) return false; - if (!aBaseTile.getAir(aX, aY, aZ) && aBaseTile.getBlock(aX, aY, aZ).getMaterial().isSolid()) return false; + if (!aBaseTile.getBlock(aX, aY, aZ).isAir(aBaseTile.getWorld(), aX, aY, aZ) || aBaseTile.getBlock(aX, aY, aZ).getMaterial().isSolid()) return false; if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseTile), aX, aY, aZ, GregTech_API.sBlockConcretes, 8, true)) return false; return true; } From 4e9e3db5ca1a5742fb204b831717e7659e17ff5a Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Mon, 16 Oct 2017 14:21:18 +0800 Subject: [PATCH 14/22] Fix unexpected recipe loading --- .../postload/GT_MachineRecipeLoader.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index a715dc44..4e587c66 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -642,19 +642,23 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.CertusQuartz, 1L), new ItemStack(Blocks.sand, 1, 32767), GT_Values.NF, GT_ModHandler.getModItem(aTextAE, "item.ItemCrystalSeed", 2L, 0), 64, 8); GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.NetherQuartz, 1L), new ItemStack(Blocks.sand, 1, 32767), GT_Values.NF, GT_ModHandler.getModItem(aTextAE, "item.ItemCrystalSeed", 2L, 600), 64, 8); GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Fluix, 1L), new ItemStack(Blocks.sand, 1, 32767), GT_Values.NF, GT_ModHandler.getModItem(aTextAE, "item.ItemCrystalSeed", 2L, 1200), 64, 8); - GT_Values.RA.addAssemblerRecipe(ItemList.FR_Wax.get(6L, new Object[0]), new ItemStack(Items.string, 1, 32767), Materials.Water.getFluid(600L), GT_ModHandler.getModItem(aTextForestry, "candle", 24L, 0), 64, 8); - GT_Values.RA.addAssemblerRecipe(ItemList.FR_Wax.get(2L, new Object[0]), ItemList.FR_Silk.get(1L, new Object[0]), Materials.Water.getFluid(200L), GT_ModHandler.getModItem(aTextForestry, "candle", 8L, 0), 16, 8); - GT_Values.RA.addAssemblerRecipe(ItemList.FR_Silk.get(9L, new Object[0]), ItemList.Circuit_Integrated.getWithDamage(0L, 9L, new Object[0]), Materials.Water.getFluid(500L), GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 1L, 3), 64, 8); - GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "propolis", 5L, 2), ItemList.Circuit_Integrated.getWithDamage(0L, 5L, new Object[0]), GT_Values.NF, GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 1L, 1), 16, 8); - GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "sturdyMachine", 1L, 0), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Diamond, 4L), Materials.Water.getFluid(5000L), ItemList.FR_Casing_Hardened.get(1L, new Object[0]), 64, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Bronze, 8L), ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), GT_Values.NF, ItemList.FR_Casing_Sturdy.get(1L, new Object[0]), 32, 16); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Tin, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 0), 16, 8); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Bronze, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 1), 32, 16); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Iron, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 2), 48, 24); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.WroughtIron, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 2), 48, 24); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Gold, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 3), 64, 32); + + if (Loader.isModLoaded(aTextForestry)) { + GT_Values.RA.addAssemblerRecipe(ItemList.FR_Wax.get(6L, new Object[0]), new ItemStack(Items.string, 1, 32767), Materials.Water.getFluid(600L), GT_ModHandler.getModItem(aTextForestry, "candle", 24L, 0), 64, 8); + GT_Values.RA.addAssemblerRecipe(ItemList.FR_Wax.get(2L, new Object[0]), ItemList.FR_Silk.get(1L, new Object[0]), Materials.Water.getFluid(200L), GT_ModHandler.getModItem(aTextForestry, "candle", 8L, 0), 16, 8); + GT_Values.RA.addAssemblerRecipe(ItemList.FR_Silk.get(9L, new Object[0]), ItemList.Circuit_Integrated.getWithDamage(0L, 9L, new Object[0]), Materials.Water.getFluid(500L), GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 1L, 3), 64, 8); + GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "propolis", 5L, 2), ItemList.Circuit_Integrated.getWithDamage(0L, 5L, new Object[0]), GT_Values.NF, GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 1L, 1), 16, 8); + GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "sturdyMachine", 1L, 0), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Diamond, 4L), Materials.Water.getFluid(5000L), ItemList.FR_Casing_Hardened.get(1L, new Object[0]), 64, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Bronze, 8L), ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), GT_Values.NF, ItemList.FR_Casing_Sturdy.get(1L, new Object[0]), 32, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Tin, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 0), 16, 8); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Bronze, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 1), 32, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Iron, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 2), 48, 24); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.WroughtIron, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 2), 48, 24); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Gold, 3L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 6L), Materials.Water.getFluid(1000L), GT_ModHandler.getModItem(aTextForestry, "chipsets", 1L, 3), 64, 32); + GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 5L, 1), ItemList.Circuit_Integrated.getWithDamage(0L, 5L, new Object[0]), GT_Values.NF, GT_OreDictUnificator.get(OrePrefixes.gem, Materials.EnderPearl, 1L), 64, 8); + } + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Wood, 1L), new ItemStack(Blocks.wool, 1, 32767), Materials.Creosote.getFluid(1000L), new ItemStack(Blocks.torch, 6, 0), 400, 1); - GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem(aTextForestry, "craftingMaterial", 5L, 1), ItemList.Circuit_Integrated.getWithDamage(0L, 5L, new Object[0]), GT_Values.NF, GT_OreDictUnificator.get(OrePrefixes.gem, Materials.EnderPearl, 1L), 64, 8); GT_Values.RA.addAssemblerRecipe(new ItemStack(Blocks.piston, 1, 32767), new ItemStack(Items.slime_ball, 1, 32767), GT_Values.NF, new ItemStack(Blocks.sticky_piston, 1, 0), 100, 4); GT_Values.RA.addAssemblerRecipe(new ItemStack(Blocks.piston, 1, 32767), ItemList.IC2_Resin.get(1L, new Object[0]), GT_Values.NF, new ItemStack(Blocks.sticky_piston, 1, 0), 100, 4); GT_Values.RA.addAssemblerRecipe(new ItemStack(Blocks.piston, 1, 32767), ItemList.Circuit_Integrated.getWithDamage(0L, 1L, new Object[0]), Materials.Glue.getFluid(100L), new ItemStack(Blocks.sticky_piston, 1, 0), 100, 4); From 15c86d4ea2eb54aa88db839d6a3ed6a83026935f Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Wed, 18 Oct 2017 17:53:59 +0800 Subject: [PATCH 15/22] Fix --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 1 + .../tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 1 + .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index c59790d1..b34f6fa0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -205,6 +205,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index f91ce480..1c02526a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -454,6 +454,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 9c05c58d..b98d9936 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -302,6 +302,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } From 32cea58782726510fb73c25ab6654664e57a2361 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 19 Oct 2017 10:30:37 +0800 Subject: [PATCH 16/22] l10n improve --- src/main/java/gregtech/GT_Mod.java | 4 ++ .../java/gregtech/api/enums/Materials.java | 15 ++++- .../java/gregtech/api/enums/OrePrefixes.java | 67 ++++++++++--------- .../api/items/GT_CoolantCell_Item.java | 17 ++++- .../gregtech/api/items/GT_Generic_Item.java | 4 ++ .../api/items/GT_MetaGenerated_Item_X01.java | 22 +++++- .../api/items/GT_MetaGenerated_Item_X32.java | 22 +++++- .../api/items/GT_MetaGenerated_Tool.java | 20 +++--- .../api/items/GT_RadioactiveCell_Item.java | 16 ++++- .../gregtech/api/util/GT_LanguageManager.java | 11 ++- .../common/blocks/GT_Block_Metal.java | 2 +- .../common/blocks/GT_Block_Ores_Abstract.java | 61 +++++++++-------- .../gregtech/common/blocks/GT_Item_Ores.java | 5 ++ .../common/blocks/GT_Item_Storage.java | 14 ++++ 14 files changed, 204 insertions(+), 76 deletions(-) diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 848791bb..36975ced 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -316,6 +316,10 @@ public class GT_Mod implements IGT_Mod { GT_Log.out.println("GT_Mod: Generating Lang-File"); GT_LanguageManager.sEnglishFile = new Configuration(new File(aEvent.getModConfigurationDirectory().getParentFile(), "GregTech.lang")); GT_LanguageManager.sEnglishFile.load(); + for (Materials aMaterial : Materials.values()) { + if (aMaterial != null) + aMaterial.mLocalizedName = GT_LanguageManager.addStringLocalization("Material." + aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName); + } GT_Log.out.println("GT_Mod: Removing all original Scrapbox Drops."); try { diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 599cc60f..de1973a8 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -818,7 +818,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public byte mEnchantmentToolsLevel = 0, mEnchantmentArmorsLevel = 0; public boolean mBlastFurnaceRequired = false, mTransparent = false; public float mToolSpeed = 1.0F, mHeatDamage = 0.0F; - public String mChemicalFormula = "?", mName = "null", mDefaultLocalName = "null", mCustomID = "null", mConfigSection = "null"; + public String mChemicalFormula = "?", mName = "null", mDefaultLocalName = "null", mCustomID = "null", mConfigSection = "null", mLocalizedName = "null"; public Dyes mColor = Dyes._NULL; public short mMeltingPoint = 0, mBlastFurnaceTemp = 0, mGasTemp = 0; public int mTypes = 0; @@ -1984,6 +1984,19 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { return new GT_FluidStack(mStandardMoltenFluid, (int) aAmount); } + public String getLocalizedNameForItem(String aFormat) { + return String.format(aFormat.replace("%s", "%temp").replace("%material", "%s"), this.mLocalizedName).replace("%temp", "%s"); + } + + public static String getLocalizedNameForItem(String aFormat, int aMaterialID) { + if (aMaterialID >= 0 && aMaterialID < 1000) { + Materials aMaterial = GregTech_API.sGeneratedMaterials[aMaterialID]; + if (aMaterial != null) + return aMaterial.getLocalizedNameForItem(aFormat); + } + return aFormat; + } + @Override public short[] getRGBA() { return mRGBa; diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index ecc6d946..7381e10a 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -898,26 +898,31 @@ public enum OrePrefixes { return name() + aMaterial; } - @SuppressWarnings("incomplete-switch") + @Deprecated public String getDefaultLocalNameForItem(Materials aMaterial) { + return aMaterial.getLocalizedNameForItem(getDefaultLocalNameFormatForItem(aMaterial)); + } + + @SuppressWarnings("incomplete-switch") + public String getDefaultLocalNameFormatForItem(Materials aMaterial) { // Certain Materials have slightly different Localizations. switch (this) { case crateGtDust: - return mLocalizedMaterialPre + OrePrefixes.dust.getDefaultLocalNameForItem(aMaterial); + return mLocalizedMaterialPre + OrePrefixes.dust.getDefaultLocalNameFormatForItem(aMaterial); case crateGtIngot: - return mLocalizedMaterialPre + OrePrefixes.ingot.getDefaultLocalNameForItem(aMaterial); + return mLocalizedMaterialPre + OrePrefixes.ingot.getDefaultLocalNameFormatForItem(aMaterial); case crateGtGem: - return mLocalizedMaterialPre + OrePrefixes.gem.getDefaultLocalNameForItem(aMaterial); + return mLocalizedMaterialPre + OrePrefixes.gem.getDefaultLocalNameFormatForItem(aMaterial); case crateGtPlate: - return mLocalizedMaterialPre + OrePrefixes.plate.getDefaultLocalNameForItem(aMaterial); + return mLocalizedMaterialPre + OrePrefixes.plate.getDefaultLocalNameFormatForItem(aMaterial); } switch (aMaterial.mName) { case "Glass": case "BorosilicateGlass": - if (name().startsWith("gem")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Crystal"; - if (name().startsWith("plate")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Pane"; - if (name().startsWith("ingot")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Bar"; - if (name().startsWith("nugget")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Chip"; + if (name().startsWith("gem")) return mLocalizedMaterialPre + "%material" + " Crystal"; + if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Pane"; + if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material" + " Bar"; + if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; break; case "Wheat": if (name().startsWith("dust")) return mLocalizedMaterialPre + "Flour"; @@ -927,11 +932,11 @@ public enum OrePrefixes { break; case "Wood": case "WoodSealed": - if (name().startsWith("bolt")) return "Short " + aMaterial.mDefaultLocalName + " Stick"; - if (name().startsWith("stick")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Stick"; - if (name().startsWith("dust")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Pulp"; - if (name().startsWith("nugget")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Chip"; - if (name().startsWith("plate")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Plank"; + if (name().startsWith("bolt")) return "Short " + "%material" + " Stick"; + if (name().startsWith("stick")) return mLocalizedMaterialPre + "%material" + " Stick"; + if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Pulp"; + if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; + if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Plank"; break; case "Plastic": case "Rubber": @@ -946,17 +951,17 @@ public enum OrePrefixes { case "PolyvinylChloride": case "Polystyrene": case "StyreneButadieneRubber": - if (name().startsWith("dust")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Pulp"; - if (name().startsWith("plate")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Sheet"; - if (name().startsWith("ingot")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Bar"; - if (name().startsWith("nugget")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Chip"; - if (name().startsWith("foil")) return "Thin " + aMaterial.mDefaultLocalName + " Sheet"; + if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Pulp"; + if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Sheet"; + if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material" + " Bar"; + if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; + if (name().startsWith("foil")) return "Thin " + "%material" + " Sheet"; break; case "FierySteel": if (mIsContainer) return mLocalizedMaterialPre + "Fiery Blood" + mLocalizedMaterialPost; break; case "Steeleaf": - if (name().startsWith("ingot")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName; + if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material"; break; case "Bone": if (name().startsWith("dust")) return mLocalizedMaterialPre + "Bone Meal"; @@ -969,7 +974,7 @@ public enum OrePrefixes { case "Chili": case "Cheese": case "Snow": - if (name().startsWith("dust")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Powder"; + if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Powder"; break; case "Paper": if (name().startsWith("dust")) return mLocalizedMaterialPre + "Chad"; @@ -996,7 +1001,7 @@ public enum OrePrefixes { case "RockSalt": case "VolcanicAsh": case "RareEarth": - if (name().startsWith("dust")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName; + if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material"; break; case "Vermiculite": case "Bentonite": @@ -1010,13 +1015,13 @@ public enum OrePrefixes { case "QuartzSand": case "Pitchblende": case "FullersEarth": - if (name().startsWith("dust")) return mLocalizedMaterialPre + aMaterial.mDefaultLocalName; + if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material"; switch (this) { case crushedCentrifuged: case crushedPurified: - return mLocalizedMaterialPre + aMaterial.mDefaultLocalName; + return mLocalizedMaterialPre + "%material"; case crushed: - return "Ground " + aMaterial.mDefaultLocalName; + return "Ground " + "%material"; } break; } @@ -1030,22 +1035,22 @@ public enum OrePrefixes { case "InfusedOrder": case "InfusedVis": case "InfusedWater": - if (name().startsWith("gem")) return mLocalizedMaterialPre + "Shard of " + aMaterial.mDefaultLocalName; - if (name().startsWith("crystal")) return mLocalizedMaterialPre + "Shard of " + aMaterial.mDefaultLocalName; + if (name().startsWith("gem")) return mLocalizedMaterialPre + "Shard of " + "%material"; + if (name().startsWith("crystal")) return mLocalizedMaterialPre + "Shard of " + "%material"; if (name().startsWith("plate")) - return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Crystal Plate"; + return mLocalizedMaterialPre + "%material" + " Crystal Plate"; if (name().startsWith("dust")) - return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Crystal Powder"; + return mLocalizedMaterialPre + "%material" + " Crystal Powder"; switch (this) { case crushedCentrifuged: case crushedPurified: case crushed: - return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + " Crystals"; + return mLocalizedMaterialPre + "%material" + " Crystals"; } break; } } // Use Standard Localization - return mLocalizedMaterialPre + aMaterial.mDefaultLocalName + mLocalizedMaterialPost; + return mLocalizedMaterialPre + "%material" + mLocalizedMaterialPost; } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java index 5a94d3b4..980967e5 100644 --- a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java @@ -5,6 +5,7 @@ import ic2.core.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import java.util.List; @@ -50,7 +51,21 @@ public class GT_CoolantCell_Item public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { super.addAdditionalToolTips(aList, aStack, aPlayer); - aList.add("Stored Heat: " + getHeatOfStack(aStack)); + int rHeat = getHeatOfStack(aStack) * 10 / this.heatStorage; + EnumChatFormatting color; + switch (rHeat) { + case 0: color = EnumChatFormatting.BLUE; break; + case 1: + case 2: color = EnumChatFormatting.GREEN; break; + case 3: + case 4: + case 5: + case 6: color = EnumChatFormatting.YELLOW; break; + case 7: + case 8: color = EnumChatFormatting.RED; break; + default: color = EnumChatFormatting.DARK_RED; break; + } + aList.add(EnumChatFormatting.WHITE + String.format(trans("000", "Stored Heat: %s"), "" + color + getHeatOfStack(aStack))); switch (getControlTagOfStack(aStack)) { case 1: aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line1")); diff --git a/src/main/java/gregtech/api/items/GT_Generic_Item.java b/src/main/java/gregtech/api/items/GT_Generic_Item.java index 42827018..73102711 100644 --- a/src/main/java/gregtech/api/items/GT_Generic_Item.java +++ b/src/main/java/gregtech/api/items/GT_Generic_Item.java @@ -155,4 +155,8 @@ public class GT_Generic_Item extends Item implements IProjectileItem { return null; } } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Item_DESCRIPTION_Index_"+aKey, aEnglish, false); + } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java index 74e50e86..fea16a90 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java @@ -54,7 +54,7 @@ public abstract class GT_MetaGenerated_Item_X01 extends GT_MetaGenerated_Item { if (tMaterial == null) continue; if (mPrefix.doGenerateItem(tMaterial)) { ItemStack tStack = new ItemStack(this, 1, i); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalization(tPrefix, tMaterial, i)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalizationFormat(tPrefix, tMaterial, i)); GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(tPrefix.mMaterialAmount / M)); String tOreName = getOreDictString(tPrefix, tMaterial); tPrefix = OrePrefixes.getOrePrefix(tOreName); @@ -75,10 +75,21 @@ public abstract class GT_MetaGenerated_Item_X01 extends GT_MetaGenerated_Item { * @param aMetaData a Index from [0 - 31999] * @return the Localized Name when default LangFiles are used. */ + @Deprecated public String getDefaultLocalization(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { return aPrefix.getDefaultLocalNameForItem(aMaterial); } + /** + * @param aPrefix the OreDict Prefix + * @param aMaterial the Material + * @param aMetaData a Index from [0 - 31999] + * @return the Localized Name Format when default LangFiles are used. + */ + public String getDefaultLocalizationFormat(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { + return aPrefix.getDefaultLocalNameFormatForItem(aMaterial); + } + /** * @param aPrefix always != null * @param aMaterial always != null @@ -102,6 +113,15 @@ public abstract class GT_MetaGenerated_Item_X01 extends GT_MetaGenerated_Item { /* ---------- INTERNAL OVERRIDES ---------- */ + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + int aDamage = aStack.getItemDamage(); + if (aDamage < 32000 && aDamage >= 0) + return Materials.getLocalizedNameForItem(aName, aDamage % 1000); + return aName; + } + @Override public ItemStack getContainerItem(ItemStack aStack) { int aMetaData = aStack.getItemDamage(); diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index cadbe685..6ffce3a5 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -52,7 +52,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { if (tMaterial == null) continue; if (doesMaterialAllowGeneration(tPrefix, tMaterial)) { ItemStack tStack = new ItemStack(this, 1, i); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalization(tPrefix, tMaterial, i)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalizationFormat(tPrefix, tMaterial, i)); GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(tPrefix.mMaterialAmount / M)); if (tPrefix.mIsUnificatable) { GT_OreDictUnificator.set(tPrefix, tMaterial, tStack); @@ -96,10 +96,21 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { * @param aMetaData a Index from [0 - 31999] * @return the Localized Name when default LangFiles are used. */ + @Deprecated public String getDefaultLocalization(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { return aPrefix.getDefaultLocalNameForItem(aMaterial); } + /** + * @param aPrefix the OreDict Prefix + * @param aMaterial the Material + * @param aMetaData a Index from [0 - 31999] + * @return the Localized Name Format when default LangFiles are used. + */ + public String getDefaultLocalizationFormat(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { + return aPrefix.getDefaultLocalNameFormatForItem(aMaterial); + } + /** * @param aMetaData a Index from [0 - 31999] * @param aMaterial the Material @@ -121,6 +132,15 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { /* ---------- INTERNAL OVERRIDES ---------- */ + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + int aDamage = aStack.getItemDamage(); + if (aDamage < 32000 && aDamage >= 0) + return Materials.getLocalizedNameForItem(aName, aDamage % 1000); + return aName; + } + @Override public ItemStack getContainerItem(ItemStack aStack) { int aDamage = aStack.getItemDamage(); diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 9ce0e913..da1c68a8 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -346,18 +346,18 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements if (tStats != null) { String name = aStack.getUnlocalizedName(); if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficiency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY + "EU/t"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 2000) + EnumChatFormatting.GRAY + "EU/t"); + aList.add(tOffset + 0, EnumChatFormatting.WHITE + String.format(trans("001", "Durability: %s/%s"), "" + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " ", " " + tMaxDamage) + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + String.format(trans("002", "%s lvl %s"), tMaterial.mLocalizedName + EnumChatFormatting.YELLOW, "" + getHarvestLevel(aStack, "")) + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + String.format(trans("005", "Turbine Efficiency: %s"), "" + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack)))) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("006", "Optimal Steam flow: %sL/sec"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY)); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("007", "Optimal Gas flow(EU burnvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY)); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("008", "Optimal Plasma flow(Plasma energyvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 2000) + EnumChatFormatting.GRAY)); } else { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + EnumChatFormatting.GRAY); + aList.add(tOffset + 0, EnumChatFormatting.WHITE + String.format(trans("001", "Durability: %s/%s"), "" + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " ", " " + tMaxDamage) + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + String.format(trans("002", "%s lvl %s"), tMaterial.mLocalizedName + EnumChatFormatting.YELLOW, "" + getHarvestLevel(aStack, "")) + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + String.format(trans("003", "Attack Damage: %s"), "" + EnumChatFormatting.BLUE + getToolCombatDamage(aStack)) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("004", "Mining Speed: %s"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed)) + EnumChatFormatting.GRAY); NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("GT.ToolStats"); diff --git a/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java b/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java index 082dab75..bf6ca2ae 100644 --- a/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java @@ -5,9 +5,12 @@ import ic2.core.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import java.util.List; +import gregtech.common.items.GT_DepletetCell_Item; + public class GT_RadioactiveCell_Item extends GT_Generic_Item implements IBoxable{ protected int cellCount; @@ -139,7 +142,18 @@ public class GT_RadioactiveCell_Item public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { super.addAdditionalToolTips(aList, aStack, aPlayer); //aList.add("Time left: " + (this.maxDelay - getDurabilityOfStack(aStack)) + " secs"); - aList.add("Durability: " + (this.maxDmg - getDurabilityOfStack(aStack)) + "/" + this.maxDmg); + int rDmg = getDurabilityOfStack(aStack) * 6 / this.maxDmg; + EnumChatFormatting color2; + switch (rDmg) { + case 0: + case 1: color2 = EnumChatFormatting.WHITE; break; + case 2: + case 3: + case 4: color2 = EnumChatFormatting.GRAY; break; + default: color2 = EnumChatFormatting.DARK_GRAY; break; + } + EnumChatFormatting color1 = this instanceof GT_DepletetCell_Item ? color2 = EnumChatFormatting.DARK_GRAY : EnumChatFormatting.WHITE; + aList.add(color1 + String.format(trans("001", "Durability: %s/%s"), "" + color2 + (this.maxDmg - getDurabilityOfStack(aStack)) + color1, "" + this.maxDmg)); } @Override diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index 59a24ef4..622c04a0 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -317,7 +317,16 @@ public class GT_LanguageManager { // addStringLocalization("Interaction_DESCRIPTION_Index_209", "Grab"); // addStringLocalization("Interaction_DESCRIPTION_Index_210", "Grab"); addStringLocalization("Interaction_DESCRIPTION_Index_211", "Items per side: "); - + + addStringLocalization("Item_DESCRIPTION_Index_000", "Stored Heat: %s"); + addStringLocalization("Item_DESCRIPTION_Index_001", "Durability: %s/%s"); + addStringLocalization("Item_DESCRIPTION_Index_002", "%s lvl %s"); + addStringLocalization("Item_DESCRIPTION_Index_003", "Attack Damage: %s"); + addStringLocalization("Item_DESCRIPTION_Index_004", "Mining Speed: %s"); + addStringLocalization("Item_DESCRIPTION_Index_005", "Turbine Efficiency: %s"); + addStringLocalization("Item_DESCRIPTION_Index_006", "Optimal Steam flow: %sL/sec"); + addStringLocalization("Item_DESCRIPTION_Index_007", "Optimal Gas flow(EU burnvalue per tick): %sEU/t"); + addStringLocalization("Item_DESCRIPTION_Index_008", "Optimal Plasma flow(Plasma energyvalue per tick): %sEU/t"); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java index 2f54c9c4..ca27928b 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java @@ -25,7 +25,7 @@ public class GT_Block_Metal extends GT_Block_Storage { for (int i = 0; i < aMats.length; i++) { if (aMats[i].mMetaItemSubID > 0 && aMats[i].mHasParentMod) { - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", "Block of " + aMats[i].mDefaultLocalName); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", "Block of %material"); GT_OreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java index 5595fa86..f46fcc6c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java @@ -57,8 +57,8 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements if (GregTech_API.sGeneratedMaterials[i] != null) { for (int j = 0; j < aOreMetaCount; j++) { if (!this.getEnabledMetas()[j]) continue; - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + (j * 1000)) + aTextName, getLocalizedName(GregTech_API.sGeneratedMaterials[i])); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + aTextName, aTextSmall + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + (j * 1000)) + aTextName, getLocalizedNameFormat(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + aTextName, aTextSmall + getLocalizedNameFormat(GregTech_API.sGeneratedMaterials[i])); if ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x8) != 0 && !aBlockedOres.contains(GregTech_API.sGeneratedMaterials[i])) { GT_OreDictUnificator.registerOre(this.getProcessingPrefix()[j] != null ? this.getProcessingPrefix()[j].get(GregTech_API.sGeneratedMaterials[i]) : "", new ItemStack(this, 1, i + (j * 1000))); if (tHideOres) { @@ -99,33 +99,38 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements FUCKING_LOCK = false; } + public String getLocalizedNameFormat(Materials aMaterial) { + switch (aMaterial.mName) { + case "InfusedAir": + case "InfusedDull": + case "InfusedEarth": + case "InfusedEntropy": + case "InfusedFire": + case "InfusedOrder": + case "InfusedVis": + case "InfusedWater": + return "%material 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 "%material"; + default: + return "%material" + OrePrefixes.ore.mLocalizedMaterialPost; + } + } + + @Deprecated public String getLocalizedName(Materials aMaterial) { - switch (aMaterial.mName) { - 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; - } + return aMaterial.getLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); } 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_) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java index 399c5d6b..6cb56f5d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -1,6 +1,7 @@ package gregtech.common.blocks; import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; @@ -24,6 +25,10 @@ public class GT_Item_Ores return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); } + public String getItemStackDisplayName(ItemStack aStack) { + return Materials.getLocalizedNameForItem(super.getItemStackDisplayName(aStack), aStack.getItemDamage() % 1000); + } + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { short tDamage = (short) getDamage(aStack); if (tDamage > 0) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java index 6dccff42..bde4f708 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java @@ -1,6 +1,7 @@ package gregtech.common.blocks; import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; @@ -20,6 +21,19 @@ public class GT_Item_Storage extends ItemBlock { return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); } + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (this.field_150939_a instanceof GT_Block_Metal) { + int aDamage = aStack.getItemDamage(); + if (aDamage >= 0 && aDamage < ((GT_Block_Metal) this.field_150939_a).mMats.length){ + Materials aMaterial = ((GT_Block_Metal) this.field_150939_a).mMats[aDamage]; + if (aMaterial != null) + return aMaterial.getLocalizedNameForItem(aName); + } + } + return aName; + } + public int getMetadata(int aMeta) { return aMeta; } From ecacfddd694eea5f5056ed78ec541553bd9f1c10 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 19 Oct 2017 16:47:28 +0800 Subject: [PATCH 17/22] l10n improve 2 --- .../gregtech/api/items/GT_MetaBase_Item.java | 10 +-- .../api/items/GT_MetaGenerated_Item_X01.java | 2 +- .../api/items/GT_MetaGenerated_Item_X32.java | 2 +- .../api/items/GT_MetaGenerated_Tool.java | 4 +- .../gregtech/api/util/GT_LanguageManager.java | 10 +++ .../common/blocks/GT_Item_Machines.java | 26 ++++++++ .../gregtech/common/blocks/GT_Item_Ores.java | 2 +- .../common/blocks/GT_Item_Storage.java | 2 +- .../common/items/GT_FluidDisplayItem.java | 6 +- .../common/items/GT_SensorCard_Item.java | 4 +- .../preload/GT_Loader_MetaTileEntities.java | 65 ++++++++++++------- 11 files changed, 94 insertions(+), 39 deletions(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 237b15fa..c4203c77 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -198,13 +198,13 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci tStats = getElectricStats(aStack); if (tStats != null) { if (tStats[3] > 0) { - aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.AQUA + String.format(trans("009", "Contains %s EU Tier: %s"), GT_Utility.formatNumbers(tStats[3]), "" + (tStats[2] >= 0 ? tStats[2] : 0)) + EnumChatFormatting.GRAY); } else { long tCharge = getRealCharge(aStack); if (tStats[3] == -2 && tCharge <= 0) { - aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.AQUA + trans("010", "Empty. You should recycle it properly.") + EnumChatFormatting.GRAY); } else { - aList.add(String.valueOf(EnumChatFormatting.AQUA) + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); + aList.add(String.valueOf(EnumChatFormatting.AQUA) + String.format(trans("011", "%s / %s EU - Voltage: %s"), GT_Utility.formatNumbers(tCharge), GT_Utility.formatNumbers(Math.abs(tStats[0])), "" + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)]) + EnumChatFormatting.GRAY); } } } @@ -212,8 +212,8 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci tStats = getFluidContainerStats(aStack); if (tStats != null && tStats[0] > 0) { FluidStack tFluid = getFluidContent(aStack); - aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? "No Fluids Contained" : GT_Utility.getFluidName(tFluid, true))) + EnumChatFormatting.GRAY); - aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? 0 : tFluid.amount) + "L / " + tStats[0] + "L") + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? trans("012", "No Fluids Contained") : GT_Utility.getFluidName(tFluid, true))) + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.BLUE + String.format(trans("013", "%sL / %sL"), "" + (tFluid == null ? 0 : tFluid.amount), "" + tStats[0]) + EnumChatFormatting.GRAY); } ArrayList> tList = mItemBehaviors.get((short) getDamage(aStack)); diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java index fea16a90..a97613f5 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java @@ -116,7 +116,7 @@ public abstract class GT_MetaGenerated_Item_X01 extends GT_MetaGenerated_Item { @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); - int aDamage = aStack.getItemDamage(); + int aDamage = getDamage(aStack); if (aDamage < 32000 && aDamage >= 0) return Materials.getLocalizedNameForItem(aName, aDamage % 1000); return aName; diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index 6ffce3a5..515735f8 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -135,7 +135,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); - int aDamage = aStack.getItemDamage(); + int aDamage = getDamage(aStack); if (aDamage < 32000 && aDamage >= 0) return Materials.getLocalizedNameForItem(aName, aDamage % 1000); return aName; diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index da1c68a8..d8b09765 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -350,8 +350,8 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements aList.add(tOffset + 1, EnumChatFormatting.WHITE + String.format(trans("002", "%s lvl %s"), tMaterial.mLocalizedName + EnumChatFormatting.YELLOW, "" + getHarvestLevel(aStack, "")) + EnumChatFormatting.GRAY); aList.add(tOffset + 2, EnumChatFormatting.WHITE + String.format(trans("005", "Turbine Efficiency: %s"), "" + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack)))) + EnumChatFormatting.GRAY); aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("006", "Optimal Steam flow: %sL/sec"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY)); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("007", "Optimal Gas flow(EU burnvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY)); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + String.format(trans("008", "Optimal Plasma flow(Plasma energyvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 2000) + EnumChatFormatting.GRAY)); + aList.add(tOffset + 4, EnumChatFormatting.WHITE + String.format(trans("007", "Optimal Gas flow(EU burnvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY)); + aList.add(tOffset + 5, EnumChatFormatting.WHITE + String.format(trans("008", "Optimal Plasma flow(Plasma energyvalue per tick): %sEU/t"), "" + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 2000) + EnumChatFormatting.GRAY)); } else { aList.add(tOffset + 0, EnumChatFormatting.WHITE + String.format(trans("001", "Durability: %s/%s"), "" + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " ", " " + tMaxDamage) + EnumChatFormatting.GRAY); diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index 622c04a0..18c94320 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -327,6 +327,16 @@ public class GT_LanguageManager { addStringLocalization("Item_DESCRIPTION_Index_006", "Optimal Steam flow: %sL/sec"); addStringLocalization("Item_DESCRIPTION_Index_007", "Optimal Gas flow(EU burnvalue per tick): %sEU/t"); addStringLocalization("Item_DESCRIPTION_Index_008", "Optimal Plasma flow(Plasma energyvalue per tick): %sEU/t"); + addStringLocalization("Item_DESCRIPTION_Index_009", "Contains %s EU Tier: %s"); + addStringLocalization("Item_DESCRIPTION_Index_010", "Empty. You should recycle it properly."); + addStringLocalization("Item_DESCRIPTION_Index_011", "%s / %s EU - Voltage: %s"); + addStringLocalization("Item_DESCRIPTION_Index_012", "No Fluids Contained"); + addStringLocalization("Item_DESCRIPTION_Index_013", "%sL / %sL"); + addStringLocalization("Item_DESCRIPTION_Index_014", "Missing Coodinates!"); + addStringLocalization("Item_DESCRIPTION_Index_015", "Device at:"); + addStringLocalization("Item_DESCRIPTION_Index_016", "Amount: %s L"); + addStringLocalization("Item_DESCRIPTION_Index_017", "Temperature: %s K"); + addStringLocalization("Item_DESCRIPTION_Index_018", "State: %s"); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index aa545064..a6a36cf7 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -2,7 +2,12 @@ package gregtech.common.blocks; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Item; import gregtech.api.util.GT_ItsNotMyFaultException; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; @@ -100,6 +105,27 @@ public class GT_Item_Machines return ""; } + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + short tDamage = (short) getDamage(aStack); + if (tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length && GregTech_API.METATILEENTITIES[tDamage] != null) { + Materials aMaterial = null; + if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaPipeEntity_Fluid) { + aMaterial = ((GT_MetaPipeEntity_Fluid) GregTech_API.METATILEENTITIES[tDamage]).mMaterial; + } else if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaPipeEntity_Cable) { + aMaterial = ((GT_MetaPipeEntity_Cable) GregTech_API.METATILEENTITIES[tDamage]).mMaterial; + } else if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaPipeEntity_Item) { + aMaterial = ((GT_MetaPipeEntity_Item) GregTech_API.METATILEENTITIES[tDamage]).mMaterial; + } else if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaPipeEntity_Frame) { + aMaterial = ((GT_MetaPipeEntity_Frame) GregTech_API.METATILEENTITIES[tDamage]).mMaterial; + } + if (aMaterial != null) { + return aMaterial.getLocalizedNameForItem(aName); + } + } + return aName; + } + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { super.onCreated(aStack, aWorld, aPlayer); short tDamage = (short) getDamage(aStack); diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java index 6cb56f5d..dd54ad1b 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -26,7 +26,7 @@ public class GT_Item_Ores } public String getItemStackDisplayName(ItemStack aStack) { - return Materials.getLocalizedNameForItem(super.getItemStackDisplayName(aStack), aStack.getItemDamage() % 1000); + return Materials.getLocalizedNameForItem(super.getItemStackDisplayName(aStack), getDamage(aStack) % 1000); } public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java index bde4f708..dad59486 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java @@ -24,7 +24,7 @@ public class GT_Item_Storage extends ItemBlock { public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); if (this.field_150939_a instanceof GT_Block_Metal) { - int aDamage = aStack.getItemDamage(); + int aDamage = getDamage(aStack); if (aDamage >= 0 && aDamage < ((GT_Block_Metal) this.field_150939_a).mMats.length){ Materials aMaterial = ((GT_Block_Metal) this.field_150939_a).mMats[aDamage]; if (aMaterial != null) diff --git a/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java b/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java index 2ceeca88..d3dee0ef 100644 --- a/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java +++ b/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java @@ -37,10 +37,10 @@ public class GT_FluidDisplayItem if (aNBT != null) { long tToolTipAmount = aNBT.getLong("mFluidDisplayAmount"); if (tToolTipAmount > 0L) { - aList.add(EnumChatFormatting.BLUE + "Amount: " + tToolTipAmount + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.BLUE + String.format(trans("016", "Amount: %s L"), "" + tToolTipAmount) + EnumChatFormatting.GRAY); } - aList.add(EnumChatFormatting.RED + "Temperature: " + aNBT.getLong("mFluidDisplayHeat") + " K" + EnumChatFormatting.GRAY); - aList.add(EnumChatFormatting.GREEN + "State: " + (aNBT.getBoolean("mFluidState") ? "Gas" : "Liquid") + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.RED + String.format(trans("017", "Temperature: %s K"), "" + aNBT.getLong("mFluidDisplayHeat")) + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.GREEN + String.format(trans("018", "State: %s"), aNBT.getBoolean("mFluidState") ? "Gas" : "Liquid") + EnumChatFormatting.GRAY); } } diff --git a/src/main/java/gregtech/common/items/GT_SensorCard_Item.java b/src/main/java/gregtech/common/items/GT_SensorCard_Item.java index b6202be1..7c38ff30 100644 --- a/src/main/java/gregtech/common/items/GT_SensorCard_Item.java +++ b/src/main/java/gregtech/common/items/GT_SensorCard_Item.java @@ -35,9 +35,9 @@ public class GT_SensorCard_Item if (aStack != null) { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT == null) { - aList.add("Missing Coodinates!"); + aList.add(trans("014", "Missing Coodinates!")); } else { - aList.add("Device at:"); + aList.add(trans("015", "Device at:")); aList.add(String.format("x: %d, y: %d, z: %d", new Object[]{Integer.valueOf(tNBT.getInteger("x")), Integer.valueOf(tNBT.getInteger("y")), Integer.valueOf(tNBT.getInteger("z"))})); } } diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java index fa1d85ae..d3550644 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java @@ -1324,7 +1324,7 @@ public class GT_Loader_MetaTileEntities implements Runnable { long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) { if (((GregTech_API.sGeneratedMaterials[i] != null) && ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x2) != 0)) || (GregTech_API.sGeneratedMaterials[i] == Materials.Wood)) { - new GT_MetaPipeEntity_Frame(4096 + i, "GT_Frame_" + GregTech_API.sGeneratedMaterials[i], GregTech_API.sGeneratedMaterials[i].mDefaultLocalName + " Frame Box", GregTech_API.sGeneratedMaterials[i]); + new GT_MetaPipeEntity_Frame(4096 + i, "GT_Frame_" + GregTech_API.sGeneratedMaterials[i], "%material Frame Box", GregTech_API.sGeneratedMaterials[i]); } } boolean bEC = !GT_Mod.gregtechproxy.mHardcoreCables; @@ -1384,7 +1384,7 @@ public class GT_Loader_MetaTileEntities implements Runnable { GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Wood), new GT_MetaPipeEntity_Fluid(5102, "GT_Pipe_Wood", "Wooden Fluid Pipe", 0.5F, Materials.Wood, 30, 350, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.Wood), new GT_MetaPipeEntity_Fluid(5103, "GT_Pipe_Wood_Large", "Large Wooden Fluid Pipe", 0.75F, Materials.Wood, 60, 350, aBoolConst_0).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(Materials.Copper), new GT_MetaPipeEntity_Fluid(5110, "GT_Pipe_Copper_Tiny", "Tiny Copper Fluid Pipe", 0.25F, Materials.Copper, 10, 1000, true).getStackForm(1L)); + /*GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(Materials.Copper), new GT_MetaPipeEntity_Fluid(5110, "GT_Pipe_Copper_Tiny", "Tiny Copper Fluid Pipe", 0.25F, Materials.Copper, 10, 1000, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(Materials.Copper), new GT_MetaPipeEntity_Fluid(5111, "GT_Pipe_Copper_Small", "Small Copper Fluid Pipe", 0.375F, Materials.Copper, 20, 1000, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Copper), new GT_MetaPipeEntity_Fluid(5112, "GT_Pipe_Copper", "Copper Fluid Pipe", 0.5F, Materials.Copper, 60, 1000, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.Copper), new GT_MetaPipeEntity_Fluid(5113, "GT_Pipe_Copper_Large", "Large Copper Fluid Pipe", 0.75F, Materials.Copper, 120, 1000, true).getStackForm(1L)); @@ -1413,16 +1413,23 @@ public class GT_Loader_MetaTileEntities implements Runnable { GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(Materials.TungstenSteel), new GT_MetaPipeEntity_Fluid(5161, "GT_Pipe_TungstenSteel_Small", "Small Tungstensteel Fluid Pipe", 0.375F, Materials.TungstenSteel, 200, 7500, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.TungstenSteel), new GT_MetaPipeEntity_Fluid(5162, "GT_Pipe_TungstenSteel", "Tungstensteel Fluid Pipe", 0.5F, Materials.TungstenSteel, 600, 7500, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.TungstenSteel), new GT_MetaPipeEntity_Fluid(5163, "GT_Pipe_TungstenSteel_Large", "Large Tungstensteel Fluid Pipe", 0.75F, Materials.TungstenSteel, 1200, 7500, true).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.TungstenSteel), new GT_MetaPipeEntity_Fluid(5164, "GT_Pipe_TungstenSteel_Huge", "Huge Tungstensteel Fluid Pipe", 0.875F, Materials.TungstenSteel, 2400, 7500, true).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.TungstenSteel), new GT_MetaPipeEntity_Fluid(5164, "GT_Pipe_TungstenSteel_Huge", "Huge Tungstensteel Fluid Pipe", 0.875F, Materials.TungstenSteel, 2400, 7500, true).getStackForm(1L));*/ + generateFluidPipes(Materials.Copper, Materials.Copper.mName, 5110, 60, 1000, true); + generateFluidPipes(Materials.Bronze, Materials.Bronze.mName, 5120, 120, 2000, true); + generateFluidPipes(Materials.Steel, Materials.Steel.mName, 5130, 240, 2500, true); + generateFluidPipes(Materials.StainlessSteel, Materials.StainlessSteel.mName, 5140, 360, 3000, true); + generateFluidPipes(Materials.Titanium, Materials.Titanium.mName, 5150, 480, 5000, true); + generateFluidPipes(Materials.TungstenSteel, Materials.TungstenSteel.mName, 5160, 600, 7500, true); GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(Materials.Ultimate), new GT_MetaPipeEntity_Fluid(5165, "GT_Pipe_HighPressure_Small", "Small High Pressure Fluid Pipe", 0.375F, Materials.Redstone, 4800, 1500, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Ultimate), new GT_MetaPipeEntity_Fluid(5166, "GT_Pipe_HighPressure", "High Pressure Fluid Pipe", 0.5F, Materials.Redstone, 7200, 1500, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.Ultimate), new GT_MetaPipeEntity_Fluid(5167, "GT_Pipe_HighPressure_Large", "Large High Pressure Fluid Pipe", 0.75F, Materials.Redstone, 9600, 1500, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Superconductor), new GT_MetaPipeEntity_Fluid(5168, "GT_Pipe_PlasmaContain", "Plasma Containment Pipe", 0.5F, Materials.Glowstone, 240, 100000, true).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5170, "GT_Pipe_Plastic_Tiny", "Tiny Plastic Fluid Pipe", 0.25F, Materials.Plastic, 60, 350, true).getStackForm(1L)); + /*GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5170, "GT_Pipe_Plastic_Tiny", "Tiny Plastic Fluid Pipe", 0.25F, Materials.Plastic, 60, 350, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5171, "GT_Pipe_Plastic_Small", "Small Plastic Fluid Pipe", 0.375F, Materials.Plastic, 120, 350, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5172, "GT_Pipe_Plastic", "Plastic Fluid Pipe", 0.5F, Materials.Plastic, 360, 350, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5173, "GT_Pipe_Plastic_Large", "Large Plastic Fluid Pipe", 0.75F, Materials.Plastic, 720, 350, true).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5174, "GT_Pipe_Plastic_Huge", "Huge Plastic Fluid Pipe", 0.875F, Materials.Plastic, 1440, 350, true).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.Plastic), new GT_MetaPipeEntity_Fluid(5174, "GT_Pipe_Plastic_Huge", "Huge Plastic Fluid Pipe", 0.875F, Materials.Plastic, 1440, 350, true).getStackForm(1L));*/ + generateFluidPipes(Materials.Plastic, Materials.Plastic.mName, "Plastic", 5170, 360, 350, true); generateFluidPipes(Materials.Polytetrafluoroethylene, Materials.Polytetrafluoroethylene.mName, "PTFE", 5175, 480, 600, true); GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.pipeSmall, Materials.TungstenSteel, 1L), ItemList.Electric_Pump_EV.get(1L, new Object[0]), GT_OreDictUnificator.get(OrePrefixes.pipeSmall, Materials.Ultimate, 1L), 300, 96); @@ -1432,7 +1439,7 @@ public class GT_Loader_MetaTileEntities implements Runnable { GT_ModHandler.addCraftingRecipe(GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Superconductor, 1L), bitsd, new Object[]{"WSW", aTextCableHull, "WSW", 'M', OrePrefixes.pipeSmall.get(Materials.Titanium), 'C', OrePrefixes.plate.get(Materials.NeodymiumMagnetic), 'W', OrePrefixes.plate.get(Materials.Plastic), 'S', OrePrefixes.wireGt02.get(Materials.Superconductor)}); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Brass), new GT_MetaPipeEntity_Item(5602, "GT_Pipe_Brass", "Brass Item Pipe", 0.5F, Materials.Brass, 1, 32768, aBoolConst_0).getStackForm(1L)); + /*GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(Materials.Brass), new GT_MetaPipeEntity_Item(5602, "GT_Pipe_Brass", "Brass Item Pipe", 0.5F, Materials.Brass, 1, 32768, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(Materials.Brass), new GT_MetaPipeEntity_Item(5603, "GT_Pipe_Brass_Large", "Large Brass Item Pipe", 0.75F, Materials.Brass, 2, 16384, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.Brass), new GT_MetaPipeEntity_Item(5604, "GT_Pipe_Brass_Huge", "Huge Brass Item Pipe", 0.875F, Materials.Brass, 4, 8192, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeRestrictiveMedium.get(Materials.Brass), new GT_MetaPipeEntity_Item(5607, "GT_Pipe_Restrictive_Brass", "Restrictive Brass Item Pipe", 0.5F, Materials.Brass, 1, 3276800, true).getStackForm(1L)); @@ -1455,12 +1462,16 @@ public class GT_Loader_MetaTileEntities implements Runnable { GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(Materials.Osmium), new GT_MetaPipeEntity_Item(5634, "GT_Pipe_Osmium_Huge", "Huge Osmium Item Pipe", 0.875F, Materials.Osmium, 32, 1024, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeRestrictiveMedium.get(Materials.Osmium), new GT_MetaPipeEntity_Item(5637, "GT_Pipe_Restrictive_Osmium", "Restrictive Osmium Item Pipe", 0.5F, Materials.Osmium, 8, 409600, true).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeRestrictiveLarge.get(Materials.Osmium), new GT_MetaPipeEntity_Item(5638, "GT_Pipe_Restrictive_Osmium_Large", "Large Restrictive Osmium Item Pipe", 0.75F, Materials.Osmium, 16, 204800, true).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.pipeRestrictiveHuge.get(Materials.Osmium), new GT_MetaPipeEntity_Item(5639, "GT_Pipe_Restrictive_Osmium_Huge", "Huge Restrictive Osmium Item Pipe", 0.875F, Materials.Osmium, 32, 102400, true).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeRestrictiveHuge.get(Materials.Osmium), new GT_MetaPipeEntity_Item(5639, "GT_Pipe_Restrictive_Osmium_Huge", "Huge Restrictive Osmium Item Pipe", 0.875F, Materials.Osmium, 32, 102400, true).getStackForm(1L));*/ + generateItemPipes(Materials.Brass, Materials.Brass.mName, 5602, 1); + generateItemPipes(Materials.Electrum, Materials.Electrum.mName, 5612, 2); + generateItemPipes(Materials.Platinum, Materials.Platinum.mName, 5622, 4); + generateItemPipes(Materials.Osmium, Materials.Osmium.mName, 5632, 8); generateItemPipes(Materials.PolyvinylChloride, Materials.PolyvinylChloride.mName, "PVC", 5640, 4); - generateItemPipes(Materials.WroughtIron, Materials.WroughtIron.mName, "Wrought Iron", 5646, 1); - generateItemPipes(Materials.Nickel, Materials.Nickel.mName, "Nickel", 5652, 1); - generateItemPipes(Materials.Cobalt, Materials.Cobalt.mName, "Cobalt", 5658, 2); - generateItemPipes(Materials.Aluminium, Materials.Aluminium.mName, "Aluminium", 5664, 2); + generateItemPipes(Materials.WroughtIron, Materials.WroughtIron.mName, 5646, 1); + generateItemPipes(Materials.Nickel, Materials.Nickel.mName, 5652, 1); + generateItemPipes(Materials.Cobalt, Materials.Cobalt.mName, 5658, 2); + generateItemPipes(Materials.Aluminium, Materials.Aluminium.mName, 5664, 2); ItemList.Automation_ChestBuffer_ULV.set(new GT_MetaTileEntity_ChestBuffer(9230, "automation.chestbuffer.tier.00", "Ultra Low Voltage Chest Buffer", 0).getStackForm(1L)); @@ -1608,19 +1619,19 @@ public class GT_Loader_MetaTileEntities implements Runnable { } private static void makeWires(Materials aMaterial, int aStartID, long aLossInsulated, long aLoss, long aAmperage, long aVoltage, boolean aInsulatable, boolean aAutoInsulated) { - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt01, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 0, aTextWire1 + aMaterial.mName.toLowerCase() + ".01", "1x " + aMaterial.mDefaultLocalName + aTextWire2, 0.125F, aMaterial, aLoss, 1L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt02, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 1, aTextWire1 + aMaterial.mName.toLowerCase() + ".02", "2x " + aMaterial.mDefaultLocalName + aTextWire2, 0.25F, aMaterial, aLoss, 2L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt04, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 2, aTextWire1 + aMaterial.mName.toLowerCase() + ".04", "4x " + aMaterial.mDefaultLocalName + aTextWire2, 0.375F, aMaterial, aLoss, 4L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt08, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 3, aTextWire1 + aMaterial.mName.toLowerCase() + ".08", "8x " + aMaterial.mDefaultLocalName + aTextWire2, 0.5F, aMaterial, aLoss, 8L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt12, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 4, aTextWire1 + aMaterial.mName.toLowerCase() + ".12", "12x " + aMaterial.mDefaultLocalName + aTextWire2, 0.625F, aMaterial, aLoss, 12L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.wireGt16, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 5, aTextWire1 + aMaterial.mName.toLowerCase() + ".16", "16x " + aMaterial.mDefaultLocalName + aTextWire2, 0.75F, aMaterial, aLoss, 16L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt01, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 0, aTextWire1 + aMaterial.mName.toLowerCase() + ".01", "1x %material" + aTextWire2, 0.125F, aMaterial, aLoss, 1L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt02, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 1, aTextWire1 + aMaterial.mName.toLowerCase() + ".02", "2x %material" + aTextWire2, 0.25F, aMaterial, aLoss, 2L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt04, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 2, aTextWire1 + aMaterial.mName.toLowerCase() + ".04", "4x %material" + aTextWire2, 0.375F, aMaterial, aLoss, 4L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt08, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 3, aTextWire1 + aMaterial.mName.toLowerCase() + ".08", "8x %material" + aTextWire2, 0.5F, aMaterial, aLoss, 8L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt12, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 4, aTextWire1 + aMaterial.mName.toLowerCase() + ".12", "12x %material" + aTextWire2, 0.625F, aMaterial, aLoss, 12L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt16, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 5, aTextWire1 + aMaterial.mName.toLowerCase() + ".16", "16x %material" + aTextWire2, 0.75F, aMaterial, aLoss, 16L * aAmperage, aVoltage, aBoolConst_0, !aAutoInsulated).getStackForm(1L)); if (aInsulatable) { - GT_OreDictUnificator.registerOre(OrePrefixes.cableGt01, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 6, aTextCable1 + aMaterial.mName.toLowerCase() + ".01", "1x " + aMaterial.mDefaultLocalName + aTextCable2, 0.25F, aMaterial, aLossInsulated, 1L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.cableGt02, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 7, aTextCable1 + aMaterial.mName.toLowerCase() + ".02", "2x " + aMaterial.mDefaultLocalName + aTextCable2, 0.375F, aMaterial, aLossInsulated, 2L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.cableGt04, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 8, aTextCable1 + aMaterial.mName.toLowerCase() + ".04", "4x " + aMaterial.mDefaultLocalName + aTextCable2, 0.5F, aMaterial, aLossInsulated, 4L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.cableGt08, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 9, aTextCable1 + aMaterial.mName.toLowerCase() + ".08", "8x " + aMaterial.mDefaultLocalName + aTextCable2, 0.625F, aMaterial, aLossInsulated, 8L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.cableGt12, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 10, aTextCable1 + aMaterial.mName.toLowerCase() + ".12", "12x " + aMaterial.mDefaultLocalName + aTextCable2, 0.75F, aMaterial, aLossInsulated, 12L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); - //GT_OreDictUnificator.registerOre(OrePrefixes.cableGt16, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 11, aTextCable1 + aMaterial.mName.toLowerCase() + ".16", "16x " + aMaterial.mDefaultLocalName + aTextCable2, 0.875F, aMaterial, aLossInsulated, 16L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt01, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 6, aTextCable1 + aMaterial.mName.toLowerCase() + ".01", "1x %material" + aTextCable2, 0.25F, aMaterial, aLossInsulated, 1L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt02, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 7, aTextCable1 + aMaterial.mName.toLowerCase() + ".02", "2x %material" + aTextCable2, 0.375F, aMaterial, aLossInsulated, 2L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt04, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 8, aTextCable1 + aMaterial.mName.toLowerCase() + ".04", "4x %material" + aTextCable2, 0.5F, aMaterial, aLossInsulated, 4L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt08, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 9, aTextCable1 + aMaterial.mName.toLowerCase() + ".08", "8x %material" + aTextCable2, 0.625F, aMaterial, aLossInsulated, 8L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt12, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 10, aTextCable1 + aMaterial.mName.toLowerCase() + ".12", "12x %material" + aTextCable2, 0.75F, aMaterial, aLossInsulated, 12L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); + //GT_OreDictUnificator.registerOre(OrePrefixes.cableGt16, aMaterial, new GT_MetaPipeEntity_Cable(aStartID + 11, aTextCable1 + aMaterial.mName.toLowerCase() + ".16", "16x %material" + aTextCable2, 0.875F, aMaterial, aLossInsulated, 16L * aAmperage, aVoltage, true, aBoolConst_0).getStackForm(1L)); } } @@ -1632,6 +1643,10 @@ public class GT_Loader_MetaTileEntities implements Runnable { run4(); } + private static void generateItemPipes(Materials aMaterial, String name, int startID, int baseInvSlots){ + generateItemPipes(aMaterial, name, "%material", startID, baseInvSlots); + } + private static void generateItemPipes(Materials aMaterial, String name, String displayName, int startID, int baseInvSlots){ GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(aMaterial), new GT_MetaPipeEntity_Item(startID, "GT_Pipe_" + displayName, displayName + " Item Pipe", 0.50F, aMaterial, baseInvSlots, 32768 / baseInvSlots, aBoolConst_0).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(aMaterial), new GT_MetaPipeEntity_Item(startID + 1, "GT_Pipe_" + displayName + "_Large", "Large " + displayName + " Item Pipe", 0.75F, aMaterial, baseInvSlots * 2, 16384 / baseInvSlots, aBoolConst_0).getStackForm(1L)); @@ -1642,6 +1657,10 @@ public class GT_Loader_MetaTileEntities implements Runnable { } + private static void generateFluidPipes(Materials aMaterial, String name, int startID, int baseCapacity, int heatCapacity, boolean gasProof){ + generateFluidPipes(aMaterial, name, "%material", startID, baseCapacity, heatCapacity, gasProof); + } + private static void generateFluidPipes(Materials aMaterial, String name, String displayName, int startID, int baseCapacity, int heatCapacity, boolean gasProof){ GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(aMaterial), new GT_MetaPipeEntity_Fluid(startID, "GT_Pipe_" + name + "_Tiny", "Tiny " + displayName + " Fluid Pipe", 0.25F, aMaterial, baseCapacity / 6, heatCapacity, gasProof).getStackForm(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(aMaterial), new GT_MetaPipeEntity_Fluid(startID + 1, "GT_Pipe_" + name + "_Small", "Small " + displayName + " Fluid Pipe", 0.375F, aMaterial, baseCapacity / 3, heatCapacity, gasProof).getStackForm(1L)); From b3e0abed70d89c775f31f0449ad50de40b55c6cc Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sat, 21 Oct 2017 00:02:40 +0800 Subject: [PATCH 18/22] Fix overflow when charging ultimate battery --- src/main/java/gregtech/api/items/GT_MetaBase_Item.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 237b15fa..c7430e92 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -256,7 +256,8 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci Long[] tStats = getElectricStats(aStack); if (tStats == null || tStats[2] > aTier || !(tStats[3] == -1 || tStats[3] == -3 || (tStats[3] < 0 && aCharge == Integer.MAX_VALUE)) || aStack.stackSize != 1) return 0; - long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); + long tTransfer = aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge); + long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), Long.MAX_VALUE - tTransfer >= tChargeBefore ? tChargeBefore + tTransfer : Long.MAX_VALUE); if (!aSimulate) setCharge(aStack, tNewCharge); return tNewCharge - tChargeBefore; } From 69fa5a369895677562a84e0e1adffe81a1783732 Mon Sep 17 00:00:00 2001 From: SuperCoder79 Date: Wed, 25 Oct 2017 08:56:26 -0400 Subject: [PATCH 19/22] fix free tin --- .../java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index a715dc44..e06cfdec 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2877,7 +2877,8 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addDefaultPolymerizationRecipes(Materials.Tetrafluoroethylene.mGas, Materials.Tetrafluoroethylene.getCells(1), Materials.Polytetrafluoroethylene.mStandardMoltenFluid); GT_Values.RA.addChemicalRecipe( Materials.Silicon.getDust(1), GT_Utility.getIntegratedCircuit(1), Materials.Chloromethane.getGas(2000), Materials.Dimethyldichlorosilane.getFluid(1000), GT_Values.NI, 240, 96); - GT_Values.RA.addChemicalRecipe( Materials.Silicon.getDust(1), GT_Utility.getIntegratedCircuit(11), Materials.Chloromethane.getGas(2000), GT_Values.NF, Materials.Dimethyldichlorosilane.getCells(1), 240, 96); + //This recipe is redundant: + //GT_Values.RA.addChemicalRecipe( Materials.Silicon.getDust(1), GT_Utility.getIntegratedCircuit(11), Materials.Chloromethane.getGas(2000), GT_Values.NF, Materials.Dimethyldichlorosilane.getCells(1), 240, 96); GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Silicon.getDust(1), Materials.Chloromethane.getCells(2), GT_Values.NF, Materials.Dimethyldichlorosilane.getFluid(1000), Materials.Empty.getCells(2), GT_Values.NI, 240, 96); GT_Values.RA.addChemicalRecipe(Materials.Dimethyldichlorosilane.getCells(1), GT_Utility.getIntegratedCircuit(1), Materials.Water.getFluid(1000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Polydimethylsiloxane.getDust(3), Materials.Empty.getCells(1), 240, 96); From 5300d49dfba70fc1cdc20d710cf1fba7bbab6b46 Mon Sep 17 00:00:00 2001 From: SuperCoder79 Date: Wed, 25 Oct 2017 10:59:54 -0400 Subject: [PATCH 20/22] fix chloroform --- .../java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index e06cfdec..54aebad1 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2858,7 +2858,7 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addChemicalRecipe(Materials.Chlorine.getCells(2), GT_Utility.getIntegratedCircuit(11), Materials.Methane.getGas(1000), Materials.HydrochloricAcid.getFluid(1000), Materials.Chloromethane.getCells(1), Materials.Empty.getCells(1), 80); GT_Values.RA.addChemicalRecipe(Materials.Methane.getCells(1), GT_Utility.getIntegratedCircuit(11), Materials.Chlorine.getGas(2000), Materials.HydrochloricAcid.getFluid(1000), Materials.Chloromethane.getCells(1), 80); - GT_Values.RA.addChemicalRecipe( Materials.Chlorine.getCells(6), GT_Utility.getIntegratedCircuit(3), Materials.Methane.getGas(1000), Materials.Chloroform.getFluid(1000), Materials.HydrochloricAcid.getCells(3), Materials.Empty.getCells(1), 80); + GT_Values.RA.addChemicalRecipe( Materials.Chlorine.getCells(6), GT_Utility.getIntegratedCircuit(3), Materials.Methane.getGas(1000), Materials.Chloroform.getFluid(1000), Materials.HydrochloricAcid.getCells(3), Materials.Empty.getCells(3), 80); GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Methane.getCells(1), Materials.Empty.getCells(2), Materials.Chlorine.getGas(6000), Materials.Chloroform.getFluid(1000), Materials.HydrochloricAcid.getCells(3), GT_Values.NI, 80, 30); GT_Values.RA.addChemicalRecipe( Materials.Chlorine.getCells(6), GT_Utility.getIntegratedCircuit(13), Materials.Methane.getGas(1000), Materials.HydrochloricAcid.getFluid(3000), Materials.Chloroform.getCells(1), Materials.Empty.getCells(5), 80); GT_Values.RA.addChemicalRecipe( Materials.Methane.getCells(1), GT_Utility.getIntegratedCircuit(13), Materials.Chlorine.getGas(6000), Materials.HydrochloricAcid.getFluid(3000), Materials.Chloroform.getCells(1), 80); From 540ddb3e09d47d14c620b2b49dd93c84d9db5c8a Mon Sep 17 00:00:00 2001 From: Dimach Date: Thu, 2 Nov 2017 17:27:30 +0200 Subject: [PATCH 21/22] Fixed bug - miners digs bedrock. --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index c59790d1..5c17d8c7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -135,8 +135,8 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 - || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), 0, aBaseMetaTileEntity.getYCoord() + drillY - 1, 0) < 0 - || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), 0, drillY - 1, 0, MINING_PIPE_TIP_BLOCK, 0, true)) { + || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord() + drillY - 1, aBaseMetaTileEntity.getZCoord()) < 0 + || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord() + drillY - 1, aBaseMetaTileEntity.getZCoord(), MINING_PIPE_TIP_BLOCK, 0, true)) { isPickingPipes = true; return false; } From 3c78346bcf531d9e99032923798d4866dde6cb41 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sun, 5 Nov 2017 16:56:45 +0100 Subject: [PATCH 22/22] prevent circuit conversation/tier jump --- .../java/gregtech/loaders/oreprocessing/ProcessingCircuit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingCircuit.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingCircuit.java index 1108ab61..2a17cfbe 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingCircuit.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingCircuit.java @@ -29,7 +29,7 @@ public class ProcessingCircuit implements gregtech.api.interfaces.IOreRecipeRegi case "Basic": GT_ModHandler.removeRecipeByOutput(aStack); GT_ModHandler.addCraftingRecipe(aStack, new Object[]{"RIR","VBV","CCC",'R',ItemList.Circuit_Parts_Resistor.get(1,new Object[0]),'C',GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.RedAlloy, 1),'V', ItemList.Circuit_Parts_Vacuum_Tube.get(1,new Object[0]),'B',ItemList.Circuit_Board_Coated.get(1,new Object[0]),'I',ItemList.IC2_Item_Casing_Steel.get(1,new Object[0])}); - GT_ModHandler.addShapelessCraftingRecipe(ItemList.Circuit_Basic.get(1L, new Object[0]), new Object[]{ItemList.Circuit_Integrated.getWildcard(1L, new Object[0])}); + GT_ModHandler.addShapelessCraftingRecipe(aStack, new Object[]{ItemList.Circuit_Integrated.getWildcard(1L, new Object[0])}); break; case "Advanced": GT_ModHandler.removeRecipeByOutput(aStack);