aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-25 10:10:01 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-25 10:10:01 +1000
commit83a72ed129bafdf25ab87e45521a1a22a3afc23e (patch)
treef2dc209e9b04c1aee7b56fc5fd186e5ef6385c96
parent65311311dea3d369bda4d7290143d28b0e711270 (diff)
downloadGT5-Unofficial-83a72ed129bafdf25ab87e45521a1a22a3afc23e.tar.gz
GT5-Unofficial-83a72ed129bafdf25ab87e45521a1a22a3afc23e.tar.bz2
GT5-Unofficial-83a72ed129bafdf25ab87e45521a1a22a3afc23e.zip
+ Initial addition of the TC Researcher.
% Tweaked changelog start point.
-rw-r--r--build.gradle4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java404
2 files changed, 406 insertions, 2 deletions
diff --git a/build.gradle b/build.gradle
index 659f512e5b..286309d2c7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -79,14 +79,14 @@ repositories {
task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
file = new File("CHANGELOG ${project.version}.md");
untaggedName = "Current release ${project.version}"
- fromCommit = "a580c9245097b5bddcfbab0d49d7667aec836b93"
+ fromCommit = "e3a9829150afd77c0a00cb85be8b7c450d120dd1"
toRef = "HEAD"
templateContent = file('changelog.mustache').getText('UTF-8')
}
task curseChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
file = new File("CHANGELOG Curse ${project.version}.md");
untaggedName = "Current Curse release ${project.version}"
- fromCommit = "1e6bf5e889344acabacec633f7be1aabcfbf4e0e"
+ fromCommit = "e3a9829150afd77c0a00cb85be8b7c450d120dd1"
toRef = "HEAD"
templateContent = file('changelogcurse.mustache').getText('UTF-8')
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java
new file mode 100644
index 0000000000..43c3ff7542
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java
@@ -0,0 +1,404 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+
+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.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+
+public class GregtechMetaTileEntityThaumcraftResearcher extends GregtechMetaTileEntity {
+
+ int mCurrentPollution;
+ int mAveragePollution;
+ int mAveragePollutionArray[] = new int[10];
+ private int mArrayPos = 0;
+ private int mTickTimer = 0;
+ private int mSecondTimer = 0;
+
+ public GregtechMetaTileEntityThaumcraftResearcher(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 GregtechMetaTileEntityThaumcraftResearcher(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, "A useful debug machine to create pollution.", 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 (pollutionMultiplier >= 9){
+ pollutionMultiplier = 1;
+ }
+ else {
+ pollutionMultiplier++;
+ }
+ PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now "+pollutionMultiplier+".");
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaTileEntityThaumcraftResearcher(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 0;}
+
+ @Override
+ public int getCapacity() {
+ return 0;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return 0;
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return 0;
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return 0;
+ }
+
+ @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;
+ }
+ this.showPollution(aPlayer.getEntityWorld(), aPlayer);
+ return true;
+ }
+
+ public int pollutionMultiplier = 1;
+
+ private void showPollution(final World worldIn, final EntityPlayer playerIn){
+ if(!PollutionUtils.mPollution()){
+ PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled.");
+ }
+ else {
+ addPollution();
+ PlayerUtils.messagePlayer(playerIn, "This chunk now contains "+getCurrentChunkPollution()+" pollution.");
+ //PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution.");
+ }
+ }
+
+ private boolean addPollution(){
+ PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000*pollutionMultiplier);
+ return true;
+ }
+
+ @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;
+ }
+
+ public int getCurrentChunkPollution(){
+ return getCurrentChunkPollution(this.getBaseMetaTileEntity());
+ }
+
+ public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){
+ return PollutionUtils.getPollution(aBaseMetaTileEntity);
+ }
+
+
+ @Override
+ public String[] getInfoData() {
+ return new String[] {
+ this.getLocalName(),
+ "Current Pollution: "+this.mCurrentPollution,
+ "Average/10 minutes:"+getAveragePollutionOverLastTen()};
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
+ return new int[] {};
+ }
+
+ @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;
+ }
+
+ //int mCurrentPollution;
+ //int mAveragePollution;
+ //int mAveragePollutionArray[] = new int[10];
+
+ @Override
+ public void saveNBTData(final NBTTagCompound aNBT) {
+ aNBT.setInteger("mCurrentPollution", this.mCurrentPollution);
+ aNBT.setInteger("mAveragePollution", this.mAveragePollution);
+ }
+
+ @Override
+ public void loadNBTData(final NBTTagCompound aNBT) {
+ this.mCurrentPollution = aNBT.getInteger("mCurrentPollution");
+ this.mAveragePollution = aNBT.getInteger("mAveragePollution");
+ }
+
+ @Override
+ public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ if (this.mCurrentPollution == 0) {
+ this.mCurrentPollution = getCurrentChunkPollution();
+ }
+ if (this.mArrayPos < 0 || this.mArrayPos > 9) {
+ this.mArrayPos = 0;
+ }
+ this.mTickTimer = 0;
+ }
+ }
+
+
+
+ @Override
+ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ //TickTimer - 20 times a second
+ if (this.mTickTimer >= 0 || this.mTickTimer <= 19){
+ this.mTickTimer++;
+ }
+ else {
+ this.mTickTimer = 0;
+ //Perform pollution update once a second
+ this.mCurrentPollution = getCurrentChunkPollution();
+ this.mSecondTimer++;
+ }
+ //Update Pollution array once a minute
+ if (this.mSecondTimer >= 60){
+ Utils.sendServerMessage("Udating Average of pollution array. Using Array slot"+this.mArrayPos);
+ this.mSecondTimer = 0;
+ if (this.mArrayPos<this.mAveragePollutionArray.length){
+ this.mAveragePollutionArray[this.mArrayPos] = this.mCurrentPollution;
+ this.mArrayPos++;
+ }
+ else if (this.mArrayPos==this.mAveragePollutionArray.length){
+ this.mAveragePollutionArray[this.mArrayPos] = this.mCurrentPollution;
+ this.mArrayPos = 0;
+ }
+ }
+ }
+ }
+
+ public int getAveragePollutionOverLastTen(){
+ int counter = 0;
+ int total = 0;
+
+ for (int i=0;i<this.mAveragePollutionArray.length;i++){
+ if (this.mAveragePollutionArray[i] != 0){
+ total += this.mAveragePollutionArray[i];
+ counter++;
+ }
+ }
+ int returnValue = 0;
+ if (total > 0 && counter > 0){
+ returnValue = (total/counter);
+ this.mAveragePollution = returnValue;
+ }
+ else {
+ returnValue = getCurrentChunkPollution();
+ }
+ Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" |");
+ return returnValue;
+ }
+
+} \ No newline at end of file