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 fb99f4d6..c989cd33 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,5 +1,6 @@ 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; @@ -8,7 +9,6 @@ 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,13 +22,11 @@ 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; @@ -166,7 +164,13 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { public String[] getInfoData() { - return new String[]{"Coordinates:", "X: " + this.mTargetX, "Y: " + this.mTargetY, "Z: " + this.mTargetZ, "Dimension: " + this.mTargetD}; + 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 + }; } @Override @@ -196,23 +200,24 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { sInterDimensionalTeleportAllowed = aConfig.get(ConfigCategories.machineconfig, "Teleporter.Interdimensional", true); } - public void onFirstTick() { - if (getBaseMetaTileEntity().isServerSide()) { + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { if ((this.mTargetX == 0) && (this.mTargetY == 0) && (this.mTargetZ == 0) && (this.mTargetD == 0)) { - this.mTargetX = getBaseMetaTileEntity().getXCoord(); - this.mTargetY = getBaseMetaTileEntity().getYCoord(); - this.mTargetZ = getBaseMetaTileEntity().getZCoord(); - this.mTargetD = getBaseMetaTileEntity().getWorld().provider.dimensionId; + this.mTargetX = aBaseMetaTileEntity.getXCoord(); + this.mTargetY = aBaseMetaTileEntity.getYCoord(); + this.mTargetZ = aBaseMetaTileEntity.getZCoord(); + this.mTargetD = aBaseMetaTileEntity.getWorld().provider.dimensionId; } - this.hasEgg = checkForEgg(); + this.hasBlock = checkForBlock(); } } - public boolean checkForEgg() { + public boolean checkForBlock() { 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) == Blocks.dragon_egg) { + if (getBaseMetaTileEntity().getBlockOffset(i, j, k) == GregTech_API.sBlockMetal5 && getBaseMetaTileEntity().getMetaIDOffset(i, j, k) == 2){ return true; } } @@ -222,7 +227,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { } public boolean hasDimensionalTeleportCapability() { - return (this.mDebug) || (this.hasEgg) || (mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && mFluid.amount >= 10); + return (this.mDebug) || (this.hasBlock) || (mFluid.isFluidEqual(Materials.Iron.getPlasma(1)) && mFluid.amount >= 1000); } public boolean isDimensionalTeleportAvailable() { @@ -232,16 +237,16 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (mFluid == null) { - mFluid = Materials.Nitrogen.getPlasma(0); + mFluid = Materials.Iron.getPlasma(0); } super.onPostTick(aBaseMetaTileEntity, aTick); if (getBaseMetaTileEntity().isServerSide()) { if (getBaseMetaTileEntity().getTimer() % 100L == 50L) { - this.hasEgg = checkForEgg(); + this.hasBlock = checkForBlock(); } if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().getRedstone())) { if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048, false)) { - if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))&& new XSTR().nextInt(10)==0) { + if (hasDimensionalTeleportCapability() && this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasBlock || mFluid.isFluidEqual(Materials.Iron.getPlasma(1)))) { mFluid.amount--; if (mFluid.amount < 1) { mFluid = null; @@ -262,7 +267,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((int) (Math.pow(tDistance, 1.5) * tDistance * (tStacksize - (mInventory[0] == null ? 0 : mInventory[0].stackSize))), false); + getBaseMetaTileEntity().decreaseStoredEnergyUnits((long)tDistance * tDistance * ((long)tStacksize - (mInventory[0] == null ? 0 : mInventory[0].stackSize)), false); } } @@ -270,10 +275,9 @@ 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; - 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 (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)))); if (mFluid.amount < 1) { mFluid = null; } @@ -285,16 +289,11 @@ 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))) { -// 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); -// } + 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); + } } } } @@ -308,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()) ? 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)))); + 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))); } @Override