diff options
Diffstat (limited to 'src/main/java/gregtech')
6 files changed, 113 insertions, 59 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index de81b09cec..5cd09577fa 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -207,13 +207,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (aID <= 0 || aID >= GregTech_API.METATILEENTITIES.length || GregTech_API.METATILEENTITIES[aID] == null) { GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!"); } else { - if (aID != 0) { - if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; - } + if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); + GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); + mTickTimer = 0; + mID = aID; + return true; } return false; } @@ -251,8 +249,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mRunningThroughTick = true; long tTime = System.currentTimeMillis(); + int tCode = 0; + boolean aSideServer = isServerSide(); + boolean aSideClient = isClientSide(); - try { for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) { case 0: tCode++; @@ -260,13 +261,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE oX = xCoord; oY = yCoord; oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) + if (aSideServer) for (byte i = 0; i < 6; i++) if (getCoverIDAtSide(i) != 0) if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) dropCover(i, i, true); - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - mMetaTileEntity.onFirstTick(this); if (!hasValidMetaTileEntity()) { mRunningThroughTick = false; @@ -275,7 +274,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 1: tCode++; - if (isClientSide()) { + if (aSideClient) { if (mColor != oColor) { mMetaTileEntity.onColorChangeClient(oColor = mColor); issueTextureUpdate(); @@ -306,7 +305,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE case 5: case 6: case 7: - if (isServerSide() && mTickTimer > 10) { + if (aSideServer && mTickTimer > 10) { for (byte i = (byte) (tCode - 2); i < 6; i++) if (getCoverIDAtSide(i) != 0) { tCode++; @@ -324,7 +323,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 8: tCode = 9; - if (isServerSide()) { + if (aSideServer) { if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; @@ -340,7 +339,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 10: tCode++; - if (isServerSide()) { + if (aSideServer) { if (mRedstone != oRedstone || mTickTimer == 10) { for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); @@ -413,10 +412,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { if (getRandomNumber(10) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } + try{GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");}catch(Exception e){} doEnergyExplosion(); } else setOnFire(); } @@ -425,10 +421,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return; } if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } + try{GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");}catch(Exception e){} doEnergyExplosion(); } } @@ -443,7 +436,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 11: tCode++; - if (isServerSide()) { + if (aSideServer) { if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { @@ -457,7 +450,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 12: tCode++; - if (isServerSide()) { + if (aSideServer) { if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { @@ -485,7 +478,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 15: tCode++; - if (isServerSide()) { + if (aSideServer) { if (mTickTimer % 10 == 0) { if (mSendClientData) { NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); @@ -522,14 +515,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } default: tCode = -1; - break; - }} + } + } } catch (Throwable e) { - //gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); + //gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } - if (isServerSide() && hasValidMetaTileEntity()) { + if (aSideServer && hasValidMetaTileEntity()) { tTime = System.currentTimeMillis() - tTime; if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; @@ -588,7 +581,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); -// mLockUpgrade = ((aValue&32) != 0); + //mLockUpgrade = ((aValue&32) != 0); break; case 1: if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); @@ -598,12 +591,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mColor = (byte) aValue; break; case 3: - mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); + mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); + mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); + mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); + mSidedRedstone[3] = (byte) ((aValue & 8) == 8 ? 15 : 0); + mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); + mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); break; case 4: if (hasValidMetaTileEntity() && mTickTimer > 20) @@ -1076,8 +1069,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) { if (!canAccessData()) return false; - if (aCheckPrecicely || privateAccess() || mOwnerName.equals("")) - if (mOwnerName.equals("") && isServerSide()) setOwnerName(aPlayer.getDisplayName()); + if (aCheckPrecicely || privateAccess() || (mOwnerName.length() == 0)) + if ((mOwnerName.length() == 0) && isServerSide()) setOwnerName(aPlayer.getDisplayName()); else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) return false; return true; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index ee45c536b5..049f34dfba 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -112,10 +112,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } if (mSolderingTool && aPlayer instanceof EntityPlayerMP) { EntityPlayerMP tPlayer = (EntityPlayerMP) aPlayer; - try { - GT_Mod.instance.achievements.issueAchievement(tPlayer, "maintainance"); - } catch (Exception e) { - } + try{GT_Mod.instance.achievements.issueAchievement(tPlayer, "maintainance");}catch(Exception e){} } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 313e6c5234..89349d7c0e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -241,10 +241,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { if (mOutputItems != null) for (ItemStack tStack : mOutputItems) if (tStack != null) { - try { - GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); - } catch (Exception e) { - } + try{GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack);}catch(Exception e){} addOutput(tStack); } if (mOutputFluids != null && mOutputFluids.length == 1) { @@ -417,7 +414,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { NBTTagCompound tNBT = mInventory[1].getTagCompound(); if (tNBT != null) { - NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");//tNBT2 dont use out if if (!tNBT.getBoolean("mDis")) { tNBT2 = new NBTTagCompound(); Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index feeeafe4b0..743a1c5ceb 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -1,28 +1,85 @@ -package gregtech.common; + package gregtech.common; +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.util.GT_Utility; +import net.minecraft.client.Minecraft; import net.minecraft.world.ChunkPosition; +import net.minecraft.world.WorldManager; public class GT_Pollution { -// List<ChunkPosition> list = new ArrayList<ChunkPosition>(chunkData.keySet()); + static List<ChunkPosition> tList = null; + static int loops = 1; public static void onWorldTick(int aTick){ - + if(aTick == 0 || (tList==null && GT_Proxy.chunkData!=null)){ + tList = new ArrayList<ChunkPosition>(GT_Proxy.chunkData.keySet()); + loops = (tList.size()/1200) + 1; + } + if(tList!=null && tList.size() > 0){ + int i = 0; + for(; i < loops ; i++){ + ChunkPosition tPos = tList.get(0); + tList.remove(0); + if(tPos!=null && GT_Proxy.chunkData.containsKey(tPos)){ + int tPollution = GT_Proxy.chunkData.get(tPos)[1]; +// System.out.println("process: "+tPos.chunkPosX+" "+tPos.chunkPosZ+" "+tPollution); + //Reduce pollution in chunk + tPollution = (int)(0.99f*tPollution); + tPollution -= 2000; + if(tPollution<=0){tPollution = 0;}else{ + //Spread Pollution + if(tPollution>50000){ + List<ChunkPosition> tNeighbor = new ArrayList(); + tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, 1, tPos.chunkPosZ+1)); + tNeighbor.add(new ChunkPosition(tPos.chunkPosX+1, 1, tPos.chunkPosZ-1)); + tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, 1, tPos.chunkPosZ+1)); + tNeighbor.add(new ChunkPosition(tPos.chunkPosX-1, 1, tPos.chunkPosZ-1)); + for(ChunkPosition tNPos : tNeighbor){ + if(GT_Proxy.chunkData.containsKey(tNPos)){ + int tNPol = GT_Proxy.chunkData.get(tNPos)[1]; + if(tNPol<tPollution){ + int tDiff = tPollution - tNPol; + tDiff = tDiff/10; + tNPol += tDiff; + tPollution -= tDiff; + GT_Proxy.chunkData.get(tNPos)[1] = tNPol; + } + }else{ + GT_Utility.getUndergroundOil(Minecraft.getMinecraft().theWorld,tPos.chunkPosX*16,tPos.chunkPosZ*16); + } + }} + int[] tArray = GT_Proxy.chunkData.get(tPos); + tArray[1] = tPollution; + GT_Proxy.chunkData.remove(tPos); + GT_Proxy.chunkData.put(tPos, tArray); + //Create Pollution effects + + } + } + } + } } public static void addPollution(ChunkPosition aPos, int aPollution){ + try{ + ChunkPosition tPos = new ChunkPosition(aPos.chunkPosX/16, 1, aPos.chunkPosZ/16); +// System.out.println("add pollution x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution); int[] tData = new int[2]; - if(GT_Proxy.chunkData.containsKey(aPos)){ - tData = GT_Proxy.chunkData.get(aPos); + if(GT_Proxy.chunkData.containsKey(tPos)){ + tData = GT_Proxy.chunkData.get(tPos); if(tData.length>1){ tData[1] += aPollution; } - GT_Proxy.chunkData.replace(aPos, tData); }else{ tData[1] += aPollution; - GT_Proxy.chunkData.put(aPos, tData); + GT_Proxy.chunkData.put(tPos, tData); + } + }catch(Exception e){ + } - } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 00668ffba8..38a1425a3e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -51,7 +51,7 @@ public class GT_MetaTileEntity_DistillationTower "1x Output Bus (Any bottom layer casing)", "1x Maintenance Hatch (Any casing)", "1x Energy Hatch (Any casing)", - "Clean Stainless Steel Casings for the rest (26 at least!)"}; + "Clean Stainless Steel Casings for the rest (36 at least!)"}; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -172,7 +172,8 @@ public class GT_MetaTileEntity_DistillationTower for (int i = 0; i < tmpHatches.length; i++) { this.mOutputHatches.add(tmpHatches[i]); } - return tAmount >= 26; + if(this.mMaintenanceHatches.size()!=1)return false; + return tAmount >= 36; } public boolean ignoreController(Block tTileEntity) { diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index d05ccf6208..40639a040b 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -1786,7 +1786,7 @@ public class GT_MachineRecipeLoader implements Runnable { addProcess(tCrop, Materials.Galena, 100); tCrop = ItemList.Crop_Drop_Aurelia.get(1, new Object[0]); addProcess(tCrop, Materials.Gold, 100); - addProcess(tCrop, Materials.Magnetite, 100); + addProcess(tCrop, Materials.Magnetite, Materials.Gold, 100); // Rare Metals Line tCrop = ItemList.Crop_Drop_Bauxite.get(1, new Object[0]); @@ -1847,6 +1847,15 @@ public class GT_MachineRecipeLoader implements Runnable { GT_ModHandler.addExtractionRecipe(tCrop, GT_OreDictUnificator.get(OrePrefixes.dustTiny, aMaterial, 1)); } } + + public void addProcess(ItemStack tCrop, Materials aMaterial, Materials aMaterialOut, int chance){ + if(GT_Mod.gregtechproxy.mNerfedCombs){ + GT_Values.RA.addChemicalRecipe(GT_Utility.copyAmount(9, tCrop), GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1), Materials.Water.getFluid(1000), aMaterialOut.mOreByProducts.isEmpty() ? null : aMaterialOut.mOreByProducts.get(0).getMolten(144), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aMaterialOut, 4), 96, 24); + GT_Values.RA.addAutoclaveRecipe(GT_Utility.copyAmount(16, tCrop), Materials.UUMatter.getFluid(Math.max(1, ((aMaterial.getMass()+9)/10))), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aMaterial, 1), 10000, (int) (aMaterial.getMass() * 128), 384); + }else{ + GT_ModHandler.addExtractionRecipe(tCrop, GT_OreDictUnificator.get(OrePrefixes.dustTiny, aMaterial, 1)); +} + } private void run2(){ |