Better linking, freestyle lines

visibileWires
Astoria 1 year ago
parent 70b99f04a6
commit 68ed0b45f5

@ -2,6 +2,9 @@ package net.brokenmoon.afloydwiremod.api;
import net.minecraft.src.NBTTagCompound;
import java.util.ArrayList;
import java.util.Stack;
public class WireConnection {
public boolean isMade;
public int x;
@ -9,17 +12,27 @@ public class WireConnection {
public int z;
public int thisslot;
public int thatslot;
public ArrayList<Integer> xadd = new ArrayList<Integer>();
public ArrayList<Integer> yadd = new ArrayList<Integer>();
public ArrayList<Integer> zadd = new ArrayList<Integer>();
public ArrayList<Integer> sideadd = new ArrayList<Integer>();
public boolean backwired = false;
public WireConnection(){
this.isMade = false;
}
public WireConnection(int x, int y, int z, int thisslot, int thatslot){
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) {
this.x = x;
this.y = y;
this.z = z;
this.thisslot = thisslot;
this.thatslot = thatslot;
this.thisslot = slot;
this.thatslot = slot1;
this.xadd = xadd;
this.yadd = yadd;
this.zadd = zadd;
this.sideadd = sideadd;
this.backwired = backwired;
this.isMade = true;
}
@ -30,6 +43,14 @@ public class WireConnection {
nbttagcompound.setBoolean("made", this.isMade);
nbttagcompound.setInteger("wthisslot", thisslot);
nbttagcompound.setInteger("wthatslot", thatslot);
nbttagcompound.setInteger("wexsize", xadd.size());
nbttagcompound.setBoolean("wback", backwired);
for(int i = 0; i < xadd.size(); i++){
nbttagcompound.setInteger("xadd" + i, xadd.get(i));
nbttagcompound.setInteger("yadd" + i, yadd.get(i));
nbttagcompound.setInteger("zadd" + i, zadd.get(i));
nbttagcompound.setInteger("sideadd" + i, sideadd.get(i));
}
return nbttagcompound;
}
@ -40,5 +61,12 @@ public class WireConnection {
this.isMade = nbttagcompound.getBoolean("made");
this.thisslot = nbttagcompound.getInteger("wthisslot");
this.thatslot = nbttagcompound.getInteger("wthatslot");
this.backwired = nbttagcompound.getBoolean("wback");
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));
this.zadd.add(i, nbttagcompound.getInteger("zadd" + i));
this.sideadd.add(i, nbttagcompound.getInteger("sideadd" + i));
}
}
}

@ -6,8 +6,8 @@ import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import org.lwjgl.input.Mouse;
import java.util.ArrayList;
public class GuiWiring extends GuiScrollable {
private ToolWiring tool;
@ -55,24 +55,41 @@ public class GuiWiring extends GuiScrollable {
this.tool.x = x;
this.tool.y = y;
this.tool.z = z;
tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
} else if (guibutton.type.equals("Output")) {
this.tool.type = "output";
this.tool.slot = guibutton.slot;
this.tool.x = x;
this.tool.y = y;
this.tool.z = z;
tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
}
} else if(!this.tool.type.equals("unpaired")) {
if(this.tool.type.equals("output")) {
if(this.tool.type.equals("input")) {
AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z);
otherEntity.outputs[guibutton.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot);
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(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord);
tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired";
} else if(this.tool.type.equals("input")) {
this.wireEntity.outputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot);
} 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);
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<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired";
}
}

@ -5,11 +5,18 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import java.util.ArrayList;
import java.util.Stack;
public class ToolWiring extends Item {
public int x = 0;
public int y = 0;
public int z = 0;
public ArrayList<Integer> xadd = new ArrayList<Integer>();
public ArrayList<Integer> yadd = new ArrayList<Integer>();
public ArrayList<Integer> zadd = new ArrayList<Integer>();
public ArrayList<Integer> sideadd = new ArrayList<Integer>();
public String type = "unpaired";
public int slot;
public ToolWiring(int i) {
@ -18,6 +25,11 @@ public class ToolWiring extends Item {
}
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);
return false;
}
}

@ -11,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.ArrayList;
@Mixin(value = RenderBlocks.class, remap = false)
public class MixinBlockRenderer {
@Shadow
@ -24,7 +26,7 @@ public class MixinBlockRenderer {
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, wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z);
this.renderLineBetweenTwoPoints(i, j, k, wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z, 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);
}
}
}
@ -33,26 +35,72 @@ 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){
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){
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(red, green, blue, alpha);
GL11.glLineWidth(width);
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3f(Math.floorMod(x1, 16l), Math.floorMod(y1, 16l), Math.floorMod(z1, 16l));
GL11.glVertex3f(Math.floorMod(x1, 16l) - (x1 - x2), Math.floorMod(y1, 16l) - (y1 - y2), Math.floorMod(z1, 16l) - (z1 - z2));
if(!backwired) {
GL11.glVertex3f(Math.floorMod(x1, 16l) + 0.5f, Math.floorMod(y1, 16l) + 0.5f, Math.floorMod(z1, 16l) + 0.5f);
} else{
GL11.glVertex3f(Math.floorMod(x1, 16l) - (x1 - x2) + 0.5f, Math.floorMod(y1, 16l) - (y1 - y2) + 0.5f, Math.floorMod(z1, 16l) - (z1 - z2) + 0.5f);
}
for(int i = 0; i < xadd.size(); i++){
float xoffset = 0;
float yoffset = 0;
float zoffset = 0;
switch(sideadd.get(i)){
case 0:
xoffset = 0.5f;
yoffset = -0.1f;
zoffset = 0.5f;
break;
case 1:
xoffset = 0.5f;
yoffset = 1.1f;
zoffset = 0.5f;
break;
case 2:
xoffset = 0.5f;
yoffset = 0.5f;
zoffset = -0.1f;
break;
case 3:
xoffset = 0.5f;
yoffset = 0.5f;
zoffset = 1.1f;
break;
case 4:
xoffset = -0.1f;
yoffset = 0.5f;
zoffset = 0.5f;
break;
case 5:
xoffset = 1.1f;
yoffset = 0.5f;
zoffset = 0.5f;
break;
}
GL11.glVertex3f(Math.floorMod(x1, 16l) - (x1 - xadd.get(i)) + xoffset, Math.floorMod(y1, 16l) - (y1 - yadd.get(i)) + yoffset, Math.floorMod(z1, 16l) - (z1 - zadd.get(i)) + zoffset);
}
if(backwired) {
GL11.glVertex3f(Math.floorMod(x1, 16l) + 0.5f, Math.floorMod(y1, 16l) + 0.5f, Math.floorMod(z1, 16l) + 0.5f);
} else{
GL11.glVertex3f(Math.floorMod(x1, 16l) - (x1 - x2) + 0.5f, Math.floorMod(y1, 16l) - (y1 - y2) + 0.5f, Math.floorMod(z1, 16l) - (z1 - z2) + 0.5f);
}
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glPopMatrix();
}
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, float alpha){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, alpha, 1);
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, float alpha, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, alpha, 1, xadd, yadd, zadd, sideadd, backwired);
}
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, 255, 1);
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean backwired){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, 255, 1, xadd, yadd, zadd, sideadd, backwired);
}
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, 255, 0, 0, 255 / 2, 1);
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){
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, 255, 0, 0, 255 / 2, 5, xadd, yadd, zadd, sideadd, backwired);
}
}

Loading…
Cancel
Save