diff --git a/StevenDimDoors/mod_pocketDim/blocks/dimHatch.java b/StevenDimDoors/mod_pocketDim/blocks/dimHatch.java new file mode 100644 index 00000000..c1f85512 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/blocks/dimHatch.java @@ -0,0 +1,128 @@ +package StevenDimDoors.mod_pocketDim.blocks; + +import java.util.Random; + +import net.minecraft.block.BlockTrapDoor; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.core.PocketManager; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; +import StevenDimDoors.mod_pocketDim.world.PocketProvider; + +public class dimHatch extends BlockTrapDoor implements IDimDoor, ITileEntityProvider +{ + + public dimHatch(int par1,int par2, Material par2Material) + { + super(par1, Material.iron); + this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab); + // this.setTextureFile("/PocketBlockTextures.png"); + // this.blockIndexInTexture = 16; + } + + public void registerIcons(IconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()); + + } + + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + + { + int var10 = par1World.getBlockMetadata(par2, par3, par4); + par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 ^ 4,2); + par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); + return true; + } + } + + //Teleports the player to the exit link of that dimension, assuming it is a pocket + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) + { + int num = par1World.getBlockMetadata(par2, par3, par4); + + if (!par1World.isRemote&&(num>3&&num<8||num>11)&&par1World.provider instanceof PocketProvider) + { + this.onPoweredBlockChange(par1World, par2, par3, par4, false); + + /* FIXME: No point in fixing the following code when it's going to be rewritten later anyway. ~SenseiKiwi + + NewDimData newDimData = (NewDimData) dimHelper.PocketManager.dimList.get(par1World.provider.dimensionId); + ILinkData exitLink=newDimData.exitDimLink; + exitLink.locDimID=par1World.provider.dimensionId; + PocketManager.instance.traverseDimDoor(par1World, exitLink, par5Entity);*/ + } + } + + public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) + { + int var6 = par1World.getBlockMetadata(par2, par3, par4); + boolean var7 = (var6 & 4) > 0; + + if (var7 != par5) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 ^ 4,2); + par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0); + } + } + + public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) + { + TileEntityTransTrapdoor tile = (TileEntityTransTrapdoor) par1World.getBlockTileEntity(par2, par3, par4); + tile.hasRift = PocketManager.getLink(par2, par3, par4, par1World)!=null; + tile.metaData = par1World.getBlockMetadata(par2, par3, par4); + tile.isShut = this.isTrapdoorOpen(par4); + } + @Override + public TileEntity createNewTileEntity(World world) + { + + return new TileEntityTransTrapdoor(); + } + + public dimHatch updateAttachedTile(World world, int x, int y, int z) + { + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile instanceof TileEntityTransTrapdoor) + { + TileEntityTransTrapdoor dimTile = (TileEntityTransTrapdoor) tile; + dimTile.hasRift = PocketManager.getLink(x, y, z, world)!=null; + dimTile.metaData = world.getBlockMetadata(x, y, z); + dimTile.isShut = this.isTrapdoorOpen( world.getBlockMetadata(x, y, z)); + } + return this; + } + @Override + public void enterDimDoor(World world, int x, int y, int z, Entity entity) { + // TODO Auto-generated method stub + + } + + @Override + public void placeDimDoor(World world, int x, int y, int z) { + // TODO Auto-generated method stub + + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) + { + world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world)); + this.updateAttachedTile(world, x, y, z); + } + @Override + public int getDrops() { + // TODO Auto-generated method stub + return 0; + } + + +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index fe576f27..8f061a05 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -38,6 +38,7 @@ import StevenDimDoors.mod_pocketDim.ticking.MobMonolith; import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner; import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift; import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo; import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket; @@ -228,6 +229,7 @@ public class mod_pocketDim GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor"); GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift"); + GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityDimHatch"); EntityRegistry.registerModEntity(MobMonolith.class, "Monolith", properties.MonolithEntityID, this, 70, 1, true); EntityList.IDtoClassMapping.put(properties.MonolithEntityID, MobMonolith.class); diff --git a/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java b/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java new file mode 100644 index 00000000..ad8dff16 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java @@ -0,0 +1,78 @@ +package StevenDimDoors.mod_pocketDim.tileentities; + +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.core.PocketManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class TileEntityTransTrapdoor extends TileEntity + +{ + public boolean hasRift; + public boolean isShut; + public int metaData; + + + + + public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z) + { + if(newID==0&&PocketManager.getLink(x, y, z, world)!=null) + { + world.setBlock(x, y, z, mod_pocketDim.blockRift.blockID); + } + return true; + } + + public boolean canUpdate() + { + return true; + } + + public void updateEntity() + { + System.out.println(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); + + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + int i = nbt.getInteger(("Size")); + + try + { + this.hasRift = nbt.getBoolean("hasRift"); + this.isShut = nbt.getBoolean("isShut"); + + this.metaData = nbt.getInteger("metaData"); + + + + + + + } + catch (Exception e) + { + + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + int i = 0; + super.writeToNBT(nbt); + nbt.setBoolean("hasRift", this.hasRift); + nbt.setBoolean("isShut", this.isShut); + + + nbt.setInteger("metaData", this.metaData); + + + + } +} diff --git a/StevenDimDoors/mod_pocketDimClient/ClientProxy.java b/StevenDimDoors/mod_pocketDimClient/ClientProxy.java index 7cb14693..b4ef347e 100644 --- a/StevenDimDoors/mod_pocketDimClient/ClientProxy.java +++ b/StevenDimDoors/mod_pocketDimClient/ClientProxy.java @@ -3,6 +3,7 @@ import net.minecraft.src.ModLoader; import StevenDimDoors.mod_pocketDim.CommonProxy; import StevenDimDoors.mod_pocketDim.ticking.MobMonolith; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -15,6 +16,7 @@ public class ClientProxy extends CommonProxy { //MinecraftForgeClient.preloadTexture(BLOCK_PNG); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransTrapdoor.class, new RenderDimTrapDoor()); //This code activates the new rift rendering, as well as a bit of code in TileEntityRift //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRift.class, new RenderRift()); diff --git a/StevenDimDoors/mod_pocketDimClient/RenderDimTrapDoor.java b/StevenDimDoors/mod_pocketDimClient/RenderDimTrapDoor.java new file mode 100644 index 00000000..8d90e6e5 --- /dev/null +++ b/StevenDimDoors/mod_pocketDimClient/RenderDimTrapDoor.java @@ -0,0 +1,200 @@ +package StevenDimDoors.mod_pocketDimClient; + +import java.nio.FloatBuffer; +import java.util.Random; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import StevenDimDoors.mod_pocketDim.DDProperties; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.blocks.dimHatch; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderDimTrapDoor extends TileEntitySpecialRenderer +{ + FloatBuffer field_76908_a = GLAllocation.createDirectFloatBuffer(16); + + public RenderDimTrapDoor() + { + if (properties == null) + properties = DDProperties.instance(); + } + + private static DDProperties properties = null; + + /** + * Renders the dimdoor. + */ + public void renderDimHatchTileEntity(TileEntityTransTrapdoor tile, double x, double y, double z, float par8) + { + try + { + ( (dimHatch) mod_pocketDim.dimHatch).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; + // float playerZ = (float)this.tileEntityRenderer.playerZ; + + //float distance = (float) tile.getDistanceFrom(playerX, playerY, playerZ); + GL11.glDisable(GL11.GL_LIGHTING); + Random rand = new Random(31100L); + float var13 = 0.75F; + + + + for (int count = 0; count < 16; ++count) + { + GL11.glPushMatrix(); + float var15 = (float)(16 - count); + float var16 = 0.2625F; + float var17 = 1.0F / (var15 + 1.0F); + + if (count == 0) + { + this.bindTextureByName("/RIFT.png"); + var17 = 0.1F; + var15 = 25.0F; + var16 = 0.125F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + if (count == 1) + { + this.bindTextureByName("/WARP.png"); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + var16 = .5F; + } + + + + GL11.glTranslatef( (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F,0, 0.0F); + GL11.glTranslatef(0, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F, 0.0F); + + GL11.glTranslatef(0,0, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F); + + GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + + GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + + + GL11.glEnable(GL11.GL_TEXTURE_GEN_S); + GL11.glEnable(GL11.GL_TEXTURE_GEN_T); + GL11.glEnable(GL11.GL_TEXTURE_GEN_R); + GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F*var15, 0.0F); + GL11.glScalef(var16, var16, var16); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glRotatef((float)(count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + + GL11.glBegin(GL11.GL_QUADS); + + + + + float var21 = rand.nextFloat() * 0.5F + 0.1F; + float var22 = rand.nextFloat() * 0.4F + 0.4F; + float var23 = rand.nextFloat() * 0.6F + 0.5F; + + if (count == 0) + { + var23 = 1.0F; + var22 = 1.0F; + } + GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F); + if(tile.metaData>7) + { + if(tile.isShut) + { + GL11.glVertex3d(x, y+0.85, z); + GL11.glVertex3d(x, y+0.85, z+1); + GL11.glVertex3d(x+1 , y+0.85 , z+1); + GL11.glVertex3d(x+1 , y+0.85 , z); + } + else + { + GL11.glVertex3d(x, y+0.95, z); + GL11.glVertex3d(x, y+0.95, z+1); + GL11.glVertex3d(x+1 , y+0.95 , z+1); + GL11.glVertex3d(x+1 , y+0.95 , z); + + } + + + } + else + { + if(tile.isShut) + { + GL11.glVertex3d(x, y+0.2, z); + GL11.glVertex3d(x, y+0.2, z+1); + GL11.glVertex3d(x+1 , y+0.2 , z+1); + GL11.glVertex3d(x+1 , y+0.2 , z); + } + else + { + GL11.glVertex3d(x, y+0.15, z); + GL11.glVertex3d(x, y+0.15, z+1); + GL11.glVertex3d(x+1 , y+0.15 , z+1); + GL11.glVertex3d(x+1 , y+0.15 , z); + } + + } + + GL11.glEnd(); + + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_GEN_S); + GL11.glDisable(GL11.GL_TEXTURE_GEN_T); + GL11.glDisable(GL11.GL_TEXTURE_GEN_R); + GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) + { + this.field_76908_a.clear(); + this.field_76908_a.put(par1).put(par2).put(par3).put(par4); + this.field_76908_a.flip(); + return this.field_76908_a; + } + + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + if (properties.DoorRenderingEnabled) + { + this.renderDimHatchTileEntity((TileEntityTransTrapdoor)par1TileEntity, par2, par4, par6, par8); + } + } +}