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
src/main/java/com/zixiken/dimdoors
|
@ -13,7 +13,6 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
@ -48,7 +47,7 @@ public abstract class DDProxyCommon implements IDDProxy {
|
||||||
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
||||||
? state.getValue(BlockDoor.FACING).rotateY()
|
? state.getValue(BlockDoor.FACING).rotateY()
|
||||||
: ModBlocks.blockDimDoor.getDefaultState().getValue(BlockDoor.FACING);
|
: 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;
|
dimTile.lockStatus = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
|
||||||
World world = te.getWorld();
|
World world = te.getWorld();
|
||||||
BlockPos pos = te.getPos();
|
BlockPos pos = te.getPos();
|
||||||
((BlockDimDoorBase) world.getBlockState(pos).getBlock()).updateAttachedTile(world, pos);
|
((BlockDimDoorBase) world.getBlockState(pos).getBlock()).updateAttachedTile(world, pos);
|
||||||
if (te.openOrClosed) {
|
if (te.doorIsOpen) {
|
||||||
renderDimDoorTileEntity(te, x, y, z);
|
renderDimDoorTileEntity(te, x, y, z);
|
||||||
if (te.lockStatus >= 1) {
|
if (te.lockStatus >= 1) {
|
||||||
for (int i = 0; i < 1 + te.lockStatus; i++) {
|
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.BlockDimDoorBase;
|
||||||
import com.zixiken.dimdoors.blocks.ModBlocks;
|
import com.zixiken.dimdoors.blocks.ModBlocks;
|
||||||
import com.zixiken.dimdoors.tileentities.DDTileEntityBase;
|
import com.zixiken.dimdoors.tileentities.DDTileEntityBase;
|
||||||
|
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
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(), "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: "
|
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;
|
return EnumActionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Location {
|
||||||
|
|
||||||
public Location(int dimID, BlockPos pos) {
|
public Location(int dimID, BlockPos pos) {
|
||||||
this.dimensionID = dimID;
|
this.dimensionID = dimID;
|
||||||
this.pos = pos.up(0); //copyOf
|
this.pos = pos; //copyOf
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntity getTileEntity() {
|
public TileEntity getTileEntity() {
|
||||||
|
|
|
@ -125,7 +125,8 @@ public class RiftRegistry {
|
||||||
if (pairedRiftID < 0) {
|
if (pairedRiftID < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DDTileEntityBase destinationRift = (DDTileEntityBase) getRiftLocation(pairedRiftID).getTileEntity();
|
Location destinationRiftLocation = getRiftLocation(pairedRiftID);
|
||||||
|
DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity();
|
||||||
return TeleportHelper.teleport(entity, destinationRift.getTeleportTargetLocation());
|
return TeleportHelper.teleport(entity, destinationRift.getTeleportTargetLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
package com.zixiken.dimdoors.shared;
|
package com.zixiken.dimdoors.shared;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
import com.zixiken.dimdoors.DimDoors;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
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.util.math.BlockPos;
|
||||||
import net.minecraft.world.Teleporter;
|
import net.minecraft.world.Teleporter;
|
||||||
import net.minecraft.world.WorldServer;
|
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);
|
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) {
|
if (entity instanceof EntityPlayerSP) {
|
||||||
DimDoors.log(location.getClass(), "Not teleporting, because EntityPlayerSP.");
|
DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos newPos = location.getPos();
|
BlockPos newPos = newLocation.getPos();
|
||||||
int oldDimID = entity.dimension;
|
int oldDimID = entity.dimension;
|
||||||
int newDimID = location.getDimensionID();
|
int newDimID = newLocation.getDimensionID();
|
||||||
WorldServer oldWorldServer = DimDoors.proxy.getWorldServer(oldDimID);
|
WorldServer oldWorldServer = DimDoors.proxy.getWorldServer(oldDimID);
|
||||||
WorldServer newWorldServer = DimDoors.proxy.getWorldServer(newDimID);
|
WorldServer newWorldServer = DimDoors.proxy.getWorldServer(newDimID);
|
||||||
DimDoors.log(location.getClass(), "Starting teleporting now:");
|
DimDoors.log(TeleportHelper.class, "Starting teleporting now:");
|
||||||
if (oldDimID == newDimID) {
|
if (oldDimID == newDimID) {
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
DimDoors.log(location.getClass(), "Using teleport method 1");
|
DimDoors.log(TeleportHelper.class, "Using teleport method 1");
|
||||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||||
|
|
||||||
player.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
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.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||||
player.timeUntilPortal = 150;
|
player.timeUntilPortal = 150;
|
||||||
} else {
|
} else {
|
||||||
DimDoors.log(location.getClass(), "Using teleport method 2");
|
DimDoors.log(TeleportHelper.class, "Using teleport method 2");
|
||||||
WorldServer world = (WorldServer) entity.world;
|
WorldServer world = (WorldServer) entity.world;
|
||||||
|
|
||||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||||
|
@ -59,22 +55,22 @@ public class TeleportHelper extends Teleporter {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
DimDoors.log(location.getClass(), "Using teleport method 3");
|
DimDoors.log(TeleportHelper.class, "Using teleport method 3");
|
||||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||||
player.changeDimension(newDimID); //@todo, this only works for Vanilla dimensions, I've heard?
|
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.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||||
player.world.updateEntityWithOptionalForce(player, false);
|
player.world.updateEntityWithOptionalForce(player, false);
|
||||||
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||||
} else if (!entity.world.isRemote) {
|
} 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.changeDimension(newDimID);
|
||||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||||
oldWorldServer.resetUpdateEntityTick();
|
oldWorldServer.resetUpdateEntityTick();
|
||||||
newWorldServer.resetUpdateEntityTick();
|
newWorldServer.resetUpdateEntityTick();
|
||||||
} else {
|
} else {
|
||||||
//does this statement ever get reached though?
|
//does this statement ever get reached though?
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
entity.timeUntilPortal = 150;
|
entity.timeUntilPortal = 150;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.zixiken.dimdoors.tileentities;
|
package com.zixiken.dimdoors.tileentities;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
import com.zixiken.dimdoors.DimDoors;
|
||||||
import com.zixiken.dimdoors.blocks.BlockDimDoor;
|
|
||||||
import com.zixiken.dimdoors.shared.Location;
|
import com.zixiken.dimdoors.shared.Location;
|
||||||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.zixiken.dimdoors.tileentities;
|
package com.zixiken.dimdoors.tileentities;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.blocks.BlockDimDoor;
|
|
||||||
import com.zixiken.dimdoors.shared.Location;
|
import com.zixiken.dimdoors.shared.Location;
|
||||||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -10,11 +9,11 @@ import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public class TileEntityDimDoor extends DDTileEntityBase {
|
public class TileEntityDimDoor extends DDTileEntityBase {
|
||||||
|
|
||||||
public boolean openOrClosed;
|
public boolean doorIsOpen = false;
|
||||||
public EnumFacing orientation = EnumFacing.SOUTH;
|
public EnumFacing orientation = EnumFacing.SOUTH;
|
||||||
public boolean hasExit;
|
public boolean hasExit = false;
|
||||||
public byte lockStatus;
|
public byte lockStatus = 1;
|
||||||
public boolean isDungeonChainLink;
|
public boolean isDungeonChainLink = false;
|
||||||
public boolean hasGennedPair = false;
|
public boolean hasGennedPair = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +21,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.openOrClosed = nbt.getBoolean("openOrClosed");
|
this.doorIsOpen = nbt.getBoolean("doorIsOpen");
|
||||||
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
|
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
|
||||||
this.hasExit = nbt.getBoolean("hasExit");
|
this.hasExit = nbt.getBoolean("hasExit");
|
||||||
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
|
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
|
||||||
|
@ -33,9 +32,9 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
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.setBoolean("hasExit", this.hasExit);
|
||||||
nbt.setInteger("orientation", this.orientation.getIndex());
|
nbt.setInteger("orientation", this.orientation.getIndex());
|
||||||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||||
|
@ -61,9 +60,7 @@ public class TileEntityDimDoor extends DDTileEntityBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getTeleportTargetLocation() {
|
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(orientation));
|
||||||
|
|
||||||
return new Location(this.getWorld().provider.getDimension(), this.getPos().offset(facing));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue