aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java98
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java687
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java521
4 files changed, 1301 insertions, 7 deletions
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;
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..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
@@ -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,10 +38,22 @@ 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][];
for (byte i = -1; i < 16; i++) {
@@ -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) {
@@ -177,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);
}
}
@@ -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/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java
new file mode 100644
index 0000000000..dc28b6b761
--- /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_WARNING("Recipe Tick 1.");
+ if (!this.mCanProcessRecipe) {
+ Utils.LOG_WARNING("Recipe Tick 1.1 - Cannot Process Recipe.");
+ if (this.mChargeConsumed < mFusionPoint) {
+ 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_WARNING("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_WARNING("Recipe Tick 1.1 - Try to Process Recipe.");
+ if (checkRecipeMulti()) {
+ Utils.LOG_WARNING("Recipe Tick 1.2 - Process Recipe was Successful.");
+ return 2;
+ }
+ }
+ Utils.LOG_WARNING("Recipe Tick 2. - Process Recipe failed.");
+ return 0;
+ }
+
+ public ArrayList<FluidStack> getStoredFluids() {
+ ArrayList<FluidStack> mList = new ArrayList<FluidStack>();
+ mList.add(this.mFluid);
+ mList.add(this.mFluid2);
+ return mList;
+ }
+
+ public boolean checkRecipeMulti() {
+ ArrayList<FluidStack> 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_Orange)};
+ }
+
+ 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_WARNING("1");
+ if (mEfficiency < 0)
+ mEfficiency = 0;
+ if (mRunningOnLoad) {
+ Utils.LOG_WARNING("2");
+ this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ checkRecipeMulti();
+ }
+ if (--mUpdate == 0 || --mStartUpCheck == 0) {
+ Utils.LOG_WARNING("3");
+ mMachine = true;
+ }
+ if (mStartUpCheck < 0) {
+ Utils.LOG_WARNING("4");
+ if (mMachine) {
+ Utils.LOG_WARNING("5");
+
+ if (aBaseMetaTileEntity.getStoredEU()
+ + (2048 * tierOverclock()) < maxEUStore()) {
+ aBaseMetaTileEntity.increaseStoredEnergyUnits(
+ 2048 * tierOverclock(), true);
+ }
+ if (this.mEUStore <= 0 && mMaxProgresstime > 0) {
+ Utils.LOG_WARNING("6");
+ stopMachine();
+ this.mLastRecipe = null;
+ }
+ if (mMaxProgresstime > 0) {
+ Utils.LOG_WARNING("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_WARNING("8");
+ if (aTick % 100 == 0
+ || aBaseMetaTileEntity.hasWorkJustBeenEnabled()
+ || aBaseMetaTileEntity
+ .hasInventoryBeenModified()) {
+ Utils.LOG_WARNING("9");
+ // turnCasingActive(mMaxProgresstime > 0);
+ if (aBaseMetaTileEntity.isAllowedToWork()) {
+ Utils.LOG_WARNING("10");
+ this.mEUStore = (int) aBaseMetaTileEntity
+ .getStoredEU();
+ if (checkRecipeMulti()) {
+ Utils.LOG_WARNING("11");
+ if (this.mEUStore < this.mLastRecipe.mSpecialValue) {
+ Utils.LOG_WARNING("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_WARNING("Bad");
+ this.mLastRecipe = null;
+ stopMachine();
+ }
+ }
+ Utils.LOG_WARNING("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/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
new file mode 100644
index 0000000000..7f2accdd00
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
@@ -0,0 +1,521 @@
+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 gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper;
+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 {
+
+ 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);
+ }
+
+ 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 "+(GT_Values.V[this.mTier]*4)+"m away.",
+ "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.",
+ "Long-Range mode currently disabled.",
+ "Free Double Distance boost to local mode.",
+ CORE.GT_Tooltip};
+ }
+
+ public int getTier(){
+ return this.mTier;
+ }
+
+ public int getMode(){
+ return this.mMode;
+ }
+
+ public Map<UUID, EntityPlayer> getLocalMap(){
+ return this.mLocalChargingMap;
+ }
+
+ public Map<EntityPlayer, UUID> getLongRangeMap(){
+ return this.mWirelessChargingMap;
+ }
+
+ @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][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][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][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][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][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][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][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][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][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][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)};
+ }
+
+ @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;
+ }
+ else {
+ this.mMode++;
+ }
+ if (this.mMode == 0){
+ PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode. [Disabled]");
+ }
+ 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]*128;}
+
+ @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()*8;
+ }
+ else {
+ return ((this.mLocalChargingMap.size()*4)+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<EntityPlayer, UUID> mWirelessChargingMap = new HashMap<EntityPlayer, UUID>();
+ private Map<UUID, EntityPlayer> mLocalChargingMap = new HashMap<UUID, EntityPlayer>();
+
+ @Override
+ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+
+ if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){
+ mHasBeenMapped = true;
+ }
+
+ if (aTick % 20 == 0 && mHasBeenMapped){
+ 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 ? this.mTier*20 : this.mTier*10);
+ 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].");
+ ChargingHelper.removeValidPlayer(mTemp, this);
+ }
+ }
+ }
+ }
+ /*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)){
+ 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].");
+ ChargingHelper.removeValidPlayer(mTemp, this);
+ }
+ }
+ }
+ } */
+
+ }
+ }
+ }
+ }
+
+
+ }
+ }
+
+ public BlockPos getTileEntityPosition(){
+ return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord());
+ }
+
+ public BlockPos getPositionOfEntity(Entity mEntity){
+ if (mEntity == null){
+ return null;
+ }
+ return EntityUtils.findBlockPosUnderEntity(mEntity);
+ }
+
+ 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){
+ 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() {
+
+ ChargingHelper.removeEntry(getTileEntityPosition(), this);
+
+ 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);
+ }
+ }
+ }
+
+
+ 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 = this.mMode == 1 ? this.mTier*20 : this.mTier*10;
+ }
+
+ if (this.mMode == 2){
+ 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*20+"m");
+
+ }
+ else {
+ PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m [Disabled]");
+
+ }
+
+ return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ);
+ }
+
+ @Override
+ public void onServerStart() {
+ mWirelessChargingMap.clear();
+ mLocalChargingMap.clear();
+ if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){
+ mHasBeenMapped = true;
+ }
+ 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