Teleport1

This commit is contained in:
Blood-Asp 2016-09-27 20:31:04 +02:00 committed by Technus
parent 601264e4bf
commit 8261ada817
2 changed files with 45 additions and 35 deletions

View file

@ -819,7 +819,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;
@ -1464,6 +1464,7 @@ 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;
@ -1482,9 +1483,9 @@ public class GT_Utility {
// aPlayer.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(aPlayer.getEntityId(), potioneffect));
// }
// FMLCommonHandler.instance().firePlayerChangedDimensionEvent(aPlayer, tOriginalWorld.provider.dimensionId, aDimension);
aPlayer.travelToDimension(aDimension);
aPlayer.travelToDimension(aDimension);
aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch);
} else {
aEntity.setPosition(aX + 0.5, aY + 0.5, aZ + 0.5);
aEntity.worldObj.removeEntity(aEntity);
@ -1519,7 +1520,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();
@ -1546,17 +1547,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);
}
@ -1753,15 +1754,15 @@ public class GT_Utility {
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");
}
}
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 {

View file

@ -9,6 +9,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,11 +23,13 @@ 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;
@ -161,7 +164,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank {
public boolean isGivingInformation() {
return true;
}
public String[] getInfoData() {
return new String[]{
@ -246,7 +249,7 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank {
}
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 && (hasBlock || mFluid.isFluidEqual(Materials.Iron.getPlasma(1)))&& new XSTR().nextInt(10)==0) {
mFluid.amount--;
if (mFluid.amount < 1) {
mFluid = null;
@ -267,7 +270,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((long) Math.pow(tDistance, 1.5) * (tStacksize - (mInventory[0] == null ? 0 : mInventory[0].stackSize)), false);
}
}
@ -275,9 +278,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)) {
//System.out.println("teleport"+(Math.pow(tDistance, 1.5)));
if (getBaseMetaTileEntity().decreaseStoredEnergyUnits((long) Math.pow(tDistance, 1.5) * 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))));
mFluid.amount = mFluid.amount - GT_Utility.safeInt(Math.min(1000L, (long)Math.pow(tDistance, 1.5) * weightCalculation(tEntity) / 8192));
if (mFluid.amount < 1) {
mFluid = null;
}
@ -289,11 +293,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 +316,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