diff --git a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java index 50d512b..57a456a 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java @@ -25,7 +25,6 @@ public abstract class AbstractWireTile extends BlockContainer { return true; } } - System.out.println(world.getBlockMetadata(x, y, z)); return false; } public void displayWiringGui(EntityPlayer player, AbstractWireTileEntity chip, ToolWiring tool, int x, int y, int z) { @@ -59,4 +58,9 @@ public abstract class AbstractWireTile extends BlockContainer { public int getRenderType(){ return 28; } + + @Override + public int getRenderBlockPass() { + return 1; + } } diff --git a/src/main/java/net/brokenmoon/afloydwiremod/api/WireConnection.java b/src/main/java/net/brokenmoon/afloydwiremod/api/WireConnection.java index 7096591..3a5ba07 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/api/WireConnection.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/api/WireConnection.java @@ -17,12 +17,17 @@ public class WireConnection { public ArrayList zadd = new ArrayList(); public ArrayList sideadd = new ArrayList(); public boolean backwired = false; + public float red = 1; + public float green = 0; + public float blue = 0; + public float alpha = 1; + public float width = 5f; public WireConnection(){ this.isMade = false; } - public WireConnection(int x, int y, int z, int slot, int slot1, ArrayList xadd, ArrayList yadd, ArrayList zadd, ArrayList sideadd, boolean backwired) { + public WireConnection(int x, int y, int z, int slot, int slot1, ArrayList xadd, ArrayList yadd, ArrayList zadd, ArrayList sideadd, boolean backwired, float red, float green, float blue, float alpha, float width) { this.x = x; this.y = y; this.z = z; @@ -31,6 +36,11 @@ public class WireConnection { this.xadd = xadd; this.yadd = yadd; this.zadd = zadd; + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + this.width = width; this.sideadd = sideadd; this.backwired = backwired; this.isMade = true; @@ -45,6 +55,11 @@ public class WireConnection { nbttagcompound.setInteger("wthatslot", thatslot); nbttagcompound.setInteger("wexsize", xadd.size()); nbttagcompound.setBoolean("wback", backwired); + nbttagcompound.setFloat("wred", red); + nbttagcompound.setFloat("wgreen", green); + nbttagcompound.setFloat("wblue", blue); + nbttagcompound.setFloat("walpha", alpha); + nbttagcompound.setFloat("wwidth", width); for(int i = 0; i < xadd.size(); i++){ nbttagcompound.setInteger("xadd" + i, xadd.get(i)); nbttagcompound.setInteger("yadd" + i, yadd.get(i)); @@ -62,6 +77,11 @@ public class WireConnection { this.thisslot = nbttagcompound.getInteger("wthisslot"); this.thatslot = nbttagcompound.getInteger("wthatslot"); this.backwired = nbttagcompound.getBoolean("wback"); + this.red = nbttagcompound.getFloat("wred"); + this.green = nbttagcompound.getFloat("wgreen"); + this.blue = nbttagcompound.getFloat("wblue"); + this.alpha = nbttagcompound.getFloat("walpha"); + this.width = nbttagcompound.getFloat("wwidth"); for(int i = 0; i < nbttagcompound.getInteger("wexsize"); i++){ this.xadd.add(i, nbttagcompound.getInteger("xadd" + i)); this.yadd.add(i, nbttagcompound.getInteger("yadd" + i)); diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWireTool.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWireTool.java new file mode 100644 index 0000000..2197757 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWireTool.java @@ -0,0 +1,49 @@ +package net.brokenmoon.afloydwiremod.gui; + +import net.brokenmoon.afloydwiremod.item.ToolWiring; +import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; +import net.minecraft.src.EntityPlayerSP; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.GuiSlider; + +public class GuiWireTool extends GuiScreen { + public ToolWiring tool; + public GuiWireTool(EntityPlayerSP entityPlayerSP, ToolWiring toolWiring) { + super.initGui(); + this.tool = toolWiring; + } + + @Override + public void initGui() { + this.controlList.add(new GuiSlider(1, this.width/2-100, this.height/2-40, 200, 20, "Red", tool.red)); + this.controlList.add(new GuiSlider(2, this.width/2-100, this.height/2-20, 200, 20, "Green", tool.green)); + this.controlList.add(new GuiSlider(3, this.width/2-100, this.height/2+00, 200, 20, "Blue", tool.blue)); + this.controlList.add(new GuiSlider(4, this.width/2-100, this.height/2+20, 200, 20, "Alpha", tool.alpha)); + this.controlList.add(new GuiSlider(5, this.width/2-100, this.height/2+40, 200, 20, "Width", tool.width)); + } + + @Override + protected void actionPerformed(GuiButton guiButton){ + if(guiButton instanceof GuiSlider){ + switch(guiButton.id){ + case 1: + tool.red = ((GuiSlider) guiButton).sliderValue; + break; + case 2: + tool.green = ((GuiSlider) guiButton).sliderValue; + break; + case 3: + tool.blue = ((GuiSlider) guiButton).sliderValue; + break; + case 4: + tool.alpha = ((GuiSlider) guiButton).sliderValue; + break; + case 5: + tool.width = ((GuiSlider) guiButton).sliderValue; + break; + } + } + } + +} diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java index 956388f..17485d5 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java @@ -72,8 +72,7 @@ public class GuiWiring extends GuiScrollable { } } else if(!this.tool.type.equals("unpaired")) { if(this.tool.type.equals("input")) { - AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z); - wireEntity.outputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false); + wireEntity.outputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false, tool.red, tool.green, tool.blue, tool.alpha, tool.width); Minecraft.getMinecraft().theWorld.markBlocksDirty(x, y, z, x, y, z); Minecraft.getMinecraft().theWorld.markBlocksDirty(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord); tool.xadd = new ArrayList(); @@ -83,7 +82,8 @@ public class GuiWiring extends GuiScrollable { tool.type = "unpaired"; } else if(this.tool.type.equals("output")) { AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z); - otherEntity.outputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true); + if(otherEntity != null) + otherEntity.outputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true, tool.red, tool.green, tool.blue, tool.alpha, tool.width); Minecraft.getMinecraft().theWorld.markBlocksDirty(x, y, z, x, y, z); Minecraft.getMinecraft().theWorld.markBlocksDirty(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord); tool.xadd = new ArrayList(); diff --git a/src/main/java/net/brokenmoon/afloydwiremod/item/ToolWiring.java b/src/main/java/net/brokenmoon/afloydwiremod/item/ToolWiring.java index 9822930..c5df477 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/item/ToolWiring.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/item/ToolWiring.java @@ -1,9 +1,8 @@ package net.brokenmoon.afloydwiremod.item; -import net.minecraft.src.EntityPlayer; -import net.minecraft.src.Item; -import net.minecraft.src.ItemStack; -import net.minecraft.src.World; +import net.brokenmoon.afloydwiremod.WireMod; +import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer; +import net.minecraft.src.*; import java.util.ArrayList; import java.util.Stack; @@ -19,17 +18,41 @@ public class ToolWiring extends Item { public ArrayList sideadd = new ArrayList(); public String type = "unpaired"; public int slot; + + public float red = 1; + public float green = 0; + public float blue = 0; + public float alpha = 1; + public float width = 0.5f; + public ToolWiring(int i) { super(i); this.maxStackSize = 1; } public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, double heightPlaced) { - xadd.add(i); - yadd.add(j); - zadd.add(k); - sideadd.add(l); - System.out.println(l); + if(entityplayer.isSneaking()){ + if (!world.isMultiplayerAndNotHost) { + this.displayWireSettings(entityplayer, this); + return true; + } + } else { + xadd.add(i); + yadd.add(j); + zadd.add(k); + sideadd.add(l); + return false; + } return false; } -} + + private void displayWireSettings(EntityPlayer player, ToolWiring toolWiring) { + if(player instanceof EntityPlayerMP) { + //Multiplayer + ((IEntityPlayer)player).displayGuiWireSettings(toolWiring); + return; + } + //Singleplayer + ((IEntityPlayer)player).displayGuiWireSettings(toolWiring); + } + } diff --git a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinBlockRenderer.java b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinBlockRenderer.java index 948ffb7..4088dd4 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinBlockRenderer.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinBlockRenderer.java @@ -23,27 +23,30 @@ public class MixinBlockRenderer { public boolean renderStandardBlock(Block block, int i, int j, int k) { return false; } @Shadow World world; - @Inject(method = "Lnet/minecraft/src/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/src/Block;III)Z", at = @At("HEAD")) + @Inject(method = "Lnet/minecraft/src/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/src/Block;III)Z", at = @At("HEAD"), cancellable = true) public void injectMethod(Block block, int i, int j, int k, CallbackInfoReturnable cir){ if(block.getRenderType() == 28){ AbstractWireTileEntity wireEntity = (AbstractWireTileEntity)this.world.getBlockTileEntity(i, j, k); + if(block instanceof AbstractWireTileSided) { + this.renderSidedBlock(block, i, j, k); + } else { + this.renderStandardBlock(block, i, j, k); + } if(wireEntity.outputs != null){ for(int it = 0; it < wireEntity.outputs.length; it++){ if(wireEntity.outputs[it].wire != null && wireEntity.outputs[it].wire.isMade){ - this.renderLineBetweenTwoPoints(i, j, k, + this.renderLineBetweenTwoPoints( + i, j, k, wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z, + wireEntity.outputs[it].wire.red, wireEntity.outputs[it].wire.green, wireEntity.outputs[it].wire.blue, wireEntity.outputs[it].wire.alpha, wireEntity.outputs[it].wire.width * 10, wireEntity.outputs[it].wire.xadd, wireEntity.outputs[it].wire.yadd, wireEntity.outputs[it].wire.zadd, wireEntity.outputs[it].wire.sideadd, wireEntity.outputs[it].wire.backwired, - block instanceof AbstractWireTileSided, Block.getBlock(world.getBlockId(wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z)) instanceof AbstractWireTileSided); + block instanceof AbstractWireTileSided, + Block.getBlock(world.getBlockId(wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z)) instanceof AbstractWireTileSided); } } } - if(block instanceof AbstractWireTileSided) { - this.renderSidedBlock(block, i, j, k); - } else { - this.renderStandardBlock(block, i, j, k); - } - + cir.setReturnValue(true); } } @@ -107,6 +110,8 @@ public class MixinBlockRenderer { public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, float alpha, float width, ArrayList xadd, ArrayList yadd, ArrayList zadd, ArrayList sideadd, boolean backwired, boolean firstblocksided, boolean secondblocksided){ GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(red, green, blue, alpha); GL11.glLineWidth(width); GL11.glBegin(GL11.GL_LINE_STRIP); @@ -356,6 +361,7 @@ public class MixinBlockRenderer { } } GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); } @@ -367,6 +373,6 @@ public class MixinBlockRenderer { renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, 255, 1, xadd, yadd, zadd, sideadd, backwired, firstblocksided, secondblocksided); } public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, ArrayList xadd, ArrayList yadd, ArrayList zadd, ArrayList sideadd, boolean backwired, boolean firstblocksided, boolean secondblocksided){ - renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, 255, 0, 0, 255 / 2, 5, xadd, yadd, zadd, sideadd, backwired, firstblocksided, secondblocksided); + renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, 255, 0, 0, 255f / 2, 5, xadd, yadd, zadd, sideadd, backwired, firstblocksided, secondblocksided); } } diff --git a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinEntityPlayerSP.java b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinEntityPlayerSP.java index 91aa9d4..787d54f 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinEntityPlayerSP.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinEntityPlayerSP.java @@ -3,6 +3,7 @@ package net.brokenmoon.afloydwiremod.mixin; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.gui.GuiProgrammer; import net.brokenmoon.afloydwiremod.gui.GuiSettings; +import net.brokenmoon.afloydwiremod.gui.GuiWireTool; import net.brokenmoon.afloydwiremod.gui.GuiWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer; @@ -29,4 +30,9 @@ public class MixinEntityPlayerSP implements IEntityPlayer { public void displayGuiSettings(AbstractWireTileEntity chip) { this.mc.displayGuiScreen(new GuiSettings(((EntityPlayerSP)(Object)this), chip)); } + + @Override + public void displayGuiWireSettings(ToolWiring toolWiring) { + this.mc.displayGuiScreen(new GuiWireTool(((EntityPlayerSP)(Object)this), toolWiring)); + } } diff --git a/src/main/java/net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer.java b/src/main/java/net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer.java index d4797f8..e6f04a2 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer.java @@ -9,4 +9,5 @@ public interface IEntityPlayer { public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z); public void displayGuiSettings(AbstractWireTileEntity chip); + public void displayGuiWireSettings(ToolWiring toolWiring); } diff --git a/src/main/resources/assets/afloydwiremod/block/chip.png b/src/main/resources/assets/afloydwiremod/block/chip.png index 9588be7..37ddbd2 100644 Binary files a/src/main/resources/assets/afloydwiremod/block/chip.png and b/src/main/resources/assets/afloydwiremod/block/chip.png differ