Fixed minor issues

Doors render right now
No longer placing doors on left clicks
This commit is contained in:
StevenRS11
2014-04-15 07:27:08 -04:00
parent be7cd9d186
commit 3664e707cf
3 changed files with 60 additions and 34 deletions

View File

@@ -17,6 +17,7 @@ import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; 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.terraingen.InitMapGenEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor; import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
@@ -84,7 +85,10 @@ public class EventHookContainer
public void onPlayerEvent(PlayerInteractEvent event) public void onPlayerEvent(PlayerInteractEvent event)
{ {
// Handle all door placement here // Handle all door placement here
if(event.action == Action.LEFT_CLICK_BLOCK)
{
return;
}
World world = event.entity.worldObj; World world = event.entity.worldObj;
ItemStack stack = event.entityPlayer.inventory.getCurrentItem(); ItemStack stack = event.entityPlayer.inventory.getCurrentItem();
if (stack != null && stack.getItem() instanceof ItemDoor) if (stack != null && stack.getItem() instanceof ItemDoor)

View File

@@ -179,12 +179,31 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
if (tile instanceof TileEntityDimDoor) if (tile instanceof TileEntityDimDoor)
{ {
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile; 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; dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7;
} }
return this; 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 * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
@@ -192,9 +211,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override @Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{ {
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4); this.updateAttachedTile(par1World, par2, par3, par4);
tile.openOrClosed = this.isDoorOpen( par1World, par2, par3, par4);
tile.orientation = this.getFullMetadata(par1World, par2, par3, par4) & 7;
} }
@Override @Override

View File

@@ -42,15 +42,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x,
double y, double z) 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 playerX = (float)this.tileEntityRenderer.playerX;
// float playerY = (float)this.tileEntityRenderer.playerY; // 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); GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F);
if (tile.openOrClosed)
{
switch (tile.orientation) switch (tile.orientation)
{ {
case 0: case 0:
GL11.glVertex3d(x + .01F, y - 1, z); GL11.glVertex3d(x + .01F, y, z);
GL11.glVertex3d(x + .01, y - 1, z + 1.0D); GL11.glVertex3d(x + .01, y , z + 1.0D);
GL11.glVertex3d(x + .01, y + 1, z + 1.0D); GL11.glVertex3d(x + .01, y + 1, z + 1.0D);
GL11.glVertex3d(x + .01, y + 1, z); GL11.glVertex3d(x + .01, y + 1, z);
break; break;
case 1: case 1:
GL11.glVertex3d(x, y + 1, z + .01); 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 + 1, y - 1, z + .01); GL11.glVertex3d(x + 1, y , z + .01);
GL11.glVertex3d(x, y - 1, z + .01); GL11.glVertex3d(x, y , z + .01);
break; break;
case 2: case 2:
GL11.glVertex3d(x + .99, y + 1, z); 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 + 1.0D); GL11.glVertex3d(x + .99, y , z + 1.0D);
GL11.glVertex3d(x + .99, y - 1, z); GL11.glVertex3d(x + .99, y , z);
break; break;
case 3: case 3:
GL11.glVertex3d(x, y - 1, z + .99); GL11.glVertex3d(x, y , z + .99);
GL11.glVertex3d(x + 1, y - 1, z + .99); GL11.glVertex3d(x + 1, y , z + .99);
GL11.glVertex3d(x + 1, y + 1, z + .99); GL11.glVertex3d(x + 1, y + 1, z + .99);
GL11.glVertex3d(x, y + 1, z + .99); GL11.glVertex3d(x, y + 1, z + .99);
break; break;
case 4: case 4:
GL11.glVertex3d(x + .15F, y - 1, z); GL11.glVertex3d(x + .15F, y , z);
GL11.glVertex3d(x + .15, y - 1, z + 1.0D); GL11.glVertex3d(x + .15, y , z + 1.0D);
GL11.glVertex3d(x + .15, y + 1, z + 1.0D); GL11.glVertex3d(x + .15, y + 1, z + 1.0D);
GL11.glVertex3d(x + .15, y + 1, z); GL11.glVertex3d(x + .15, y + 1, z);
break; break;
case 5: case 5:
GL11.glVertex3d(x, y + 1, z + .15); 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 + 1, y - 1, z + .15); GL11.glVertex3d(x + 1, y , z + .15);
GL11.glVertex3d(x, y - 1, z + .15); GL11.glVertex3d(x, y , z + .15);
break; break;
case 6: case 6:
GL11.glVertex3d(x + .85, y + 1, z); 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 + 1.0D); GL11.glVertex3d(x + .85, y , z + 1.0D);
GL11.glVertex3d(x + .85, y - 1, z); GL11.glVertex3d(x + .85, y , z);
break; break;
case 7: case 7:
GL11.glVertex3d(x, y - 1, z + .85); GL11.glVertex3d(x, y , z + .85);
GL11.glVertex3d(x + 1, y - 1, z + .85); GL11.glVertex3d(x + 1, y , z + .85);
GL11.glVertex3d(x + 1, y + 1, z + .85); GL11.glVertex3d(x + 1, y + 1, z + .85);
GL11.glVertex3d(x, y + 1, z + .85); GL11.glVertex3d(x, y + 1, z + .85);
break; break;
} }
}
GL11.glEnd(); GL11.glEnd();
@@ -298,8 +289,22 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
{ {
if (properties.DoorRenderingEnabled) if (properties.DoorRenderingEnabled)
{
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); renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6);
} }
} }
}
} }