Funky fresh colorful, transparent wires

visibileWires
Astoria 2 years ago
parent 0b3f389337
commit d50e817bcd

@ -25,7 +25,6 @@ public abstract class AbstractWireTile extends BlockContainer {
return true; return true;
} }
} }
System.out.println(world.getBlockMetadata(x, y, z));
return false; return false;
} }
public void displayWiringGui(EntityPlayer player, AbstractWireTileEntity chip, ToolWiring tool, int x, int y, int z) { 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(){ public int getRenderType(){
return 28; return 28;
} }
@Override
public int getRenderBlockPass() {
return 1;
}
} }

@ -17,12 +17,17 @@ public class WireConnection {
public ArrayList<Integer> zadd = new ArrayList<Integer>(); public ArrayList<Integer> zadd = new ArrayList<Integer>();
public ArrayList<Integer> sideadd = new ArrayList<Integer>(); public ArrayList<Integer> sideadd = new ArrayList<Integer>();
public boolean backwired = false; 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(){ public WireConnection(){
this.isMade = false; this.isMade = false;
} }
public WireConnection(int x, int y, int z, int slot, int slot1, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired) { public WireConnection(int x, int y, int z, int slot, int slot1, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired, float red, float green, float blue, float alpha, float width) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
@ -31,6 +36,11 @@ public class WireConnection {
this.xadd = xadd; this.xadd = xadd;
this.yadd = yadd; this.yadd = yadd;
this.zadd = zadd; this.zadd = zadd;
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
this.width = width;
this.sideadd = sideadd; this.sideadd = sideadd;
this.backwired = backwired; this.backwired = backwired;
this.isMade = true; this.isMade = true;
@ -45,6 +55,11 @@ public class WireConnection {
nbttagcompound.setInteger("wthatslot", thatslot); nbttagcompound.setInteger("wthatslot", thatslot);
nbttagcompound.setInteger("wexsize", xadd.size()); nbttagcompound.setInteger("wexsize", xadd.size());
nbttagcompound.setBoolean("wback", backwired); 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++){ for(int i = 0; i < xadd.size(); i++){
nbttagcompound.setInteger("xadd" + i, xadd.get(i)); nbttagcompound.setInteger("xadd" + i, xadd.get(i));
nbttagcompound.setInteger("yadd" + i, yadd.get(i)); nbttagcompound.setInteger("yadd" + i, yadd.get(i));
@ -62,6 +77,11 @@ public class WireConnection {
this.thisslot = nbttagcompound.getInteger("wthisslot"); this.thisslot = nbttagcompound.getInteger("wthisslot");
this.thatslot = nbttagcompound.getInteger("wthatslot"); this.thatslot = nbttagcompound.getInteger("wthatslot");
this.backwired = nbttagcompound.getBoolean("wback"); 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++){ for(int i = 0; i < nbttagcompound.getInteger("wexsize"); i++){
this.xadd.add(i, nbttagcompound.getInteger("xadd" + i)); this.xadd.add(i, nbttagcompound.getInteger("xadd" + i));
this.yadd.add(i, nbttagcompound.getInteger("yadd" + i)); this.yadd.add(i, nbttagcompound.getInteger("yadd" + i));

@ -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;
}
}
}
}

@ -72,8 +72,7 @@ public class GuiWiring extends GuiScrollable {
} }
} else if(!this.tool.type.equals("unpaired")) { } else if(!this.tool.type.equals("unpaired")) {
if(this.tool.type.equals("input")) { 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, tool.red, tool.green, tool.blue, tool.alpha, tool.width);
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);
Minecraft.getMinecraft().theWorld.markBlocksDirty(x, y, z, x, y, z); 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); 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<Integer>(); tool.xadd = new ArrayList<Integer>();
@ -83,7 +82,8 @@ public class GuiWiring extends GuiScrollable {
tool.type = "unpaired"; tool.type = "unpaired";
} else if(this.tool.type.equals("output")) { } else if(this.tool.type.equals("output")) {
AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z); 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(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); 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<Integer>(); tool.xadd = new ArrayList<Integer>();

@ -1,9 +1,8 @@
package net.brokenmoon.afloydwiremod.item; package net.brokenmoon.afloydwiremod.item;
import net.minecraft.src.EntityPlayer; import net.brokenmoon.afloydwiremod.WireMod;
import net.minecraft.src.Item; import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.minecraft.src.ItemStack; import net.minecraft.src.*;
import net.minecraft.src.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Stack; import java.util.Stack;
@ -19,17 +18,41 @@ public class ToolWiring extends Item {
public ArrayList<Integer> sideadd = new ArrayList<Integer>(); public ArrayList<Integer> sideadd = new ArrayList<Integer>();
public String type = "unpaired"; public String type = "unpaired";
public int slot; 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) { public ToolWiring(int i) {
super(i); super(i);
this.maxStackSize = 1; this.maxStackSize = 1;
} }
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, double heightPlaced) { public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, double heightPlaced) {
xadd.add(i); if(entityplayer.isSneaking()){
yadd.add(j); if (!world.isMultiplayerAndNotHost) {
zadd.add(k); this.displayWireSettings(entityplayer, this);
sideadd.add(l); return true;
System.out.println(l); }
} else {
xadd.add(i);
yadd.add(j);
zadd.add(k);
sideadd.add(l);
return false;
}
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);
}
}

@ -23,27 +23,30 @@ public class MixinBlockRenderer {
public boolean renderStandardBlock(Block block, int i, int j, int k) { return false; } public boolean renderStandardBlock(Block block, int i, int j, int k) { return false; }
@Shadow @Shadow
World world; 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<Boolean> cir){ public void injectMethod(Block block, int i, int j, int k, CallbackInfoReturnable<Boolean> cir){
if(block.getRenderType() == 28){ if(block.getRenderType() == 28){
AbstractWireTileEntity wireEntity = (AbstractWireTileEntity)this.world.getBlockTileEntity(i, j, k); 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){ if(wireEntity.outputs != null){
for(int it = 0; it < wireEntity.outputs.length; it++){ for(int it = 0; it < wireEntity.outputs.length; it++){
if(wireEntity.outputs[it].wire != null && wireEntity.outputs[it].wire.isMade){ 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.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.xadd, wireEntity.outputs[it].wire.yadd, wireEntity.outputs[it].wire.zadd, wireEntity.outputs[it].wire.sideadd,
wireEntity.outputs[it].wire.backwired, 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) { cir.setReturnValue(true);
this.renderSidedBlock(block, i, j, k);
} else {
this.renderStandardBlock(block, i, j, k);
}
} }
} }
@ -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<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired, boolean firstblocksided, boolean secondblocksided){ 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<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired, boolean firstblocksided, boolean secondblocksided){
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D); 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.glColor4f(red, green, blue, alpha);
GL11.glLineWidth(width); GL11.glLineWidth(width);
GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glBegin(GL11.GL_LINE_STRIP);
@ -356,6 +361,7 @@ public class MixinBlockRenderer {
} }
} }
GL11.glEnd(); GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glPopMatrix(); 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); 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<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired, boolean firstblocksided, boolean secondblocksided){ public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> 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);
} }
} }

@ -3,6 +3,7 @@ package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.GuiProgrammer; import net.brokenmoon.afloydwiremod.gui.GuiProgrammer;
import net.brokenmoon.afloydwiremod.gui.GuiSettings; import net.brokenmoon.afloydwiremod.gui.GuiSettings;
import net.brokenmoon.afloydwiremod.gui.GuiWireTool;
import net.brokenmoon.afloydwiremod.gui.GuiWiring; import net.brokenmoon.afloydwiremod.gui.GuiWiring;
import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer; import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
@ -29,4 +30,9 @@ public class MixinEntityPlayerSP implements IEntityPlayer {
public void displayGuiSettings(AbstractWireTileEntity chip) { public void displayGuiSettings(AbstractWireTileEntity chip) {
this.mc.displayGuiScreen(new GuiSettings(((EntityPlayerSP)(Object)this), 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));
}
} }

@ -9,4 +9,5 @@ public interface IEntityPlayer {
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z); public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z);
public void displayGuiSettings(AbstractWireTileEntity chip); public void displayGuiSettings(AbstractWireTileEntity chip);
public void displayGuiWireSettings(ToolWiring toolWiring);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 4.3 KiB

Loading…
Cancel
Save