Finished TransientDoor.

Better sanity check in BaseDimDoor.
This commit is contained in:
Michael Zanga 2016-07-21 10:58:50 -04:00
parent d36bc87a6a
commit b1fa82fc63
4 changed files with 31 additions and 64 deletions

View file

@ -257,12 +257,9 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override @Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) { public void enterDimDoor(World world, BlockPos pos, Entity entity) {
// FX entities dont exist on the server
if (world.isRemote) {return;}
// Check that this is the top block of the door // Check that this is the top block of the door
if (world.getBlockState(pos).getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) {
boolean canUse = state.getValue(BlockDoor.OPEN); boolean canUse = state.getValue(BlockDoor.OPEN);
if (canUse && entity instanceof EntityPlayer) if (canUse && entity instanceof EntityPlayer)
// Dont check for non-player entites // Dont check for non-player entites

View file

@ -2,12 +2,15 @@ package com.zixiken.dimdoors.blocks;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.DDTeleporter; import com.zixiken.dimdoors.core.DDTeleporter;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
@ -24,82 +27,49 @@ public class TransientDoor extends BaseDimDoor {
} }
@Override @Override
public void enterDimDoor(World world, int x, int y, int z, Entity entity) public void enterDimDoor(World world, BlockPos pos, Entity entity) {
{
// We need to ignore particle entities
if (world.isRemote)
{
return;
}
// Check that this is the top block of the door // Check that this is the top block of the door
if (world.getBlock(x, y - 1, z) == this) IBlockState state = world.getBlockState(pos.down());
{ if (!world.isRemote && state.getBlock() == this) {
boolean canUse = true; if (entity instanceof EntityPlayer && isEntityFacingDoor(state, (EntityLivingBase) entity)) {
int metadata = world.getBlockMetadata(x, y - 1, z);
if (canUse && entity instanceof EntityPlayer)
{
// Don't check for non-living entities since it might not work right
canUse = isEntityFacingDoor(metadata, (EntityLivingBase) entity);
}
if (canUse)
{
// Teleport the entity through the link, if it exists // Teleport the entity through the link, if it exists
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId); DimLink link = PocketManager.getLink(pos, world.provider.getDimensionId());
if (link != null) if (link != null && link.linkType() != LinkType.PERSONAL) {
{
if (link.linkType() != LinkType.PERSONAL || entity instanceof EntityPlayer) {
DDTeleporter.traverseDimDoor(world, link, entity, this); DDTeleporter.traverseDimDoor(world, link, entity, this);
// Turn the door into a rift AFTER teleporting the player. // Turn the door into a rift AFTER teleporting the player.
// The door's orientation may be necessary for the teleport. // The door's orientation may be necessary for the teleport.
world.setBlock(x, y, z, DimDoors.blockRift); world.setBlockState(pos, DimDoors.blockRift.getDefaultState());
world.setBlockToAir(x, y - 1, z); world.setBlockToAir(pos.down());
} }
} }
} }
} else {
else if (world.getBlock(x, y + 1, z) == this) BlockPos up = pos.up();
{ if (world.getBlockState(up).getBlock() == this) enterDimDoor(world, up, entity);
enterDimDoor(world, x, y + 1, z, entity);
} }
} }
@Override @Override
public void placeLink(World world, int x, int y, int z) public void placeLink(World world, BlockPos pos) {
{ IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && world.getBlock(x, y - 1, z) == this) if (!world.isRemote && state.getBlock() == this) {
{
NewDimData dimension = PocketManager.createDimensionData(world); NewDimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(x, y, z); DimLink link = dimension.getLink(pos);
if (link == null && dimension.isPocketDimension()) if (link == null && dimension.isPocketDimension()) {
{ dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING));
dimension.createLink(x, y, z, LinkType.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
} }
} }
} }
@Override @Override
public Item getDoorItem() public Item getDoorItem() {return null;}
{
return null;
}
@Override @Override
public boolean isCollidable() public boolean isCollidable() {return false;}
{
return false;
}
//The old textures are transparent. We should get the same effect with no render,
//though setting opaque to false might be necessary for ao/culling purposes
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) public int getRenderType() {return -1;}
{
return null;
}
@Override
public int getRenderType()
{
return 8;
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB