diff --git a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java index 7775adac..24cb238c 100644 --- a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java +++ b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java @@ -132,8 +132,12 @@ public class ConfigHandler public static boolean vanillaPotionHealthBoostEnabled; public static boolean vanillaPotionAbsorptionEnabled; + // General public static int sacrificialPackConversion; + // Client + public static boolean alwaysRenderRoutingLines; + // Compat public static int wailaAltarDisplayMode; public static boolean thaumcraftGogglesUpgrade; @@ -273,6 +277,10 @@ public class ConfigHandler BloodMagicAPI.setLoggingEnabled(config.getBoolean("enableLogging", category, true, "Allows logging information to the console. Fatal errors will bypass this")); sacrificialPackConversion = config.getInt("sacrificialPackConversion", category, 20, 0, 100, "Base multiplier for the Coat of Arms. DamageDealt * sacrificialPackConversion"); + category = "Client"; + config.addCustomCategoryComment(category, "Client only settings"); + alwaysRenderRoutingLines = config.getBoolean("alwaysRenderRoutingLines", category, false, "Always renders the beams between routing nodes. If false, only renders while a Node Router is being held."); + category = "Compatibility"; config.addCustomCategoryComment(category, "Compatibility settings"); wailaAltarDisplayMode = config.getInt("wailaAltarDisplayMode", category + ".waila", 1, 0, 2, "The mode for the Waila display on Blood Altars.\n0 - Always display information\n1 - Only display when Divination/Seer sigil is in hand.\n2 - Only display when Divination/Seer sigil is in inventory"); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java b/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java new file mode 100644 index 00000000..5cc184f8 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java @@ -0,0 +1,9 @@ +package WayofTime.bloodmagic.api.iface; + +/** + * Held items that implement this will cause the beams between + * routing nodes to render. + */ +public interface INodeRenderer +{ +} diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java index 36496a1d..c433999b 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java @@ -26,6 +26,7 @@ public class ConfigGui extends GuiConfig // adds sections declared in ConfigHandler. toLowerCase() is used // because the configuration class automatically does this, so must we. list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Potions".toLowerCase()))); + list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Client".toLowerCase()))); list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Compatibility".toLowerCase()))); list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Teleposer Blacklist".toLowerCase()))); list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Well of Suffering Blacklist".toLowerCase()))); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/RenderItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/client/render/RenderItemRoutingNode.java index bc906c95..ae82c484 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/RenderItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/RenderItemRoutingNode.java @@ -2,6 +2,10 @@ package WayofTime.bloodmagic.client.render; import java.util.List; +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.api.iface.INodeRenderer; +import WayofTime.bloodmagic.registry.ModItems; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; @@ -18,93 +22,96 @@ import WayofTime.bloodmagic.tile.routing.TileRoutingNode; public class RenderItemRoutingNode extends TileEntitySpecialRenderer { - private static final ResourceLocation field_110629_a = new ResourceLocation("textures/entity/beacon_beam.png"); + private static final ResourceLocation beamTexture = new ResourceLocation("textures/entity/beacon_beam.png"); + private static final Minecraft mc = Minecraft.getMinecraft(); // private static final ResourceLocation test = new ResourceLocation("luminescence:textures/models/InputMirror.png"); @Override public void renderTileEntityAt(TileRoutingNode tileNode, double x, double y, double z, float partialTicks, int destroyStage) { - List connectionList = tileNode.getConnected(); - for (BlockPos wantedPos : connectionList) + if ((mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof INodeRenderer) || ConfigHandler.alwaysRenderRoutingLines) { - BlockPos offsetPos = wantedPos.subtract(tileNode.getPos()); + List connectionList = tileNode.getConnected(); + for (BlockPos wantedPos : connectionList) { + BlockPos offsetPos = wantedPos.subtract(tileNode.getPos()); - //The beam renders towards the east by default. + //The beam renders towards the east by default. - int xd = offsetPos.getX(); - int yd = offsetPos.getY(); - int zd = offsetPos.getZ(); - double distance = Math.sqrt(xd * xd + yd * yd + zd * zd); - double subLength = MathHelper.sqrt_double(xd * xd + zd * zd); - float rotYaw = -((float) (Math.atan2(zd, xd) * 180.0D / Math.PI)); - float rotPitch = ((float) (Math.atan2(yd, subLength) * 180.0D / Math.PI)); + int xd = offsetPos.getX(); + int yd = offsetPos.getY(); + int zd = offsetPos.getZ(); + double distance = Math.sqrt(xd * xd + yd * yd + zd * zd); + double subLength = MathHelper.sqrt_double(xd * xd + zd * zd); + float rotYaw = -((float) (Math.atan2(zd, xd) * 180.0D / Math.PI)); + float rotPitch = ((float) (Math.atan2(yd, subLength) * 180.0D / Math.PI)); - GlStateManager.pushMatrix(); - float f1 = 1.0f; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); - this.bindTexture(field_110629_a); - 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); - GlStateManager.disableLighting(); - GlStateManager.disableCull(); - float f2 = 0; - float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.pushMatrix(); + float f1 = 1.0f; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer wr = tessellator.getWorldRenderer(); + this.bindTexture(beamTexture); + 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); + GlStateManager.disableLighting(); + GlStateManager.disableCull(); + float f2 = 0; + float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - double width = 0.06; + double width = 0.06; - float test = (tileNode.getWorld().getTotalWorldTime() + partialTicks) / 5f; + float test = (tileNode.getWorld().getTotalWorldTime() + partialTicks) / 5f; - double d18 = -width / 2; - double d19 = -width / 2; - double d20 = width / 2; - double d21 = -width / 2; - double d22 = -width / 2; - double d23 = width / 2; - double d24 = width / 2; - double d25 = width / 2; - double d26 = (double) (distance * f1); - double d27 = 0.0D; - double d28 = 1.0D; - double d29 = (double) (f3) + test; - double d30 = (double) (distance * f1) + d29; + double d18 = -width / 2; + double d19 = -width / 2; + double d20 = width / 2; + double d21 = -width / 2; + double d22 = -width / 2; + double d23 = width / 2; + double d24 = width / 2; + double d25 = width / 2; + double d26 = (double) (distance * f1); + double d27 = 0.0D; + double d28 = 1.0D; + double d29 = (double) (f3) + test; + double d30 = (double) (distance * f1) + d29; - GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5); + GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5); - GlStateManager.rotate(rotYaw, 0, 1, 0); - GlStateManager.rotate(rotPitch, 0, 0, 1); + GlStateManager.rotate(rotYaw, 0, 1, 0); + GlStateManager.rotate(rotPitch, 0, 0, 1); // tessellator.setBrightness(240); // float s = 1F / 16F; - wr.begin(7, DefaultVertexFormats.POSITION_TEX); + wr.begin(7, DefaultVertexFormats.POSITION_TEX); // tessellator.setColorRGBA(255, 255, 255, 100); - wr.pos(d26, d18, d19).tex(d28, d30).endVertex(); - wr.pos(0, d18, d19).tex(d28, d29).endVertex(); - wr.pos(0, d20, d21).tex(d27, d29).endVertex(); - wr.pos(d26, d20, d21).tex(d27, d30).endVertex(); - wr.pos(d26, d24, d25).tex(d28, d30).endVertex(); - wr.pos(0, d24, d25).tex(d28, d29).endVertex(); - wr.pos(0, d22, d23).tex(d27, d29).endVertex(); - wr.pos(d26, d22, d23).tex(d27, d30).endVertex(); - wr.pos(d26, d20, d21).tex(d28, d30).endVertex(); - wr.pos(0, d20, d21).tex(d28, d29).endVertex(); - wr.pos(0, d24, d25).tex(d27, d29).endVertex(); - wr.pos(d26, d24, d25).tex(d27, d30).endVertex(); - wr.pos(d26, d22, d23).tex(d28, d30).endVertex(); - wr.pos(0, d22, d23).tex(d28, d29).endVertex(); - wr.pos(0, d18, d19).tex(d27, d29).endVertex(); - wr.pos(d26, d18, d19).tex(d27, d30).endVertex(); + wr.pos(d26, d18, d19).tex(d28, d30).endVertex(); + wr.pos(0, d18, d19).tex(d28, d29).endVertex(); + wr.pos(0, d20, d21).tex(d27, d29).endVertex(); + wr.pos(d26, d20, d21).tex(d27, d30).endVertex(); + wr.pos(d26, d24, d25).tex(d28, d30).endVertex(); + wr.pos(0, d24, d25).tex(d28, d29).endVertex(); + wr.pos(0, d22, d23).tex(d27, d29).endVertex(); + wr.pos(d26, d22, d23).tex(d27, d30).endVertex(); + wr.pos(d26, d20, d21).tex(d28, d30).endVertex(); + wr.pos(0, d20, d21).tex(d28, d29).endVertex(); + wr.pos(0, d24, d25).tex(d27, d29).endVertex(); + wr.pos(d26, d24, d25).tex(d27, d30).endVertex(); + wr.pos(d26, d22, d23).tex(d28, d30).endVertex(); + wr.pos(0, d22, d23).tex(d28, d29).endVertex(); + wr.pos(0, d18, d19).tex(d27, d29).endVertex(); + wr.pos(d26, d18, d19).tex(d27, d30).endVertex(); - ShaderHelper.useShader(ShaderHelper.psiBar, (int) tileNode.getWorld().getTotalWorldTime()); - tessellator.draw(); - ShaderHelper.releaseShader(); + ShaderHelper.useShader(ShaderHelper.psiBar, (int) tileNode.getWorld().getTotalWorldTime()); + tessellator.draw(); + ShaderHelper.releaseShader(); - GlStateManager.enableLighting(); - GlStateManager.enableTexture2D(); - GlStateManager.popMatrix(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); + GlStateManager.popMatrix(); + } } } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRoutingNode.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRoutingNode.java new file mode 100644 index 00000000..61079204 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRoutingNode.java @@ -0,0 +1,13 @@ +package WayofTime.bloodmagic.item.block; + +import WayofTime.bloodmagic.api.iface.INodeRenderer; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public class ItemBlockRoutingNode extends ItemBlock implements INodeRenderer +{ + public ItemBlockRoutingNode(Block block) + { + super(block); + } +} diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java index d4da40d9..e55bb7c9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java @@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.routing; import java.util.LinkedList; import java.util.List; +import WayofTime.bloodmagic.api.iface.INodeRenderer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,7 +22,7 @@ import WayofTime.bloodmagic.routing.IRoutingNode; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemNodeRouter extends Item +public class ItemNodeRouter extends Item implements INodeRenderer { public ItemNodeRouter() { diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index 846ab044..2e7ba371 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.registry; +import WayofTime.bloodmagic.item.block.*; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -35,15 +36,6 @@ import WayofTime.bloodmagic.block.BlockRitualStone; import WayofTime.bloodmagic.block.BlockSoulForge; import WayofTime.bloodmagic.block.BlockSpectral; import WayofTime.bloodmagic.block.BlockTeleposer; -import WayofTime.bloodmagic.item.block.ItemBlockBloodRune; -import WayofTime.bloodmagic.item.block.ItemBlockBloodStoneBrick; -import WayofTime.bloodmagic.item.block.ItemBlockBloodTank; -import WayofTime.bloodmagic.item.block.ItemBlockCrystal; -import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal; -import WayofTime.bloodmagic.item.block.ItemBlockPath; -import WayofTime.bloodmagic.item.block.ItemBlockPedestal; -import WayofTime.bloodmagic.item.block.ItemBlockRitualController; -import WayofTime.bloodmagic.item.block.ItemBlockRitualStone; import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.tile.TileAltar; import WayofTime.bloodmagic.tile.TileBloodTank; @@ -119,10 +111,10 @@ public class ModBlocks soulForge = registerBlock(new BlockSoulForge()); crystal = registerBlock(new BlockCrystal(), ItemBlockCrystal.class); bloodStoneBrick = registerBlock(new BlockBloodStoneBrick(), ItemBlockBloodStoneBrick.class); - masterRoutingNode = registerBlock(new BlockMasterRoutingNode()); - inputRoutingNode = registerBlock(new BlockInputRoutingNode()); - outputRoutingNode = registerBlock(new BlockOutputRoutingNode()); - itemRoutingNode = registerBlock(new BlockItemRoutingNode()); + masterRoutingNode = registerBlock(new BlockMasterRoutingNode(), ItemBlockRoutingNode.class); + inputRoutingNode = registerBlock(new BlockInputRoutingNode(), ItemBlockRoutingNode.class); + outputRoutingNode = registerBlock(new BlockOutputRoutingNode(), ItemBlockRoutingNode.class); + itemRoutingNode = registerBlock(new BlockItemRoutingNode(), ItemBlockRoutingNode.class); incenseAltar = registerBlock(new BlockIncenseAltar()); pathBlock = registerBlock(new BlockPath(), ItemBlockPath.class); demonCrucible = registerBlock(new BlockDemonCrucible());