From d9447cbfbadc92313b4fe4a5c704fa598bd56896 Mon Sep 17 00:00:00 2001 From: Cricket Date: Mon, 22 Jun 2015 16:00:35 -0400 Subject: [PATCH] Beacons are done but they render oddly --- .../com/cricketcraft/chisel/Features.java | 13 ++ .../chisel/block/BlockCarvableBeacon.java | 70 +++++++++++ .../tileentity/TileEntityCarvableBeacon.java | 14 +++ .../render/tile/RenderCarvableBeacon.java | 114 ++++++++++++++++++ .../chisel/init/ChiselBlocks.java | 1 + .../chisel/proxy/ClientProxy.java | 3 + .../chisel/proxy/CommonProxy.java | 2 + .../resources/assets/chisel/lang/en_US.lang | 19 +++ .../assets/chisel/textures/blocks/beacon.png | Bin 0 -> 208 bytes 9 files changed, 236 insertions(+) create mode 100644 src/main/java/com/cricketcraft/chisel/block/BlockCarvableBeacon.java create mode 100644 src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityCarvableBeacon.java create mode 100644 src/main/java/com/cricketcraft/chisel/client/render/tile/RenderCarvableBeacon.java create mode 100644 src/main/resources/assets/chisel/textures/blocks/beacon.png diff --git a/src/main/java/com/cricketcraft/chisel/Features.java b/src/main/java/com/cricketcraft/chisel/Features.java index 64758c85..496ef495 100644 --- a/src/main/java/com/cricketcraft/chisel/Features.java +++ b/src/main/java/com/cricketcraft/chisel/Features.java @@ -216,6 +216,19 @@ public enum Features { } }, + BEACON { + @Override + void addBlocks(){ + BlockCarvableBeacon beacon = (BlockCarvableBeacon) new BlockCarvableBeacon().setCreativeTab(ChiselTabs.tabOtherChiselBlocks); + Carving.chisel.addVariation("beacon", Blocks.beacon, 0, 0); + for(int meta = 0; meta < 16; meta++){ + beacon.carverHelper.addVariation("tile.beacon." + ItemDye.field_150923_a[meta] + ".desc", meta, "beacon", (meta + 1)); + } + beacon.carverHelper.registerAll(beacon, "beacon"); + Carving.chisel.registerOre("beacon", "beacon"); + } + }, + BLOOD_RUNE("AWWayofTime") { @Override diff --git a/src/main/java/com/cricketcraft/chisel/block/BlockCarvableBeacon.java b/src/main/java/com/cricketcraft/chisel/block/BlockCarvableBeacon.java new file mode 100644 index 00000000..02bbe883 --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/block/BlockCarvableBeacon.java @@ -0,0 +1,70 @@ +package com.cricketcraft.chisel.block; + +import com.cricketcraft.chisel.api.ICarvable; +import com.cricketcraft.chisel.api.carving.CarvableHelper; +import com.cricketcraft.chisel.api.carving.IVariationInfo; +import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon; +import com.cricketcraft.chisel.init.ChiselTabs; +import net.minecraft.block.BlockBeacon; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockCarvableBeacon extends BlockBeacon implements ICarvable { + + public CarvableHelper carverHelper; + + public BlockCarvableBeacon() { + super(); + setCreativeTab(ChiselTabs.tabOtherChiselBlocks); + setLightLevel(5.0F); + carverHelper = new CarvableHelper(this); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityCarvableBeacon(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX, float hitY, float hitZ) { + if (world.isRemote) { + return true; + } else { + TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z); + + if (tileentitybeacon != null) { + player.func_146104_a(tileentitybeacon); + } + + return true; + } + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, player, stack); + + if (stack.hasDisplayName()) { + ((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName()); + } + } + + @Override + public int getRenderType(){ + return 34; + } + + @Override + public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) { + return carverHelper.getVariation(metadata); + } + + @Override + public IVariationInfo getVariation(ItemStack stack) { + return carverHelper.getVariation(stack.getItemDamage()); + } +} diff --git a/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityCarvableBeacon.java b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityCarvableBeacon.java new file mode 100644 index 00000000..03637ac1 --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityCarvableBeacon.java @@ -0,0 +1,14 @@ +package com.cricketcraft.chisel.block.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.util.AxisAlignedBB; + +public class TileEntityCarvableBeacon extends TileEntityBeacon { + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } +} diff --git a/src/main/java/com/cricketcraft/chisel/client/render/tile/RenderCarvableBeacon.java b/src/main/java/com/cricketcraft/chisel/client/render/tile/RenderCarvableBeacon.java new file mode 100644 index 00000000..5a0f094a --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/client/render/tile/RenderCarvableBeacon.java @@ -0,0 +1,114 @@ +package com.cricketcraft.chisel.client.render.tile; + +import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemDye; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class RenderCarvableBeacon extends TileEntityBeaconRenderer{ + private static final ResourceLocation texture = new ResourceLocation("textures/entity/beacon_beam.png"); + + public void renderTileEntityAt(TileEntityCarvableBeacon beacon, double x, double y, double z, float partialTicks) { + float f1 = beacon.func_146002_i(); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + if(f1 > 0.1F){ + Color color = new Color(ItemDye.field_150922_c[beacon.getWorldObj().getBlockMetadata(beacon.xCoord, beacon.yCoord, beacon.zCoord)]); + Tessellator tessellator = Tessellator.instance; + this.bindTexture(texture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + float f2 = (float) beacon.getWorldObj().getTotalWorldTime() + partialTicks; + float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); + byte b0 = 1; + double d3 = (double) f2 * 0.025D * (1.0D - (double) (b0 & 1) * 2.5D); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32); + double d5 = (double) b0 * 0.2D; + double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5; + double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5; + double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5; + double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5; + double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5; + double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5; + double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5; + double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5; + double d23 = (double) (256.0F * f1); + double d25 = 0.0D; + double d27 = 1.0D; + double d28 = (double) (-1.0F + f3); + double d29 = (double) (256.0F * f1) * (0.5D / d5) + d28; + tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d27, d29); + tessellator.addVertexWithUV(x + d7, y, z + d9, d27, d28); + tessellator.addVertexWithUV(x + d11, y, z + d13, d25, d28); + tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d25, d29); + tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d27, d29); + tessellator.addVertexWithUV(x + d19, y, z + d21, d27, d28); + tessellator.addVertexWithUV(x + d15, y, z + d17, d25, d28); + tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d25, d29); + tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d27, d29); + tessellator.addVertexWithUV(x + d11, y, z + d13, d27, d28); + tessellator.addVertexWithUV(x + d19, y, z + d21, d25, d28); + tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d25, d29); + tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d27, d29); + tessellator.addVertexWithUV(x + d15, y, z + d17, d27, d28); + tessellator.addVertexWithUV(x + d7, y, z + d9, d25, d28); + tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d25, d29); + tessellator.draw(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32); + double d30 = 0.2D; + double d4 = 0.2D; + double d6 = 0.8D; + double d8 = 0.2D; + double d10 = 0.2D; + double d12 = 0.8D; + double d14 = 0.8D; + double d16 = 0.8D; + double d18 = (double) (256.0F * f1); + double d20 = 0.0D; + double d22 = 1.0D; + double d24 = (double) (-1.0F + f3); + double d26 = (double) (256.0F * f1) + d24; + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); + tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); + tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); + tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); + tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); + tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); + tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); + tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); + tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } + } + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { + this.renderTileEntityAt((TileEntityCarvableBeacon) tile, x, y, z, partialTicks); + } +} diff --git a/src/main/java/com/cricketcraft/chisel/init/ChiselBlocks.java b/src/main/java/com/cricketcraft/chisel/init/ChiselBlocks.java index b6cf5459..124f293a 100644 --- a/src/main/java/com/cricketcraft/chisel/init/ChiselBlocks.java +++ b/src/main/java/com/cricketcraft/chisel/init/ChiselBlocks.java @@ -12,6 +12,7 @@ public final class ChiselBlocks { public static final Block autoChisel = null; public static final BlockCarvable antiBlock = null; + public static final BlockCarvableBeacon beacon = null; public static final BlockCarvable marble = null; public static final BlockCarvable marble_pillar = null; public static final BlockCarvable limestone = null; diff --git a/src/main/java/com/cricketcraft/chisel/proxy/ClientProxy.java b/src/main/java/com/cricketcraft/chisel/proxy/ClientProxy.java index eac8eb45..3a289c28 100644 --- a/src/main/java/com/cricketcraft/chisel/proxy/ClientProxy.java +++ b/src/main/java/com/cricketcraft/chisel/proxy/ClientProxy.java @@ -1,11 +1,13 @@ package com.cricketcraft.chisel.proxy; import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel; +import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon; import com.cricketcraft.chisel.block.tileentity.TileEntityPresent; import com.cricketcraft.chisel.client.player.PlayerSpecials; import com.cricketcraft.chisel.client.render.*; import com.cricketcraft.chisel.client.render.item.ItemChiselRenderer; import com.cricketcraft.chisel.client.render.tile.RenderAutoChisel; +import com.cricketcraft.chisel.client.render.tile.RenderCarvableBeacon; import com.cricketcraft.chisel.client.render.tile.RenderPresent; import com.cricketcraft.chisel.entity.EntityBallOMoss; import com.cricketcraft.chisel.entity.EntityChiselSnowman; @@ -47,6 +49,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerBlockHandler(rac); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.autoChisel), rac); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAutoChisel.class, rac); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCarvableBeacon.class, new RenderCarvableBeacon()); RenderPresent rp = new RenderPresent(); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.present), rp); diff --git a/src/main/java/com/cricketcraft/chisel/proxy/CommonProxy.java b/src/main/java/com/cricketcraft/chisel/proxy/CommonProxy.java index 620ac259..15faabd2 100644 --- a/src/main/java/com/cricketcraft/chisel/proxy/CommonProxy.java +++ b/src/main/java/com/cricketcraft/chisel/proxy/CommonProxy.java @@ -1,5 +1,6 @@ package com.cricketcraft.chisel.proxy; +import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -13,6 +14,7 @@ public class CommonProxy { public void registerTileEntities() { GameRegistry.registerTileEntity(TileEntityAutoChisel.class, "autoChisel"); GameRegistry.registerTileEntity(TileEntityPresent.class, "tile.chisel.present"); + GameRegistry.registerTileEntity(TileEntityCarvableBeacon.class, "tile.chisel.beacon"); } public void preInit() { diff --git a/src/main/resources/assets/chisel/lang/en_US.lang b/src/main/resources/assets/chisel/lang/en_US.lang index 9fe81fe9..facebbc7 100644 --- a/src/main/resources/assets/chisel/lang/en_US.lang +++ b/src/main/resources/assets/chisel/lang/en_US.lang @@ -119,6 +119,25 @@ autochisel.slot.automation.tooltip=Automation Upgrade autochisel.slot.stack.tooltip=Stack Upgrade autochisel.slot.reversion.tooltip=Reversion Upgrade +#Beacon +tile.chisel.beacon.name=Beacon +tile.beacon.black.desc=Black Beamed Beacon +tile.beacon.blue.desc=Blue Beamed Beacon +tile.beacon.brown.desc=Brown Beamed Beacon +tile.beacon.cyan.desc=Cyan Beamed Beacon +tile.beacon.green.desc=Green Beamed Beacon +tile.beacon.lightBlue.desc=Light Blue Beamed Beacon +tile.beacon.silver.desc=Light Gray Beamed Beacon +tile.beacon.lime.desc=Lime Beamed Beacon +tile.beacon.magenta.desc=Magenta Beamed Beacon +tile.beacon.orange.desc=Orange Beamed Beacon +tile.beacon.pink.desc=Pink Beamed Beacon +tile.beacon.purple.desc=Purple Beamed Beacon +tile.beacon.red.desc=Red Beamed Beacon +tile.beacon.white.desc=White Beamed Beacon +tile.beacon.yellow.desc=Yellow Beamed Beacon +tile.beacon.gray.desc=Gray Beamed Beacon + #Leaves tile.chisel.leaves.name=Leaf tile.leaves.6.desc=Dead Leaves diff --git a/src/main/resources/assets/chisel/textures/blocks/beacon.png b/src/main/resources/assets/chisel/textures/blocks/beacon.png new file mode 100644 index 0000000000000000000000000000000000000000..a69e59dcc192116931a8b86cd14c4cdbe1b41ce5 GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`(>+}rLn>}1|L|8#U=X}zZJzMx zGW&*P71Q*4H4a7$-AU(Hryr1*?s$WDM>+30LD}Xf8>AbSSw4Bz`u}JD`vnOTBz7rE zuqkBE`~33lf93!G8x1>plQ`NK1N0kICYr`KC#5(SNHKg?_Ym~?Y`s8+<1kO7B!e-_ zQEnCK23>)Z-