Moar Teleporting fixing
Some renaming And moving the storage of a DimDoor's orientation over from the BlockDoorBase to the TileEntityDimDoor
This commit is contained in:
parent
a9f2f3a82d
commit
a9fb3f5445
8 changed files with 31 additions and 33 deletions
|
@ -13,7 +13,6 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
@ -48,7 +47,7 @@ public abstract class DDProxyCommon implements IDDProxy {
|
|||
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
||||
? state.getValue(BlockDoor.FACING).rotateY()
|
||||
: ModBlocks.blockDimDoor.getDefaultState().getValue(BlockDoor.FACING);
|
||||
dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
|
||||
dimTile.doorIsOpen = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
|
||||
dimTile.lockStatus = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
|
|||
World world = te.getWorld();
|
||||
BlockPos pos = te.getPos();
|
||||
((BlockDimDoorBase) world.getBlockState(pos).getBlock()).updateAttachedTile(world, pos);
|
||||
if (te.openOrClosed) {
|
||||
if (te.doorIsOpen) {
|
||||
renderDimDoorTileEntity(te, x, y, z);
|
||||
if (te.lockStatus >= 1) {
|
||||
for (int i = 0; i < 1 + te.lockStatus; i++) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.zixiken.dimdoors.blocks.BlockDimDoor;
|
|||
import com.zixiken.dimdoors.blocks.BlockDimDoorBase;
|
||||
import com.zixiken.dimdoors.blocks.ModBlocks;
|
||||
import com.zixiken.dimdoors.tileentities.DDTileEntityBase;
|
||||
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -135,8 +136,13 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
}
|
||||
DimDoors.log(this.getClass(), "New Door rift-ID after placement: " + newTileEntityDimDoor.getRiftID());
|
||||
DimDoors.log(this.getClass(), "Facing direction of Door-block at pos of this Rift tile entity is: "
|
||||
+ newTileEntityDimDoor.getWorld().getBlockState(newTileEntityDimDoor.getPos()).getValue(BlockDimDoor.FACING));
|
||||
|
||||
+ newTileEntityDimDoor.getWorld().getBlockState(newTileEntityDimDoor.getPos()).getValue(BlockDimDoor.FACING));
|
||||
if (newTileEntityDimDoor instanceof TileEntityDimDoor) {
|
||||
TileEntityDimDoor tileEntityDimDoor = (TileEntityDimDoor) newTileEntityDimDoor;
|
||||
tileEntityDimDoor.orientation
|
||||
= newTileEntityDimDoor.getWorld().getBlockState(newTileEntityDimDoor.getPos()).getValue(BlockDimDoor.FACING).getOpposite();
|
||||
//storing the orientation inside the tile-entity, because that thing can actually save the orientation in the worldsave, unlike the block itself, which fucks up somehow
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class Location {
|
|||
|
||||
public Location(int dimID, BlockPos pos) {
|
||||
this.dimensionID = dimID;
|
||||
this.pos = pos.up(0); //copyOf
|
||||
this.pos = pos; //copyOf
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity() {
|
||||
|
|
|
@ -125,7 +125,8 @@ public class RiftRegistry {
|
|||
if (pairedRiftID < 0) {
|
||||
return false;
|
||||
}
|
||||
DDTileEntityBase destinationRift = (DDTileEntityBase) getRiftLocation(pairedRiftID).getTileEntity();
|
||||
Location destinationRiftLocation = getRiftLocation(pairedRiftID);
|
||||
DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity();
|
||||
return TeleportHelper.teleport(entity, destinationRift.getTeleportTargetLocation());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package com.zixiken.dimdoors.shared;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.server.SPacketUpdateHealth;
|
||||
import net.minecraft.server.management.PlayerList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
@ -28,21 +24,21 @@ public class TeleportHelper extends Teleporter {
|
|||
entityIn.setPositionAndUpdate(pos.getX() + .5, pos.getY() + .05, pos.getZ() + .5);
|
||||
}
|
||||
|
||||
public static boolean teleport(Entity entity, Location location) {
|
||||
public static boolean teleport(Entity entity, Location newLocation) {
|
||||
if (entity instanceof EntityPlayerSP) {
|
||||
DimDoors.log(location.getClass(), "Not teleporting, because EntityPlayerSP.");
|
||||
DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP.");
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockPos newPos = location.getPos();
|
||||
BlockPos newPos = newLocation.getPos();
|
||||
int oldDimID = entity.dimension;
|
||||
int newDimID = location.getDimensionID();
|
||||
int newDimID = newLocation.getDimensionID();
|
||||
WorldServer oldWorldServer = DimDoors.proxy.getWorldServer(oldDimID);
|
||||
WorldServer newWorldServer = DimDoors.proxy.getWorldServer(newDimID);
|
||||
DimDoors.log(location.getClass(), "Starting teleporting now:");
|
||||
DimDoors.log(TeleportHelper.class, "Starting teleporting now:");
|
||||
if (oldDimID == newDimID) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
DimDoors.log(location.getClass(), "Using teleport method 1");
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 1");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
|
||||
player.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
|
@ -50,7 +46,7 @@ public class TeleportHelper extends Teleporter {
|
|||
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||
player.timeUntilPortal = 150;
|
||||
} else {
|
||||
DimDoors.log(location.getClass(), "Using teleport method 2");
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 2");
|
||||
WorldServer world = (WorldServer) entity.world;
|
||||
|
||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
|
@ -59,22 +55,22 @@ public class TeleportHelper extends Teleporter {
|
|||
}
|
||||
} else {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
DimDoors.log(location.getClass(), "Using teleport method 3");
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 3");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
player.changeDimension(newDimID); //@todo, this only works for Vanilla dimensions, I've heard?
|
||||
player.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
player.world.updateEntityWithOptionalForce(player, false);
|
||||
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||
} else if (!entity.world.isRemote) {
|
||||
DimDoors.log(location.getClass(), "Using teleport method 4");
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 4");
|
||||
entity.changeDimension(newDimID);
|
||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
oldWorldServer.resetUpdateEntityTick();
|
||||
newWorldServer.resetUpdateEntityTick();
|
||||
} else {
|
||||
//does this statement ever get reached though?
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
entity.timeUntilPortal = 150;
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zixiken.dimdoors.tileentities;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.blocks.BlockDimDoor;
|
||||
import com.zixiken.dimdoors.shared.Location;
|
||||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||
import java.util.Random;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.zixiken.dimdoors.tileentities;
|
||||
|
||||
import com.zixiken.dimdoors.blocks.BlockDimDoor;
|
||||
import com.zixiken.dimdoors.shared.Location;
|
||||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||
import java.util.Random;
|
||||
|
@ -10,11 +9,11 @@ import net.minecraft.util.EnumFacing;
|
|||
|
||||
public class TileEntityDimDoor extends DDTileEntityBase {
|
||||
|
||||
public boolean openOrClosed;
|
||||
public boolean doorIsOpen = false;
|
||||
public EnumFacing orientation = EnumFacing.SOUTH;
|
||||
public boolean hasExit;
|
||||
public byte lockStatus;
|
||||
public boolean isDungeonChainLink;
|
||||
public boolean hasExit = false;
|
||||
public byte lockStatus = 1;
|
||||
public boolean isDungeonChainLink = false;
|
||||
public boolean hasGennedPair = false;
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +21,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
|||
super.readFromNBT(nbt);
|
||||
|
||||
try {
|
||||
this.openOrClosed = nbt.getBoolean("openOrClosed");
|
||||
this.doorIsOpen = nbt.getBoolean("doorIsOpen");
|
||||
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
|
||||
this.hasExit = nbt.getBoolean("hasExit");
|
||||
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
|
||||
|
@ -33,9 +32,9 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
|||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setBoolean("openOrClosed", this.openOrClosed);
|
||||
nbt.setBoolean("doorIsOpen", this.doorIsOpen);
|
||||
nbt.setBoolean("hasExit", this.hasExit);
|
||||
nbt.setInteger("orientation", this.orientation.getIndex());
|
||||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||
|
@ -61,9 +60,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
|||
|
||||
@Override
|
||||
public Location getTeleportTargetLocation() {
|
||||
EnumFacing facing = getWorld().getBlockState(getPos()).getValue(BlockDimDoor.FACING).getOpposite(); //@todo this will allways return South after world-load?
|
||||
|
||||
return new Location(this.getWorld().provider.getDimension(), this.getPos().offset(facing));
|
||||
return new Location(this.getWorld().provider.getDimension(), this.getPos().offset(orientation));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue