parent
8a62b60380
commit
d9d0340a65
7 changed files with 64 additions and 83 deletions
|
@ -376,9 +376,8 @@ public class GT_Mod implements IGT_Mod {
|
||||||
if (tConfig1.get("general", "disable_STDOUT", false).getBoolean(false)) System.out.close();
|
if (tConfig1.get("general", "disable_STDOUT", false).getBoolean(false)) System.out.close();
|
||||||
if (tConfig1.get("general", "disable_STDERR", false).getBoolean(false)) System.err.close();
|
if (tConfig1.get("general", "disable_STDERR", false).getBoolean(false)) System.err.close();
|
||||||
|
|
||||||
GregTech_API.UE_ENERGY_COMPATIBILITY = tConfig1.get("compatibility", "UniversalElectricity.Energy", true).getBoolean(true);
|
|
||||||
GregTech_API.IC_ENERGY_COMPATIBILITY = tConfig1.get("compatibility", "Industrialcraft.Energy", true).getBoolean(true);
|
GregTech_API.IC_ENERGY_COMPATIBILITY = tConfig1.get("compatibility", "Industrialcraft.Energy", true).getBoolean(true);
|
||||||
GregTech_API.BC_ENERGY_COMPATIBILITY = tConfig1.get("compatibility", "Buildcraft.Energy", true).getBoolean(true);
|
GregTech_API.RF_ENERGY_COMPATIBILITY = tConfig1.get("compatibility", "Cofh.Energy", true).getBoolean(true);
|
||||||
|
|
||||||
GregTech_API.sMachineExplosions = tConfig1.get("machines", "machines_explosion_damage", true).getBoolean(false);
|
GregTech_API.sMachineExplosions = tConfig1.get("machines", "machines_explosion_damage", true).getBoolean(false);
|
||||||
GregTech_API.sMachineFlammable = tConfig1.get("machines", "machines_flammable", true).getBoolean(false);
|
GregTech_API.sMachineFlammable = tConfig1.get("machines", "machines_flammable", true).getBoolean(false);
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class GregTech_API {
|
||||||
public static Object sBlockIcons, sItemIcons;
|
public static Object sBlockIcons, sItemIcons;
|
||||||
|
|
||||||
/** Configured Booleans */
|
/** Configured Booleans */
|
||||||
public static boolean DEBUG_MODE = false, SECONDARY_DEBUG_MODE = false, IC_ENERGY_COMPATIBILITY = true, UE_ENERGY_COMPATIBILITY = true, BC_ENERGY_COMPATIBILITY = true;
|
public static boolean DEBUG_MODE = false, SECONDARY_DEBUG_MODE = false, IC_ENERGY_COMPATIBILITY = true, RF_ENERGY_COMPATIBILITY = true;
|
||||||
|
|
||||||
/** The Configuration Objects */
|
/** The Configuration Objects */
|
||||||
public static GT_Config sRecipeFile = null, sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null, sUnification = null, sSpecialFile = null;
|
public static GT_Config sRecipeFile = null, sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null, sUnification = null, sSpecialFile = null;
|
||||||
|
@ -468,7 +468,7 @@ public class GregTech_API {
|
||||||
return new gregtechmod.api.items.GT_Tool_Item(aUnlocalized, "item.bug.tooltip", aMaxDamage, 0, false);
|
return new gregtechmod.api.items.GT_Tool_Item(aUnlocalized, "item.bug.tooltip", aMaxDamage, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class<?> sBaseMetaTileEntityClass = null;
|
private static Class<? extends BaseMetaTileEntity> sBaseMetaTileEntityClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity
|
* This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity
|
||||||
|
@ -476,25 +476,13 @@ public class GregTech_API {
|
||||||
public static BaseMetaTileEntity constructBaseMetaTileEntity() {
|
public static BaseMetaTileEntity constructBaseMetaTileEntity() {
|
||||||
if (sBaseMetaTileEntityClass == null) {
|
if (sBaseMetaTileEntityClass == null) {
|
||||||
try {
|
try {
|
||||||
if (UE_ENERGY_COMPATIBILITY && BC_ENERGY_COMPATIBILITY && IC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityICUEMJ")).newInstance();
|
if (RF_ENERGY_COMPATIBILITY && IC_ENERGY_COMPATIBILITY) return (sBaseMetaTileEntityClass = gregtechmod.api.metatileentity.BaseMetaTileEntityICRF.class).newInstance();
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
} catch(Throwable e) {/*Do nothing*/}
|
||||||
try {
|
try {
|
||||||
if (BC_ENERGY_COMPATIBILITY && IC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityICMJ")).newInstance();
|
if (IC_ENERGY_COMPATIBILITY) return (sBaseMetaTileEntityClass = gregtechmod.api.metatileentity.BaseMetaTileEntityIC.class).newInstance();
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
} catch(Throwable e) {/*Do nothing*/}
|
||||||
try {
|
try {
|
||||||
if (UE_ENERGY_COMPATIBILITY && IC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityICUE")).newInstance();
|
if (RF_ENERGY_COMPATIBILITY) return (sBaseMetaTileEntityClass = gregtechmod.api.metatileentity.BaseMetaTileEntityRF.class).newInstance();
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
|
||||||
try {
|
|
||||||
if (IC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityIC")).newInstance();
|
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
|
||||||
try {
|
|
||||||
if (UE_ENERGY_COMPATIBILITY && BC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityUEMJ")).newInstance();
|
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
|
||||||
try {
|
|
||||||
if (UE_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityUE")).newInstance();
|
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
|
||||||
try {
|
|
||||||
if (BC_ENERGY_COMPATIBILITY) return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = Class.forName("gregtechmod.api.metatileentity.BaseMetaTileEntityMJ")).newInstance();
|
|
||||||
} catch(Throwable e) {/*Do nothing*/}
|
} catch(Throwable e) {/*Do nothing*/}
|
||||||
try {
|
try {
|
||||||
return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = BaseMetaTileEntity.class).newInstance();
|
return (BaseMetaTileEntity)(sBaseMetaTileEntityClass = BaseMetaTileEntity.class).newInstance();
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
aNBT.setString ("mOwnerName" , mOwnerName);
|
aNBT.setString ("mOwnerName" , mOwnerName);
|
||||||
aNBT.setBoolean ("mLockUpgrade" , mLockUpgrade);
|
aNBT.setBoolean ("mLockUpgrade" , mLockUpgrade);
|
||||||
aNBT.setBoolean ("mMuffler" , mMuffler);
|
aNBT.setBoolean ("mMuffler" , mMuffler);
|
||||||
aNBT.setBoolean ("mMJConverter" , mRFConverter);
|
aNBT.setBoolean ("mRFConverter" , mRFConverter);
|
||||||
aNBT.setBoolean ("mSteamConverter" , mSteamConverter);
|
aNBT.setBoolean ("mSteamConverter" , mSteamConverter);
|
||||||
aNBT.setBoolean ("mActive" , mActive);
|
aNBT.setBoolean ("mActive" , mActive);
|
||||||
aNBT.setBoolean ("mRedstone" , mRedstone);
|
aNBT.setBoolean ("mRedstone" , mRedstone);
|
||||||
|
@ -521,6 +521,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
|
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
|
||||||
NBTTagCompound data = packet.func_148857_g();
|
NBTTagCompound data = packet.func_148857_g();
|
||||||
|
mRFConverter = data.getBoolean("oRFUpgrade");
|
||||||
this.receiveMetaTileEntityData(data.getShort("mID"),
|
this.receiveMetaTileEntityData(data.getShort("mID"),
|
||||||
data.getIntArray("mCoverSides"),
|
data.getIntArray("mCoverSides"),
|
||||||
data.getByte("oTextureData"),
|
data.getByte("oTextureData"),
|
||||||
|
@ -537,6 +538,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
data.setByte("oTextureData", oTextureData = (byte)((getFrontFacing() & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)));
|
data.setByte("oTextureData", oTextureData = (byte)((getFrontFacing() & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)));
|
||||||
data.setByte("oUpdateData", oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0);
|
data.setByte("oUpdateData", oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0);
|
||||||
data.setByte("oColor", oColor = mColor);
|
data.setByte("oColor", oColor = mColor);
|
||||||
|
data.setBoolean("oRFUpgrade", mRFConverter);
|
||||||
data.setByte("oRedstoneData", oRedstoneData = (byte)(
|
data.setByte("oRedstoneData", oRedstoneData = (byte)(
|
||||||
((mSidedRedstone[0] > 0) ? 1 : 0) |
|
((mSidedRedstone[0] > 0) ? 1 : 0) |
|
||||||
((mSidedRedstone[1] > 0) ? 2 : 0) |
|
((mSidedRedstone[1] > 0) ? 2 : 0) |
|
||||||
|
@ -566,6 +568,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
((mSidedRedstone[4] > 0) ? 16 : 0) |
|
((mSidedRedstone[4] > 0) ? 16 : 0) |
|
||||||
((mSidedRedstone[5] > 0) ? 32 : 0)));
|
((mSidedRedstone[5] > 0) ? 32 : 0)));
|
||||||
tOut.aColorData = (oColor = mColor);
|
tOut.aColorData = (oColor = mColor);
|
||||||
|
tOut.aRFUpgrade = mRFConverter;
|
||||||
oLightValue = oLightValueClient = -1;
|
oLightValue = oLightValueClient = -1;
|
||||||
return tOut;
|
return tOut;
|
||||||
}
|
}
|
||||||
|
@ -654,8 +657,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer)?" ":" not ") + "accessible for you");
|
tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer)?" ":" not ") + "accessible for you");
|
||||||
}
|
}
|
||||||
if (aLogLevel > 0) {
|
if (aLogLevel > 0) {
|
||||||
if (getRFCapacity() > 0 && hasRFConverterUpgrade()) tList.add(getStoredRF() + " of " + getRFCapacity() + " MJ");
|
if (getRFCapacity() > 0 && hasRFConverterUpgrade()) tList.add("RF energy strored: " + getStoredRF() + " of " + getRFCapacity() + " RF");
|
||||||
if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam");
|
if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) tList.add("Steam stored: " + getStoredSteam() + " of " + getSteamCapacity() + " Steam");
|
||||||
tList.add("Machine is " + (mActive?"active":"inactive"));
|
tList.add("Machine is " + (mActive?"active":"inactive"));
|
||||||
if (mNeedsBatteryUpgrade && isBatteryUpgradable(10000, (byte)1)) tList.add("WARNING: Requires more Energy Capacity to work! Add Battery Upgrades!");
|
if (mNeedsBatteryUpgrade && isBatteryUpgradable(10000, (byte)1)) tList.add("WARNING: Requires more Energy Capacity to work! Add Battery Upgrades!");
|
||||||
if (!mHasEnoughEnergy) tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process.");
|
if (!mHasEnoughEnergy) tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process.");
|
||||||
|
@ -709,14 +712,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
@Override public boolean isActive() {return mActive;}
|
@Override public boolean isActive() {return mActive;}
|
||||||
@Override public void setActive(boolean aActive) {mActive = aActive;}
|
@Override public void setActive(boolean aActive) {mActive = aActive;}
|
||||||
@Override public long getTimer() {return mTickTimer;}
|
@Override public long getTimer() {return mTickTimer;}
|
||||||
@Override public boolean decreaseStoredEnergyUnits(int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (getUniversalEnergyCapacity() < aEnergy) mNeedsBatteryUpgrade = true; return mHasEnoughEnergy = decreaseStoredMJ(aEnergy, false) || decreaseStoredSteam(aEnergy, false) || decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || (aIgnoreTooLessEnergy && (decreaseStoredMJ(aEnergy, true) || decreaseStoredSteam(aEnergy, true)));}
|
@Override public boolean decreaseStoredEnergyUnits(int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (getUniversalEnergyCapacity() < aEnergy) mNeedsBatteryUpgrade = true; return mHasEnoughEnergy = decreaseStoredRF(aEnergy * 8, false) || decreaseStoredSteam(aEnergy, false) || decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || (aIgnoreTooLessEnergy && (decreaseStoredRF(aEnergy * 8, true) || decreaseStoredSteam(aEnergy, true)));}
|
||||||
@Override public boolean increaseStoredEnergyUnits(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) {setStoredEU(mMetaTileEntity.getEUVar() + aEnergy); return true;} return false;}
|
@Override public boolean increaseStoredEnergyUnits(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) {setStoredEU(mMetaTileEntity.getEUVar() + aEnergy); return true;} return false;}
|
||||||
@Override public boolean inputEnergyFrom(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUInputs [aSide]:false)&&!mReleaseEnergy; return isEnergyInputSide (aSide);}
|
@Override public boolean inputEnergyFrom(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUInputs [aSide]:false)&&!mReleaseEnergy; return isEnergyInputSide (aSide);}
|
||||||
@Override public boolean outputsEnergyTo(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUOutputs[aSide]:false)|| mReleaseEnergy; return isEnergyOutputSide(aSide);}
|
@Override public boolean outputsEnergyTo(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUOutputs[aSide]:false)|| mReleaseEnergy; return isEnergyOutputSide(aSide);}
|
||||||
@Override public int getOutputAmperage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUPulses()==1&&mMetaTileEntity.isTransformingLowEnergy()&&mTransformers>0?4:mMetaTileEntity.maxEUPulses(); return 0;}
|
@Override public int getOutputAmperage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUPulses()==1&&mMetaTileEntity.isTransformingLowEnergy()&&mTransformers>0?4:mMetaTileEntity.maxEUPulses(); return 0;}
|
||||||
@Override public int getOutputVoltage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) return mMetaTileEntity.maxEUOutput() * (mTransformers>0?(int)Math.pow(4, mTransformers-(mMetaTileEntity.isTransformingLowEnergy()?1:0)):1); return 0;}
|
@Override public int getOutputVoltage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) return mMetaTileEntity.maxEUOutput() * (mTransformers>0?(int)Math.pow(4, mTransformers-(mMetaTileEntity.isTransformingLowEnergy()?1:0)):1); return 0;}
|
||||||
@Override public int getInputVoltage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput()*(int)Math.pow(4, mTransformers); return mMetaTileEntity.isElectric()?Integer.MAX_VALUE:0;}
|
@Override public int getInputVoltage() {if (hasValidMetaTileEntity() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput()*(int)Math.pow(4, mTransformers); return mMetaTileEntity.isElectric()?Integer.MAX_VALUE:0;}
|
||||||
@Override public boolean increaseStoredRF(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getRFVar() < getRFCapacity() || aIgnoreTooMuchEnergy) {setStoredMJ(mMetaTileEntity.getRFVar() + aEnergy); return true;} return false;}
|
@Override public boolean increaseStoredRF(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getRFVar() < getRFCapacity() || aIgnoreTooMuchEnergy) {setStoredRF(mMetaTileEntity.getRFVar() + aEnergy); return true;} return false;}
|
||||||
@Override public boolean increaseStoredSteam(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy); return true;} return false;}
|
@Override public boolean increaseStoredSteam(int aEnergy, boolean aIgnoreTooMuchEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy); return true;} return false;}
|
||||||
@Override public String getDescription() {if (hasValidMetaTileEntity()) return mMetaTileEntity.getDescription(); return "";}
|
@Override public String getDescription() {if (hasValidMetaTileEntity()) return mMetaTileEntity.getDescription(); return "";}
|
||||||
@Override public boolean isValidSlot(int aIndex) {if (hasValidMetaTileEntity()) return mMetaTileEntity.isValidSlot(aIndex); return false;}
|
@Override public boolean isValidSlot(int aIndex) {if (hasValidMetaTileEntity()) return mMetaTileEntity.isValidSlot(aIndex); return false;}
|
||||||
|
@ -737,10 +740,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
protected boolean hasValidMetaTileEntity() {return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this;}
|
protected boolean hasValidMetaTileEntity() {return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this;}
|
||||||
|
|
||||||
public boolean setStoredEU (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setEUVar (aEnergy); return true;}
|
public boolean setStoredEU (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setEUVar (aEnergy); return true;}
|
||||||
public boolean setStoredMJ (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setRFVar (aEnergy); return true;}
|
public boolean setStoredRF (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setRFVar (aEnergy); return true;}
|
||||||
public boolean setStoredSteam (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setSteamVar (aEnergy); return true;}
|
public boolean setStoredSteam (int aEnergy) {if (!hasValidMetaTileEntity()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setSteamVar (aEnergy); return true;}
|
||||||
public boolean decreaseStoredEU (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredEU (mMetaTileEntity.getEUVar() - aEnergy); if (mMetaTileEntity.getEUVar() < 0) {setStoredEU (0); return false;} return true;} return false;}
|
public boolean decreaseStoredEU (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredEU (mMetaTileEntity.getEUVar() - aEnergy); if (mMetaTileEntity.getEUVar() < 0) {setStoredEU (0); return false;} return true;} return false;}
|
||||||
public boolean decreaseStoredMJ (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getRFVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredMJ (mMetaTileEntity.getRFVar() - aEnergy); if (mMetaTileEntity.getRFVar() < 0) {setStoredMJ (0); return false;} return true;} return false;}
|
public boolean decreaseStoredRF (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getRFVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredRF (mMetaTileEntity.getRFVar() - aEnergy); if (mMetaTileEntity.getRFVar() < 0) {setStoredRF (0); return false;} return true;} return false;}
|
||||||
public boolean decreaseStoredSteam (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy); if (mMetaTileEntity.getSteamVar() < 0) {setStoredSteam(0); return false;} return true;} return false;}
|
public boolean decreaseStoredSteam (int aEnergy, boolean aIgnoreTooLessEnergy) {if (!hasValidMetaTileEntity()) return false; if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy); if (mMetaTileEntity.getSteamVar() < 0) {setStoredSteam(0); return false;} return true;} return false;}
|
||||||
|
|
||||||
public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) {if (!hasValidMetaTileEntity()) return false; if (aCheckPrecicely || unbreakable() || privateAccess() || mOwnerName.equals("")) if (mOwnerName.equals("")&&isServerSide()) setOwnerName(aPlayer.getDisplayName()); else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) return false; return true;}
|
public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) {if (!hasValidMetaTileEntity()) return false; if (aCheckPrecicely || unbreakable() || privateAccess() || mOwnerName.equals("")) if (mOwnerName.equals("")&&isServerSide()) setOwnerName(aPlayer.getDisplayName()); else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) return false; return true;}
|
||||||
|
@ -777,7 +780,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
NBTTagCompound tNBT = new NBTTagCompound();
|
NBTTagCompound tNBT = new NBTTagCompound();
|
||||||
if (mMuffler ) tNBT.setBoolean ("mMuffler" , mMuffler);
|
if (mMuffler ) tNBT.setBoolean ("mMuffler" , mMuffler);
|
||||||
if (mLockUpgrade ) tNBT.setBoolean ("mLockUpgrade" , mLockUpgrade);
|
if (mLockUpgrade ) tNBT.setBoolean ("mLockUpgrade" , mLockUpgrade);
|
||||||
if (mRFConverter ) tNBT.setBoolean ("mMJConverter" , mRFConverter);
|
if (mRFConverter ) tNBT.setBoolean ("mRFConverter" , mRFConverter);
|
||||||
if (mSteamConverter ) tNBT.setBoolean ("mSteamConverter" , mSteamConverter);
|
if (mSteamConverter ) tNBT.setBoolean ("mSteamConverter" , mSteamConverter);
|
||||||
if (mColor > 0) tNBT.setByte ("mColor" , mColor);
|
if (mColor > 0) tNBT.setByte ("mColor" , mColor);
|
||||||
if (mTransformers > 0) tNBT.setByte ("mTransformers" , mTransformers);
|
if (mTransformers > 0) tNBT.setByte ("mTransformers" , mTransformers);
|
||||||
|
@ -1190,19 +1193,27 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMufflerUpgrade() {
|
public boolean addMufflerUpgrade() {
|
||||||
if (isMufflerUpgradable()) return mMuffler = true;
|
if (isMufflerUpgradable()) {
|
||||||
|
issueBlockUpdate();
|
||||||
|
return mMuffler = true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRFConverterUpgrade() {
|
public boolean addRFConverterUpgrade() {
|
||||||
if (isRFConverterUpgradable()) return mRFConverter = true;
|
if (isRFConverterUpgradable()) {
|
||||||
|
getWorld().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
issueBlockUpdate();
|
||||||
|
return mRFConverter = true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addOverclockerUpgrade() {
|
public boolean addOverclockerUpgrade() {
|
||||||
if (isOverclockerUpgradable()) {
|
if (isOverclockerUpgradable()) {
|
||||||
|
issueBlockUpdate();
|
||||||
mOverclockers++;
|
mOverclockers++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1212,6 +1223,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
@Override
|
@Override
|
||||||
public boolean addTransformerUpgrade() {
|
public boolean addTransformerUpgrade() {
|
||||||
if (isTransformerUpgradable()) {
|
if (isTransformerUpgradable()) {
|
||||||
|
issueBlockUpdate();
|
||||||
mTransformers++;
|
mTransformers++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1222,6 +1234,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
public boolean addBatteryUpgrade(int aStorage, byte aTier) {
|
public boolean addBatteryUpgrade(int aStorage, byte aTier) {
|
||||||
mNeedsBatteryUpgrade = false;
|
mNeedsBatteryUpgrade = false;
|
||||||
if (isBatteryUpgradable(aStorage, aTier)) {
|
if (isBatteryUpgradable(aStorage, aTier)) {
|
||||||
|
issueBlockUpdate();
|
||||||
mUpgradedStorage+=aStorage;
|
mUpgradedStorage+=aStorage;
|
||||||
mOtherUpgrades++;
|
mOtherUpgrades++;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,65 +1,42 @@
|
||||||
package gregtechmod.api.metatileentity;
|
package gregtechmod.api.metatileentity;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
||||||
*
|
*
|
||||||
* This file contains all the needed 'implements' of the Interfaces for the Michael Jackson Stuff.
|
* This file contains all the needed 'implements' of the Interfaces for the Michael Jackson Stuff.
|
||||||
*/
|
*/
|
||||||
public class BaseMetaTileEntityRF extends BaseMetaTileEntity /*implements IEnergyHandler*/ {
|
public class BaseMetaTileEntityRF extends BaseMetaTileEntity implements IEnergyHandler {
|
||||||
/*
|
|
||||||
IPowerProvider mProvider;
|
|
||||||
|
|
||||||
public BaseMetaTileEntityMJ() {
|
@Override
|
||||||
super();
|
public boolean canConnectEnergy(ForgeDirection from) {
|
||||||
|
return hasRFConverterUpgrade() && inputEnergyFrom((byte)from.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus() {
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||||
super.updateStatus();
|
if (inputEnergyFrom((byte)from.ordinal()) && getRFCapacity() - getStoredRF() > 0) {
|
||||||
if (hasMJConverterUpgrade()) {
|
int energy = Math.min(maxReceive, getRFCapacity() - getStoredRF());
|
||||||
if (mProvider == null) {
|
return simulate ? energy : (mStoredRF += energy);
|
||||||
mProvider = PowerFramework.currentFramework.createPowerProvider();
|
|
||||||
mProvider.configure(100, 1, 100, 1, 10000);
|
|
||||||
} else {
|
|
||||||
if (getMJCapacity() > 0 && getStoredMJ() < getMJCapacity()) {
|
|
||||||
increaseStoredMJ((int)mProvider.useEnergy(1, getMJCapacity() - getStoredMJ(), true), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPowerProvider(IPowerProvider aProvider) {
|
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||||
mProvider = aProvider;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPowerProvider getPowerProvider() {
|
public int getEnergyStored(ForgeDirection from) {
|
||||||
return mProvider;
|
return hasRFConverterUpgrade() ? getStoredRF() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doWork() {
|
public int getMaxEnergyStored(ForgeDirection from) {
|
||||||
|
return hasRFConverterUpgrade() ? getRFCapacity() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int powerRequest(ForgeDirection aSide) {
|
|
||||||
if (getPowerProvider() == null || !hasValidMetaTileEntity()) return 0;
|
|
||||||
if (!getMetaTileEntity().isEnetInput() || !getCoverBehaviorAtSide((byte)aSide.ordinal()).letsEnergyIn((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), this)) return 0;
|
|
||||||
return (int) Math.ceil(Math.min(getPowerProvider().getMaxEnergyReceived(), getPowerProvider().getMaxEnergyStored() - getPowerProvider().getEnergyStored()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doWork(PowerHandler workProvider) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
}
|
|
@ -655,6 +655,7 @@ public class GT_BlockMetaID_Machine extends BlockContainer implements IDebugable
|
||||||
if (!aWorld.isRemote && tTileEntity instanceof GT_TileEntityMetaID_Machine) {
|
if (!aWorld.isRemote && tTileEntity instanceof GT_TileEntityMetaID_Machine) {
|
||||||
if (((GT_TileEntityMetaID_Machine) tTileEntity).isUseableByPlayer(aPlayer)) {
|
if (((GT_TileEntityMetaID_Machine) tTileEntity).isUseableByPlayer(aPlayer)) {
|
||||||
((GT_TileEntityMetaID_Machine) tTileEntity).openGUI(aPlayer, aWorld.getBlockMetadata(aX, aY, aZ));
|
((GT_TileEntityMetaID_Machine) tTileEntity).openGUI(aPlayer, aWorld.getBlockMetadata(aX, aY, aZ));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class GT_TileEntityPacket extends GT_Packet {
|
||||||
public byte aUpdateData;
|
public byte aUpdateData;
|
||||||
public byte aRedstoneData;
|
public byte aRedstoneData;
|
||||||
public byte aColorData;
|
public byte aColorData;
|
||||||
|
public boolean aRFUpgrade;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
@ -33,6 +34,7 @@ public class GT_TileEntityPacket extends GT_Packet {
|
||||||
aUpdateData = buf.readByte();
|
aUpdateData = buf.readByte();
|
||||||
aRedstoneData = buf.readByte();
|
aRedstoneData = buf.readByte();
|
||||||
aColorData = buf.readByte();
|
aColorData = buf.readByte();
|
||||||
|
aRFUpgrade = buf.readBoolean();
|
||||||
super.fromBytes(buf);
|
super.fromBytes(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,13 +50,14 @@ public class GT_TileEntityPacket extends GT_Packet {
|
||||||
buf.writeByte(aUpdateData);
|
buf.writeByte(aUpdateData);
|
||||||
buf.writeByte(aRedstoneData);
|
buf.writeByte(aRedstoneData);
|
||||||
buf.writeByte(aColorData);
|
buf.writeByte(aColorData);
|
||||||
|
buf.writeBoolean(aRFUpgrade);
|
||||||
super.toBytes(buf);
|
super.toBytes(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("GT_TileEntityPacket[x=%d, y=%d, z=%d, ID=%d, TextureData=%d, UpdateData=%d, RedstoneData=%d, ColorData=%d, CoverData=%s]",
|
return String.format("GT_TileEntityPacket[x=%d, y=%d, z=%d, ID=%d, TextureData=%d, UpdateData=%d, RedstoneData=%d, ColorData=%d, RFUpgrade=%s, CoverData=%s]",
|
||||||
aX, aY, aZ, (int)aID, (int)aTextureData, (int)aUpdateData, (int)aRedstoneData, (int)aColorData,
|
aX, aY, aZ, (int)aID, (int)aTextureData, (int)aUpdateData, (int)aRedstoneData, (int)aColorData, aRFUpgrade,
|
||||||
Arrays.stream(aCovers).mapToObj(i -> new Integer(i)).collect(Collectors.toList()).toString());
|
Arrays.stream(aCovers).mapToObj(i -> new Integer(i)).collect(Collectors.toList()).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in a new issue