diff options
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 172 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java | 72 |
2 files changed, 116 insertions, 128 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index cfd0b4b880..c425278db0 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -51,7 +51,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; @@ -95,14 +94,6 @@ public class GT_Utility { GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData); } - public static int safeInt(long number, int margin){ - return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number; - } - - public static int safeInt(long number){ - return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number; - } - public static Field getPublicField(Object aObject, String aField) { Field rField = null; try { @@ -819,7 +810,7 @@ public class GT_Utility { return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack); return null; } - + public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){ if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false; boolean rReturn = false; @@ -869,10 +860,12 @@ public class GT_Utility { return false; } } + ItemStack[] tStack = GT_OreDictUnificator.getStackArray(true, aOutput); + if(tStack==null||(tStack.length>0&>_Utility.areStacksEqual(aInput, tStack[0])))return false; if (tOreName != null) { - aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, GT_OreDictUnificator.getStackArray(true, aOutput))); + aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } else { - aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, GT_OreDictUnificator.getStackArray(true, aOutput))); + aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } return true; } @@ -929,7 +922,7 @@ public class GT_Utility { } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { - return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 0.9F + new Random().nextFloat() * 0.2F, aX, aY, aZ); + return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) { @@ -1053,35 +1046,15 @@ public class GT_Utility { } public static boolean isOpaqueBlock(World aWorld, int aX, int aY, int aZ) { - boolean result; - try { - result=aWorld.getBlock(aX, aY, aZ).isOpaqueCube(); - } catch (Throwable e) { - result=true; - } - return result; - + return aWorld.getBlock(aX, aY, aZ).isOpaqueCube(); } public static boolean isBlockAir(World aWorld, int aX, int aY, int aZ) { - boolean result; - try { - result=aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ); - } catch (Throwable e) { - result=false; - } - return result; - } + return aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ); + } public static boolean hasBlockHitBox(World aWorld, int aX, int aY, int aZ) { - boolean result; - try { - result=aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null; - } catch (Throwable e) { - result=false; - } - return result; - + return aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null; } public static void setCoordsOnFire(World aWorld, int aX, int aY, int aZ, boolean aReplaceCenter) { @@ -1123,7 +1096,6 @@ public class GT_Utility { * Converts a Number to a String */ public static String parseNumberToString(int aNumber) { - String tString = E; boolean temp = true, negative = false; if (aNumber < 0) { @@ -1131,15 +1103,18 @@ public class GT_Utility { negative = true; } + StringBuilder tStringB = new StringBuilder(); for (int i = 1000000000; i > 0; i /= 10) { int tDigit = (aNumber / i) % 10; if (temp && tDigit != 0) temp = false; if (!temp) { - tString += tDigit; - if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tString += ","; + tStringB.append(tDigit); + if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(","); } } + String tString = tStringB.toString(); + if (tString.equals(E)) tString = "0"; return negative ? "-" + tString : tString; @@ -1438,7 +1413,7 @@ public class GT_Utility { Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() { @Override public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) { - return -aValue1.getValue().compareTo(aValue2.getValue()); + return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO } }); LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>(); @@ -1480,26 +1455,27 @@ public class GT_Utility { if (tTargetWorld != null && tOriginalWorld != null && tTargetWorld != tOriginalWorld) { if (aEntity.ridingEntity != null) aEntity.mountEntity(null); if (aEntity.riddenByEntity != null) aEntity.riddenByEntity.mountEntity(null); - if (aEntity instanceof EntityPlayerMP) { EntityPlayerMP aPlayer = (EntityPlayerMP) aEntity; - aPlayer.dimension = aDimension; - aPlayer.playerNetServerHandler.sendPacket(new S07PacketRespawn(aPlayer.dimension, aPlayer.worldObj.difficultySetting, aPlayer.worldObj.getWorldInfo().getTerrainType(), aPlayer.theItemInWorldManager.getGameType())); - tOriginalWorld.removePlayerEntityDangerously(aPlayer); - aPlayer.isDead = false; - aPlayer.setWorld(tTargetWorld); - MinecraftServer.getServer().getConfigurationManager().func_72375_a(aPlayer, tOriginalWorld); +// aPlayer.dimension = aDimension; +// aPlayer.playerNetServerHandler.sendPacket(new S07PacketRespawn(aPlayer.dimension, aPlayer.worldObj.difficultySetting, aPlayer.worldObj.getWorldInfo().getTerrainType(), aPlayer.theItemInWorldManager.getGameType())); +// tOriginalWorld.removePlayerEntityDangerously(aPlayer); +// aPlayer.isDead = false; +// aPlayer.setWorld(tTargetWorld); +// MinecraftServer.getServer().getConfigurationManager().func_72375_a(aPlayer, tOriginalWorld); +// aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch); +// aPlayer.theItemInWorldManager.setWorld(tTargetWorld); +// MinecraftServer.getServer().getConfigurationManager().updateTimeAndWeatherForPlayer(aPlayer, tTargetWorld); +// MinecraftServer.getServer().getConfigurationManager().syncPlayerInventory(aPlayer); +// Iterator tIterator = aPlayer.getActivePotionEffects().iterator(); +// while (tIterator.hasNext()) { +// PotionEffect potioneffect = (PotionEffect) tIterator.next(); +// aPlayer.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(aPlayer.getEntityId(), potioneffect)); +// } +// FMLCommonHandler.instance().firePlayerChangedDimensionEvent(aPlayer, tOriginalWorld.provider.dimensionId, aDimension); + aPlayer.travelToDimension(aDimension); aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch); - aPlayer.theItemInWorldManager.setWorld(tTargetWorld); - MinecraftServer.getServer().getConfigurationManager().updateTimeAndWeatherForPlayer(aPlayer, tTargetWorld); - MinecraftServer.getServer().getConfigurationManager().syncPlayerInventory(aPlayer); - Iterator tIterator = aPlayer.getActivePotionEffects().iterator(); - while (tIterator.hasNext()) { - PotionEffect potioneffect = (PotionEffect) tIterator.next(); - aPlayer.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(aPlayer.getEntityId(), potioneffect)); - } - aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch); - FMLCommonHandler.instance().firePlayerChangedDimensionEvent(aPlayer, tOriginalWorld.provider.dimensionId, aDimension); + } else { aEntity.setPosition(aX + 0.5, aY + 0.5, aZ + 0.5); aEntity.worldObj.removeEntity(aEntity); @@ -1534,7 +1510,7 @@ public class GT_Utility { public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) { - + Random tRandom = new Random((aWorld.getSeed() + (aX / 96) + (7 * (aZ / 96)))); int oil = tRandom.nextInt(3); double amount = tRandom.nextInt(50) + tRandom.nextDouble(); @@ -1561,17 +1537,17 @@ public class GT_Utility { int tAmount = (int) (Math.pow(amount, 5) / 100); ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16); int[] tInts = new int[2]; - if(GT_Proxy.chunkData.containsKey(tPos)){ - tInts = GT_Proxy.chunkData.get(tPos); - if(tInts.length>0){ - if(tInts[0]>=0){tAmount = tInts[0];} - } - GT_Proxy.chunkData.remove(tPos); - } - tAmount = tAmount - 5; - tInts[0] = tAmount; - GT_Proxy.chunkData.put(tPos, tInts); - + if(GT_Proxy.chunkData.containsKey(tPos)){ + tInts = GT_Proxy.chunkData.get(tPos); + if(tInts.length>0){ + if(tInts[0]>=0){tAmount = tInts[0];} + } + GT_Proxy.chunkData.remove(tPos); + } + tAmount = tAmount - 5; + tInts[0] = tAmount; + GT_Proxy.chunkData.put(tPos, tInts); + return new FluidStack(tFluid, tAmount); } @@ -1585,15 +1561,15 @@ public class GT_Utility { Block tBlock = aWorld.getBlock(aX, aY, aZ); - tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET + " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " -----"); + tList.add("----- X: " + aX + " Y: " + aY + " Z: " + aZ + " -----"); try { - if (tTileEntity != null && tTileEntity instanceof IInventory) - tList.add("Name: " + EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName()+EnumChatFormatting.RESET + " MetaData: " +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ)+EnumChatFormatting.RESET); + if (tTileEntity instanceof IInventory) + tList.add("Name: " + ((IInventory) tTileEntity).getInventoryName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ)); else - tList.add("Name: " +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ " MetaData: " +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ)+EnumChatFormatting.RESET); + tList.add("Name: " + tBlock.getUnlocalizedName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ)); - tList.add("Hardness: " +EnumChatFormatting.YELLOW+ tBlock.getBlockHardness(aWorld, aX, aY, aZ) +EnumChatFormatting.RESET+ " Blast Resistance: " +EnumChatFormatting.YELLOW+ tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ)+EnumChatFormatting.RESET); - if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD+"Is valid Beacon Pyramid Material"+EnumChatFormatting.RESET ); + tList.add("Hardness: " + tBlock.getBlockHardness(aWorld, aX, aY, aZ) + " Blast Resistance: " + tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ)); + if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add("Is valid Beacon Pyramid Material"); } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -1603,7 +1579,7 @@ public class GT_Utility { rEUAmount += 500; FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide)); if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) { - tList.add("Tank " + i + ": " +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) +EnumChatFormatting.RESET+ " L / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(tTanks[i].capacity) +EnumChatFormatting.RESET+ " L of " +EnumChatFormatting.GOLD+ getFluidName(tTanks[i].fluid, true)+EnumChatFormatting.RESET); + tList.add("Tank " + i + ": " + GT_Utility.formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + " / " + GT_Utility.formatNumbers(tTanks[i].capacity) + " " + getFluidName(tTanks[i].fluid, true)); } } } catch (Throwable e) { @@ -1620,8 +1596,8 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.reactor.IReactor) { rEUAmount += 500; - tList.add("Heat: " +EnumChatFormatting.GREEN+ ((ic2.api.reactor.IReactor) tTileEntity).getHeat() +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+ ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()+EnumChatFormatting.RESET); - tList.add("HEM: " +EnumChatFormatting.YELLOW+((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() +EnumChatFormatting.RESET/*+ " Base EU Output: " + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/);//TODO WHAT? + tList.add("Heat: " + ((ic2.api.reactor.IReactor) tTileEntity).getHeat() + "/" + ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat() + + " HEM: " + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() + " Base EU Output: "/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1629,8 +1605,8 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.tile.IWrenchable) { rEUAmount += 100; - tList.add("Facing: " +EnumChatFormatting.GREEN+ ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() +EnumChatFormatting.RESET+ " / Chance: " +EnumChatFormatting.YELLOW+ (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) +EnumChatFormatting.RESET+ "%"); - tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? EnumChatFormatting.GREEN+"You can remove this with a Wrench"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"You can NOT remove this with a Wrench"+EnumChatFormatting.RESET); + tList.add("Facing: " + ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() + " / Chance: " + (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) + "%"); + tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? "You can remove this with a Wrench" : "You can NOT remove this with a Wrench"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1664,7 +1640,7 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) { rEUAmount += 200; - tList.add("Conduction Loss: " +EnumChatFormatting.YELLOW+ ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss()+EnumChatFormatting.RESET); + tList.add("Conduction Loss: " + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss()); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1672,7 +1648,7 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) { rEUAmount += 200; - tList.add("Contained Energy: " +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()+EnumChatFormatting.RESET+" EU"); + tList.add("Contained Energy: " + ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() + " of " + ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()); //aList.add(((ic2.api.tile.IEnergyStorage)tTileEntity).isTeleporterCompatible(ic2.api.Direction.YP)?"Teleporter Compatible":"Not Teleporter Compatible"); } } catch (Throwable e) { @@ -1681,7 +1657,7 @@ public class GT_Utility { try { if (tTileEntity instanceof IUpgradableMachine) { rEUAmount += 500; - if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN+"Has Muffler Upgrade"+EnumChatFormatting.RESET); + if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add("Has Muffler Upgrade"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1691,7 +1667,7 @@ public class GT_Utility { rEUAmount += 400; int tValue = 0; if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress())) - tList.add("Progress: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(((IMachineProgress) tTileEntity).getProgress()/20) +EnumChatFormatting.RESET+ " s / " +EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(tValue/20) +EnumChatFormatting.RESET+" s"); + tList.add("Progress: " + GT_Utility.formatNumbers(tValue) + " / " + GT_Utility.formatNumbers(((IMachineProgress) tTileEntity).getProgress())); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1707,16 +1683,16 @@ public class GT_Utility { } try { if (tTileEntity instanceof IBasicEnergyContainer && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) { - tList.add("Max IN: " +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getInputVoltage() +EnumChatFormatting.RESET+ " EU at "+EnumChatFormatting.RED+((IBasicEnergyContainer)tTileEntity).getInputAmperage()+EnumChatFormatting.RESET+" A"); - tList.add("Max OUT: " +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() +EnumChatFormatting.RESET+ " EU at " +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() +EnumChatFormatting.RESET+ " A"); - tList.add("Energy: " +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) +EnumChatFormatting.RESET+ " EU"); + tList.add("Max IN: " + ((IBasicEnergyContainer) tTileEntity).getInputVoltage() + " EU"); + tList.add("Max OUT: " + ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() + " EU at " + ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() + " Amperes"); + tList.add("Energy: " + GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + " / " + GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + "EU"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } try { if (tTileEntity instanceof IGregTechTileEntity) { - tList.add("Owned by: " +EnumChatFormatting.BLUE+ ((IGregTechTileEntity) tTileEntity).getOwnerName()+EnumChatFormatting.RESET); + tList.add("Owned by: " + ((IGregTechTileEntity) tTileEntity).getOwnerName()); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -1750,10 +1726,11 @@ public class GT_Utility { + " Humidity: " + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity() + " Air-Quality: " + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality() ); - String tString = E; + StringBuilder tStringB = new StringBuilder(); for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) { - tString += ", " + tAttribute; + tStringB.append(", ").append(tAttribute); } + String tString = tStringB.toString(); tList.add("Attributes:" + tString.replaceFirst(",", E)); tList.add("Discovered by: " + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy()); } @@ -1764,8 +1741,19 @@ public class GT_Utility { } if (aPlayer.capabilities.isCreativeMode&>_Values.D1) { FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ); - tList.add(EnumChatFormatting.GOLD+"Oil"+EnumChatFormatting.RESET+" in Chunk: " +EnumChatFormatting.YELLOW+ tFluid.amount + " " + tFluid.getLocalizedName()+EnumChatFormatting.RESET); + tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName()); + } +// if(aPlayer.capabilities.isCreativeMode){ + ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16); + if(GT_Proxy.chunkData.containsKey(tPos)){ + int[] tPollution = GT_Proxy.chunkData.get(tPos); + if(tPollution.length>1){ + tList.add("Pollution in Chunk: "+tPollution[1]); + }else{ + tList.add("No Pollution in Chunk"); + } } +// } try { if (tBlock instanceof IDebugableBlock) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java index 4299684129..3265c1576a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.basic; -import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; @@ -9,6 +8,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_Container_Teleporter; @@ -22,16 +22,17 @@ import net.minecraft.entity.boss.EntityDragonPart; import net.minecraft.entity.effect.EntityWeatherEffect; import net.minecraft.entity.item.*; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fluids.FluidStack; @@ -45,7 +46,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { public int mTargetZ = 0; public int mTargetD = 0; public boolean mDebug = false; - public boolean hasBlock = false; + public boolean hasEgg = false; public GT_MetaTileEntity_Teleporter(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 3, "Teleport long distances with this little device."); @@ -137,7 +138,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - this.hasBlock = checkForBlock(); + this.hasEgg = checkForEgg(); aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -161,16 +162,10 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { public boolean isGivingInformation() { return true; } - + public String[] getInfoData() { - return new String[]{ - "Coordinates:", - "X: "+ EnumChatFormatting.GREEN+ this.mTargetX+EnumChatFormatting.RESET, - "Y: "+EnumChatFormatting.GREEN+ this.mTargetY+EnumChatFormatting.RESET, - "Z: "+EnumChatFormatting.GREEN+ this.mTargetZ+EnumChatFormatting.RESET, - "Dimension: " + EnumChatFormatting.YELLOW+this.mTargetD+EnumChatFormatting.RESET - }; + return new String[]{"Coordinates:", "X: " + this.mTargetX, "Y: " + this.mTargetY, "Z: " + this.mTargetZ, "Dimension: " + this.mTargetD}; } @Override @@ -200,24 +195,23 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { sInterDimensionalTeleportAllowed = aConfig.get(ConfigCategories.machineconfig, "Teleporter.Interdimensional", true); } - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - if (aBaseMetaTileEntity.isServerSide()) { + public void onFirstTick() { + if (getBaseMetaTileEntity().isServerSide()) { if ((this.mTargetX == 0) && (this.mTargetY == 0) && (this.mTargetZ == 0) && (this.mTargetD == 0)) { - this.mTargetX = aBaseMetaTileEntity.getXCoord(); - this.mTargetY = aBaseMetaTileEntity.getYCoord(); - this.mTargetZ = aBaseMetaTileEntity.getZCoord(); - this.mTargetD = aBaseMetaTileEntity.getWorld().provider.dimensionId; + this.mTargetX = getBaseMetaTileEntity().getXCoord(); + this.mTargetY = getBaseMetaTileEntity().getYCoord(); + this.mTargetZ = getBaseMetaTileEntity().getZCoord(); + this.mTargetD = getBaseMetaTileEntity().getWorld().provider.dimensionId; } - this.hasBlock = checkForBlock(); + this.hasEgg = checkForEgg(); } } - public boolean checkForBlock() { + public boolean checkForEgg() { for (byte i = -5; i <= 5; i = (byte) (i + 1)) { for (byte j = -5; j <= 5; j = (byte) (j + 1)) { for (byte k = -5; k <= 5; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getBlockOffset(i, j, k) == GregTech_API.sBlockMetal5 && getBaseMetaTileEntity().getMetaIDOffset(i, j, k) == 2){ + if (getBaseMetaTileEntity().getBlockOffset(i, j, k) == Blocks.dragon_egg) { return true; } } @@ -227,7 +221,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { } public boolean hasDimensionalTeleportCapability() { - return (this.mDebug) || (this.hasBlock) || (mFluid.isFluidEqual(Materials.Iron.getPlasma(1)) && mFluid.amount >= 1000); + return (this.mDebug) || (this.hasEgg) || (mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && mFluid.amount >= 10); } public boolean isDimensionalTeleportAvailable() { @@ -237,16 +231,16 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (mFluid == null) { - mFluid = Materials.Iron.getPlasma(0); + mFluid = Materials.Nitrogen.getPlasma(0); } super.onPostTick(aBaseMetaTileEntity, aTick); if (getBaseMetaTileEntity().isServerSide()) { if (getBaseMetaTileEntity().getTimer() % 100L == 50L) { - this.hasBlock = checkForBlock(); + this.hasEgg = checkForEgg(); } if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().getRedstone())) { if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048, false)) { - if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasBlock || mFluid.isFluidEqual(Materials.Iron.getPlasma(1)))) { + if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))&& new XSTR().nextInt(10)==0) { mFluid.amount--; if (mFluid.amount < 1) { mFluid = null; @@ -267,7 +261,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { int tStacksize = mInventory[0].stackSize; GT_Utility.moveOneItemStack(this, tTile, (byte) 0, (byte) 0, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); if (mInventory[0] == null || mInventory[0].stackSize < tStacksize) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits((long)tDistance * tDistance * ((long)tStacksize - (mInventory[0] == null ? 0 : mInventory[0].stackSize)), false); + getBaseMetaTileEntity().decreaseStoredEnergyUnits((int) (Math.pow(tDistance, 1.5) * tDistance * (tStacksize - (mInventory[0] == null ? 0 : mInventory[0].stackSize))), false); } } @@ -275,9 +269,10 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { for (Object tObject : getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 2) + 2, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 2) + 2, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 2) + 2))) { if (((tObject instanceof Entity)) && (!((Entity) tObject).isDead)) { Entity tEntity = (Entity) tObject; - if (getBaseMetaTileEntity().decreaseStoredEnergyUnits((long)(tDistance * tDistance * weightCalculation(tEntity)), false)) { - if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasBlock || mFluid.isFluidEqual(Materials.Iron.getPlasma(1)))) { - mFluid.amount = mFluid.amount - (GT_Utility.safeInt(Math.min(1000L, (long)(tDistance * tDistance * weightCalculation(tEntity) / 8192)))); + System.out.println("teleport"+(Math.pow(tDistance, 1.5))); + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits((int) (Math.pow(tDistance, 1.5) * weightCalculation(tEntity)), false)) { + if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))) { + mFluid.amount = mFluid.amount - ((int) Math.min(10, (Math.pow(tDistance, 1.5) * weightCalculation(tEntity) / 8192))); if (mFluid.amount < 1) { mFluid = null; } @@ -289,11 +284,16 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { tEntity.riddenByEntity.mountEntity(null); } if ((this.mTargetD == getBaseMetaTileEntity().getWorld().provider.dimensionId) || (!isDimensionalTeleportAvailable()) || (!GT_Utility.moveEntityToDimensionAtCoords(tEntity, this.mTargetD, this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D))) { - if ((tEntity instanceof EntityLivingBase)) { - ((EntityLivingBase) tEntity).setPositionAndUpdate(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D); - } else { - tEntity.setPosition(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D); - } +// System.out.println("tele"); +//// System.out.println("tdim: "+mTargetD+" proDim: "+getBaseMetaTileEntity().getWorld().provider.dimensionId); +// if ((tEntity instanceof EntityLivingBase)) { +// if(this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId){ +// System.out.println("move dim"); +// GT_Utility.moveEntityToDimensionAtCoords(tEntity, mTargetD, mTargetX, mTargetY, mTargetZ); +// }else{((EntityLivingBase) tEntity).setPositionAndUpdate(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D);} +// } else { +// tEntity.setPosition(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D); +// } } } } @@ -307,7 +307,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { } private int distanceCalculation() { - return Math.abs(((this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId) && (isDimensionalTeleportAvailable()) ? 100 : 1) * (int) Math.sqrt(Math.pow(getBaseMetaTileEntity().getXCoord() - this.mTargetX, 2.0D) + Math.pow(getBaseMetaTileEntity().getYCoord() - this.mTargetY, 2.0D) + Math.pow(getBaseMetaTileEntity().getZCoord() - this.mTargetZ, 2.0D))); + return Math.abs(((this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId) && (isDimensionalTeleportAvailable()) ? 4000 : (int) Math.sqrt(Math.pow(getBaseMetaTileEntity().getXCoord() - this.mTargetX, 2.0D) + Math.pow(getBaseMetaTileEntity().getYCoord() - this.mTargetY, 2.0D) + Math.pow(getBaseMetaTileEntity().getZCoord() - this.mTargetZ, 2.0D)))); } @Override |