diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java index aa04337..9f7fd0c 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java @@ -17,6 +17,7 @@ import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.terraingen.InitMapGenEvent; import net.minecraftforge.event.world.WorldEvent; import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor; @@ -84,7 +85,10 @@ public class EventHookContainer public void onPlayerEvent(PlayerInteractEvent event) { // Handle all door placement here - + if(event.action == Action.LEFT_CLICK_BLOCK) + { + return; + } World world = event.entity.worldObj; ItemStack stack = event.entityPlayer.inventory.getCurrentItem(); if (stack != null && stack.getItem() instanceof ItemDoor) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index 9c56e91..1b85af9 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -179,11 +179,30 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn if (tile instanceof TileEntityDimDoor) { TileEntityDimDoor dimTile = (TileEntityDimDoor) tile; - dimTile.openOrClosed = PocketManager.getLink(x, y, z, world.provider.dimensionId) != null; + dimTile.openOrClosed = this.isDoorOnRift(world, x, y, z); dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7; } return this; } + + public boolean isDoorOnRift(World world, int x, int y, int z) + { + if(this.isUpperDoorBlock( world.getBlockMetadata(x, y, z))) + { + if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y-1, z, world.provider.dimensionId) != null) + { + return true; + } + } + else + { + if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y+1, z, world.provider.dimensionId) != null) + { + return true; + } + } + return false; + } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two @@ -192,9 +211,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn @Override public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { - TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4); - tile.openOrClosed = this.isDoorOpen( par1World, par2, par3, par4); - tile.orientation = this.getFullMetadata(par1World, par2, par3, par4) & 7; + this.updateAttachedTile(par1World, par2, par3, par4); } @Override diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java index 6639974..23e72bb 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java @@ -42,15 +42,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z) { - try - { - mod_pocketDim.dimensionalDoor.updateAttachedTile(tile.worldObj, - tile.xCoord, tile.yCoord, tile.zCoord); - } - catch (Exception e) - { - e.printStackTrace(); - } + // float playerX = (float)this.tileEntityRenderer.playerX; // float playerY = (float)this.tileEntityRenderer.playerY; @@ -215,62 +207,61 @@ public class RenderDimDoor extends TileEntitySpecialRenderer } GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F); - if (tile.openOrClosed) - { + switch (tile.orientation) { case 0: - GL11.glVertex3d(x + .01F, y - 1, z); - GL11.glVertex3d(x + .01, y - 1, z + 1.0D); + GL11.glVertex3d(x + .01F, y, z); + GL11.glVertex3d(x + .01, y , z + 1.0D); GL11.glVertex3d(x + .01, y + 1, z + 1.0D); GL11.glVertex3d(x + .01, y + 1, z); break; case 1: GL11.glVertex3d(x, y + 1, z + .01); GL11.glVertex3d(x + 1, y + 1, z + .01); - GL11.glVertex3d(x + 1, y - 1, z + .01); - GL11.glVertex3d(x, y - 1, z + .01); + GL11.glVertex3d(x + 1, y , z + .01); + GL11.glVertex3d(x, y , z + .01); break; case 2: GL11.glVertex3d(x + .99, y + 1, z); GL11.glVertex3d(x + .99, y + 1, z + 1.0D); - GL11.glVertex3d(x + .99, y - 1, z + 1.0D); - GL11.glVertex3d(x + .99, y - 1, z); + GL11.glVertex3d(x + .99, y , z + 1.0D); + GL11.glVertex3d(x + .99, y , z); break; case 3: - GL11.glVertex3d(x, y - 1, z + .99); - GL11.glVertex3d(x + 1, y - 1, z + .99); + GL11.glVertex3d(x, y , z + .99); + GL11.glVertex3d(x + 1, y , z + .99); GL11.glVertex3d(x + 1, y + 1, z + .99); GL11.glVertex3d(x, y + 1, z + .99); break; case 4: - GL11.glVertex3d(x + .15F, y - 1, z); - GL11.glVertex3d(x + .15, y - 1, z + 1.0D); + GL11.glVertex3d(x + .15F, y , z); + GL11.glVertex3d(x + .15, y , z + 1.0D); GL11.glVertex3d(x + .15, y + 1, z + 1.0D); GL11.glVertex3d(x + .15, y + 1, z); break; case 5: GL11.glVertex3d(x, y + 1, z + .15); GL11.glVertex3d(x + 1, y + 1, z + .15); - GL11.glVertex3d(x + 1, y - 1, z + .15); - GL11.glVertex3d(x, y - 1, z + .15); + GL11.glVertex3d(x + 1, y , z + .15); + GL11.glVertex3d(x, y , z + .15); break; case 6: GL11.glVertex3d(x + .85, y + 1, z); GL11.glVertex3d(x + .85, y + 1, z + 1.0D); - GL11.glVertex3d(x + .85, y - 1, z + 1.0D); - GL11.glVertex3d(x + .85, y - 1, z); + GL11.glVertex3d(x + .85, y , z + 1.0D); + GL11.glVertex3d(x + .85, y , z); break; case 7: - GL11.glVertex3d(x, y - 1, z + .85); - GL11.glVertex3d(x + 1, y - 1, z + .85); + GL11.glVertex3d(x, y , z + .85); + GL11.glVertex3d(x + 1, y , z + .85); GL11.glVertex3d(x + 1, y + 1, z + .85); GL11.glVertex3d(x, y + 1, z + .85); break; } - } + GL11.glEnd(); @@ -299,7 +290,21 @@ public class RenderDimDoor extends TileEntitySpecialRenderer { if (properties.DoorRenderingEnabled) { - renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6); + TileEntityDimDoor tile = (TileEntityDimDoor) par1TileEntity; + try + { + mod_pocketDim.dimensionalDoor.updateAttachedTile(tile.worldObj, + tile.xCoord, tile.yCoord, tile.zCoord); + } + catch (Exception e) + { + e.printStackTrace(); + } + + if (tile.openOrClosed) + { + renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6); + } } } }