From c43dd31d6e670325094d12e0c35bafb73c8470b9 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 8 Jun 2013 17:04:09 +1000 Subject: [PATCH] Altar blocks getting closer to done, all that's left is some brightness bugs and the lack of gem drops --- src/minecraft/biomesoplenty/ClientProxy.java | 3 + .../biomesoplenty/blocks/BlockAltar.java | 63 ++++++++++--------- .../blocks/renderers/AltarRenderer.java | 19 +----- .../blocks/renderers/RenderUtils.java | 6 +- .../tileentity/TileEntityAltar.java | 45 +++++++++++++ 5 files changed, 89 insertions(+), 47 deletions(-) diff --git a/src/minecraft/biomesoplenty/ClientProxy.java b/src/minecraft/biomesoplenty/ClientProxy.java index 32996fd03..cc3330f6a 100644 --- a/src/minecraft/biomesoplenty/ClientProxy.java +++ b/src/minecraft/biomesoplenty/ClientProxy.java @@ -17,6 +17,7 @@ import biomesoplenty.api.Items; import biomesoplenty.blocks.renderers.AltarRenderer; import biomesoplenty.blocks.renderers.FoliageRenderer; import biomesoplenty.blocks.renderers.PlantsRenderer; +import biomesoplenty.blocks.renderers.RenderUtils; import biomesoplenty.blocks.renderers.SmallBlockRenderer; import biomesoplenty.items.projectiles.EntityDart; import biomesoplenty.items.projectiles.EntityMudball; @@ -34,6 +35,8 @@ public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { + RenderUtils.altarModel = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart()); //RenderingRegistry.registerEntityRenderingHandler(EntityPoisonDart.class, new RenderPoisonDart()); diff --git a/src/minecraft/biomesoplenty/blocks/BlockAltar.java b/src/minecraft/biomesoplenty/blocks/BlockAltar.java index 89e648dfc..eca4d330a 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockAltar.java +++ b/src/minecraft/biomesoplenty/blocks/BlockAltar.java @@ -1,8 +1,12 @@ package biomesoplenty.blocks; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -16,6 +20,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; @@ -25,6 +32,7 @@ import biomesoplenty.BiomesOPlenty; import biomesoplenty.api.Blocks; import biomesoplenty.api.Items; import biomesoplenty.blocks.renderers.AltarRenderer; +import biomesoplenty.blocks.renderers.RenderUtils; import biomesoplenty.blocks.renderers.SmallBlockRenderer; import biomesoplenty.tileentity.TileEntityAltar; @@ -111,9 +119,10 @@ public class BlockAltar extends Block if (!world.isRemote) { tileentityaltar.setPresent(equippedItem.getItemName(), true); + System.out.println(equippedItem.getItemName()); --equippedItem.stackSize; } - + world.markBlockForUpdate(x, y, z); return true; @@ -125,7 +134,6 @@ public class BlockAltar extends Block return false; } - @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { @@ -149,7 +157,7 @@ public class BlockAltar extends Block @Override public int getRenderType() { - return AltarRenderer.altarModel; + return RenderUtils.altarModel; } @Override @@ -160,40 +168,37 @@ public class BlockAltar extends Block if (tileentityaltar != null) { - if (!world.isRemote) + if (tileentityaltar.getPresent("ruby")); { - if (tileentityaltar.getPresent("ruby")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 10)); - } + ret.add(new ItemStack(Items.miscItems.get(), 1, 10)); + } - if (tileentityaltar.getPresent("peridot")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 11)); - } + if (tileentityaltar.getPresent("peridot")); + { + ret.add(new ItemStack(Items.miscItems.get(), 1, 11)); + } - if (tileentityaltar.getPresent("topaz")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 12)); - } + if (tileentityaltar.getPresent("topaz")); + { + ret.add(new ItemStack(Items.miscItems.get(), 1, 12)); + } - if (tileentityaltar.getPresent("tanzanite")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 13)); - } + if (tileentityaltar.getPresent("tanzanite")); + { + ret.add(new ItemStack(Items.miscItems.get(), 1, 13)); + } - if (tileentityaltar.getPresent("apatite")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 14)); - } + if (tileentityaltar.getPresent("apatite")); + { + ret.add(new ItemStack(Items.miscItems.get(), 1, 14)); + } - if (tileentityaltar.getPresent("sapphire")); - { - ret.add(new ItemStack(Items.miscItems.get(), 1, 15)); - } + if (tileentityaltar.getPresent("sapphire")); + { + ret.add(new ItemStack(Items.miscItems.get(), 1, 15)); } } - + ret.add(new ItemStack(Blocks.altar.get().blockID, 1, 0)); return ret; diff --git a/src/minecraft/biomesoplenty/blocks/renderers/AltarRenderer.java b/src/minecraft/biomesoplenty/blocks/renderers/AltarRenderer.java index 56dd5064f..a225d7564 100644 --- a/src/minecraft/biomesoplenty/blocks/renderers/AltarRenderer.java +++ b/src/minecraft/biomesoplenty/blocks/renderers/AltarRenderer.java @@ -18,63 +18,48 @@ import cpw.mods.fml.client.registry.RenderingRegistry; public class AltarRenderer implements ISimpleBlockRenderingHandler { - public static int altarModel = RenderingRegistry.getNextAvailableRenderId(); - @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { TileEntityAltar tileentityaltar = (TileEntityAltar) world.getBlockTileEntity(x, y, z); - if (modelId == altarModel) + if (modelId == RenderUtils.altarModel) { if (tileentityaltar != null) { - renderer.renderAllFaces = false; - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.altarFrame, world, x, y, z); if (tileentityaltar.getPresent("apatite")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.frameApatite, world, x, y, z); } if (tileentityaltar.getPresent("peridot")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.framePeridot, world, x, y, z); } if (tileentityaltar.getPresent("ruby")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.frameRuby, world, x, y, z); } if (tileentityaltar.getPresent("sapphire")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.frameSapphire, world, x, y, z); } if (tileentityaltar.getPresent("tanzanite")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.frameTanzanite, world, x, y, z); } if (tileentityaltar.getPresent("topaz")) { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.renderAltarSlotFaces(renderer, block, BlockAltar.frameTopaz, world, x, y, z); } - - renderer.renderAllFaces = false; - - renderer.clearOverrideBlockTexture(); } } @@ -107,6 +92,6 @@ public class AltarRenderer implements ISimpleBlockRenderingHandler @Override public int getRenderId() { - return altarModel; + return RenderUtils.altarModel; } } diff --git a/src/minecraft/biomesoplenty/blocks/renderers/RenderUtils.java b/src/minecraft/biomesoplenty/blocks/renderers/RenderUtils.java index bf2402546..a025b1873 100644 --- a/src/minecraft/biomesoplenty/blocks/renderers/RenderUtils.java +++ b/src/minecraft/biomesoplenty/blocks/renderers/RenderUtils.java @@ -2,6 +2,8 @@ package biomesoplenty.blocks.renderers; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.client.registry.RenderingRegistry; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; @@ -13,6 +15,8 @@ import net.minecraftforge.common.ForgeDirection; public class RenderUtils { + public static int altarModel = -1; + public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) { Tessellator tessellator = Tessellator.instance; @@ -671,7 +675,7 @@ public class RenderUtils } private static boolean renderFaceWithColorMultiplier(RenderBlocks renderer, Block block, IBlockAccess world, Icon icon, int x, int y, int z, float r, float g, float b, int brightness, ForgeDirection face) { - renderer.enableAO = false; + //renderer.enableAO = false; Tessellator tessellator = Tessellator.instance; boolean flag = false; float yMod = 0.5F; diff --git a/src/minecraft/biomesoplenty/tileentity/TileEntityAltar.java b/src/minecraft/biomesoplenty/tileentity/TileEntityAltar.java index 1832345a0..31df171a0 100644 --- a/src/minecraft/biomesoplenty/tileentity/TileEntityAltar.java +++ b/src/minecraft/biomesoplenty/tileentity/TileEntityAltar.java @@ -2,7 +2,11 @@ package biomesoplenty.tileentity; import java.lang.reflect.Field; +import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -39,6 +43,47 @@ public class TileEntityAltar extends TileEntity nbt.setBoolean("topazPresent", topazPresent); } + @Override + public Packet getDescriptionPacket() + { + if (this.worldObj.isRemote) + { + return null; + } + else + { + NBTTagCompound nbt = new NBTTagCompound(); + + nbt.setBoolean("apatitePresent", apatitePresent); + nbt.setBoolean("peridotPresent", peridotPresent); + nbt.setBoolean("rubyPresent", rubyPresent); + nbt.setBoolean("sapphirePresent", sapphirePresent); + nbt.setBoolean("tanzanitePresent", tanzanitePresent); + nbt.setBoolean("topazPresent", topazPresent); + + return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 0, nbt); + } + } + + @Override + public void onDataPacket(INetworkManager var1, Packet132TileEntityData packet) + { + //if (this.worldObj.isRemote) + //{ + if (packet.actionType == 0) + { + this.apatitePresent = packet.customParam1.getBoolean("apatitePresent"); + this.peridotPresent = packet.customParam1.getBoolean("peridotPresent"); + this.rubyPresent = packet.customParam1.getBoolean("rubyPresent"); + this.sapphirePresent = packet.customParam1.getBoolean("sapphirePresent"); + this.tanzanitePresent = packet.customParam1.getBoolean("tanzanitePresent"); + this.topazPresent = packet.customParam1.getBoolean("topazPresent"); + } + //} + + this.worldObj.markBlockForUpdate(packet.xPosition, packet.yPosition, packet.zPosition); + } + public void setPresent(String presentGem, boolean state) { if (presentGem == "apatite")