private void renderSimpleGeode( IBlockAccess world, int x, int y, int z, Block b, int meta, RenderBlocks rb) { IIcon icos = ((BlockTieredOre) b).getGeodeStoneIcon(Math.abs(x + y * x * z + z) % 16); IIcon ico = ((BlockTieredOre) b).getGeodeIcon(meta); if (b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) rb.renderFaceYNeg(b, x, y, z, icos); if (b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) rb.renderFaceYPos(b, x, y, z, icos); if (b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) rb.renderFaceZNeg(b, x, y, z, icos); if (b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) rb.renderFaceZPos(b, x, y, z, icos); if (b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) rb.renderFaceXNeg(b, x, y, z, icos); if (b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) rb.renderFaceXPos(b, x, y, z, icos); Tessellator.instance.setBrightness(240); Tessellator.instance.setColorOpaque(255, 255, 255); double d = 0.0025; if (b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) rb.renderFaceYNeg(b, x, y + d, z, ico); if (b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) rb.renderFaceYPos(b, x, y - d, z, ico); if (b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) rb.renderFaceZNeg(b, x, y, z + d, ico); if (b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) rb.renderFaceZPos(b, x, y, z - d, ico); if (b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) rb.renderFaceXNeg(b, x + d, y, z, ico); if (b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) rb.renderFaceXPos(b, x - d, y, z, ico); }
@Override @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int meta) { return par1 == ForgeDirection.UP.ordinal() ? iconTop : par1 == ForgeDirection.DOWN.ordinal() ? iconBottom : iconSide; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks rb) { Tessellator v5 = Tessellator.instance; int meta = world.getBlockMetadata(x, y, z); /* float f1 = 0.5F; float f2 = 1; float f3 = 0.8F; float f4 = 0.8F; float f5 = 0.6F; float f6 = 0.6F; v5.setBrightness(rb.renderMinY > 0.0D ? l : b.getMixedBrightnessForBlock(world, x, y - 1, z)); v5.setColorOpaque_F(f1, f1, f1); rb.renderFaceYNeg(b, x, y, z, ico); v5.setBrightness(rb.renderMaxY < 1.0D ? l : b.getMixedBrightnessForBlock(world, x, y + 1, z)); v5.setColorOpaque_F(f2, f2, f2); rb.renderFaceYPos(b, x, y, z, ico); v5.setBrightness(rb.renderMinZ > 0.0D ? l : b.getMixedBrightnessForBlock(world, x, y, z - 1)); v5.setColorOpaque_F(f3, f3, f3); rb.renderFaceZNeg(b, x, y, z, ico); v5.setBrightness(rb.renderMaxZ < 1.0D ? l : b.getMixedBrightnessForBlock(world, x, y, z + 1)); v5.setColorOpaque_F(f4, f4, f4); rb.renderFaceZPos(b, x, y, z, ico); v5.setBrightness(rb.renderMinX > 0.0D ? l : b.getMixedBrightnessForBlock(world, x - 1, y, z)); v5.setColorOpaque_F(f5, f5, f5); rb.renderFaceXNeg(b, x, y, z, ico); v5.setBrightness(rb.renderMaxX < 1.0D ? l : b.getMixedBrightnessForBlock(world, x + 1, y, z)); v5.setColorOpaque_F(f6, f6, f6); rb.renderFaceXPos(b, x, y, z, ico); */ rb.renderStandardBlockWithAmbientOcclusion(b, x, y, z, 1, 1, 1); IIcon ico = CrystalElement.elements[meta].getFaceRune(); v5.setBrightness(240); v5.setColorOpaque_F(255, 255, 255); if (b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) rb.renderFaceYNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) rb.renderFaceYPos(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) rb.renderFaceZNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) rb.renderFaceZPos(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) rb.renderFaceXNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) rb.renderFaceXPos(b, x, y, z, ico); return true; }
@Override public boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int i, float f1, float f2, float f3) { if (w.getTileEntity(x, y, z) instanceof TileEntityAlchemicChemistryKit) { TileEntityAlchemicChemistryKit te = (TileEntityAlchemicChemistryKit) w.getTileEntity(x, y, z); ItemStack item = player.getCurrentEquippedItem(); if (player.isSneaking()) { if (te.getStackInSlot(0) != null && te.getStackInSlot(1) != null) { ItemStack stack = FMAlchemyAPI.instance.getAlchemicChemistryOutput( te.getStackInSlot(0).getItem(), te.getStackInSlot(1).getItem()); if (stack != null) { te.setInventorySlotContents(0, null); te.setInventorySlotContents(1, null); te.setInventorySlotContents(0, stack); } } } else { if (i == ForgeDirection.UP.ordinal()) { if (item != null) { if (te.getStackInSlot(0) != null) { if (!w.isRemote) { w.spawnEntityInWorld(new EntityItem(w, x, y + 1, z, te.getStackInSlot(0))); } te.setInventorySlotContents(0, null); } else { ItemStack toput = new ItemStack(item.getItem(), 1, item.getItemDamage()); toput.stackTagCompound = item.stackTagCompound; te.setInventorySlotContents(0, toput); item.stackSize--; } return true; } } else { if (item != null) { if (te.getStackInSlot(1) != null) { if (!w.isRemote) { w.spawnEntityInWorld(new EntityItem(w, x, y + 1, z, te.getStackInSlot(1))); } te.setInventorySlotContents(1, null); } else { ItemStack toput = new ItemStack(item.getItem(), 1, item.getItemDamage()); toput.stackTagCompound = item.stackTagCompound; te.setInventorySlotContents(1, toput); item.stackSize--; } return true; } } return false; } } return false; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks rb) { Tessellator v5 = Tessellator.instance; int meta = world.getBlockMetadata(x, y, z); BlockTieredOre t = (BlockTieredOre) b; if (t.isPlayerSufficientTier(world, x, y, z, Minecraft.getMinecraft().thePlayer)) { if (TieredOres.list[meta].renderAsGeode()) { this.renderGeode(world, x, y, z, b, meta, rb); // this.renderSimpleGeode(world, x, y, z, b, meta, rb); } else { rb.renderStandardBlockWithAmbientOcclusion(b, x, y, z, 1, 1, 1); IIcon ico = t.getOverlay(meta); v5.setBrightness(240); v5.setColorOpaque(255, 255, 255); if (b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) rb.renderFaceYNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) rb.renderFaceYPos(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) rb.renderFaceZNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) rb.renderFaceZPos(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) rb.renderFaceXNeg(b, x, y, z, ico); if (b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) rb.renderFaceXPos(b, x, y, z, ico); } } else { rb.renderBlockAllFaces(t.getDisguise(meta), x, y, z); // rb.renderStandardBlockWithAmbientOcclusion(t.getDisguise(), x, y, z, 1, 1, 1); } return true; }
@Override public boolean onItemUse( ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { if (world.isRemote) { return true; } if (!containsSoul(itemstack)) { return false; } if (player == null) { return false; } Entity mob; NBTTagCompound root = itemstack.stackTagCompound; if (root.hasKey("isStub")) { String entityId = root.getString("id"); mob = EntityList.createEntityByName(entityId, world); } else { mob = EntityList.createEntityFromNBT(root, world); } if (mob == null) { return true; } mob.readFromNBT(root); Block blk = world.getBlock(x, y, z); double spawnX = x + Facing.offsetsXForSide[side] + 0.5; double spawnY = y + Facing.offsetsYForSide[side]; double spawnZ = z + Facing.offsetsZForSide[side] + 0.5; if (side == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) { spawnY += 0.5; } mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0); boolean spaceClear = world.checkNoEntityCollision(mob.boundingBox) && world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty(); if (!spaceClear) { return false; } if (itemstack.hasDisplayName() && mob instanceof EntityLiving) { ((EntityLiving) mob).setCustomNameTag(itemstack.getDisplayName()); } world.spawnEntityInWorld(mob); if (mob instanceof EntityLiving) { ((EntityLiving) mob).playLivingSound(); } Entity riddenByEntity = mob.riddenByEntity; while (riddenByEntity != null) { riddenByEntity.setLocationAndAngles( spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F); world.spawnEntityInWorld(riddenByEntity); if (riddenByEntity instanceof EntityLiving) { ((EntityLiving) riddenByEntity).playLivingSound(); } riddenByEntity = riddenByEntity.riddenByEntity; } if (!player.capabilities.isCreativeMode) { if (itemstack.stackSize > 1) { itemstack.stackSize--; player.inventory.addItemStackToInventory(new ItemStack(this)); player.inventoryContainer.detectAndSendChanges(); } else { itemstack.setTagCompound(null); } } return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { IIcon soulariumIcon = EnderIO.blockSoulFuser.getIcon(ForgeDirection.EAST.ordinal(), 0); override = renderer.overrideBlockTexture; // Horrible hack to get the MC lighting engine to set the correct values for me if (renderer != null && world != null) { renderer.setOverrideBlockTexture(IconUtil.blankTexture); renderer.renderStandardBlock(Blocks.stone, x, y, z); renderer.setOverrideBlockTexture(null); } BoundingBox bb; Tessellator.instance.addTranslation(x, y, z); bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.85, 0.85); setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH); CubeRenderer.render(bb, icons, true); float slabWidth = 0.15f; bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1); bb = bb.translate(0, 0.5f - (slabWidth / 2), 0); setIcons( soulariumIcon, EnderIO.blockSoulFuser.getIcon(ForgeDirection.UP.ordinal(), 0), ForgeDirection.UP); CubeRenderer.render(bb, icons, true); bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1); bb = bb.translate(0, -0.5f + (slabWidth / 2), 0); setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH); CubeRenderer.render(bb, icons, true); IIcon endermanIcon; int facing = ForgeDirection.SOUTH.ordinal(); if (world == null || !(world.getTileEntity(x, y, z) instanceof TileSoulBinder)) { endermanIcon = EnderIO.blockSoulFuser.endermanSkullIcon; } else { TileSoulBinder sb = (TileSoulBinder) world.getTileEntity(x, y, z); facing = sb.facing; endermanIcon = sb.isActive() ? EnderIO.blockSoulFuser.endermanSkullIconOn : EnderIO.blockSoulFuser.endermanSkullIcon; } renderSkull(forFacing(ForgeDirection.SOUTH, facing), soulariumIcon, endermanIcon); renderSkull( forFacing(ForgeDirection.WEST, facing), soulariumIcon, EnderIO.blockSoulFuser.skeletonSkullIcon); renderSkull( forFacing(ForgeDirection.NORTH, facing), soulariumIcon, EnderIO.blockSoulFuser.zombieSkullIcon); renderSkull( forFacing(ForgeDirection.EAST, facing), soulariumIcon, EnderIO.blockSoulFuser.creeperSkullIcon); Tessellator.instance.addTranslation(-x, -y, -z); return true; }
@Override protected int processSideToIconIndexMapping(int side) { if (side == ForgeDirection.UP.ordinal()) return 0; if (side == ForgeDirection.DOWN.ordinal()) return 1; return 2; }
private void renderGeode( IBlockAccess world, int x, int y, int z, Block b, int meta, RenderBlocks rb) { /* Coordinate c = new Coordinate(x, y, z); Long val = renderMap.get(c); if (val != null) ReikaJavaLibrary.pConsole("Rerendering "+TieredOres.list[meta]+" geode at "+x+", "+y+", "+z+"; "+(System.currentTimeMillis()-val.longValue())+" ms since last render here."); else ReikaJavaLibrary.pConsole("Rerendering "+TieredOres.list[meta]+" geode at "+x+", "+y+", "+z+"; Has not rendered before."); renderMap.put(c, System.currentTimeMillis()); */ TessellatorVertexList v5 = new TessellatorVertexList(); Tessellator.instance.setColorOpaque_I(0xffffff); Tessellator.instance.addTranslation(x, y, z); IIcon stone = ((BlockTieredOre) b).getDisguise(meta).getIcon(0, 0); float us = stone.getMinU(); float vs = stone.getMinV(); float dus = stone.getMaxU(); float dvs = stone.getMaxV(); IIcon obsidian = Blocks.obsidian.getIcon(0, 0); float ub = obsidian.getMinU(); float vb = obsidian.getMinV(); float dub = obsidian.getMaxU(); float dvb = obsidian.getMaxV(); IIcon ico = ((BlockTieredOre) b).getGeodeIcon(meta); float uo = ico.getMinU(); float vo = ico.getMinV(); float duo = ico.getMaxU(); float dvo = ico.getMaxV(); double s = 1D / numSections; int da = offsetArray[(x % 16 + 16) % 16][(y % 16 + 16) % 16][(z % 16 + 16) % 16]; for (int i = 0; i < numSections; i++) { double d = i * s; for (int k = 0; k < numSections; k++) { double d2 = k * s; boolean center = false; // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, k); // center |= ReikaMathLibrary.isValueInsideBoundsIncl(1, numSections-2, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, k); // center |= ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(1, numSections-2, k); float us1 = center ? (float) (ub + (dub - ub) * d) : (float) (us + (dus - us) * d); float vs1 = center ? (float) (vb + (dvb - vb) * d2) : (float) (vs + (dvs - vs) * d2); float us2 = center ? (float) (ub + (dub - ub) * (d + s)) : (float) (us + (dus - us) * (d + s)); float vs2 = center ? (float) (vb + (dvb - vb) * (d2 + s)) : (float) (vs + (dvs - vs) * (d2 + s)); v5.addVertexWithUV(d, stoneOffsets[da][(i) * numSections + (k + 1)], d2 + s, us1, vs1); v5.addVertexWithUV( d + s, stoneOffsets[da][(i + 1) * numSections + (k + 1)], d2 + s, us2, vs1); v5.addVertexWithUV(d + s, stoneOffsets[da][(i + 1) * numSections + (k)], d2, us2, vs2); v5.addVertexWithUV(d, stoneOffsets[da][(i) * numSections + (k)], d2, us1, vs2); } } /* if (world != null) { ReikaJavaLibrary.pConsole("*************************************"); for (int i = 0; i < 6; i++) { ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; ReikaJavaLibrary.pConsole(dir+" > "+b.shouldSideBeRendered(world, x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, dir.ordinal())); } ReikaJavaLibrary.pConsole("---------------------------------------"); } */ if (world == null || b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y + 1, z)); Tessellator.instance.setColorOpaque_F(1F, 1F, 1F); } Tessellator.instance.setNormal(0, 1, 0); v5.render(); } v5.invertY(); if (world == null || b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y - 1, z)); Tessellator.instance.setColorOpaque_F(0.5F, 0.5F, 0.5F); } Tessellator.instance.setNormal(0, -1, 0); v5.render(); } v5.rotateYtoX(); if (world == null || b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x - 1, y, z)); Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F); } Tessellator.instance.setNormal(-1, 0, 0); v5.render(); } v5.invertX(); if (world == null || b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x + 1, y, z)); Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F); } Tessellator.instance.setNormal(1, 0, 0); v5.render(); } v5.rotateXtoZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z + 1)); Tessellator.instance.setColorOpaque_F(0.7F, 0.7F, 0.7F); } Tessellator.instance.setNormal(0, 0, -1); v5.render(); } v5.invertZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z - 1)); Tessellator.instance.setColorOpaque_F(0.7F, 0.7F, 0.7F); } Tessellator.instance.setNormal(0, 0, 1); v5.render(); } v5.clear(); if (world != null) Tessellator.instance.setBrightness(240); for (int i = 0; i < numSections; i++) { double d = i * s; double db = d + s; for (int k = 0; k < numSections; k++) { double d2 = k * s; double d2b = d2 + s; float uo1 = (float) (uo + (duo - uo) * d); float vo1 = (float) (vo + (dvo - vo) * d2); float uo2 = (float) (uo + (duo - uo) * (d + s)); float vo2 = (float) (vo + (dvo - vo) * (d2 + s)); if (i == 0) { d = 0.2; } else if (i == numSections - 1) { db = 0.8; } if (k == 0) { d2 = 0.2; } else if (k == numSections - 1) { d2b = 0.8; } v5.addVertexWithUV(d, oreOffsets[da][(i) * numSections + (k + 1)], d2b, uo1, vo1); v5.addVertexWithUV(db, oreOffsets[da][(i + 1) * numSections + (k + 1)], d2b, uo2, vo1); v5.addVertexWithUV(db, oreOffsets[da][(i + 1) * numSections + (k)], d2, uo2, vo2); v5.addVertexWithUV(d, oreOffsets[da][(i) * numSections + (k)], d2, uo1, vo2); } } if (world == null || b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) { Tessellator.instance.setNormal(0, 1, 0); v5.render(); } v5.invertY(); if (world == null || b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) { Tessellator.instance.setNormal(0, -1, 0); v5.render(); } v5.rotateYtoX(); if (world == null || b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) { Tessellator.instance.setNormal(-1, 0, 0); v5.render(); } v5.invertX(); if (world == null || b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) { Tessellator.instance.setNormal(1, 0, 0); v5.render(); } v5.rotateXtoZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) { Tessellator.instance.setNormal(0, 0, -1); v5.render(); } v5.invertZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) { Tessellator.instance.setNormal(0, 0, 1); v5.render(); } Tessellator.instance.addTranslation(-x, -y, -z); }