From 2cbc0ee9f27bc1d2a21d44d1b4a0c248a315c316 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 10:26:36 +1000 Subject: + Added Wireless Chargers. > These are a basic design-only implementation for reference, so they may never be completed and are more of a proof of concept. --- .../basic/GregtechMetaWirelessCharger.java | 455 +++++++++++++++++++++ 1 file changed, 455 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java new file mode 100644 index 0000000000..7239dc41ac --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -0,0 +1,455 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.core.util.entity.EntityUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { + + public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaWirelessCharger(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "3 Modes, Long-Range, Local and Mixed.", + "Long-Range: Can supply 2A of power to a single player upto "+(this.mTier*4)+"m away.", + "Local: Can supply 1A to each player within 50m.", + "Mixed: Provides both 2A of long range and 1A per player locally.", + "Mixed mode is more conservative of power and as a result only", + "gets half the distances each singular mode gets.", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMode >= 2){ + this.mMode = 0; + } + else { + this.mMode++; + } + if (this.mMode == 0){ + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode."); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Mode."); + } + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaWirelessCharger(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return GT_Values.V[this.mTier]*32;} + + @Override + public int getCapacity() { + return (int) (GT_Values.V[this.mTier]*32); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + if (this.mMode == 0){ + return 2; + } + else if (this.mMode == 1){ + return this.mLocalChargingMap.size(); + } + else { + return (this.mLocalChargingMap.size()+this.mWirelessChargingMap.size()); + } + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + return true; + } + + public int mMode = 0; + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return null; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mMode", this.mMode); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mMode = aNBT.getInteger("mMode"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity().isServerSide()) { + + } + } + + + private Map mWirelessChargingMap = new HashMap(); + private Map mLocalChargingMap = new HashMap(); + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + + + if (aTick % 20 == 0){ + if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + + if (this.mMode == 1 || this.mMode == 2){ + int tempRange = (this.mMode == 1 ? 50 : 25); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + if (mLocalChargingMap.put(mTemp.getPersistentID(), mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + } + } + + } + else { + if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + if (mLocalChargingMap.remove(mTemp.getPersistentID()) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + } + } + } + } + if (this.mMode == 0 || this.mMode == 2){ + int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()) != null){ + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + } + } + + } + else { + if (mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.remove(mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + } + } + } + } + + } + } + } + } + + + } + } + + private BlockPos getTileEntityPosition(){ + return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } + + private BlockPos getPositionOfEntity(Entity mEntity){ + if (mEntity == null){ + return null; + } + return EntityUtils.findBlockPosUnderEntity(mEntity); + } + + private double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ + int[] objectArray1 = new int[]{objectA.xPos, objectA.yPos, objectA.zPos}; + int[] objectArray2 = new int[]{objectB.xPos, objectB.yPos, objectB.zPos}; + if (objectA == null || objectB == null){ + return 0f; + } + final double distance = Math.sqrt( + (objectArray2[0]-objectArray1[0])*(objectArray2[0]-objectArray1[0]) + +(objectArray2[1]-objectArray1[1])*(objectArray2[1]-objectArray1[1]) + +(objectArray2[2]-objectArray1[2])*(objectArray2[2]-objectArray1[2])); + return distance; + } + + @Override + public void onRemoval() { + mWirelessChargingMap.clear(); + super.onRemoval(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + + int tempRange; + + if (this.mMode == 0 || this.mMode == 2){ + tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + } + else { + tempRange = 50; + } + + if (this.mMode == 2){ + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: 25m | Long: "+tempRange); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Local Mode: 50m"); + + } + else { + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); + + } + + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onServerStart() { + mWirelessChargingMap.clear(); + super.onServerStart(); + } + +} \ No newline at end of file -- cgit From a914dfd170c03a97de1181e2f7ad39ab09380cb1 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 10:47:20 +1000 Subject: $ Fixed Tooltips, Mode Changing and Info Messages on the Wireless Charger. $ Fixed bad tier registration with the Wireless Charger. --- .../basic/GregtechMetaWirelessCharger.java | 56 ++++++++++------------ .../gregtech/GregtechWirelessChargers.java | 16 +++---- 2 files changed, 34 insertions(+), 38 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 7239dc41ac..7d71ae9b54 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -37,8 +37,8 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { public String[] getDescription() { return new String[] {this.mDescription, "3 Modes, Long-Range, Local and Mixed.", - "Long-Range: Can supply 2A of power to a single player upto "+(this.mTier*4)+"m away.", - "Local: Can supply 1A to each player within 50m.", + "Long-Range: Can supply 2A of power to a single player upto "+(GT_Values.V[this.mTier]*4)+"m away.", + "Local: Can supply 1A to each player within "+this.mTier*10+"m.", "Mixed: Provides both 2A of long range and 1A per player locally.", "Mixed mode is more conservative of power and as a result only", "gets half the distances each singular mode gets.", @@ -70,52 +70,52 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; } public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; } public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } @Override @@ -343,14 +343,12 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { EntityPlayer mTemp = (EntityPlayer) mTempPlayer; if (this.mMode == 1 || this.mMode == 2){ - int tempRange = (this.mMode == 1 ? 50 : 25); + int tempRange = (this.mMode == 1 ? this.mTier*10 : this.mTier*5); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ - if (mLocalChargingMap.put(mTemp.getPersistentID(), mTemp) != null){ - PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); - } + mLocalChargingMap.put(mTemp.getPersistentID(), mTemp); + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); } - } else { if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ @@ -364,11 +362,9 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mWirelessChargingMap.containsKey(mTemp)){ - if (mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()) != null){ - PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); - } + mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); } - } else { if (mWirelessChargingMap.containsKey(mTemp)){ @@ -421,28 +417,28 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - + int tempRange; - + if (this.mMode == 0 || this.mMode == 2){ tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); } else { - tempRange = 50; + tempRange = this.mMode == 1 ? this.mTier*10 : this.mTier*5; } - + if (this.mMode == 2){ - PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: 25m | Long: "+tempRange); + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*5+"m | Long: "+tempRange+"m"); } else if (this.mMode == 1){ - PlayerUtils.messagePlayer(aPlayer, "Local Mode: 50m"); - + PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*10+"m"); + } else { PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); - + } - + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java index f23dc3ab3d..538112d365 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -18,23 +18,23 @@ public class GregtechWirelessChargers { int mID = 890; GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", - "Wireless Charger MK I", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_MV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.02.tier.single", - "Wireless Charger MK II", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK II", 2, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_HV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.03.tier.single", - "Wireless Charger MK III", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK III", 3, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_EV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.04.tier.single", "Wireless Charger MK IV", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_IV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.05.tier.single", - "Wireless Charger MK V", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK V", 5, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_LuV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.06.tier.single", - "Wireless Charger MK VI", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK VI", 6, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_ZPM.set(new GregtechMetaWirelessCharger(mID++, "wificharger.07.tier.single", - "Wireless Charger MK VII", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK VII", 7, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_UV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.08.tier.single", - "Wireless Charger MK VIII", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK VIII", 8, "Hopefully won't give you cancer.", 0).getStackForm(1L)); GregtechItemList.Charger_MAX.set(new GregtechMetaWirelessCharger(mID++, "wificharger.09.tier.single", - "Wireless Charger MK IX", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + "Wireless Charger MK IX", 9, "Hopefully won't give you cancer.", 0).getStackForm(1L)); } -- cgit From 30cb683d7cf0d7d83e07ecb0d3d7cb3a6ecdbe16 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 11:52:20 +1000 Subject: + Created the base framework for wireless charging. --- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 2 + .../gregtech/common/helpers/ChargingHelper.java | 251 +++++++++++++++++++++ .../basic/GregtechMetaWirelessCharger.java | 45 +++- .../gregtech/GregtechWirelessChargers.java | 6 +- 4 files changed, 297 insertions(+), 7 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 5dfb9ebd2b..b95ab04024 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.util.GT_Config; import gregtech.api.util.MultiblockRecipeMapHandler; @@ -15,6 +16,7 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.*; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java new file mode 100644 index 0000000000..98d7442429 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -0,0 +1,251 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.Side; +import gregtech.api.enums.GT_Values; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class ChargingHelper { + + protected static Map mChargerMap = new HashMap(); + private int mTickTimer = 0; + + public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (!mChargerMap.containsKey(mPos)){ + if (mChargerMap.put(mPos, mEntity) == null){ + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (mChargerMap.containsKey(mPos)){ + if (mChargerMap.remove(mPos, mEntity)){ + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + private static Map> mValidPlayers = new HashMap>(); + + public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ + if (!mValidPlayers.containsKey(mPlayer)){ + Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.put(mPlayer, mEntry) == null){ + Utils.LOG_INFO("Added a Player to the Tick Map."); + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ + if (mValidPlayers.containsKey(mPlayer)){ + Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.remove(mPlayer, mEntry)){ + Utils.LOG_INFO("Removed a Player to the Tick Map."); + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + + //Called whenever the player is updated or ticked. + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if (event.player != null){ + Utils.LOG_INFO("Found Player."); + if (event.side == Side.SERVER){ + Utils.LOG_INFO("Found Server-Side."); + + mTickTimer++; + + if (mTickTimer % 20 == 0){ + + long mVoltage = 0; + long mEuStored = 0; + + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(event.player)){ + + for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ + mVoltage = mEntityTemp.getInputTier(); + mEuStored = mEntityTemp.getEUVar(); + if (mVoltage > 0 && mEuStored >= mVoltage){ + + InventoryPlayer mPlayerInventory = event.player.inventory; + ItemStack[] mArmourContents = mPlayerInventory.armorInventory; + ItemStack[] mInventoryContents = mPlayerInventory.mainInventory; + + Map LR = mEntityTemp.getLongRangeMap(); + Map LO = mEntityTemp.getLocalMap(); + + long mStartingEu = mEntityTemp.getEUVar(); + long mCurrentEu = mEntityTemp.getEUVar(); + long mEuUsed = 0; + if (mEntityTemp.getMode() == 0){ + + if (!LR.isEmpty() && LR.containsKey(event.player)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); + } + } + else if (mEntityTemp.getMode() == 1){ + if (!LO.isEmpty() && LO.containsValue(event.player)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); + } + } + else { + if (!LR.isEmpty() && LR.containsKey(event.player)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); + } + if (!LO.isEmpty() && LO.containsValue(event.player)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); + } + } + + if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0){ + long mMaxDistance; + if (mEntityTemp.getMode() == 0){ + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); + } + else if (mEntityTemp.getMode() == 1){ + mMaxDistance = (mEntityTemp.getTier()*10); + } + else { + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); + } + double mDistance = calculateDistance(mEntityTemp, event); + long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); + + if (mVoltageCost > 0){ + if (mVoltageCost > mEntityTemp.maxEUInput()){ + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); + } + else { + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); + } + } + + } + + } + else { + Utils.LOG_INFO("Voltage: "+mVoltage+" | Eu Storage: "+mEuStored); + } + } + } + } + } + } + } + + public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, TickEvent.PlayerTickEvent event){ + return mEntityTemp.getDistanceBetweenTwoPositions(mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(event.player)); + } + + public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ + if (mEntity == null || mItems == null || mItems.length == 0){ + return mEntity.getEUVar(); + } + int mChargedItems = 0; + final int mTier = mEntity.getTier(); + final long mVoltage = mEntity.getInputTier(); + long mEuStored = mEntity.getEUVar(); + final long mEuStoredOriginal = mEntity.getEUVar(); + for (ItemStack mTemp : mItems){ + if (isItemValid(mTemp)){ + ElectricItem.manager.charge(mTemp, mVoltage, mTier, false, false); + mEntity.setEUVar(mEuStored-mVoltage); + mEuStored = mEntity.getEUVar(); + mChargedItems++; + Utils.LOG_INFO("Charged "+mTemp.getDisplayName()+" by "+mVoltage+" for "+mPlayer.getCommandSenderName()); + } + } + if (mChargedItems < 1){ + return mEuStoredOriginal; + } + return mEntity.getEUVar(); + } + + public boolean isItemValid(final ItemStack itemstack) { + if ((accepts(itemstack)) || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + + //Called when the client ticks. + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + + } + + //Called when the server ticks. Usually 20 ticks a second. + @SubscribeEvent + public void onServerTick(TickEvent.ServerTickEvent event) { + + } + + //Called when a new frame is displayed (See fps) + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + + } + + //Called when the world ticks + @SubscribeEvent + public void onWorldTick(TickEvent.WorldTickEvent event) { + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 7d71ae9b54..9b84916459 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -17,6 +17,7 @@ import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -25,6 +26,8 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { + private boolean mHasBeenMapped = false; + public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); } @@ -44,6 +47,22 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { "gets half the distances each singular mode gets.", CORE.GT_Tooltip}; } + + public int getTier(){ + return this.mTier; + } + + public int getMode(){ + return this.mMode; + } + + public Map getLocalMap(){ + return this.mLocalChargingMap; + } + + public Map getLongRangeMap(){ + return this.mWirelessChargingMap; + } @Override public ITexture[][][] getTextureSet(final ITexture[] aTextures) { @@ -335,8 +354,11 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { super.onPostTick(aBaseMetaTileEntity, aTick); if (this.getBaseMetaTileEntity().isServerSide()) { + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } - if (aTick % 20 == 0){ + if (aTick % 20 == 0 && mHasBeenMapped){ if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ @@ -347,13 +369,15 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ mLocalChargingMap.put(mTemp.getPersistentID(), mTemp); + ChargingHelper.addValidPlayer(mTemp, this); PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); } } else { if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ if (mLocalChargingMap.remove(mTemp.getPersistentID()) != null){ - PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + ChargingHelper.removeValidPlayer(mTemp, this); } } } @@ -364,12 +388,14 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { if (!mWirelessChargingMap.containsKey(mTemp)){ mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + ChargingHelper.addValidPlayer(mTemp, this); } } else { if (mWirelessChargingMap.containsKey(mTemp)){ if (mWirelessChargingMap.remove(mTemp) != null){ - PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + ChargingHelper.removeValidPlayer(mTemp, this); } } } @@ -384,18 +410,18 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } - private BlockPos getTileEntityPosition(){ + public BlockPos getTileEntityPosition(){ return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); } - private BlockPos getPositionOfEntity(Entity mEntity){ + public BlockPos getPositionOfEntity(Entity mEntity){ if (mEntity == null){ return null; } return EntityUtils.findBlockPosUnderEntity(mEntity); } - private double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ + public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ int[] objectArray1 = new int[]{objectA.xPos, objectA.yPos, objectA.zPos}; int[] objectArray2 = new int[]{objectB.xPos, objectB.yPos, objectB.zPos}; if (objectA == null || objectB == null){ @@ -411,6 +437,9 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onRemoval() { mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.onRemoval(); } @@ -445,6 +474,10 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onServerStart() { mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } super.onServerStart(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java index 538112d365..bd5f1abc54 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -1,10 +1,12 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import net.minecraft.item.ItemStack; @@ -15,7 +17,9 @@ public class GregtechWirelessChargers { long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; - int mID = 890; + int mID = 890; + + FMLCommonHandler.instance().bus().register(ChargingHelper.class); GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); -- cgit From 161828da23fa09495fb1c2b16411e30c3c4fed01 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 12:55:51 +1000 Subject: $ Redid the LivingEntityUpdate event, fix it not working as intended. $ Fixed persistent player mappings to null Wireless Chargers. --- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 10 - .../gregtech/common/helpers/ChargingHelper.java | 279 +++++++++++---------- .../basic/GregtechMetaWirelessCharger.java | 33 ++- .../gregtech/GregtechWirelessChargers.java | 8 +- 4 files changed, 180 insertions(+), 150 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index b95ab04024..8251387aff 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -1,27 +1,19 @@ package gtPlusPlus.xmod.gregtech; -import java.io.File; import java.util.ArrayList; import java.util.List; -import cpw.mods.fml.common.FMLCommonHandler; -import gregtech.api.GregTech_API; import gregtech.api.util.GT_Config; -import gregtech.api.util.MultiblockRecipeMapHandler; -import gregtech.api.world.GT_Worldgen; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.recipe.RECIPES_LaserEngraver; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; -import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.*; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; -import net.minecraftforge.common.config.Configuration; public class HANDLER_GT { @@ -30,7 +22,6 @@ public class HANDLER_GT { public static GTPP_Config sCustomWorldgenFile = null; public static final List sCustomWorldgenList = new ArrayList(); - @SuppressWarnings("unused") public static void preInit(){ new MetaGeneratedGregtechItems(); @@ -40,7 +31,6 @@ public class HANDLER_GT { GregtechFluidHandler.run(); } - @SuppressWarnings("unused") public static void init(){ //Load General Blocks and set up some Basic Meta Tile Entitie states diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 98d7442429..5bbe6bcb02 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -4,9 +4,8 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.relauncher.Side; import gregtech.api.enums.GT_Values; import gregtech.api.items.GT_MetaGenerated_Tool; import gtPlusPlus.core.util.Utils; @@ -20,13 +19,119 @@ import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; public class ChargingHelper { + private static Map> mValidPlayers = new HashMap>(); protected static Map mChargerMap = new HashMap(); private int mTickTimer = 0; + //Called whenever the player is updated or ticked. + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTick(LivingUpdateEvent event) { + if (event.entity != null && event.entityLiving != null){ + if (event.entityLiving instanceof EntityPlayer){ + EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; + + + if (mPlayerMan != null){ + //Utils.LOG_INFO("Found Player."); + + if (Utils.isServer()){ + //Utils.LOG_INFO("Found Server-Side."); + + mTickTimer++; + if (mTickTimer % 20 == 0){ + + long mVoltage = 0; + long mEuStored = 0; + + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan)){ + + for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ + if (mEntityTemp != null){ + mVoltage = mEntityTemp.getInputTier(); + mEuStored = mEntityTemp.getEUVar(); + if (mVoltage > 0 && mEuStored >= mVoltage){ + + InventoryPlayer mPlayerInventory = mPlayerMan.inventory; + ItemStack[] mArmourContents = mPlayerInventory.armorInventory; + ItemStack[] mInventoryContents = mPlayerInventory.mainInventory; + + Map LR = mEntityTemp.getLongRangeMap(); + Map LO = mEntityTemp.getLocalMap(); + + long mStartingEu = mEntityTemp.getEUVar(); + long mCurrentEu = mEntityTemp.getEUVar(); + long mEuUsed = 0; + if (mEntityTemp.getMode() == 0){ + + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + else if (mEntityTemp.getMode() == 1){ + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + else { + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + + if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 && mEntityTemp != null){ + long mMaxDistance; + if (mEntityTemp.getMode() == 0){ + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); + } + else if (mEntityTemp.getMode() == 1){ + mMaxDistance = (mEntityTemp.getTier()*10); + } + else { + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); + } + double mDistance = calculateDistance(mEntityTemp, mPlayerMan); + long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); + + if (mVoltageCost > 0){ + if (mVoltageCost > mEntityTemp.maxEUInput()){ + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); + } + else { + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); + } + } + + } + + } + else { + Utils.LOG_INFO("Voltage: "+mVoltage+" | Eu Storage: "+mEuStored); + } + } + } + } + } + } + } + } + } + } + public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } if (!mChargerMap.containsKey(mPos)){ if (mChargerMap.put(mPos, mEntity) == null){ return true; @@ -39,8 +144,11 @@ public class ChargingHelper { return false; } } - + public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } if (mChargerMap.containsKey(mPos)){ if (mChargerMap.remove(mPos, mEntity)){ return true; @@ -54,139 +162,76 @@ public class ChargingHelper { } } - private static Map> mValidPlayers = new HashMap>(); - public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ - if (!mValidPlayers.containsKey(mPlayer)){ + if (mEntity == null){ + return false; + } + Utils.LOG_INFO("trying to map new player"); + if (mValidPlayers.containsKey(mPlayer)){ + Utils.LOG_INFO("Key contains player already?"); + return false; + } + else { + Utils.LOG_INFO("key not found, adding"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.put(mPlayer, mEntry) == null){ Utils.LOG_INFO("Added a Player to the Tick Map."); return true; } else { + Utils.LOG_INFO("Tried to add player but it was already there?"); return false; } } - else { - return false; - } } - + public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } + Utils.LOG_INFO("trying to remove player from map"); if (mValidPlayers.containsKey(mPlayer)){ + Utils.LOG_INFO("key found, removing"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.remove(mPlayer, mEntry)){ Utils.LOG_INFO("Removed a Player to the Tick Map."); return true; } else { + Utils.LOG_INFO("Tried to remove player but it was not there?"); return false; } } else { + Utils.LOG_INFO("Key does not contain player?"); return false; } } - - - //Called whenever the player is updated or ticked. - @SubscribeEvent - public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (event.player != null){ - Utils.LOG_INFO("Found Player."); - if (event.side == Side.SERVER){ - Utils.LOG_INFO("Found Server-Side."); - - mTickTimer++; - - if (mTickTimer % 20 == 0){ - - long mVoltage = 0; - long mEuStored = 0; - - if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(event.player)){ - - for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ - mVoltage = mEntityTemp.getInputTier(); - mEuStored = mEntityTemp.getEUVar(); - if (mVoltage > 0 && mEuStored >= mVoltage){ - - InventoryPlayer mPlayerInventory = event.player.inventory; - ItemStack[] mArmourContents = mPlayerInventory.armorInventory; - ItemStack[] mInventoryContents = mPlayerInventory.mainInventory; - - Map LR = mEntityTemp.getLongRangeMap(); - Map LO = mEntityTemp.getLocalMap(); - - long mStartingEu = mEntityTemp.getEUVar(); - long mCurrentEu = mEntityTemp.getEUVar(); - long mEuUsed = 0; - if (mEntityTemp.getMode() == 0){ - - if (!LR.isEmpty() && LR.containsKey(event.player)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); - } - } - else if (mEntityTemp.getMode() == 1){ - if (!LO.isEmpty() && LO.containsValue(event.player)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); - } - } - else { - if (!LR.isEmpty() && LR.containsKey(event.player)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); - } - if (!LO.isEmpty() && LO.containsValue(event.player)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, event.player); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, event.player); - } - } - - if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0){ - long mMaxDistance; - if (mEntityTemp.getMode() == 0){ - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); - } - else if (mEntityTemp.getMode() == 1){ - mMaxDistance = (mEntityTemp.getTier()*10); - } - else { - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); - } - double mDistance = calculateDistance(mEntityTemp, event); - long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); - - if (mVoltageCost > 0){ - if (mVoltageCost > mEntityTemp.maxEUInput()){ - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); - } - else { - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); - } - } - - } - - } - else { - Utils.LOG_INFO("Voltage: "+mVoltage+" | Eu Storage: "+mEuStored); - } - } - } - } - } + + public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, EntityPlayer mPlayerMan){ + if (mEntityTemp == null || mPlayerMan == null){ + return 0; } + return mEntityTemp.getDistanceBetweenTwoPositions(mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(mPlayerMan)); } - public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, TickEvent.PlayerTickEvent event){ - return mEntityTemp.getDistanceBetweenTwoPositions(mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(event.player)); + public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ + if (mEntity == null){ + return -100; + } + if (mItems == null || mItems.length == 0){ + return mEntity.getEUVar(); + } + long mInitialValue = mEntity.getEUVar(); + long mReturnValue = chargeItemsEx(mEntity, mItems, mPlayer); + return ((mReturnValue < mInitialValue) ? mReturnValue : mInitialValue); } - public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ - if (mEntity == null || mItems == null || mItems.length == 0){ + public long chargeItemsEx(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ + if (mEntity == null){ + return -100; + } + if (mItems == null || mItems.length == 0){ return mEntity.getEUVar(); } int mChargedItems = 0; @@ -224,28 +269,4 @@ public class ChargingHelper { || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); } - //Called when the client ticks. - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - - } - - //Called when the server ticks. Usually 20 ticks a second. - @SubscribeEvent - public void onServerTick(TickEvent.ServerTickEvent event) { - - } - - //Called when a new frame is displayed (See fps) - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent event) { - - } - - //Called when the world ticks - @SubscribeEvent - public void onWorldTick(TickEvent.WorldTickEvent event) { - - } - } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 9b84916459..1ceb4c6a7b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -27,7 +27,7 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { private boolean mHasBeenMapped = false; - + public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); } @@ -47,19 +47,19 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { "gets half the distances each singular mode gets.", CORE.GT_Tooltip}; } - + public int getTier(){ return this.mTier; } - + public int getMode(){ return this.mMode; } - + public Map getLocalMap(){ return this.mLocalChargingMap; } - + public Map getLongRangeMap(){ return this.mWirelessChargingMap; } @@ -139,6 +139,18 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + if (this.mMode >= 2){ this.mMode = 0; } @@ -438,8 +450,17 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { public void onRemoval() { mWirelessChargingMap.clear(); mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + ChargingHelper.removeEntry(getTileEntityPosition(), this); - + super.onRemoval(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java index bd5f1abc54..688b522c2b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -1,14 +1,11 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import cpw.mods.fml.common.FMLCommonHandler; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; -import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; public class GregtechWirelessChargers { @@ -19,7 +16,8 @@ public class GregtechWirelessChargers { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; int mID = 890; - FMLCommonHandler.instance().bus().register(ChargingHelper.class); + FMLCommonHandler.instance().bus().register(new ChargingHelper()); + MinecraftForge.EVENT_BUS.register(new ChargingHelper()); GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); -- cgit From 5144539962acc7d02248ed7075507b850044d877 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 15:50:56 +1000 Subject: + Added in annoying logging. $ Fixed NPE when tickhandler tries to get null Tile entity. % Tweaked Stored Energy and A/in/t for Wireless Charger. --- .../gregtech/common/helpers/ChargingHelper.java | 22 +++++++++++++++++++--- .../basic/GregtechMetaWirelessCharger.java | 6 +++--- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index f4e53bc5dc..41ae1a911b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -37,6 +37,7 @@ public class ChargingHelper { //Called whenever the player is updated or ticked. @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerTick(LivingUpdateEvent event) { + try { if (event.entity != null && event.entityLiving != null){ if (event.entityLiving instanceof EntityPlayer){ EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; @@ -133,6 +134,10 @@ public class ChargingHelper { } } } + } + catch (Throwable t){ + Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + } } public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ @@ -256,14 +261,18 @@ public class ChargingHelper { for (ItemStack mTemp : mItems){ mItemSlot++; - Utils.LOG_INFO("Trying to Tick slot "+mItemSlot); + if (mTemp != null){ + Utils.LOG_INFO("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); + } //Is item Electrical if (isItemValid(mTemp)){ + Utils.LOG_INFO("1"); //Transfer Limit double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); //Check if Tile has more or equal EU to what can be transferred into the item. if (mEuStored >= mItemEuTLimit){ + Utils.LOG_INFO("2"); double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); @@ -273,7 +282,8 @@ public class ChargingHelper { } //Try get charge direct from NBT for GT and IC2 stacks - try { + try { + Utils.LOG_INFO("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 @@ -310,6 +320,8 @@ public class ChargingHelper { else { mVoltageIncrease = mItemEuTLimit; } + + Utils.LOG_INFO("4"); int mMulti; if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ @@ -324,12 +336,15 @@ public class ChargingHelper { else { mMulti = 1; } + Utils.LOG_INFO("5"); int mMultiVoltage = (int) (mMulti*mVoltageIncrease); if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ + Utils.LOG_INFO("6"); if (GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, mTier, true, false) == 0){ + Utils.LOG_INFO("6.5"); for (int i=0; i mitemCurrentCharge){ + Utils.LOG_INFO("7"); mEntity.setEUVar((long) (mEuStored-(mVoltage*mMulti))); mEuStored = mEntity.getEUVar(); Utils.LOG_INFO("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); @@ -349,7 +365,7 @@ public class ChargingHelper { } else { if (mTemp != null){ - Utils.LOG_INFO("Found Non-Valid item."+mTemp.getDisplayName()); + Utils.LOG_INFO("Found Non-Valid item. "+mTemp.getDisplayName()); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 1ceb4c6a7b..f0b2958c17 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -184,7 +184,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} @Override public boolean isTeleporterCompatible() {return false;} @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return GT_Values.V[this.mTier]*32;} + @Override public long maxEUStore() {return GT_Values.V[this.mTier]*128;} @Override public int getCapacity() { @@ -207,10 +207,10 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { return 2; } else if (this.mMode == 1){ - return this.mLocalChargingMap.size(); + return this.mLocalChargingMap.size()*8; } else { - return (this.mLocalChargingMap.size()+this.mWirelessChargingMap.size()); + return ((this.mLocalChargingMap.size()*4)+this.mWirelessChargingMap.size()); } } -- cgit From e76e27e165640bda7363f5c6996ff1a7655bc535 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 16:29:01 +1000 Subject: $ First fix towards invalid tile entity mapping. --- .../gregtech/common/helpers/ChargingHelper.java | 151 +++++++++++---------- .../basic/GregtechMetaWirelessCharger.java | 16 ++- 2 files changed, 93 insertions(+), 74 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 41ae1a911b..4a59a621f7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -7,13 +7,10 @@ import java.util.UUID; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.enums.GT_Values; -import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_ModHandler; import gregtech.common.items.GT_MetaGenerated_Item_01; import gregtech.common.items.GT_MetaGenerated_Item_02; -import gregtech.common.items.GT_MetaGenerated_Item_03; import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.tools.GT_Tool; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.array.Pair; @@ -33,98 +30,95 @@ public class ChargingHelper { private static Map> mValidPlayers = new HashMap>(); protected static Map mChargerMap = new HashMap(); private int mTickTimer = 0; - + private final int mTickMultiplier = 20; + //Called whenever the player is updated or ticked. @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerTick(LivingUpdateEvent event) { try { - if (event.entity != null && event.entityLiving != null){ - if (event.entityLiving instanceof EntityPlayer){ - EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; - + if (event.entity != null && event.entityLiving != null){ + if (event.entityLiving instanceof EntityPlayer){ + EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; - if (mPlayerMan != null){ - //Utils.LOG_INFO("Found Player."); - if (Utils.isServer()){ - //Utils.LOG_INFO("Found Server-Side."); + if (mPlayerMan != null){ + //Utils.LOG_INFO("Found Player."); - mTickTimer++; - if (mTickTimer % 10 == 0){ + if (Utils.isServer()){ + //Utils.LOG_INFO("Found Server-Side."); - long mVoltage = 0; - long mEuStored = 0; + mTickTimer++; + if (mTickTimer % mTickMultiplier == 0){ - if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan)){ + long mVoltage = 0; + long mEuStored = 0; - InventoryPlayer mPlayerInventory = mPlayerMan.inventory; - ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); - ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan)){ - for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ - if (mEntityTemp != null){ - mVoltage = mEntityTemp.getInputTier(); - mEuStored = mEntityTemp.getEUVar(); - if (mVoltage > 0 && mEuStored >= mVoltage){ + InventoryPlayer mPlayerInventory = mPlayerMan.inventory; + ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); + ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); - Map LR = mEntityTemp.getLongRangeMap(); - Map LO = mEntityTemp.getLocalMap(); + for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ + if (mEntityTemp != null){ + mVoltage = mEntityTemp.maxEUInput(); + mEuStored = mEntityTemp.getEUVar(); + if (mVoltage > 0 && mEuStored >= mVoltage){ - long mStartingEu = mEntityTemp.getEUVar(); - long mCurrentEu = mEntityTemp.getEUVar(); - long mEuUsed = 0; - if (mEntityTemp.getMode() == 0){ + Map LR = mEntityTemp.getLongRangeMap(); + Map LO = mEntityTemp.getLocalMap(); - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - else if (mEntityTemp.getMode() == 1){ - if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - else { - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - - if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 && mEntityTemp != null){ - long mMaxDistance; + long mStartingEu = mEntityTemp.getEUVar(); + long mCurrentEu = mEntityTemp.getEUVar(); + long mEuUsed = 0; if (mEntityTemp.getMode() == 0){ - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); + + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } } else if (mEntityTemp.getMode() == 1){ - mMaxDistance = (mEntityTemp.getTier()*10); + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } } else { - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); - } - double mDistance = calculateDistance(mEntityTemp, mPlayerMan); - long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } - if (mVoltageCost > 0){ - if (mVoltageCost > mEntityTemp.maxEUInput()){ - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); + if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 && mEntityTemp != null){ + long mMaxDistance; + if (mEntityTemp.getMode() == 0){ + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); + } + else if (mEntityTemp.getMode() == 1){ + mMaxDistance = (mEntityTemp.getTier()*10); } else { - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); + } + double mDistance = calculateDistance(mEntityTemp, mPlayerMan); + long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); + + if (mVoltageCost > 0){ + if (mVoltageCost > mEntityTemp.maxEUInput()){ + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); + } + else { + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); + } } } - } - - } - else { - //Utils.LOG_INFO("Voltage: "+mVoltage+" | Eu Storage: "+mEuStored); } } } @@ -134,10 +128,21 @@ public class ChargingHelper { } } } - } + catch (Throwable t){ - Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + //Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + + if (!mChargerMap.isEmpty()){ + for (GregtechMetaWirelessCharger r : mChargerMap.values()){ + if (r == null){ + mChargerMap.remove(r); + } + } + } + //t.printStackTrace(); } + + } public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ @@ -320,7 +325,7 @@ public class ChargingHelper { else { mVoltageIncrease = mItemEuTLimit; } - + Utils.LOG_INFO("4"); int mMulti; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index f0b2958c17..a2714c4bab 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -448,6 +448,9 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onRemoval() { + + ChargingHelper.removeEntry(getTileEntityPosition(), this); + mWirelessChargingMap.clear(); mLocalChargingMap.clear(); if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ @@ -459,7 +462,6 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } - ChargingHelper.removeEntry(getTileEntityPosition(), this); super.onRemoval(); } @@ -502,4 +504,16 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { super.onServerStart(); } + @Override + public void onExplosion() { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.onExplosion(); + } + + @Override + public void doExplosion(long aExplosionPower) { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.doExplosion(aExplosionPower); + } + } \ No newline at end of file -- cgit From af9369d63b91b26515a45f7a3419c98e4d6f8f05 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 17:50:23 +1000 Subject: + Added recipes for Wireless Chargers. $ Fixed exploit using Long-Range mode, temporarily disabled. --- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 47 ++++++++++++++++++ .../gregtech/common/helpers/ChargingHelper.java | 56 +++++++++++----------- .../basic/GregtechMetaWirelessCharger.java | 9 ++-- 3 files changed, 80 insertions(+), 32 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 124e109f25..a8a4e5ad13 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1053,6 +1053,53 @@ public class RECIPES_Machines { "plateStainlessSteel",CI.emitter_ULV,"plateStainlessSteel", ItemUtils.getSimpleStack(ModBlocks.blockProjectTable)); } + + //Wireless Chargers + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LV, CI.circuitTier1, CI.emitter_LV, + CI.component_Plate[3], CI.machineHull_LV, CI.component_Plate[3], + CI.sensor_LV, CI.fieldGenerator_LV, CI.sensor_LV, + GregtechItemList.Charger_LV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MV, CI.circuitTier2, CI.emitter_MV, + CI.component_Plate[4], CI.machineHull_MV, CI.component_Plate[4], + CI.sensor_MV, CI.fieldGenerator_MV, CI.sensor_MV, + GregtechItemList.Charger_MV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_HV, CI.circuitTier3, CI.emitter_HV, + CI.component_Plate[5], CI.machineHull_HV, CI.component_Plate[5], + CI.sensor_HV, CI.fieldGenerator_HV, CI.sensor_HV, + GregtechItemList.Charger_HV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_EV, CI.circuitTier4, CI.emitter_EV, + CI.component_Plate[6], CI.machineHull_EV, CI.component_Plate[6], + CI.sensor_EV, CI.fieldGenerator_EV, CI.sensor_EV, + GregtechItemList.Charger_EV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_IV, CI.circuitTier5, CI.emitter_IV, + CI.component_Plate[7], CI.machineHull_IV, CI.component_Plate[7], + CI.sensor_IV, CI.fieldGenerator_IV, CI.sensor_IV, + GregtechItemList.Charger_IV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LuV, CI.circuitTier6, CI.emitter_LuV, + CI.component_Plate[8], CI.machineHull_LuV, CI.component_Plate[8], + CI.sensor_LuV, CI.fieldGenerator_LuV, CI.sensor_LuV, + GregtechItemList.Charger_LuV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_ZPM, CI.circuitTier7, CI.emitter_ZPM, + CI.component_Plate[9], CI.machineHull_ZPM, CI.component_Plate[9], + CI.sensor_ZPM, CI.fieldGenerator_ZPM, CI.sensor_ZPM, + GregtechItemList.Charger_ZPM.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_UV, CI.circuitTier8, CI.emitter_UV, + CI.component_Plate[10], CI.machineHull_UV, CI.component_Plate[10], + CI.sensor_UV, CI.fieldGenerator_UV, CI.sensor_UV, + GregtechItemList.Charger_UV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MAX, CI.circuitTier9, CI.emitter_MAX, + CI.component_Plate[11], CI.machineHull_MAX, CI.component_Plate[11], + CI.sensor_MAX, CI.fieldGenerator_MAX, CI.sensor_MAX, + GregtechItemList.Charger_MAX.get(1)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 4a59a621f7..6ff0536c85 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -42,10 +42,10 @@ public class ChargingHelper { if (mPlayerMan != null){ - //Utils.LOG_INFO("Found Player."); + //Utils.LOG_WARNING("Found Player."); if (Utils.isServer()){ - //Utils.LOG_INFO("Found Server-Side."); + //Utils.LOG_WARNING("Found Server-Side."); mTickTimer++; if (mTickTimer % mTickMultiplier == 0){ @@ -73,10 +73,10 @@ public class ChargingHelper { long mEuUsed = 0; if (mEntityTemp.getMode() == 0){ - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + /*if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } + }*/ } else if (mEntityTemp.getMode() == 1){ if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ @@ -85,10 +85,10 @@ public class ChargingHelper { } } else { - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + /*if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } + }*/ if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); @@ -130,7 +130,7 @@ public class ChargingHelper { } catch (Throwable t){ - //Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + //Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); if (!mChargerMap.isEmpty()){ for (GregtechMetaWirelessCharger r : mChargerMap.values()){ @@ -183,20 +183,20 @@ public class ChargingHelper { if (mEntity == null){ return false; } - Utils.LOG_INFO("trying to map new player"); + Utils.LOG_WARNING("trying to map new player"); if (mValidPlayers.containsKey(mPlayer)){ - Utils.LOG_INFO("Key contains player already?"); + Utils.LOG_WARNING("Key contains player already?"); return false; } else { - Utils.LOG_INFO("key not found, adding"); + Utils.LOG_WARNING("key not found, adding"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.put(mPlayer, mEntry) == null){ - Utils.LOG_INFO("Added a Player to the Tick Map."); + Utils.LOG_WARNING("Added a Player to the Tick Map."); return true; } else { - Utils.LOG_INFO("Tried to add player but it was already there?"); + Utils.LOG_WARNING("Tried to add player but it was already there?"); return false; } } @@ -206,21 +206,21 @@ public class ChargingHelper { if (mEntity == null){ return false; } - Utils.LOG_INFO("trying to remove player from map"); + Utils.LOG_WARNING("trying to remove player from map"); if (mValidPlayers.containsKey(mPlayer)){ - Utils.LOG_INFO("key found, removing"); + Utils.LOG_WARNING("key found, removing"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.remove(mPlayer, mEntry)){ - Utils.LOG_INFO("Removed a Player to the Tick Map."); + Utils.LOG_WARNING("Removed a Player to the Tick Map."); return true; } else { - Utils.LOG_INFO("Tried to remove player but it was not there?"); + Utils.LOG_WARNING("Tried to remove player but it was not there?"); return false; } } else { - Utils.LOG_INFO("Key does not contain player?"); + Utils.LOG_WARNING("Key does not contain player?"); return false; } } @@ -267,17 +267,17 @@ public class ChargingHelper { for (ItemStack mTemp : mItems){ mItemSlot++; if (mTemp != null){ - Utils.LOG_INFO("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); + Utils.LOG_WARNING("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); } //Is item Electrical if (isItemValid(mTemp)){ - Utils.LOG_INFO("1"); + Utils.LOG_WARNING("1"); //Transfer Limit double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); //Check if Tile has more or equal EU to what can be transferred into the item. if (mEuStored >= mItemEuTLimit){ - Utils.LOG_INFO("2"); + Utils.LOG_WARNING("2"); double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); @@ -288,7 +288,7 @@ public class ChargingHelper { //Try get charge direct from NBT for GT and IC2 stacks try { - Utils.LOG_INFO("3"); + Utils.LOG_WARNING("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 @@ -326,7 +326,7 @@ public class ChargingHelper { mVoltageIncrease = mItemEuTLimit; } - Utils.LOG_INFO("4"); + Utils.LOG_WARNING("4"); int mMulti; if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ @@ -341,15 +341,15 @@ public class ChargingHelper { else { mMulti = 1; } - Utils.LOG_INFO("5"); + Utils.LOG_WARNING("5"); int mMultiVoltage = (int) (mMulti*mVoltageIncrease); if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ - Utils.LOG_INFO("6"); + Utils.LOG_WARNING("6"); if (GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, mTier, true, false) == 0){ - Utils.LOG_INFO("6.5"); + Utils.LOG_WARNING("6.5"); for (int i=0; i mitemCurrentCharge){ - Utils.LOG_INFO("7"); + Utils.LOG_WARNING("7"); mEntity.setEUVar((long) (mEuStored-(mVoltage*mMulti))); mEuStored = mEntity.getEUVar(); - Utils.LOG_INFO("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); + Utils.LOG_WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); mChargedItems++; } } @@ -370,7 +370,7 @@ public class ChargingHelper { } else { if (mTemp != null){ - Utils.LOG_INFO("Found Non-Valid item. "+mTemp.getDisplayName()); + Utils.LOG_WARNING("Found Non-Valid item. "+mTemp.getDisplayName()); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index a2714c4bab..0bd3e6b3bd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -45,6 +45,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { "Mixed: Provides both 2A of long range and 1A per player locally.", "Mixed mode is more conservative of power and as a result only", "gets half the distances each singular mode gets.", + "Long-Range mode currently disabled.", CORE.GT_Tooltip}; } @@ -158,7 +159,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { this.mMode++; } if (this.mMode == 0){ - PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode."); + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode. [Disabled]"); } else if (this.mMode == 1){ PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); @@ -394,7 +395,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } } - if (this.mMode == 0 || this.mMode == 2){ + /*if (this.mMode == 0 || this.mMode == 2){ int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mWirelessChargingMap.containsKey(mTemp)){ @@ -411,7 +412,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } } - } + } */ } } @@ -487,7 +488,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } else { - PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m [Disabled]"); } -- cgit From dd884036eb476a301d681d7f9736d51e9b8390ce Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 18:02:16 +1000 Subject: $ Fixed tooltips and double local-distance range for Wireless Charger. --- .../machines/basic/GregtechMetaWirelessCharger.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 0bd3e6b3bd..7f2accdd00 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -41,11 +41,12 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { return new String[] {this.mDescription, "3 Modes, Long-Range, Local and Mixed.", "Long-Range: Can supply 2A of power to a single player upto "+(GT_Values.V[this.mTier]*4)+"m away.", - "Local: Can supply 1A to each player within "+this.mTier*10+"m.", + "Local: Can supply several Amps to each player within "+this.mTier*20+"m.", "Mixed: Provides both 2A of long range and 1A per player locally.", "Mixed mode is more conservative of power and as a result only", - "gets half the distances each singular mode gets.", + "Gets half the distances each singular mode gets.", "Long-Range mode currently disabled.", + "Free Double Distance boost to local mode.", CORE.GT_Tooltip}; } @@ -378,7 +379,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { EntityPlayer mTemp = (EntityPlayer) mTempPlayer; if (this.mMode == 1 || this.mMode == 2){ - int tempRange = (this.mMode == 1 ? this.mTier*10 : this.mTier*5); + int tempRange = (this.mMode == 1 ? this.mTier*20 : this.mTier*10); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ mLocalChargingMap.put(mTemp.getPersistentID(), mTemp); @@ -477,14 +478,14 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); } else { - tempRange = this.mMode == 1 ? this.mTier*10 : this.mTier*5; + tempRange = this.mMode == 1 ? this.mTier*20 : this.mTier*10; } if (this.mMode == 2){ - PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*5+"m | Long: "+tempRange+"m"); + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*10+"m | Long: "+tempRange+"m [Disabled]"); } else if (this.mMode == 1){ - PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*10+"m"); + PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*20+"m"); } else { -- cgit From 7769afdb2d66194197b6621029f1b4438e2225e7 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 21:06:01 +1000 Subject: $ Pollution Scrubber uses Turbine Blades very fast. Fixes #155. --- .../machines/basic/GregtechMetaAtmosphericReconditioner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 9fcecf8e2f..69892ea995 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -264,7 +264,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi if (damageValue <= 1){ if (this.mOptimalAirFlow > 0){ - damageValue = (this.mOptimalAirFlow/10); + damageValue = (this.mOptimalAirFlow/10/2); } else { return false; -- cgit From e827267bf3c2d43f66cef0347878e38a22d6bccd Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 22:05:56 +1000 Subject: + Added the ability for the Pollution Detector to output redstone when above a level set by the screwdriver. + Added pollution to the Wash plant. % Improved Pollution Detector right click message. --- .../basic/GregtechMetaPollutionDetector.java | 96 ++++++++++++++++++++-- ...GregtechMetaTileEntity_IndustrialWashPlant.java | 2 +- 2 files changed, 92 insertions(+), 6 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java index 4e6647060e..3474431355 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java @@ -15,6 +15,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { @@ -25,6 +26,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { private int mArrayPos = 0; private int mTickTimer = 0; private int mSecondTimer = 0; + private long mRedstoneLevel = 0; public GregtechMetaPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); @@ -36,9 +38,21 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { @Override public String[] getDescription() { - return new String[] {this.mDescription, "Right click to check pollution levels.", "Does not use power.", CORE.GT_Tooltip}; + return new String[] {this.mDescription, "Right click to check pollution levels.", + "Configure with screwdriver to set redstone output amount.", + "Does not use power.", CORE.GT_Tooltip}; } + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return aSide == aFacing + ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) }; + } + @Override public ITexture[][][] getTextureSet(final ITexture[] aTextures) { final ITexture[][][] rTextures = new ITexture[10][17][]; @@ -57,10 +71,10 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { return rTextures; } - @Override + /*@Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } + }*/ public ITexture[] getFront(final byte aColor) { @@ -205,7 +219,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { return new String[] { this.getLocalName(), "Current Pollution: "+this.mCurrentPollution, - "Average/10 minutes:"+getAveragePollutionOverLastTen()}; + "Emit Redstone at pollution level: "+this.mRedstoneLevel}; } @Override @@ -303,12 +317,14 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { public void saveNBTData(final NBTTagCompound aNBT) { aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); aNBT.setInteger("mAveragePollution", this.mAveragePollution); + aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); } @Override public void loadNBTData(final NBTTagCompound aNBT) { this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); } @Override @@ -324,11 +340,26 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { } } - + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); + + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + this.markDirty(); + for (int i=0;i<6;i++){ + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 16); + } + } + else { + for (int i=0;i<6;i++){ + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 0); + } + } + if (this.getBaseMetaTileEntity().isServerSide()) { //TickTimer - 20 times a second if (this.mTickTimer >= 0 || this.mTickTimer <= 19){ @@ -378,4 +409,59 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { return returnValue; } + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + this.mRedstoneLevel -= 5000; + break; + case 1: + this.mRedstoneLevel += 5000; + break; + case 2: + this.mRedstoneLevel -= 50000; + break; + case 3: + this.mRedstoneLevel += 50000; + } + this.markDirty(); + GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); + } + + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowGeneralRedstoneOutput() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + this.markDirty(); + return true; + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + this.markDirty(); + return true; + } + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java index cf311210c7..9b7927c5ad 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java @@ -241,7 +241,7 @@ extends GregtechMeta_MultiBlockBase { @Override public int getPollutionPerTick(final ItemStack aStack) { - return 0; + return 20; } @Override -- cgit From a9f330848748bf4c75fab648407124f70c70e462 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 15:47:20 +1000 Subject: + Added in the Compact Fusion Reactor. % Did work on the CFR. $ Fixed a tooltip on the Pollution Detector. --- src/Java/gregtech/api/util/Recipe_GT.java | 6 + src/Java/gtPlusPlus/GTplusplus.java | 2 + .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 1 + .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../GT_MetaTileEntity_DeluxeMachine.java | 861 +++++++++++++++++++++ .../common/blocks/textures/TexturesGtBlock.java | 6 + .../basic/GregtechMetaPollutionDetector.java | 2 +- ...regtechMetaTileEntity_CompactFusionReactor.java | 687 ++++++++++++++++ .../gregtech/GregtechMiniRaFusion.java | 61 ++ .../TileEntities/MACHINE_CASING_FUSION_FRONT.png | Bin 0 -> 515 bytes .../MACHINE_CASING_FUSION_FRONT_ACTIVE.png | Bin 0 -> 502 bytes 11 files changed, 1629 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 8c9ae25d95..082dc6e264 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -271,6 +271,12 @@ public class Recipe_GT extends GT_Recipe{ "Advanced Material Combiner", null, "gregtech:textures/gui/basicmachines/MixerAdvanced", 4, 4, 1, 0, 2, "", 1, "", true, true); + //Mini Fusion + public static final GT_Recipe_Map sSlowFusionRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.slowfusionreactor", + "Slow Fusion Reactor", null, "gregtech:textures/gui/basicmachines/Default", 0, 0, 0, 2, 1, "Start: ", 1, + " EU", true, false); + + /** * HashMap of Recipes based on their Items */ diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 2c08414743..ae5ea3eda4 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -177,6 +177,8 @@ public class GTplusplus implements ActionListener { "gregtech", true, "Used to wash the dirt, riiiiight offff.."); CORE.configSwitches.enableMultiblock_ThermalBoiler = config.getBoolean("enableMachineThermalBoiler", "gregtech", true, "Thermal Boiler from GT4. Can Filter Lava for resources."); + CORE.configSwitches.enableMultiblock_IndustrialCuttingMachine = config.getBoolean("enableMultiblock_IndustrialCuttingMachine", + "gregtech", true, "Very fast and efficient Cutting Machine."); // Options RF2EU_Battery.rfPerEU = config.getInt("rfUsedPerEUForUniversalBatteries", "configurables", 4, 1, 1000, diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index e504e16761..eecbcec9e9 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -99,6 +99,7 @@ public class COMPAT_HANDLER { GregtechWirelessChargers.run(); GregtechIndustrialGeneratorArray.run(); GregtechIndustrialCuttingFactory.run(); + GregtechMiniRaFusion.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index fbffa4adf1..7a0df6c43c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -266,7 +266,10 @@ public enum GregtechItemList implements GregtechItemContainer { Generator_Array_Controller, //Cutting Factory Controller - Industrial_CuttingFactoryController, + Industrial_CuttingFactoryController, + + //Tiny Fusion + Miniature_Fusion, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java new file mode 100644 index 0000000000..ee0722069b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -0,0 +1,861 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import java.util.Arrays; + +import static gregtech.api.enums.GT_Values.V; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_DeluxeTank { + /** + * return values for checkRecipe() + */ + protected static final int + DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; + public final ItemStack[] mOutputItems; + public final int mInputSlotCount, mAmperage; + public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public FluidStack mOutputFluid; + public String mGUIName = "", mNEIName = ""; + /** + * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered + */ + protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; + + /** + * @param aOverlays 0 = SideFacingActive + * 1 = SideFacingInactive + * 2 = FrontFacingActive + * 3 = FrontFacingInactive + * 4 = TopFacingActive + * 5 = TopFacingInactive + * 6 = BottomFacingActive + * 7 = BottomFacingInactive + * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- + * 8 = BottomFacingPipeActive + * 9 = BottomFacingPipeInactive + * 10 = TopFacingPipeActive + * 11 = TopFacingPipeInactive + * 12 = SideFacingPipeActive + * 13 = SideFacingPipeInactive + */ + public GT_MetaTileEntity_DeluxeMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GT_MetaTileEntity_DeluxeMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public boolean setMainFacing(byte aDirection){ + mMainFacing = aDirection; + if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aDirection)); + } + onFacingChange(); + onMachineBlockUpdate(); + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + aTextures = Arrays.copyOf(aTextures, 14); + + for (int i = 0; i < aTextures.length; i++) + if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } + + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return mMainFacing > 1 || aFacing > 1; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 16; + } + + @Override + public long maxEUStore() { + return V[mTier] * 64; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxSteamStore() { + return maxEUStore(); + } + + @Override + public long maxAmperesIn() { + return (mEUt * 2) / V[mTier] + 1; + } + + @Override + public int getInputSlot() { + return OTHER_SLOT_COUNT; + } + + @Override + public int getOutputSlot() { + return OTHER_SLOT_COUNT + mInputSlotCount; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + @Override + public int rechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int rechargerSlotCount() { + return mCharge ? 1 : 0; + } + + @Override + public int dechargerSlotCount() { + return mDecharge ? 1 : 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return true; + } + + @Override + public FluidStack getDisplayedFluid() { + return displaysOutputFluid() ? getDrainableStack() : null; + } + + @Override + public FluidStack getDrainableStack() { + return mFluidOut; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluidOut = aFluid; + return mFluidOut; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + if(!GT_Mod.gregtechproxy.mForceFreeFace) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + for(byte i=0;i < 6; i++){ + if(aBaseMetaTileEntity.getAirAtSide(i)){ + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + mMainFacing = -1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer", mFluidTransfer); + aNBT.setBoolean("mItemTransfer", mItemTransfer); + aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); + aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); + if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); + + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) + aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); + mItemTransfer = aNBT.getBoolean("mItemTransfer"); + mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); + mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); + mEUt = aNBT.getInteger("mEUt"); + mMainFacing = aNBT.getInteger("mMainFacing"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); + mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); + + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + + //Utils.LOG_INFO("Ticking Tank."); + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + + doDisplayThings(); + + boolean tSucceeded = false; + + if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { + if (++mProgresstime >= mMaxProgresstime) { + for (int i = 0; i < mOutputItems.length; i++) + for (int j = 0; j < mOutputItems.length; j++) + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) + break; + if (mOutputFluid != null) + if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); + else if (mOutputFluid.isFluidEqual(getDrainableStack())) + getDrainableStack().amount += mOutputFluid.amount; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + mEUt = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mStuttering = false; + tSucceeded = true; + endProcess(); + } + if (mProgresstime > 5) mStuttering = false; + XSTR aXSTR = new XSTR(); + if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + } else { + if (!mStuttering) { + stutterProcess(); + if (canHaveInsufficientEnergy()) mProgresstime = -100; + mStuttering = true; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + Utils.LOG_INFO("R0"); + + if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + } + } + if (getDrainableStack() == null) tRemovedOutputFluid = true; + } + + if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + } + } + + if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; + Utils.LOG_INFO("R1"); + if (allowToCheckRecipe()) { + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-mMaxProgresstime: "+mMaxProgresstime); + Utils.LOG_INFO("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); + Utils.LOG_INFO("R2-tSucceeded: "+tSucceeded); + Utils.LOG_INFO("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); + Utils.LOG_INFO("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); + Utils.LOG_INFO("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); + Utils.LOG_INFO("R2--------------------------------------------------"); + if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + Utils.LOG_INFO("R3"); + if (checkRecipe() == 2) { + if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + Utils.LOG_INFO("R4"); + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) + mOutputItems[i].stackSize = 64; + mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + mMaxProgresstime = Math.max(1, mMaxProgresstime); + if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { + mEUt = mMaxProgresstime = 1; + } + startProcess(); + } else { + mMaxProgresstime = 0; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + } + } + } else { + if (!mStuttering) { + stutterProcess(); + mStuttering = true; + } + } + } + } + + protected void doDisplayThings() { + if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + mMainFacing = getBaseMetaTileEntity().getFrontFacing(); + } + if (mMainFacing >= 2 && !mHasBeenUpdated) { + mHasBeenUpdated = true; + //getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + } + + if (displaysInputFluid()) { + int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + if (getFillableStack() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) + mInventory[tDisplayStackSlot] = null; + } else { + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + } + } + } + + protected boolean hasEnoughEnergyToCheckRecipe() { + return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); + } + + protected boolean drainEnergyForProcess(long aEUt) { + return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); + } + + protected void calculateOverclockedNess(GT_Recipe aRecipe) { + calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); + } + + protected void calculateOverclockedNess(int aEUt, int aDuration) { + if (aEUt <= 16) { + mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); + mMaxProgresstime = aDuration / (1 << (mTier - 1)); + } else { + mEUt = aEUt; + mMaxProgresstime = aDuration; + while (mEUt <= V[mTier - 1] * mAmperage) { + mEUt *= 4; + mMaxProgresstime /= 2; + } + } + } + + protected ItemStack getSpecialSlot() { + return mInventory[3]; + } + + protected ItemStack getOutputAt(int aIndex) { + return mInventory[getOutputSlot() + aIndex]; + } + + protected ItemStack[] getAllOutputs() { + ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); + return rOutputs; + } + + protected boolean canOutput(GT_Recipe aRecipe) { + return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + } + + protected boolean canOutput(ItemStack... aOutputs) { + if (aOutputs == null) return true; + ItemStack[] tOutputSlots = getAllOutputs(); + for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) + if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + mOutputBlocked++; + return false; + } + return true; + } + + protected boolean canOutput(FluidStack aOutput) { + return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + } + + protected ItemStack getInputAt(int aIndex) { + return mInventory[getInputSlot() + aIndex]; + } + + protected ItemStack[] getAllInputs() { + ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + return rInputs; + } + + protected boolean isOutputEmpty() { + boolean rIsEmpty = true; + for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + return rIsEmpty; + } + + protected boolean displaysInputFluid() { + return true; + } + + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public void onValueUpdate(byte aValue) { + mMainFacing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) mMainFacing; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + } + + public boolean doesAutoOutput() { + return mItemTransfer; + } + + public boolean doesAutoOutputFluids() { + return mFluidTransfer; + } + + public boolean allowToCheckRecipe() { + return true; + } + + public boolean showPipeFacing() { + return true; + } + + /** + * Called whenever the Machine successfully started a Process, useful for Sound Effects + */ + public void startProcess() { + // + } + + /** + * Called whenever the Machine successfully finished a Process, useful for Sound Effects + */ + public void endProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process, useful for Sound Effects + */ + public void abortProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects + */ + public void stutterProcess() { + if (useStandardStutterSound()) sendSound((byte) 8); + } + + /** + * If this Machine can have the Insufficient Energy Line Problem + */ + public boolean canHaveInsufficientEnergy() { + return true; + } + + public boolean useStandardStutterSound() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + mNEIName, + "Progress:", (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + mAllowInputFromOutputSide = !mAllowInputFromOutputSide; + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden")); + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) + return false; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; + return true; + } + + /** + * @return the Recipe List which is used for this Machine, this is a useful Default Handler + */ + public GT_Recipe_Map getRecipeList() { + return null; + } + + /** + * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case + *

+ * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. + *

+ * Funny how Eclipse marks the word Enum as not correctly spelled. + * + * @return see constants above + */ + public int checkRecipe() { + return checkRecipe(false); + } + + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ + return //TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || + DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + } + + + /** + * + * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... + * @return + */ + public int checkRecipe(boolean skipOC){ + GT_Recipe_Map tMap = getRecipeList(); + if (tMap == null) return DID_NOT_FIND_RECIPE; + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + if (tRecipe == null) return DID_NOT_FIND_RECIPE; + + if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && + !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; + if (!canOutput(tRecipe)) { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) + mOutputItems[i] = tRecipe.getOutput(i); + mOutputFluid = tRecipe.getFluidOutput(0); + calculateOverclockedNess(tRecipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index fbf615a499..be1ceb2fd7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -62,6 +62,12 @@ public class TexturesGtBlock { public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; + //Controllers + private static final CustomIcon Internal_Casing_Fusion_Simple_Front = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT"); + public static final CustomIcon Casing_Fusion_Simple_Front = Internal_Casing_Fusion_Simple_Front; + private static final CustomIcon Internal_Casing_Fusion_Simple_Front_Active = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE"); + public static final CustomIcon Casing_Fusion_Simple_Front_Active = Internal_Casing_Fusion_Simple_Front_Active; + //Machine Casings //Simple private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java index 3474431355..8ca0a672b2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java @@ -191,7 +191,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { } else { PlayerUtils.messagePlayer(playerIn, "This chunk contains "+getCurrentChunkPollution()+" pollution."); - PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution."); + PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: "+this.mRedstoneLevel); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java new file mode 100644 index 0000000000..b604eb94a2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -0,0 +1,687 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.Random; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_CompactFusionReactor +extends +GT_MetaTileEntity_DeluxeMachine { + + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_CompactFusionReactor(int aID, String aName, + String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, + 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_CompactFusionReactor(String aName, int aTier, + String aDescription, ITexture[][][] aTextures, String aGUIName, + String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, + aNEIName); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, + "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", + "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2.", + CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_CompactFusionReactor(this.mName, + this.mTier, this.mDescription, this.mTextures, this.mGUIName, + this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, final byte aFacing, final byte aColorIndex, + final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) + || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + @Override + public int checkRecipe() { + Utils.LOG_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Utils.LOG_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Utils.LOG_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits( + (mFusionPoint / 100), false)) { + Utils.LOG_INFO("Recipe Tick 1.3 - Charging Internal storage. "+(mFusionPoint / 100)+"/"+mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + + } + } else { + Utils.LOG_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Utils.LOG_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Utils.LOG_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList getStoredFluids() { + ArrayList mList = new ArrayList(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), + (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList + .get(i)).amount >= ((FluidStack) tFluidList + .get(j)).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList + .toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sFusionRecipes + .findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, + false, GT_Values.V[8], tFluids, new ItemStack[]{}); + if ((tRecipe == null && !mRunningOnLoad) + || (maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, + new ItemStack[]{})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt + * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration + / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) + - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) + - (tRandom.nextFloat() * 1.6F), + 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) + - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) + - (tRandom.nextFloat() * 0.6F), + 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) + - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) + - (tRandom.nextFloat() * 2.6F), + 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) + mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName()+" Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount + / (float) this.mLastRecipe.mDuration; + } + } + + return new String[]{"Fusion Reactor MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), + "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: "+fusionName}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_MatterFab)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{this.getCasingTexture(),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_MatterFab_Active)}; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{ + this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, + long aTick) { + //super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + Utils.LOG_INFO("1"); + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad) { + Utils.LOG_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Utils.LOG_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + Utils.LOG_INFO("4"); + if (mMachine) { + Utils.LOG_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + + (2048 * tierOverclock()) < maxEUStore()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits( + 2048 * tierOverclock(), true); + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Utils.LOG_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Utils.LOG_INFO("7"); + this.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + mEfficiency = Math.max(0, + (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + + } + this.mEUStore = (int) aBaseMetaTileEntity + .getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipeMulti(); + } + } else { + Utils.LOG_INFO("8"); + if (aTick % 100 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity + .hasInventoryBeenModified()) { + Utils.LOG_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Utils.LOG_INFO("10"); + this.mEUStore = (int) aBaseMetaTileEntity + .getStoredEU(); + if (checkRecipeMulti()) { + Utils.LOG_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Utils.LOG_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity + .decreaseStoredEnergyUnits( + this.mLastRecipe.mSpecialValue, + true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + // turnCasingActive(false); + Utils.LOG_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Utils.LOG_INFO("Good"); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (mEUt < 0) { + if (!drainEnergyInput( + ((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) + return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch(aSide) { + case 0 : + return true; + case 1 : + return true; + case 2 : + return true; + case 3 : + return false; + case 4 : + return false; + case 5 : + return false; + default : + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch(aSide) { + case 0 : + return false; + case 1 : + return false; + case 2 : + return false; + case 3 : + return true; + case 4 : + return true; + case 5 : + return true; + default : + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + // TODO Auto-generated method stub + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + // TODO Auto-generated method stub + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return false; + } + else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.canDrain(aSide, aFluid); + } + else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, + boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return 0; + } + else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.fill(aSide, aFluid, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, + boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.drain(aSide, aFluid, doDrain); + } + else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, + boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.drain(aSide, maxDrain, doDrain); + } + else { + return null; + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java new file mode 100644 index 0000000000..d48815e563 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import java.util.Collection; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_BasicWasher; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_CompactFusionReactor; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMiniRaFusion { + + public static void run() { + //if (CORE.configSwitches.enableMachine_SimpleWasher){ + generateSlowFusionRecipes(); + // Register the Simple Fusion Entity. + GregtechItemList.Miniature_Fusion + .set(new GregtechMetaTileEntity_CompactFusionReactor(993, "simplefusion.tier.00", "Ra, Sun God - Mk I", 6) + .getStackForm(1L)); + //} + } + + private static boolean generateSlowFusionRecipes(){ + int mRecipeCount = 0; + GT_Recipe_Map r = GT_Recipe.GT_Recipe_Map.sFusionRecipes; + final Collection x = r.mRecipeList; + Utils.LOG_INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug."); + for (final GT_Recipe newBo : x) { + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.addRecipe( + true, + newBo.mInputs, + newBo.mOutputs, + newBo.mSpecialItems, + newBo.mFluidInputs.clone(), //Fluid In + newBo.mFluidOutputs.clone(), //Fluid Out + newBo.mDuration*4, //Duration + newBo.mEUt, //Eu + newBo.mSpecialValue //Special + ) != null){ + mRecipeCount++; + } + } + + + + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.mRecipeList.size() > mRecipeCount){ + return true; + } + return false; + } +} diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png new file mode 100644 index 0000000000..05c8741fa7 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png new file mode 100644 index 0000000000..4f7290c571 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png differ -- cgit From 4487354c88d814123e1374198d96275ac8c85406 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 15:54:35 +1000 Subject: ^ Version Bump. % Tweaked SFR side texture when active. --- build.gradle | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java | 2 +- src/resources/mcmod.info | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/build.gradle b/build.gradle index efbc8c0232..1321368c96 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.91-release" +version = "1.6.93-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 6cb37837aa..cdccd4164f 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -35,7 +35,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.91-release"; + public static final String VERSION = "1.6.93-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java index b604eb94a2..2572f36372 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -399,7 +399,7 @@ GT_MetaTileEntity_DeluxeMachine { public ITexture[] getSides(final byte aColor) { return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( - TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getFrontActive(final byte aColor) { diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 68f69d5530..032322a414 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.91-release", + "version": "1.6.93-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From 87e0f8f11686cff0b13f95e37c2cf1169860d7ee Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 17:50:02 +1000 Subject: + Gave people free capes. % Redid cape handler. - Removed annoying logging. --- .../GT_MetaTileEntity_DeluxeMachine.java | 38 ++++++++++---------- .../gregtech/common/render/GTPP_CapeRenderer.java | 42 +++++++++++++--------- ...regtechMetaTileEntity_CompactFusionReactor.java | 42 +++++++++++----------- 3 files changed, 66 insertions(+), 56 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java index ee0722069b..cea9d8eb2f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -408,7 +408,7 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ if (aBaseMetaTileEntity.isServerSide()) { - //Utils.LOG_INFO("Ticking Tank."); + //Utils.LOG_WARNING("Ticking Tank."); mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; @@ -452,7 +452,7 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } boolean tRemovedOutputFluid = false; - Utils.LOG_INFO("R0"); + Utils.LOG_WARNING("R0"); if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); @@ -477,27 +477,27 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; else mOutputBlocked++; - Utils.LOG_INFO("R1"); + Utils.LOG_WARNING("R1"); if (allowToCheckRecipe()) { - Utils.LOG_INFO("R2--------------------------------------------------"); - Utils.LOG_INFO("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); - Utils.LOG_INFO("R2--------------------------------------------------"); - Utils.LOG_INFO("R2-mMaxProgresstime: "+mMaxProgresstime); - Utils.LOG_INFO("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); - Utils.LOG_INFO("R2--------------------------------------------------"); - Utils.LOG_INFO("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); - Utils.LOG_INFO("R2-tSucceeded: "+tSucceeded); - Utils.LOG_INFO("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); - Utils.LOG_INFO("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); - Utils.LOG_INFO("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); - Utils.LOG_INFO("R2--------------------------------------------------"); - Utils.LOG_INFO("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); - Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_WARNING("R2--------------------------------------------------"); + Utils.LOG_WARNING("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); + Utils.LOG_WARNING("R2--------------------------------------------------"); + Utils.LOG_WARNING("R2-mMaxProgresstime: "+mMaxProgresstime); + Utils.LOG_WARNING("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); + Utils.LOG_WARNING("R2--------------------------------------------------"); + Utils.LOG_WARNING("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); + Utils.LOG_WARNING("R2-tSucceeded: "+tSucceeded); + Utils.LOG_WARNING("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); + Utils.LOG_WARNING("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); + Utils.LOG_WARNING("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); + Utils.LOG_WARNING("R2--------------------------------------------------"); + Utils.LOG_WARNING("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); + Utils.LOG_WARNING("R2--------------------------------------------------"); if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - Utils.LOG_INFO("R3"); + Utils.LOG_WARNING("R3"); if (checkRecipe() == 2) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; - Utils.LOG_INFO("R4"); + Utils.LOG_WARNING("R4"); for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; for (int i = 0; i < mOutputItems.length; i++) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index f6507aa1c4..89b144fc5f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -25,6 +25,12 @@ public class GTPP_CapeRenderer setRenderManager(RenderManager.instance); } + private final String[] mOrangeCapes = {"ImmortalPharaoh7", "Walmart_Employee", "ArchonCerulean", "asturrial"}; //Orange.png + private final String[] mBlueCapes = {"fobius", "cantankerousrex", "stephen_2015", "Dyonovan", "Bear989Sr", "CrazyJ1984"}; //Fancycape.png + private final String[] mTestCapes = {"123_456_789", "doomsquirter", "ukdunc"}; //TesterCape.png + private final String[] mDevCapes = {"draknyte1", "redmage17"}; //Capes for Developers + + public void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; if (GT_Utility.getFullInvisibility(aPlayer)) { @@ -40,27 +46,31 @@ public class GTPP_CapeRenderer } try { ResourceLocation tResource = null; - if (aPlayer.getDisplayName().equalsIgnoreCase("draknyte1")) { - tResource = this.mCapes[3]; - } - else if (aPlayer.getDisplayName().equalsIgnoreCase("fobius")) { - tResource = this.mCapes[2]; - } - else if (aPlayer.getDisplayName().equalsIgnoreCase("doomsquirter")) { - tResource = this.mCapes[1]; + + for (String mName : mOrangeCapes){ + if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[0]; + } } - else if (aPlayer.getDisplayName().equalsIgnoreCase("ukdunc")) { - tResource = this.mCapes[1]; + for (String mName : mBlueCapes){ + if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[1]; + } } - else if (aPlayer.getDisplayName().equalsIgnoreCase("cantankerousrex")) { - tResource = this.mCapes[2]; + for (String mName : mTestCapes){ + if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[2]; + } } - else if (aPlayer.getDisplayName().equalsIgnoreCase("123_456_789")) { - tResource = this.mCapes[1]; + for (String mName : mDevCapes){ + if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[3]; + } } - else if (this.mCapeList.contains(aPlayer.getDisplayName().toLowerCase())) { + + /*if (this.mCapeList.contains(aPlayer.getDisplayName().toLowerCase())) { tResource = this.mCapes[0]; - } + }*/ if ((tResource != null) && (!aPlayer.getHideCape())) { bindTexture(tResource); GL11.glPushMatrix(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java index 2572f36372..dc28b6b761 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -147,16 +147,16 @@ GT_MetaTileEntity_DeluxeMachine { long mFusionPoint = 20000000L; @Override public int checkRecipe() { - Utils.LOG_INFO("Recipe Tick 1."); + Utils.LOG_WARNING("Recipe Tick 1."); if (!this.mCanProcessRecipe) { - Utils.LOG_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + Utils.LOG_WARNING("Recipe Tick 1.1 - Cannot Process Recipe."); if (this.mChargeConsumed < mFusionPoint) { - Utils.LOG_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + Utils.LOG_WARNING("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); this.mCharging = true; this.mCanProcessRecipe = false; if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits( (mFusionPoint / 100), false)) { - Utils.LOG_INFO("Recipe Tick 1.3 - Charging Internal storage. "+(mFusionPoint / 100)+"/"+mFusionPoint); + Utils.LOG_WARNING("Recipe Tick 1.3 - Charging Internal storage. "+(mFusionPoint / 100)+"/"+mFusionPoint); mChargeConsumed += (mFusionPoint / 100); } } else { @@ -166,13 +166,13 @@ GT_MetaTileEntity_DeluxeMachine { } } else { - Utils.LOG_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + Utils.LOG_WARNING("Recipe Tick 1.1 - Try to Process Recipe."); if (checkRecipeMulti()) { - Utils.LOG_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + Utils.LOG_WARNING("Recipe Tick 1.2 - Process Recipe was Successful."); return 2; } } - Utils.LOG_INFO("Recipe Tick 2. - Process Recipe failed."); + Utils.LOG_WARNING("Recipe Tick 2. - Process Recipe failed."); return 0; } @@ -435,22 +435,22 @@ GT_MetaTileEntity_DeluxeMachine { long aTick) { //super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { - Utils.LOG_INFO("1"); + Utils.LOG_WARNING("1"); if (mEfficiency < 0) mEfficiency = 0; if (mRunningOnLoad) { - Utils.LOG_INFO("2"); + Utils.LOG_WARNING("2"); this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); checkRecipeMulti(); } if (--mUpdate == 0 || --mStartUpCheck == 0) { - Utils.LOG_INFO("3"); + Utils.LOG_WARNING("3"); mMachine = true; } if (mStartUpCheck < 0) { - Utils.LOG_INFO("4"); + Utils.LOG_WARNING("4"); if (mMachine) { - Utils.LOG_INFO("5"); + Utils.LOG_WARNING("5"); if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { @@ -458,12 +458,12 @@ GT_MetaTileEntity_DeluxeMachine { 2048 * tierOverclock(), true); } if (this.mEUStore <= 0 && mMaxProgresstime > 0) { - Utils.LOG_INFO("6"); + Utils.LOG_WARNING("6"); stopMachine(); this.mLastRecipe = null; } if (mMaxProgresstime > 0) { - Utils.LOG_INFO("7"); + Utils.LOG_WARNING("7"); this.getBaseMetaTileEntity() .decreaseStoredEnergyUnits(mEUt, true); if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { @@ -485,21 +485,21 @@ GT_MetaTileEntity_DeluxeMachine { checkRecipeMulti(); } } else { - Utils.LOG_INFO("8"); + Utils.LOG_WARNING("8"); if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity .hasInventoryBeenModified()) { - Utils.LOG_INFO("9"); + Utils.LOG_WARNING("9"); // turnCasingActive(mMaxProgresstime > 0); if (aBaseMetaTileEntity.isAllowedToWork()) { - Utils.LOG_INFO("10"); + Utils.LOG_WARNING("10"); this.mEUStore = (int) aBaseMetaTileEntity .getStoredEU(); if (checkRecipeMulti()) { - Utils.LOG_INFO("11"); + Utils.LOG_WARNING("11"); if (this.mEUStore < this.mLastRecipe.mSpecialValue) { - Utils.LOG_INFO("12"); + Utils.LOG_WARNING("12"); mMaxProgresstime = 0; // turnCasingActive(false); } @@ -515,12 +515,12 @@ GT_MetaTileEntity_DeluxeMachine { } } else { // turnCasingActive(false); - Utils.LOG_INFO("Bad"); + Utils.LOG_WARNING("Bad"); this.mLastRecipe = null; stopMachine(); } } - Utils.LOG_INFO("Good"); + Utils.LOG_WARNING("Good"); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); } } -- cgit