Compare commits

..

No commits in common. 'main' and 'visibileWires' have entirely different histories.

@ -1,3 +1,32 @@
# Astoria's Wiremod # Minimal Mod
TODO Babric example mod, without the examples.
## Prerequisites
- JDK for Java 17 ([Eclipse Temurin](https://adoptium.net/temurin/releases/) recommended)
- IntelliJ IDEA
- Minecraft Development plugin (Optional, but highly recommended)
## Setup instructions
1. Download or clone this repository and put it somewhere.
```
git clone https://github.com/Turnip-Labs/bta-minimal-mod.git
```
2. Import the project in IntelliJ IDEA, close it and open it again.
3. Create a new run configuration by going in `Run > Edit Configurations`
Then click on the plus icon and select Gradle. In the `Tasks and Arguments` field enter `build`
Running it will build your finished jar files and put them in `build/libs/`
4. Open `File > Settings` and head to `Build, Execution, Development > Build Tools > Gradle`
Change `Build and run using` and `Run tests using` to `IntelliJ IDEA`
5. Open `File > Project Structure`, select `Project` and set `Compiler output` to your project's path/out.
6. Done! Now all that's left is to change every mention of `examplemod` to your own mod id. Happy modding!

@ -1,6 +1,5 @@
plugins { plugins {
id 'babric-loom' version '0.12-SNAPSHOT' id 'babric-loom' version '0.12-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java' id 'java'
} }
@ -8,23 +7,6 @@ group = project.mod_group
archivesBaseName = project.mod_name archivesBaseName = project.mod_name
version = project.mod_version version = project.mod_version
//Begin shadowing weirdness
configurations {
shade
}
shadowJar {
archiveClassifier.set('shadow')
configurations = [project.configurations.shade]
}
tasks.assemble.dependsOn tasks.shadowJar
remapJar {
dependsOn(shadowJar)
inputFile.set(shadowJar.archiveFile)
}
//End shadowing weirdness
loom { loom {
gluedMinecraftJar() gluedMinecraftJar()
noIntermediateMappings() noIntermediateMappings()
@ -80,9 +62,6 @@ dependencies {
modImplementation "org.slf4j:slf4j-api:1.8.0-beta4" modImplementation "org.slf4j:slf4j-api:1.8.0-beta4"
modImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0" modImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
//TOML
modImplementation include(shadow('com.moandjiezana.toml:toml4j:0.7.2'))
} }
java { java {

@ -2,56 +2,34 @@ package net.brokenmoon.afloydwiremod;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixin.AccessorPacket;
import net.brokenmoon.afloydwiremod.packet.*;
import net.brokenmoon.afloydwiremod.ter.TERDisplay;
import net.brokenmoon.afloydwiremod.ter.TERWire;
import net.brokenmoon.afloydwiremod.tile.ChipTile; import net.brokenmoon.afloydwiremod.tile.ChipTile;
import net.brokenmoon.afloydwiremod.item.ToolProgrammer; import net.brokenmoon.afloydwiremod.item.ToolProgrammer;
import net.brokenmoon.afloydwiremod.tile.DisplayTile;
import net.brokenmoon.afloydwiremod.tile.RedstoneLinkTile; import net.brokenmoon.afloydwiremod.tile.RedstoneLinkTile;
import net.brokenmoon.afloydwiremod.tileentity.*; import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.brokenmoon.afloydwiremod.tileentity.RedstoneLinkTileEntity;
import net.brokenmoon.afloydwiremod.tileentity.TERWire;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material; import net.minecraft.src.Material;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.BlockHelper; import turniplabs.halplibe.helper.BlockHelper;
import turniplabs.halplibe.helper.EntityHelper; import turniplabs.halplibe.helper.EntityHelper;
import turniplabs.halplibe.helper.ItemHelper; import turniplabs.halplibe.helper.ItemHelper;
import turniplabs.halplibe.helper.RecipeHelper;
public class WireMod implements ModInitializer { public class WireMod implements ModInitializer {
public static final String MOD_ID = "afloydwiremod"; public static final String MOD_ID = "afloydwiremod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final WiremodConfig config = new WiremodConfig();
public WireMod(){ public static Block ChipTile = BlockHelper.createBlock(MOD_ID, new ChipTile(905, Material.iron), "chipTile", "chip.png", Block.soundMetalFootstep,5, 5, 0 );
AccessorPacket.callAddIdClassMapping(config.programmerGuiPacket, true, true, WiremodProgrammerGuiPacket.class);
AccessorPacket.callAddIdClassMapping(config.programmingPacket, true, true, WiremodProgrammerPacket.class);
AccessorPacket.callAddIdClassMapping(config.wiringGuiPacket, true, true, WiremodWiringGuiPacket.class);
AccessorPacket.callAddIdClassMapping(config.syncPacket, true, true, WiremodPacketSyncIO.class);
AccessorPacket.callAddIdClassMapping(config.wiringPacket, true, true, WiremodWiringPacket.class);
AccessorPacket.callAddIdClassMapping(config.wiringSettingsPacket, true, true, WiremodWireGuiPacket.class);
AccessorPacket.callAddIdClassMapping(config.chipSettingsPacket, true, true, WiremodSettingsPacket.class);
}
//Tile public static Item ToolProgrammer = ItemHelper.createItem(MOD_ID, new ToolProgrammer(906), "toolProgrammer", "progtool.png");
public static Block ChipTile = BlockHelper.createBlock(MOD_ID, new ChipTile(config.chipTileID, Material.iron), "chipTile", "chip.png", Block.soundMetalFootstep,1.5f, 6f, 0 ); public static Item ToolWiring = ItemHelper.createItem(MOD_ID, new ToolWiring(907), "toolWiring", "wiretool.png");
public static Block LinkTileInactive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(config.linkTileInactiveID, Material.iron, false), "linkTile", "linkOff.png", Block.soundStoneFootstep, 1.5f, 6f, 0);
public static Block LinkTileActive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(config.linkTileActiveID, Material.iron, true), "linkTile", "linkOn.png", Block.soundStoneFootstep, 1.5f, 6f, 0); public static Block LinkTileInactive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(908, Material.iron, false), "linkTile", "linkOff.png", Block.soundStoneFootstep, 5, 5, 0);
public static Block ScreenTile = BlockHelper.createBlock(MOD_ID, new DisplayTile(config.displayTileID, Material.glass), "displayTile", "display.png", Block.soundGlassFootstep, 1.5f, 6f, 0); public static Block LinkTileActive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(909, Material.iron, true), "linkTile", "linkOn.png", Block.soundStoneFootstep, 5, 5, 0);
//Item
public static Item ToolProgrammer = ItemHelper.createItem(MOD_ID, new ToolProgrammer(config.programmerItemID), "toolProgrammer", "progtool.png");
public static ToolWiring ToolWiringClass = new ToolWiring(config.wiringItemID);
public static Item ToolWiring = ItemHelper.createItem(MOD_ID, ToolWiringClass, "toolWiring", "wiretool.png");
public static Item RedSilica = ItemHelper.createItem(MOD_ID, new Item(config.redsilicaID), "redSilica", "redsilica.png");
public static Item ChipDie = ItemHelper.createItem(MOD_ID, new Item(config.dieID), "chipDie", "circuitdie.png");
public static Item BrokenDie = ItemHelper.createItem(MOD_ID, new Item(config.dieOvercookedID), "chipDieBroken", "circuitdead.png");
@Override @Override
public void onInitialize() { public void onInitialize() {
@ -60,20 +38,5 @@ public class WireMod implements ModInitializer {
EntityHelper.createTileEntity(ChipTileEntity.class, "Chip"); EntityHelper.createTileEntity(ChipTileEntity.class, "Chip");
EntityHelper.createTileEntity(RedstoneLinkTileEntity.class, "Redstone Link"); EntityHelper.createTileEntity(RedstoneLinkTileEntity.class, "Redstone Link");
EntityHelper.createSpecialTileEntity(AbstractWireTileEntity.class, new TERWire(), "Wire"); EntityHelper.createSpecialTileEntity(AbstractWireTileEntity.class, new TERWire(), "Wire");
EntityHelper.createSpecialTileEntity(DisplayTileEntity.class, new TERDisplay(), "Display");
//Recipes
//Silica
RecipeHelper.Crafting.createShapelessRecipe(RedSilica, 8, new Object[]{new ItemStack(Item.dustRedstone, 1), new ItemStack(Item.dustRedstone, 1), new ItemStack(Item.dustRedstone, 1), new ItemStack(Block.sand, 1)});
//Dies
RecipeHelper.Smelting.createRecipe(ChipDie, RedSilica);
RecipeHelper.Blasting.createRecipe(BrokenDie, RedSilica);
//Tools
RecipeHelper.Crafting.createRecipe(ToolWiring, 1, new Object[]{"ABC", "#D#", "#D#", 'A', Item.nuggetIron, 'B', Item.ingotIron, 'C', RedSilica, 'D', Item.stick});
RecipeHelper.Crafting.createRecipe(ToolProgrammer, 1, new Object[]{"ABC", "#D#", "#D#", 'A', Item.nuggetIron, 'B', Item.ingotIron, 'C', ChipDie, 'D', Item.stick});
//Blocks
RecipeHelper.Crafting.createRecipe(ChipTile, 1, new Object[]{"#A#", "ABA", "#A#", 'A', Item.nuggetIron, 'B', ChipDie});
RecipeHelper.Crafting.createRecipe(ScreenTile, 1, new Object[]{"#A#", "BCB", "#B#", 'A', Block.glass, 'B', Item.nuggetIron, 'C', ChipDie});
RecipeHelper.Crafting.createRecipe(LinkTileInactive, 1, new Object[]{"#A#", "BCB", "#B#", 'A', Block.blockRedstone, 'B', Item.nuggetIron, 'C', ChipDie});
} }
} }

@ -1,83 +0,0 @@
package net.brokenmoon.afloydwiremod;
import com.moandjiezana.toml.Toml;
import java.io.*;
import static net.brokenmoon.afloydwiremod.WireMod.LOGGER;
public class WiremodConfig {
//Packet ID's
public int programmerGuiPacket;
public int programmingPacket;
public int wiringGuiPacket;
public int syncPacket;
public int wiringPacket;
public int wiringSettingsPacket;
public int chipSettingsPacket;
//Tiles
public int chipTileID;
public int linkTileInactiveID;
public int linkTileActiveID;
public int displayTileID;
//Items
public int programmerItemID;
public int wiringItemID;
public int redsilicaID;
public int dieID;
public int dieOvercookedID;
public int scrollrate;
public WiremodConfig(){
Toml toml = new Toml().read(this.getConfig());
//Packets
programmingPacket = toml.getLong("ids.packet.programming", (long)109).intValue();
programmerGuiPacket = toml.getLong("ids.packet.programmerGui", (long)110).intValue();
wiringPacket = toml.getLong("ids.packet.wiring", (long)111).intValue();
wiringGuiPacket = toml.getLong("ids.packet.wiringGui", (long)112).intValue();
wiringSettingsPacket = toml.getLong("ids.packet.wiringSettingsGui", (long)113).intValue();
syncPacket = toml.getLong("ids.packet.sync", (long)114).intValue();
chipSettingsPacket = toml.getLong("ids.packet.chipSettingsGui", (long)115).intValue();
//Tiles
chipTileID = toml.getLong("ids.tile.chipTile", (long)905).intValue();
linkTileInactiveID = toml.getLong("ids.tile.linkTileInactive", (long)906).intValue();
linkTileActiveID = toml.getLong("ids.tile.linkTileActive", (long)907).intValue();
displayTileID = toml.getLong("ids.tile.displayTile", (long)908).intValue();
//Items
programmerItemID = toml.getLong("ids.item.programmingTool", (long)909).intValue();
wiringItemID = toml.getLong("ids.item.wiringTool", (long)910).intValue();
redsilicaID = toml.getLong("ids.item.redSilica", (long)911).intValue();
dieID = toml.getLong("ids.item.chipDie", (long)912).intValue();
dieOvercookedID = toml.getLong("ids.item.chipDieOvercooked", (long)913).intValue();
//Various settings
scrollrate = toml.getLong("misc.scrollrate", (long)5).intValue();
}
public static File getConfig() {
File config = new File("config/AWM.toml");
if (!config.exists()) {
LOGGER.warn("Config For AWM Not Found! Creating new config based upon default :)");
InputStream in;
OutputStream out;
try {
File configDir = new File("config");
if (!configDir.exists())
configDir.mkdir();
in = WireMod.class.getClassLoader().getResourceAsStream("assets/afloydwiremod/config.toml");
out = new FileOutputStream(config);
byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
return getConfig();
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
LOGGER.info("Config for AWM loaded!");
return config;
}
}
}

@ -55,9 +55,7 @@ public abstract class AbstractWireTile extends BlockContainer {
((IEntityPlayer)player).displayGuiSettings(chip); ((IEntityPlayer)player).displayGuiSettings(chip);
} }
@Override @Override
public void onBlockRemoval(World world, int x, int y, int z) { public int getRenderType(){
AbstractWireTileEntity tile = (AbstractWireTileEntity) world.getBlockTileEntity(x, y, z); return 28;
tile.prepForDelete();
super.onBlockRemoval(world, x, y, z);
} }
} }

@ -1,8 +1,9 @@
package net.brokenmoon.afloydwiremod.api; package net.brokenmoon.afloydwiremod.api;
import net.brokenmoon.afloydwiremod.gui.WiringButton; import net.brokenmoon.afloydwiremod.gui.WiringButton;
import net.brokenmoon.afloydwiremod.packet.WiremodPacketSyncIO; import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.*; import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
public abstract class AbstractWireTileEntity extends TileEntity { public abstract class AbstractWireTileEntity extends TileEntity {
public WiringButton[] inputs = null; public WiringButton[] inputs = null;
@ -10,9 +11,9 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public boolean initialized = false; public boolean initialized = false;
public boolean hasSettings = false; public boolean hasSettings = false;
public void update() { @Override
public void updateEntity() {
updateIO(); updateIO();
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
} }
@Override @Override
@ -78,63 +79,23 @@ public abstract class AbstractWireTileEntity extends TileEntity {
for (int i = 0; i < outputs.length; ++i) { for (int i = 0; i < outputs.length; ++i) {
if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) { if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) {
WireConnection wire = outputs[i].wire; WireConnection wire = outputs[i].wire;
Boolean doUpdate = false;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z); AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip == null || otherChip.outputs == null){ if(otherChip == null){
this.outputs[i].wire = new WireConnection(); this.outputs[i].wire = new WireConnection();
} else { break;
if (outputs[i].floatvalue != otherChip.inputs[wire.thatslot].floatvalue) {
otherChip.inputs[wire.thatslot].floatvalue = outputs[i].floatvalue;
doUpdate = true;
}
if (!outputs[i].stringvalue.equals(otherChip.inputs[wire.thatslot].stringvalue)) {
otherChip.inputs[wire.thatslot].stringvalue = outputs[i].stringvalue;
doUpdate = true;
}
if (doUpdate)
otherChip.update();
} }
} if(otherChip.outputs == null) {
} this.outputs[i].wire = new WireConnection();
} break;
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
public void prepForDelete() {
if(outputs != null) {
for (int i = 0; i < outputs.length; ++i) {
if (outputs[i].wire != null) {
WireConnection wire = outputs[i].wire;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip != null) {
outputs[i].floatvalue = 0;
outputs[i].stringvalue = "";
outputs[i].wire.isMade = false;
otherChip.inputs[wire.thatslot].wire = new WireConnection();
this.updateIO();
otherChip.updateIO();
} }
worldObj.markBlockNeedsUpdate(wire.x, wire.y, wire.z); if(outputs[i].floatvalue != otherChip.inputs[wire.thatslot].floatvalue) {
} otherChip.inputs[wire.thatslot].floatvalue = outputs[i].floatvalue;
} }
} if(!outputs[i].stringvalue.equals(otherChip.inputs[wire.thatslot].stringvalue)) {
if(inputs != null) { otherChip.inputs[wire.thatslot].stringvalue = outputs[i].stringvalue;
for (int i = 0; i < inputs.length; ++i) {
if (inputs[i].wire != null) {
WireConnection wire = inputs[i].wire;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip != null) {
otherChip.outputs[wire.thatslot].wire = new WireConnection();
otherChip.updateIO();
} }
worldObj.markBlockNeedsUpdate(wire.x, wire.y, wire.z);
} }
} }
} }
} }
@Override
public Packet getDescriptionPacket() {
return new WiremodPacketSyncIO(this.xCoord, this.yCoord, this.zCoord, inputs, outputs);
}
} }

@ -73,40 +73,7 @@ public abstract class AbstractWireTileSided extends AbstractWireTile{
@Override @Override
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
if (this.dropTileIfCantStay(world, i, j, k)) { this.dropTileIfCantStay(world, i, j, k);
int i1 = world.getBlockMetadata(i, j, k);
boolean flag = true;
switch(i1){
case 0:
if(world.isBlockNormalCube(i, j + 1, k))
flag = false;
break;
case 1:
if(world.isBlockNormalCube(i - 1, j, k))
flag = false;
break;
case 2:
if(world.isBlockNormalCube(i + 1, j, k))
flag = false;
break;
case 3:
if(world.isBlockNormalCube(i, j, k - 1))
flag = false;
break;
case 4:
if(world.isBlockNormalCube(i, j, k + 1))
flag = false;
break;
case 5:
if(this.canPlaceOnTop(world, i, j - 1, k))
flag = false;
break;
}
if (flag) {
this.dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
world.setBlockWithNotify(i, j, k, 0);
}
}
} }
private boolean dropTileIfCantStay(World world, int i, int j, int k) { private boolean dropTileIfCantStay(World world, int i, int j, int k) {
@ -168,9 +135,4 @@ public abstract class AbstractWireTileSided extends AbstractWireTile{
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override
public int getRenderType(){
return 28;
}
} }

@ -46,15 +46,6 @@ public class WireConnection {
this.isMade = true; this.isMade = true;
} }
public WireConnection(int xCoord, int yCoord, int zCoord, int slot, int slot1) {
this.x = xCoord;
this.y = yCoord;
this.z = zCoord;
this.thisslot = slot;
this.thatslot = slot1;
this.isMade = true;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("wx", this.x); nbttagcompound.setInteger("wx", this.x);
nbttagcompound.setInteger("wy", this.y); nbttagcompound.setInteger("wy", this.y);

@ -9,14 +9,36 @@ public class GuiButtonExtended extends GuiButton {
public String type; public String type;
public int slot; public int slot;
public static final int width = 80; public int scroll;
public static final int width = 50;
public static final int height = 10; public static final int height = 10;
public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) { public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * (id + 1)), width, height, s); super(id, xPosition / 2 - (width / 2), 50 - height + (height * id), width, height, s);
this.type = extra; this.type = extra;
this.slot = slot; this.slot = slot;
} }
public GuiButtonExtended(int id, int xPosition, String s) { public GuiButtonExtended(int id, int xPosition, String s) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * (id + 1)), width, height, s); super(id, xPosition / 2 - (width / 2), 50 - height + (height * id), width, height, s);
}
@Override
public void drawButton(Minecraft minecraft, int i, int j) {
if (!this.visible) {
return;
}
FontRenderer fontrenderer = minecraft.fontRenderer;
GL11.glBindTexture(3553, minecraft.renderEngine.getTexture("/gui/gui.png"));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
boolean flag = i >= this.xPosition && j >= this.yPosition + scroll && i < this.xPosition + this.width && j < this.yPosition + scroll + this.height;
int k = this.getButtonState(flag);
this.drawTexturedModalRect(this.xPosition, this.yPosition + scroll, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition + scroll, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(minecraft, i, j);
if (!this.enabled) {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, -6250336);
} else if (flag) {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, 0xFFFFA0);
} else {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, 0xE0E0E0);
}
} }
} }

@ -1,161 +1,36 @@
package net.brokenmoon.afloydwiremod.gui; package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*; import net.minecraft.src.*;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiProgrammer extends GuiScrollable { public class GuiProgrammer extends GuiScrollable {
private AbstractWireTileEntity wireEntity; private AbstractWireTileEntity wireEntity;
public int xSize = 100;
public int ySize = 180;
private int numOfElements = 0;
@Override @Override
public void initGui() { public void initGui() {
//this.height - 240 is top //this.height - 240 is top
//This.width / 2 //This.width / 2
numOfElements = 0; this.controlList.add(new GuiButtonExtended(1, this.width, "Constant"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Constant")); this.controlList.add(new GuiButtonExtended(2, this.width, "Count"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Increment"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Decrement"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Counter"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Duplicate"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Addition"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Subtraction"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Multiplication"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Division"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Memory"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Pulse"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "TRUE"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "FALSE"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "AND"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NAND"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "OR"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NOR"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "XOR"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "XNOR"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NOT"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "=="));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "!="));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, ">"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, ">="));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<"));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<="));
this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<=>"));
} }
public GuiProgrammer(EntityPlayer player, ChipTileEntity wireEntity) { public GuiProgrammer(EntityPlayer player, AbstractWireTileEntity wireEntity) {
super.initGui(); super.initGui();
this.player = player;
this.wireEntity = wireEntity; this.wireEntity = wireEntity;
} }
@Override @Override
protected void actionPerformed(GuiButton guibutton) { protected void actionPerformed(GuiButton guibutton) {
switch(guibutton.displayString){ if(wireEntity instanceof ChipTileEntity) {
case "Constant": if (guibutton.id == 1) {
this.setMode("constant"); ((ChipTileEntity) wireEntity).setMode("constant");
break; } else if (guibutton.id == 2) {
case "Increment": ((ChipTileEntity) wireEntity).setMode("count");
this.setMode("inc"); }
break;
case "Duplicate":
this.setMode("dup");
break;
case "Addition":
this.setMode("add");
break;
case "Subtraction":
this.setMode("sub");
break;
case "Multiplication":
this.setMode("mult");
break;
case "Division":
this.setMode("div");
break;
case "Decrement":
this.setMode("dec");
break;
case "Counter":
this.setMode("incdec");
break;
case "Memory":
this.setMode("mem");
break;
case "TRUE":
case "FALSE":
case "NOT":
case "AND":
case "OR":
case "XOR":
case "NAND":
case "NOR":
case "XNOR":
case "==":
case "!=":
case ">":
case ">=":
case "<":
case "<=":
case "<=>":
case "Pulse":
this.setMode(guibutton.displayString);
break;
} }
this.mc.displayGuiScreen(null); this.mc.displayGuiScreen(null);
} }
public void setMode(String string){
if(this.player instanceof EntityClientPlayerMP){
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;
netclienthandler.addToSendQueue(new WiremodProgrammerPacket(string, wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord));
return;
}
((ChipTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord)).setMode(string);
}
@Override
public void drawScreen(int x, int y, float renderPartialTicks){
this.drawDefaultBackground();
//Draw the overlay
this.drawGuiBackground(renderPartialTicks);
GL11.glPushMatrix();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor((width / 2 - 60) * this.mc.resolution.scale, (height / 2 - 80) * this.mc.resolution.scale, 120 * this.mc.resolution.scale, 160 * this.mc.resolution.scale);
int k = (this.height - this.ySize) / 2;
int wheel = Mouse.getDWheel();
if(wheel > 0)
scroll += WireMod.config.scrollrate;
if (wheel < 0)
scroll -= WireMod.config.scrollrate;
if(scroll > 0)
scroll = 0;
if(-scroll > (numOfElements - 16) * GuiButtonExtended.height)
scroll = -((numOfElements - 16) * GuiButtonExtended.height);
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButtonExtended guibutton = (GuiButtonExtended)this.controlList.get(i);
guibutton.yPosition = k + (guibutton.height * (guibutton.id + 1) + scroll);
guibutton.drawButton(this.mc, x, y);
}
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
protected void drawGuiBackground(float f) {
int guiTexture = this.mc.renderEngine.getTexture("/assets/afloydwiremod/gui/programmer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(guiTexture);
int j = (this.width - this.xSize) / 2;
int k = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize);
}
} }

@ -1,11 +1,31 @@
package net.brokenmoon.afloydwiremod.gui; package net.brokenmoon.afloydwiremod.gui;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton; import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen; import net.minecraft.src.GuiScreen;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
public class GuiScrollable extends GuiScreen { public class GuiScrollable extends GuiScreen {
public EntityPlayer player; private int scroll;
public int scroll; @Override
public void drawScreen(int x, int y, float renderPartialTicks) {
//TODO: Tweak these values later to fit all the stuff
int wheel = Mouse.getDWheel();
if(wheel > 0)
scroll++;
if (wheel < 0)
scroll--;
if(scroll > 150)
scroll = 150;
if(scroll < 0)
scroll = 0;
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButtonExtended guibutton = (GuiButtonExtended)this.controlList.get(i);
if(scroll >= 0)
guibutton.scroll = scroll;
if(scroll <= 0)
guibutton.scroll = scroll;
if(guibutton.yPosition >= 50 && guibutton.yPosition <= 200)
guibutton.drawButton(this.mc, x, y);
}
}
} }

@ -3,13 +3,12 @@ package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.WireConnection; import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.packet.WiremodSettingsPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWiringPacket;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.src.*; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
public class GuiSettings extends GuiScreen { public class GuiSettings extends GuiScreen {
private EntityPlayer player;
private AbstractWireTileEntity wireEntity; private AbstractWireTileEntity wireEntity;
@Override @Override
public void initGui() { public void initGui() {
@ -17,64 +16,33 @@ public class GuiSettings extends GuiScreen {
//This.width / 2 - 214 is left //This.width / 2 - 214 is left
//Inputs //Inputs
if(wireEntity instanceof ChipTileEntity){ if(wireEntity instanceof ChipTileEntity){
switch(((ChipTileEntity) wireEntity).mode){ if(((ChipTileEntity) wireEntity).mode.equals("constant")){
case "constant": initConst();
initConst();
break;
case "Pulse":
initPulse();
break;
} }
} }
} }
private void initPulse() {
this.controlList.add(new GuiButton(1, this.width /2 - 100, this.height/2 - 20 - 10, "+"));
this.controlList.add(1,new GuiButton(0, this.width /2 - 100, this.height/2 - 10, ((ChipTileEntity)wireEntity).tickAmount + ""));
this.controlList.add(new GuiButton(2, this.width /2 - 100, this.height/2 + 20 - 10, "-"));
}
public void initConst(){ public void initConst(){
this.controlList.add(new GuiButton(1, this.width /2 - 100, this.height/2 - 20 - 10, "+")); this.controlList.add(new GuiButton(1, this.width /2, this.height/2 - 20, "+"));
this.controlList.add(1,new GuiButton(0, this.width /2 - 100, this.height/2 - 10 , wireEntity.outputs[0].floatvalue + "")); this.controlList.add(1,new GuiButton(0, this.width /2, this.height/2 , wireEntity.outputs[0].floatvalue + ""));
this.controlList.add(new GuiButton(2, this.width /2 - 100, this.height/2 + 20 - 10, "-")); this.controlList.add(new GuiButton(2, this.width /2, this.height/2 + 20, "-"));
} }
public GuiSettings(EntityPlayer player, AbstractWireTileEntity wireEntity) { public GuiSettings(EntityPlayer player, AbstractWireTileEntity wireEntity) {
super.initGui(); super.initGui();
this.player = player;
this.wireEntity = wireEntity; this.wireEntity = wireEntity;
} }
@Override @Override
protected void actionPerformed(GuiButton guiButton){ protected void actionPerformed(GuiButton guiButton){
if(wireEntity instanceof ChipTileEntity){ if(wireEntity instanceof ChipTileEntity){
switch(((ChipTileEntity)wireEntity).mode){ if(((ChipTileEntity)wireEntity).mode.equals("constant")){
case "constant": constAction(guiButton);
constAction(guiButton);
break;
case "Pulse":
pulseAction(guiButton);
break;
} }
} }
} }
private void pulseAction(GuiButton guiButton) {
if(guiButton.id == 1){
((ChipTileEntity)wireEntity).tickAmount++;
}
if(guiButton.id == 2 && ((ChipTileEntity)wireEntity).tickAmount > 0){
((ChipTileEntity)wireEntity).tickAmount--;
}
if(this.player instanceof EntityClientPlayerMP){
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;
netclienthandler.addToSendQueue(new WiremodSettingsPacket(1, ((ChipTileEntity)wireEntity).tickAmount, wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord));
}
this.controlList.get(1).displayString = ((ChipTileEntity)wireEntity).tickAmount + "";
}
private void constAction(GuiButton guiButton) { private void constAction(GuiButton guiButton) {
if(guiButton.id == 1){ if(guiButton.id == 1){
wireEntity.outputs[0].floatvalue++; wireEntity.outputs[0].floatvalue++;
@ -83,10 +51,5 @@ public class GuiSettings extends GuiScreen {
wireEntity.outputs[0].floatvalue--; wireEntity.outputs[0].floatvalue--;
} }
this.controlList.get(1).displayString = wireEntity.outputs[0].floatvalue + ""; this.controlList.get(1).displayString = wireEntity.outputs[0].floatvalue + "";
if(this.player instanceof EntityClientPlayerMP){
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;
netclienthandler.addToSendQueue(new WiremodSettingsPacket(0, wireEntity.outputs[0].floatvalue, wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord));
}
wireEntity.updateIO();
} }
} }

@ -1,6 +1,5 @@
package net.brokenmoon.afloydwiremod.gui; package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -16,18 +15,18 @@ public class GuiWireTool extends GuiScreen {
public GuiSlider blue; public GuiSlider blue;
public GuiSlider alpha; public GuiSlider alpha;
public GuiSlider widthslider; public GuiSlider widthslider;
public GuiWireTool(EntityPlayerSP entityPlayerSP) { public GuiWireTool(EntityPlayerSP entityPlayerSP, ToolWiring toolWiring) {
super.initGui(); super.initGui();
this.tool = WireMod.ToolWiringClass; this.tool = toolWiring;
} }
@Override @Override
public void initGui() { public void initGui() {
red = new GuiSlider(1, this.width/2-100, this.height/2-50, 200, 20, "Red", tool.red); red = new GuiSlider(1, this.width/2-100, this.height/2-40, 200, 20, "Red", tool.red);
green = new GuiSlider(2, this.width/2-100, this.height/2-30, 200, 20, "Green", tool.green); green = new GuiSlider(2, this.width/2-100, this.height/2-20, 200, 20, "Blue", tool.green);
blue = new GuiSlider(3, this.width/2-100, this.height/2-10, 200, 20, "Blue", tool.blue); blue = new GuiSlider(3, this.width/2-100, this.height/2-0, 200, 20, "Green", tool.blue);
alpha = new GuiSlider(4, this.width/2-100, this.height/2+10, 200, 20, "Alpha", tool.alpha); alpha = new GuiSlider(4, this.width/2-100, this.height/2+20, 200, 20, "Alpha", tool.alpha);
widthslider = new GuiSlider(5, this.width/2-100, this.height/2+30, 200, 20, "Width", tool.width); widthslider = new GuiSlider(5, this.width/2-100, this.height/2+40, 200, 20, "Width", tool.width);
this.controlList.add(red); this.controlList.add(red);
this.controlList.add(green); this.controlList.add(green);
this.controlList.add(blue); this.controlList.add(blue);

@ -3,13 +3,9 @@ package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.WireConnection; import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.item.ToolWiring; import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWiringPacket;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton; import net.minecraft.src.GuiButton;
import net.minecraft.src.NetClientHandler;
import java.util.ArrayList; import java.util.ArrayList;
@ -20,7 +16,6 @@ public class GuiWiring extends GuiScrollable {
private int y; private int y;
private int z; private int z;
private AbstractWireTileEntity wireEntity; private AbstractWireTileEntity wireEntity;
private AbstractWireTileEntity otherEntity;
@Override @Override
public void initGui() { public void initGui() {
//this.height - 240 is top //this.height - 240 is top
@ -28,26 +23,24 @@ public class GuiWiring extends GuiScrollable {
//Inputs //Inputs
if(wireEntity.inputs != null && !this.tool.type.equals("input")) { if(wireEntity.inputs != null && !this.tool.type.equals("input")) {
for (int i = 0; i < wireEntity.inputs.length; i++) { for (int i = 0; i < wireEntity.inputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i, this.width - GuiButtonExtended.width, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot)); this.controlList.add(new GuiButtonExtended(i + 1, this.width - 50, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot));
} }
} }
//Outputs //Outputs
if(wireEntity.outputs != null && !this.tool.type.equals("output")) { if(wireEntity.outputs != null && !this.tool.type.equals("output")) {
for (int i = 0; i < wireEntity.outputs.length; i++) { for (int i = 0; i < wireEntity.outputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i, this.width + GuiButtonExtended.width, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot)); this.controlList.add(new GuiButtonExtended(i + 1, this.width + 50, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot));
} }
} }
} }
public GuiWiring(EntityPlayer player, ToolWiring tool, AbstractWireTileEntity wireEntity, int x, int y, int z) { public GuiWiring(EntityPlayer player, ToolWiring tool, AbstractWireTileEntity wireEntity, int x, int y, int z) {
super.initGui(); super.initGui();
this.player = player;
this.tool = tool; this.tool = tool;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
this.wireEntity = wireEntity; this.wireEntity = wireEntity;
otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z);
} }
@Override @Override
@ -78,46 +71,17 @@ public class GuiWiring extends GuiScrollable {
tool.sideadd = new ArrayList<Integer>(); tool.sideadd = new ArrayList<Integer>();
} }
} else if(!this.tool.type.equals("unpaired")) { } else if(!this.tool.type.equals("unpaired")) {
if(this.tool.type.equals("input") && wireEntity.outputs[guibutton.slot].wire.isMade != true && otherEntity != null && otherEntity.inputs[tool.slot].wire.isMade != true) { if(this.tool.type.equals("input")) {
if(this.player instanceof EntityClientPlayerMP){ 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);
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;
netclienthandler.addToSendQueue(new WiremodWiringPacket(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, 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));
netclienthandler.addToSendQueue(new WiremodWiringPacket(this.tool.x, this.tool.y, this.tool.z, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, guibutton.slot, tool.slot));
} else{
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);
otherEntity.inputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot);
wireEntity.update();
wireEntity.updateIO();
otherEntity.update();
otherEntity.updateIO();
}
tool.xadd = new ArrayList<Integer>(); tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>(); tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>(); tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>(); tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired"; tool.type = "unpaired";
} else if(this.tool.type.equals("output") && otherEntity.outputs[tool.slot].wire.isMade != true && otherEntity != null && wireEntity.inputs[guibutton.slot].wire.isMade != true ) { } else if(this.tool.type.equals("output")) {
if(otherEntity != null) { AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(tool.x, tool.y, tool.z);
if(this.player instanceof EntityClientPlayerMP){ if(otherEntity != null)
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue; 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);
netclienthandler.addToSendQueue(new WiremodWiringPacket(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true, tool.red, tool.green, tool.blue, tool.alpha, tool.width));
netclienthandler.addToSendQueue(new WiremodWiringPacket(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, tool.slot, guibutton.slot));
} else{
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);
wireEntity.inputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot);
wireEntity.update();
wireEntity.updateIO();
otherEntity.update();
otherEntity.updateIO();
}
}
tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired";
} else{
tool.xadd = new ArrayList<Integer>(); tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>(); tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>(); tool.zadd = new ArrayList<Integer>();

@ -7,9 +7,4 @@ public class ToolProgrammer extends Item {
super(i); super(i);
this.maxStackSize = 1; this.maxStackSize = 1;
} }
@Override
public boolean isFull3D() {
return true;
}
} }

@ -1,7 +1,6 @@
package net.brokenmoon.afloydwiremod.item; package net.brokenmoon.afloydwiremod.item;
import net.brokenmoon.afloydwiremod.WireMod; import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer; import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.minecraft.src.*; import net.minecraft.src.*;
@ -34,11 +33,10 @@ public class ToolWiring extends Item {
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) {
if(entityplayer.isSneaking()){ if(entityplayer.isSneaking()){
if (!world.isMultiplayerAndNotHost) { if (!world.isMultiplayerAndNotHost) {
this.displayWireSettings(entityplayer); this.displayWireSettings(entityplayer, this);
return true; return true;
} }
} else { } else {
if(!(world.getBlockTileEntity(i, j, k) instanceof AbstractWireTileEntity))
xadd.add(i); xadd.add(i);
yadd.add(j); yadd.add(j);
zadd.add(k); zadd.add(k);
@ -48,18 +46,13 @@ public class ToolWiring extends Item {
return false; return false;
} }
private void displayWireSettings(EntityPlayer player) { private void displayWireSettings(EntityPlayer player, ToolWiring toolWiring) {
if(player instanceof EntityPlayerMP) { if(player instanceof EntityPlayerMP) {
//Multiplayer //Multiplayer
((IEntityPlayer)player).displayGuiWireSettings(); ((IEntityPlayer)player).displayGuiWireSettings(toolWiring);
return; return;
} }
//Singleplayer //Singleplayer
((IEntityPlayer)player).displayGuiWireSettings(); ((IEntityPlayer)player).displayGuiWireSettings(toolWiring);
}
@Override
public boolean isFull3D() {
return true;
} }
} }

@ -1,13 +0,0 @@
package net.brokenmoon.afloydwiremod.mixin;
import net.minecraft.src.Packet;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(value = Packet.class, remap = false)
public interface AccessorPacket {
@Invoker("addIdClassMapping")
static void callAddIdClassMapping(int i, boolean clientPacket, boolean serverPacket, Class class1) {
throw new AssertionError();
}
}

@ -26,7 +26,12 @@ public class MixinBlockRenderer {
@Inject(method = "Lnet/minecraft/src/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/src/Block;III)Z", at = @At("HEAD"), cancellable = true) @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){
cir.setReturnValue(this.renderSidedBlock(block, i, j, k)); if(block instanceof AbstractWireTileSided) {
this.renderSidedBlock(block, i, j, k);
} else {
this.renderStandardBlock(block, i, j, k);
}
cir.setReturnValue(true);
} }
} }

@ -1,37 +0,0 @@
package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerGuiPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWireGuiPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWiringGuiPacket;
import net.minecraft.src.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = EntityPlayerMP.class, remap = false)
public class MixinEntityPlayerMP implements IEntityPlayer {
@Shadow public NetServerHandler playerNetServerHandler;
@Override
public void displayGuiProgrammer(AbstractWireTileEntity chip) {
this.playerNetServerHandler.sendPacket(new WiremodProgrammerGuiPacket(0, chip.xCoord, chip.yCoord, chip.zCoord));
}
@Override
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z) {
this.playerNetServerHandler.sendPacket(new WiremodWiringGuiPacket(chip.xCoord, chip.yCoord, chip.zCoord, x, y, z));
}
@Override
public void displayGuiSettings(AbstractWireTileEntity chip) {
this.playerNetServerHandler.sendPacket(new WiremodProgrammerGuiPacket(1, chip.xCoord, chip.yCoord, chip.zCoord));
}
@Override
public void displayGuiWireSettings() {
this.playerNetServerHandler.sendPacket(new WiremodWireGuiPacket());
}
}

@ -17,10 +17,8 @@ import org.spongepowered.asm.mixin.Shadow;
public class MixinEntityPlayerSP implements IEntityPlayer { public class MixinEntityPlayerSP implements IEntityPlayer {
@Shadow @Shadow
protected Minecraft mc; protected Minecraft mc;
@Override
public void displayGuiProgrammer(AbstractWireTileEntity chip) { public void displayGuiProgrammer(AbstractWireTileEntity chip) {
this.mc.displayGuiScreen(new GuiProgrammer(((EntityPlayerSP)(Object)this), (ChipTileEntity) chip)); this.mc.displayGuiScreen(new GuiProgrammer(((EntityPlayerSP)(Object)this), chip));
} }
@Override @Override
@ -34,7 +32,7 @@ public class MixinEntityPlayerSP implements IEntityPlayer {
} }
@Override @Override
public void displayGuiWireSettings() { public void displayGuiWireSettings(ToolWiring toolWiring) {
this.mc.displayGuiScreen(new GuiWireTool(((EntityPlayerSP)(Object)this))); this.mc.displayGuiScreen(new GuiWireTool(((EntityPlayerSP)(Object)this), toolWiring));
} }
} }

@ -1,70 +0,0 @@
package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.GuiWiring;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.brokenmoon.afloydwiremod.packet.*;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.TileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = NetClientHandler.class, remap = false)
public class MixinNetClientHandler implements INetHandler {
@Shadow
Minecraft mc;
@Override
public void wiremodHandleOpenProgrammerGUI(WiremodProgrammerGuiPacket packet) {
if(packet.mode == 0)
((IEntityPlayer)this.mc.thePlayer).displayGuiProgrammer((ChipTileEntity)this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z));
if(packet.mode == 1)
((IEntityPlayer)this.mc.thePlayer).displayGuiSettings((AbstractWireTileEntity)this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z));
}
@Override
public void wiremodHandleProgramTile(WiremodProgrammerPacket wiremodProgrammerPacket) {
}
@Override
public void wiremodHandleOpenWiringGUI(WiremodWiringGuiPacket packet) {
if(this.mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ToolWiring)
((IEntityPlayer)this.mc.thePlayer).displayGuiWiring(((ToolWiring)this.mc.thePlayer.inventory.getCurrentItem().getItem()), (AbstractWireTileEntity) this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z), packet.x2, packet.y2, packet.z2);
}
@Override
public void wiremodHandleIODisc(WiremodPacketSyncIO packet) {
boolean test = this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z) instanceof ChipTileEntity;
TileEntity tileentity;
if (this.mc.theWorld.blockExists(packet.x, packet.y, packet.z) && (tileentity = this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z)) instanceof AbstractWireTileEntity) {
AbstractWireTileEntity wireEntity = (AbstractWireTileEntity)tileentity;
wireEntity.inputs = packet.io;
wireEntity.outputs = packet.oi;
wireEntity.onInventoryChanged();
if(wireEntity instanceof ChipTileEntity){
((ChipTileEntity) wireEntity).mode = packet.mode;
((ChipTileEntity) wireEntity).tickAmount = packet.tickAmount;
}
}
}
@Override
public void wiremodHandleWireChips(WiremodWiringPacket wiremodWiringPacket) {
}
@Override
public void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket) {
((IEntityPlayer)this.mc.thePlayer).displayGuiWireSettings();
}
@Override
public void wiremodHandleSettings(WiremodSettingsPacket wiremodSettingsPacket) {
}
}

@ -1,88 +0,0 @@
package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.brokenmoon.afloydwiremod.packet.*;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.NetServerHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.ArrayList;
@Mixin(value = NetServerHandler.class, remap = false)
public class MixinNetServerHandler implements INetHandler {
@Shadow
private MinecraftServer mcServer;
@Shadow
private EntityPlayerMP playerEntity;
@Override
public void wiremodHandleOpenProgrammerGUI(WiremodProgrammerGuiPacket packet) {
}
@Override
public void wiremodHandleProgramTile(WiremodProgrammerPacket packet) {
((ChipTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x, packet.y, packet.z)).setMode(packet.mode);
}
@Override
public void wiremodHandleOpenWiringGUI(WiremodWiringGuiPacket wiremodWiringGuiPacket) {
}
@Override
public void wiremodHandleIODisc(WiremodPacketSyncIO wiremodPacketSyncIO) {
}
@Override
public void wiremodHandleWireChips(WiremodWiringPacket packet) {
switch(packet.type){
case 0:
AbstractWireTileEntity wireEntity;
if(!packet.backwired) {
wireEntity = (AbstractWireTileEntity) this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x1, packet.y1, packet.z1);
wireEntity.outputs[packet.slot1].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot1, packet.slot2, packet.xadd, packet.yadd, packet.zadd, packet.sideadd, packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width);
} else{
wireEntity = (AbstractWireTileEntity) this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x2, packet.y2, packet.z2);
wireEntity.outputs[packet.slot2].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot2, packet.slot1, packet.xadd, packet.yadd, packet.zadd, packet.sideadd, packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width);
}
wireEntity.update();
wireEntity.updateIO();
break;
case 1:
AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x1, packet.y1, packet.z1);
otherEntity.inputs[packet.slot2].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot2, packet.slot1);
otherEntity.update();
otherEntity.updateIO();
break;
}
this.mcServer.getWorldManager(this.playerEntity.dimension).markBlockNeedsUpdate(packet.x1, packet.y1, packet.z1);
this.mcServer.getWorldManager(this.playerEntity.dimension).markBlockNeedsUpdate(packet.x2, packet.y2, packet.z2);
}
@Override
public void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket) {
}
@Override
public void wiremodHandleSettings(WiremodSettingsPacket packet) {
AbstractWireTileEntity wireEntity = (AbstractWireTileEntity) this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x, packet.y, packet.z);
switch(packet.mode){
case 0:
wireEntity.outputs[0].floatvalue = packet.value;
wireEntity.update();
break;
case 1:
((ChipTileEntity)wireEntity).tickAmount = (int)packet.value;
wireEntity.update();
break;
}
}
}

@ -9,5 +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(); public void displayGuiWireSettings(ToolWiring toolWiring);
} }

@ -1,19 +0,0 @@
package net.brokenmoon.afloydwiremod.mixinInterfaces;
import net.brokenmoon.afloydwiremod.packet.*;
public interface INetHandler {
void wiremodHandleOpenProgrammerGUI(WiremodProgrammerGuiPacket packet);
void wiremodHandleProgramTile(WiremodProgrammerPacket wiremodProgrammerPacket);
void wiremodHandleOpenWiringGUI(WiremodWiringGuiPacket wiremodWiringGuiPacket);
void wiremodHandleIODisc(WiremodPacketSyncIO wiremodPacketSyncIO);
void wiremodHandleWireChips(WiremodWiringPacket wiremodWiringPacket);
void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket);
void wiremodHandleSettings(WiremodSettingsPacket wiremodSettingsPacket);
}

@ -1,306 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.gui.WiringButton;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodPacketSyncIO extends Packet {
public int x;
public int y;
public int z;
private int size;
public WiringButton[] io;
public WiringButton[] oi;
public String mode;
public int tickAmount;
public WiremodPacketSyncIO(){
this.isChunkDataPacket = true;
}
public WiremodPacketSyncIO(int xCoord, int yCoord, int zCoord, WiringButton[] inputs, WiringButton[] outputs) {
this.isChunkDataPacket = true;
this.x = xCoord;
this.y = yCoord;
this.z = zCoord;
this.io = inputs;
this.oi = outputs;
}
public WiremodPacketSyncIO(int xCoord, int yCoord, int zCoord, WiringButton[] inputs, WiringButton[] outputs, String mode, int tickamount) {
this.isChunkDataPacket = true;
this.x = xCoord;
this.y = yCoord;
this.z = zCoord;
this.io = inputs;
this.oi = outputs;
this.mode = mode;
this.tickAmount = tickamount;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.x = dataInputStream.readInt();
this.y = dataInputStream.readInt();
this.z = dataInputStream.readInt();
if(dataInputStream.readBoolean()){
//INPUT
int length = dataInputStream.readInt();
io = new WiringButton[length];
for(int i = 0; i < length; ++i){
io[i] = new WiringButton();
io[i].x = dataInputStream.readInt();
io[i].y = dataInputStream.readInt();
io[i].slot = dataInputStream.readInt();
io[i].buttonString = dataInputStream.readUTF();
io[i].floatvalue = dataInputStream.readFloat();
io[i].stringvalue = dataInputStream.readUTF();
if(dataInputStream.readBoolean()){
this.io[i].wire = new WireConnection();
this.io[i].wire.x = dataInputStream.readInt();
this.io[i].wire.y = dataInputStream.readInt();
this.io[i].wire.z = dataInputStream.readInt();
this.io[i].wire.thisslot = dataInputStream.readInt();
this.io[i].wire.thatslot = dataInputStream.readInt();
this.io[i].wire.red = dataInputStream.readFloat();
this.io[i].wire.green = dataInputStream.readFloat();
this.io[i].wire.blue = dataInputStream.readFloat();
this.io[i].wire.alpha = dataInputStream.readFloat();
this.io[i].wire.width = dataInputStream.readFloat();
this.io[i].wire.backwired = dataInputStream.readBoolean();
this.io[i].wire.isMade = dataInputStream.readBoolean();
if(dataInputStream.readBoolean()){
int ixlength = dataInputStream.readInt();
for(int ix = 0; ix < ixlength; ix++){
this.io[i].wire.xadd.add(dataInputStream.readInt());
this.io[i].wire.yadd.add(dataInputStream.readInt());
this.io[i].wire.zadd.add(dataInputStream.readInt());
this.io[i].wire.sideadd.add(dataInputStream.readInt());
}
}
}
}
}
if(dataInputStream.readBoolean()){
int length = dataInputStream.readInt();
oi = new WiringButton[length];
for(int i = 0; i < length; ++i){
oi[i] = new WiringButton();
oi[i].x = dataInputStream.readInt();
oi[i].y = dataInputStream.readInt();
oi[i].slot = dataInputStream.readInt();
oi[i].buttonString = dataInputStream.readUTF();
oi[i].floatvalue = dataInputStream.readFloat();
oi[i].stringvalue = dataInputStream.readUTF();
if(dataInputStream.readBoolean()){
this.oi[i].wire = new WireConnection();
this.oi[i].wire.x = dataInputStream.readInt();
this.oi[i].wire.y = dataInputStream.readInt();
this.oi[i].wire.z = dataInputStream.readInt();
this.oi[i].wire.thisslot = dataInputStream.readInt();
this.oi[i].wire.thatslot = dataInputStream.readInt();
this.oi[i].wire.red = dataInputStream.readFloat();
this.oi[i].wire.green = dataInputStream.readFloat();
this.oi[i].wire.blue = dataInputStream.readFloat();
this.oi[i].wire.alpha = dataInputStream.readFloat();
this.oi[i].wire.width = dataInputStream.readFloat();
this.oi[i].wire.backwired = dataInputStream.readBoolean();
this.oi[i].wire.isMade = dataInputStream.readBoolean();
if(dataInputStream.readBoolean()){
int ixlength = dataInputStream.readInt();
for(int ix = 0; ix < ixlength; ix++){
this.oi[i].wire.xadd.add(dataInputStream.readInt());
this.oi[i].wire.yadd.add(dataInputStream.readInt());
this.oi[i].wire.zadd.add(dataInputStream.readInt());
this.oi[i].wire.sideadd.add(dataInputStream.readInt());
}
}
}
}
}
if(dataInputStream.readBoolean()){
this.mode = dataInputStream.readUTF();
}
if(dataInputStream.readBoolean()){
this.tickAmount = dataInputStream.readInt();
}
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(x);
dataOutputStream.writeInt(y);
dataOutputStream.writeInt(z);
size = size + 4;
size = size + 4;
size = size + 4;
if(io != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(io.length);
size = size + 4;
for(int i = 0; i < this.io.length; ++i){
dataOutputStream.writeInt(this.io[i].x);
size = size + 4;
dataOutputStream.writeInt(this.io[i].y);
size = size + 4;
dataOutputStream.writeInt(this.io[i].slot);
size = size + 4;
dataOutputStream.writeUTF(this.io[i].buttonString);
size = size + this.io[i].buttonString.length();
dataOutputStream.writeFloat(this.io[i].floatvalue);
size = size + 4;
dataOutputStream.writeUTF(this.io[i].stringvalue);
size = size + this.io[i].stringvalue.length();
if(io[i].wire != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(this.io[i].wire.x);
dataOutputStream.writeInt(this.io[i].wire.y);
dataOutputStream.writeInt(this.io[i].wire.z);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeInt(this.io[i].wire.thisslot);
dataOutputStream.writeInt(this.io[i].wire.thatslot);
dataOutputStream.writeFloat(this.io[i].wire.red);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeFloat(this.io[i].wire.green);
dataOutputStream.writeFloat(this.io[i].wire.blue);
dataOutputStream.writeFloat(this.io[i].wire.alpha);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeFloat(this.io[i].wire.width);
dataOutputStream.writeBoolean(this.io[i].wire.backwired);
dataOutputStream.writeBoolean(this.io[i].wire.isMade);
size = size + 4;
size++;
size++;
if(this.io[i].wire.xadd != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(this.io[i].wire.xadd.size());
size = size + 4;
for(int ix = 0; ix < this.io[i].wire.xadd.size(); ix++){
dataOutputStream.writeInt(this.io[i].wire.xadd.get(ix));
dataOutputStream.writeInt(this.io[i].wire.yadd.get(ix));
dataOutputStream.writeInt(this.io[i].wire.zadd.get(ix));
dataOutputStream.writeInt(this.io[i].wire.sideadd.get(ix));
size = size + 4;
size = size + 4;
size = size + 4;
size = size + 4;
}
} else {
dataOutputStream.writeBoolean(false);
size++;
}
} else{
dataOutputStream.writeBoolean(false);
size++;
}
}
} else {
dataOutputStream.writeBoolean(false);
size++;
}
if(oi != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(oi.length);
size = size + 4;
for(int i = 0; i < this.oi.length; ++i){
dataOutputStream.writeInt(this.oi[i].x);
size = size + 4;
dataOutputStream.writeInt(this.oi[i].y);
size = size + 4;
dataOutputStream.writeInt(this.oi[i].slot);
size = size + 4;
dataOutputStream.writeUTF(this.oi[i].buttonString);
size = size + this.oi[i].buttonString.length();
dataOutputStream.writeFloat(this.oi[i].floatvalue);
size = size + 4;
dataOutputStream.writeUTF(this.oi[i].stringvalue);
size = size + this.oi[i].stringvalue.length();
if(oi[i].wire != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(this.oi[i].wire.x);
dataOutputStream.writeInt(this.oi[i].wire.y);
dataOutputStream.writeInt(this.oi[i].wire.z);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeInt(this.oi[i].wire.thisslot);
dataOutputStream.writeInt(this.oi[i].wire.thatslot);
dataOutputStream.writeFloat(this.oi[i].wire.red);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeFloat(this.oi[i].wire.green);
dataOutputStream.writeFloat(this.oi[i].wire.blue);
dataOutputStream.writeFloat(this.oi[i].wire.alpha);
size = size + 4;
size = size + 4;
size = size + 4;
dataOutputStream.writeFloat(this.oi[i].wire.width);
dataOutputStream.writeBoolean(this.oi[i].wire.backwired);
dataOutputStream.writeBoolean(this.oi[i].wire.isMade);
size = size + 4;
size++;
size++;
if(this.oi[i].wire.xadd != null){
dataOutputStream.writeBoolean(true);
size++;
dataOutputStream.writeInt(this.oi[i].wire.xadd.size());
size = size + 4;
for(int ix = 0; ix < this.oi[i].wire.xadd.size(); ix++){
dataOutputStream.writeInt(this.oi[i].wire.xadd.get(ix));
dataOutputStream.writeInt(this.oi[i].wire.yadd.get(ix));
dataOutputStream.writeInt(this.oi[i].wire.zadd.get(ix));
dataOutputStream.writeInt(this.oi[i].wire.sideadd.get(ix));
size = size + 4;
size = size + 4;
size = size + 4;
size = size + 4;
}
} else {
dataOutputStream.writeBoolean(false);
size++;
}
} else{
dataOutputStream.writeBoolean(false);
size++;
}
}
} else {
dataOutputStream.writeBoolean(false);
size++;
}
dataOutputStream.writeBoolean(this.mode != null);
if(this.mode != null){
dataOutputStream.writeUTF(mode);
}
dataOutputStream.writeBoolean(this.tickAmount != 0);
if(this.tickAmount != 0){
dataOutputStream.writeInt(tickAmount);
}
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleIODisc(this);
}
@Override
public int getPacketSize() {
return size;
}
}

@ -1,53 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodProgrammerGuiPacket extends Packet {
public int mode;
public int x;
public int y;
public int z;
public WiremodProgrammerGuiPacket(){
}
public WiremodProgrammerGuiPacket(int i, int x, int y, int z){
this.mode = i;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.mode = dataInputStream.readInt();
this.x = dataInputStream.readInt();
this.y = dataInputStream.readInt();
this.z = dataInputStream.readInt();
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(this.mode);
dataOutputStream.writeInt(this.x);
dataOutputStream.writeInt(this.y);
dataOutputStream.writeInt(this.z);
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleOpenProgrammerGUI(this);
}
@Override
public int getPacketSize() {
return 4 * 4;
}
}

@ -1,51 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodProgrammerPacket extends Packet {
public WiremodProgrammerPacket(){
}
public String mode;
public int x;
public int y;
public int z;
public WiremodProgrammerPacket(String mode, int x, int y, int z){
this.mode = mode;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.mode = dataInputStream.readUTF();
this.x = dataInputStream.readInt();
this.y = dataInputStream.readInt();
this.z = dataInputStream.readInt();
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeUTF(mode);
dataOutputStream.writeInt(this.x);
dataOutputStream.writeInt(this.y);
dataOutputStream.writeInt(this.z);
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleProgramTile(this);
}
@Override
public int getPacketSize() {
return (4 * 3) + this.mode.length();
}
}

@ -1,63 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodSettingsPacket extends Packet {
public int mode;
public float value;
public int size;
public int x;
public int y;
public int z;
public WiremodSettingsPacket(){
}
//Settings which changes one variable
public WiremodSettingsPacket(int mode, float amount, int x, int y, int z) {
this.mode = mode;
this.value = amount;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.mode = dataInputStream.readInt();
this.x = dataInputStream.readInt();
this.y = dataInputStream.readInt();
this.z = dataInputStream.readInt();
if(mode == 0 || mode == 1){
this.value = dataInputStream.readFloat();
}
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(mode);
dataOutputStream.writeInt(x);
dataOutputStream.writeInt(y);
dataOutputStream.writeInt(z);
if(mode == 0 || mode == 1){
dataOutputStream.writeFloat(value);
size += 4;
}
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleSettings(this);
}
@Override
public int getPacketSize() {
return 16 + size;
}
}

@ -1,31 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodWireGuiPacket extends Packet {
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleWireToolSettingsGui(this);
}
@Override
public int getPacketSize() {
return 0;
}
}

@ -1,58 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodWiringGuiPacket extends Packet {
public int x;
public int y;
public int z;
public int x2;
public int y2;
public int z2;
public WiremodWiringGuiPacket(){
}
public WiremodWiringGuiPacket(int x, int y, int z, int x2, int y2, int z2){
this.x = x;
this.y = y;
this.z = z;
this.x2 = x2;
this.y2 = y2;
this.z2 = z2;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.x = dataInputStream.readInt();
this.y = dataInputStream.readInt();
this.z = dataInputStream.readInt();
this.x2 = dataInputStream.readInt();
this.y2 = dataInputStream.readInt();
this.z2 = dataInputStream.readInt();
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(this.x);
dataOutputStream.writeInt(this.y);
dataOutputStream.writeInt(this.z);
dataOutputStream.writeInt(this.x2);
dataOutputStream.writeInt(this.y2);
dataOutputStream.writeInt(this.z2);
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleOpenWiringGUI(this);
}
@Override
public int getPacketSize() {
return 6 * 4;
}
}

@ -1,145 +0,0 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
public class WiremodWiringPacket extends Packet {
public int type;
public int x1;
public int y1;
public int z1;
public int x2;
public int y2;
public int z2;
public int slot1;
public int slot2;
public ArrayList<Integer> xadd;
public ArrayList<Integer> yadd;
public ArrayList<Integer> zadd;
public ArrayList<Integer> sideadd;
public boolean backwired;
public float red = 1.0f;
public float green = 0f;
public float blue = 0f;
public float alpha = 1f;
public float width = 0.5f;
private int size = 0;
public WiremodWiringPacket(){
}
public WiremodWiringPacket(int x1, int y1, int z1, int x2, int y2, int z2, int slot1, int slot2, ArrayList<Integer> xadd, ArrayList<Integer> yadd, ArrayList<Integer> zadd, ArrayList<Integer> sideadd, boolean b, float red, float green, float blue, float alpha, float width) {
this.type = 0;
this.x1 = x1;
this.y1 = y1;
this.z1 = z1;
this.x2 = x2;
this.y2 = y2;
this.z2 = z2;
this.slot1 = slot1;
this.slot2 = slot2;
this.xadd = xadd;
this.yadd = yadd;
this.zadd = zadd;
this.sideadd = sideadd;
this.backwired = b;
this.red = red;
this.blue = blue;
this.green = green;
this.alpha = alpha;
this.width = width;
}
public WiremodWiringPacket(int x1, int y1, int z1, int x2, int y2, int z2, int slot1, int slot2) {
this.type = 1;
this.x1 = x1;
this.y1 = y1;
this.z1 = z1;
this.x2 = x2;
this.y2 = y2;
this.z2 = z2;
this.slot1 = slot1;
this.slot2 = slot2;
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.type = dataInputStream.readInt();
this.x1 = dataInputStream.readInt();
this.y1 = dataInputStream.readInt();
this.z1 = dataInputStream.readInt();
this.x2 = dataInputStream.readInt();
this.y2 = dataInputStream.readInt();
this.z2 = dataInputStream.readInt();
this.slot1 = dataInputStream.readInt();
this.slot2 = dataInputStream.readInt();
backwired = dataInputStream.readBoolean();
red = dataInputStream.readFloat();
green = dataInputStream.readFloat();
blue = dataInputStream.readFloat();
alpha = dataInputStream.readFloat();
width = dataInputStream.readFloat();
boolean isxadd = dataInputStream.readBoolean();
xadd = new ArrayList<>();
yadd = new ArrayList<>();
zadd = new ArrayList<>();
sideadd = new ArrayList<>();
if(isxadd){
int length = dataInputStream.readInt();
for(int i = 0; i < length; i++) {
xadd.add(dataInputStream.readInt());
yadd.add(dataInputStream.readInt());
zadd.add(dataInputStream.readInt());
sideadd.add(dataInputStream.readInt());
}
}
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(type);
dataOutputStream.writeInt(x1);
dataOutputStream.writeInt(y1);
dataOutputStream.writeInt(z1);
dataOutputStream.writeInt(x2);
dataOutputStream.writeInt(y2);
dataOutputStream.writeInt(z2);
dataOutputStream.writeInt(slot1);
dataOutputStream.writeInt(slot2);
dataOutputStream.writeBoolean(backwired);
dataOutputStream.writeFloat(red);
dataOutputStream.writeFloat(green);
dataOutputStream.writeFloat(blue);
dataOutputStream.writeFloat(alpha);
dataOutputStream.writeFloat(width);
dataOutputStream.writeBoolean(xadd != null);
if(xadd != null){
dataOutputStream.writeInt(xadd.size());
size = 4;
for(int i = 0; i < xadd.size(); i++){
dataOutputStream.writeInt(xadd.get(i));
size += 4;
dataOutputStream.writeInt(yadd.get(i));
size += 4;
dataOutputStream.writeInt(zadd.get(i));
size += 4;
dataOutputStream.writeInt(sideadd.get(i));
size += 4;
}
}
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleWireChips(this);
}
@Override
public int getPacketSize() {
return 14 * 4 + 2 + size;
}
}

@ -1,73 +0,0 @@
package net.brokenmoon.afloydwiremod.ter;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
import net.brokenmoon.afloydwiremod.tileentity.DisplayTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Block;
import net.minecraft.src.FontRenderer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import java.awt.*;
public class TERDisplay extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double e, double f, float g) {
this.renderDisplay((DisplayTileEntity)tileEntity, d, e, f, g);
}
private void renderDisplay(DisplayTileEntity tileEntity, double d, double e, double f, float g) {
if(tileEntity.inputs != null){
for(int it = 0; it < tileEntity.inputs.length; it++){
if(tileEntity.inputs[it] != null && tileEntity.isLineReversed != null){
this.renderTextLine(d, e, f, it, tileEntity.inputs[it].floatvalue, tileEntity.inputs[it].stringvalue, tileEntity.isLineReversed[it], Minecraft.getMinecraft().theWorld.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
}
}
}
}
private void renderTextLine(double d, double d1, double d2, int line, float floatvalue, String stringvalue, boolean reversed, int meta) {
String strToRender;
if(reversed) {
strToRender = floatvalue + stringvalue;
}else{
strToRender = stringvalue + floatvalue;
}
FontRenderer fontRenderer = this.getFontRenderer();
GL11.glPushMatrix();
GL11.glTranslatef((float)d, (float)d1, (float)d2);
float yoff = 0.151f;
switch(meta) {
case 5:
GL11.glTranslatef(0.5f, yoff, 0.53f);
GL11.glRotatef(-90f, 1, 0, 0);
break;
case 0:
GL11.glTranslatef(0.5f, 1 - yoff, 0.47f);
GL11.glRotatef(90f, 1, 0, 0);
break;
case 4:
GL11.glTranslatef(0.5f, 0.47f, 1 - yoff);
GL11.glRotatef(180f, 0, 1, 0);
break;
case 3:
GL11.glTranslatef(0.5f, 0.47f, yoff);
break;
case 1:
GL11.glRotatef(90f, 0, 1, 0);
GL11.glTranslatef(-0.5f, 0.47f, yoff);
break;
case 2:
GL11.glRotatef(-90f, 0, 1, 0);
GL11.glTranslatef(0.5f, 0.47f, - 1 + yoff);
break;
}
GL11.glScalef(0.02f, -0.02f, 0.02f);
fontRenderer.drawString(strToRender, -fontRenderer.getStringWidth(strToRender) / 2, line * 10 - 4 * 5, 0xFFFFFF);
fontRenderer.drawString(strToRender, -fontRenderer.getStringWidth(strToRender) / 2, line * 10 - 4 * 5, 0xFFFFFF);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glPopMatrix();
}
}

@ -1,17 +0,0 @@
package net.brokenmoon.afloydwiremod.tile;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
import net.brokenmoon.afloydwiremod.tileentity.DisplayTileEntity;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
public class DisplayTile extends AbstractWireTileSided {
public DisplayTile(int i, Material material) {
super(i, material);
}
@Override
protected TileEntity getBlockEntity() {
return new DisplayTileEntity();
}
}

@ -64,12 +64,10 @@ public class RedstoneLinkTile extends AbstractWireTile {
@Override @Override
public void updateTick(World world, int i, int j, int k, Random random) { public void updateTick(World world, int i, int j, int k, Random random) {
RedstoneLinkTileEntity link = (RedstoneLinkTileEntity) world.getBlockTileEntity(i, j, k); RedstoneLinkTileEntity link = (RedstoneLinkTileEntity) world.getBlockTileEntity(i, j, k);
if (world.isBlockGettingPowered(i, j, k) || world.isBlockIndirectlyGettingPowered(i, j, k)) { if (world.isBlockGettingPowered(i, j, k)) {
link.outputs[0].floatvalue = 1.0f; link.outputs[0].floatvalue = 1.0f;
link.updateIO();
} else { } else {
link.outputs[0].floatvalue = 0.0f; link.outputs[0].floatvalue = 0.0f;
link.updateIO();
} }
} }

@ -2,266 +2,20 @@ package net.brokenmoon.afloydwiremod.tileentity;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.WiringButton; import net.brokenmoon.afloydwiremod.gui.WiringButton;
import net.brokenmoon.afloydwiremod.packet.WiremodPacketSyncIO;
import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet;
public class ChipTileEntity extends AbstractWireTileEntity { public class ChipTileEntity extends AbstractWireTileEntity {
public String mode = "none"; public String mode = "none";
private boolean shouldIncrement = true; private boolean shouldIncrement = true;
private boolean shouldDecrement = true;
private int timer;
public int tickAmount = 0;
@Override @Override
public void updateEntity(){ public void updateEntity() {
if(timer == 0){
switch (mode){
case "Pulse":
outputs[0].floatvalue = 0;
outputs[0].stringvalue = "";
updateIO();
}
} else{
timer--;
}
}
@Override
public void update() {
switch (mode) { switch (mode) {
case "inc": case "count":
doIncrement(); doIncrement();
updateIO();
break;
case "dec":
doDecrement();
updateIO();
break;
case "incdec":
doIncrementDecrement();
updateIO();
break;
case "mem":
doMemory();
updateIO();
break;
case "dup":
doDup();
updateIO();
break;
case "add":
doAdd();
updateIO();
break;
case "sub":
doSub();
updateIO();
break;
case "mult":
doMult();
updateIO();
break;
case "div":
doDiv();
updateIO();
break;
case "NOT":
doNOT();
updateIO();
break;
case "AND":
doAND();
updateIO();
break;
case "OR":
doOR();
updateIO();
break;
case "XOR":
doXOR();
updateIO();
break;
case "NAND":
doNAND();
updateIO();
break;
case "NOR":
doNOR();
updateIO();
break;
case "XNOR":
doXNOR();
updateIO();
break;
case "TRUE":
outputs[0].floatvalue = 1.0f;
updateIO();
break;
case "FALSE":
outputs[0].floatvalue = 0.0f;
updateIO();
break;
case "==":
doEquals();
updateIO();
break;
case "!=":
doNotEquals();
updateIO();
break;
case ">":
doGreater();
updateIO();
break;
case ">=":
doGreaterEq();
updateIO();
break;
case "<":
doLess();
updateIO();
break;
case "<=":
doLessEq();
updateIO();
break;
case "<=>":
doSpaceShip();
updateIO();
break;
case "Pulse":
doPulse();
break; break;
} }
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); updateIO();
}
private void doPulse() {
if(inputs[0].floatvalue != 0 && timer == 0) {
outputs[0].floatvalue = inputs[0].floatvalue;
outputs[0].stringvalue = inputs[0].stringvalue;
updateIO();
if(tickAmount == 0){
outputs[0].floatvalue = 0;
outputs[0].stringvalue = "";
updateIO();
} else{
timer = tickAmount - 1;
}
}
}
private void doSpaceShip() {
outputs[0].floatvalue = Float.compare(inputs[0].floatvalue, inputs[1].floatvalue);
}
private void doLessEq() {
outputs[0].floatvalue = inputs[0].floatvalue <= inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doLess() {
outputs[0].floatvalue = inputs[0].floatvalue < inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doGreaterEq() {
outputs[0].floatvalue = inputs[0].floatvalue >= inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doGreater() {
outputs[0].floatvalue = inputs[0].floatvalue > inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doNotEquals() {
outputs[0].floatvalue = inputs[0].floatvalue != inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doEquals() {
outputs[0].floatvalue = inputs[0].floatvalue == inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doXNOR() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 ^ inputs[1].floatvalue != 0 ? 0.0f : 1.0f;
}
private void doNOR() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 || inputs[1].floatvalue != 0 ? 0.0f : 1.0f;
}
private void doNAND() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 && inputs[1].floatvalue != 0 ? 0.0f : 1.0f;
}
private void doXOR() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 ^ inputs[1].floatvalue != 0 ? 1.0f : 0.0f;
}
private void doOR() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 || inputs[1].floatvalue != 0 ? 1.0f : 0.0f;
}
private void doAND() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 && inputs[1].floatvalue != 0 ? 1.0f : 0.0f;
}
private void doNOT() {
this.outputs[0].floatvalue = inputs[0].floatvalue != 0 ? 0.0f : 1.0f;
}
private void doIncrementDecrement() {
if (inputs[3].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue + this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true;
}
if (this.inputs[2].floatvalue > 0 && shouldDecrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue - this.inputs[0].floatvalue;
shouldDecrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldDecrement) {
shouldDecrement = true;
}
}
private void doDecrement() {
if (inputs[2].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue - this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true;
}
}
private void doDiv() {
outputs[0].floatvalue = inputs[0].floatvalue / inputs[1].floatvalue;
}
private void doMult() {
outputs[0].floatvalue = inputs[0].floatvalue * inputs[1].floatvalue;
}
private void doSub() {
outputs[0].floatvalue = inputs[0].floatvalue - inputs[1].floatvalue;
}
private void doDup() {
outputs[0].floatvalue = inputs[0].floatvalue;
outputs[1].floatvalue = inputs[0].floatvalue;
outputs[0].stringvalue = inputs[0].stringvalue;
outputs[1].stringvalue = inputs[0].stringvalue;
}
private void doAdd() {
outputs[0].floatvalue = inputs[0].floatvalue + inputs[1].floatvalue;
outputs[0].stringvalue = inputs[0].stringvalue + inputs[1].stringvalue;
} }
public void doIncrement() { public void doIncrement() {
@ -272,19 +26,7 @@ public class ChipTileEntity extends AbstractWireTileEntity {
if (this.inputs[1].floatvalue > 0 && shouldIncrement) { if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue + this.inputs[0].floatvalue; this.outputs[0].floatvalue = this.outputs[0].floatvalue + this.inputs[0].floatvalue;
shouldIncrement = false; shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) { System.out.println("Incrementing to " + this.outputs[0].floatvalue);
shouldIncrement = true;
}
}
private void doMemory() {
if (inputs[2].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) { } else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true; shouldIncrement = true;
} }
@ -294,94 +36,33 @@ public class ChipTileEntity extends AbstractWireTileEntity {
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
this.mode = nbttagcompound.getString("mode"); this.mode = nbttagcompound.getString("mode");
this.tickAmount = nbttagcompound.getInteger("tickAmount");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound); super.writeToNBT(nbttagcompound);
nbttagcompound.setString("mode", mode); nbttagcompound.setString("mode", mode);
nbttagcompound.setInteger("tickAmount", tickAmount);
} }
public void setMode(String string) { public void setMode(String string) {
if (mode.equals("none")) { if (mode.equals("none")) {
mode = string; if (string.equals("constant")) {
switch(string) { mode = string;
case "constant": this.inputs = new WiringButton[0];
hasSettings = true; this.outputs = new WiringButton[1];
case "TRUE": this.outputs[0] = new WiringButton(214, 240, "Output", 0);
case "FALSE": initialized = true;
this.inputs = new WiringButton[0]; hasSettings = true;
this.outputs = new WiringButton[1]; } else if (string.equals("count")) {
this.outputs[0] = new WiringButton(214, 240, "Output", 0); mode = string;
break; this.inputs = new WiringButton[3];
case "inc": this.outputs = new WiringButton[1];
case "dec": this.outputs[0] = new WiringButton(214, 240, "Output", 0);
case "mem": this.inputs[0] = new WiringButton(214, 220, "Source", 0);
this.inputs = new WiringButton[3]; this.inputs[1] = new WiringButton(214, 200, "Clock", 1);
this.outputs = new WiringButton[1]; this.inputs[2] = new WiringButton(214, 180, "Reset", 2);
this.outputs[0] = new WiringButton(214, 240, "Output", 0); initialized = true;
this.inputs[0] = new WiringButton(214, 220, "Source", 0);
this.inputs[1] = new WiringButton(214, 200, "Clock", 1);
this.inputs[2] = new WiringButton(214, 180, "Reset", 2);
break;
case "incdec":
this.inputs = new WiringButton[4];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
this.inputs[0] = new WiringButton(214, 220, "Source", 0);
this.inputs[1] = new WiringButton(214, 220, "Increment", 1);
this.inputs[2] = new WiringButton(214, 200, "Decrement", 2);
this.inputs[3] = new WiringButton(214, 180, "Reset", 3);
break;
case "dup":
this.inputs = new WiringButton[1];
this.outputs = new WiringButton[2];
this.outputs[0] = new WiringButton(214, 230, "Output A", 0);
this.outputs[1] = new WiringButton(214, 210, "Output B", 1);
this.inputs[0] = new WiringButton(214, 230, "Input", 0);
break;
case "Pulse":
hasSettings = true;
case "NOT":
this.inputs = new WiringButton[1];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 230, "Output", 0);
this.inputs[0] = new WiringButton(214, 210, "Input", 0);
break;
case "AND":
case "OR":
case "XOR":
case "NAND":
case "NOR":
case "XNOR":
case "add":
case "sub":
case "mult":
case "div":
case "==":
case "!=":
case ">":
case ">=":
case "<":
case "<=":
case "<=>":
this.inputs = new WiringButton[2];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 230, "Output", 0);
this.inputs[0] = new WiringButton(214, 210, "Input A", 0);
this.inputs[1] = new WiringButton(214, 190, "Input B", 1);
break;
} }
initialized = true;
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
update();
} }
} }
@Override
public Packet getDescriptionPacket() {
return new WiremodPacketSyncIO(this.xCoord, this.yCoord, this.zCoord, inputs, outputs, mode, tickAmount);
}
} }

@ -1,35 +0,0 @@
package net.brokenmoon.afloydwiremod.tileentity;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.WiringButton;
import net.minecraft.src.NBTTagCompound;
public class DisplayTileEntity extends AbstractWireTileEntity {
public boolean[] isLineReversed = new boolean[4];
public DisplayTileEntity(){
super();
inputs = new WiringButton[4];
inputs[0] = new WiringButton(214, 220, "Line 1", 0);
inputs[1] = new WiringButton(214, 220, "Line 2", 1);
inputs[2] = new WiringButton(214, 220, "Line 3", 2);
inputs[3] = new WiringButton(214, 220, "Line 4", 3);
outputs = new WiringButton[0];
this.initialized = true;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
for(int i = 0; i < isLineReversed.length; i++){
isLineReversed[i] = nbttagcompound.getBoolean("reverse" + i);
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
for(int i = 0; i < isLineReversed.length; i++){
nbttagcompound.setBoolean("reverse" + i, isLineReversed[i]);
}
}
}

@ -31,7 +31,7 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
nbttagcompound.setBoolean("activity", this.isActive); nbttagcompound.setBoolean("activity", this.isActive);
} }
@Override @Override
public void update() { public void updateEntity() {
if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){ if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){
this.shouldnotremove = true; this.shouldnotremove = true;
RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord); RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
@ -43,6 +43,6 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
this.shouldnotremove = false; this.shouldnotremove = false;
this.isActive = false; this.isActive = false;
} }
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); updateIO();
} }
} }

@ -1,4 +1,4 @@
package net.brokenmoon.afloydwiremod.ter; package net.brokenmoon.afloydwiremod.tileentity;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided; import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
@ -18,7 +18,7 @@ public class TERWire extends TileEntitySpecialRenderer {
public void renderWireAt(AbstractWireTileEntity wireEntity, double x, double y, double z, float weird) { public void renderWireAt(AbstractWireTileEntity wireEntity, double x, double y, double z, float weird) {
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] != null && wireEntity.outputs[it].wire != null && wireEntity.outputs[it].wire.isMade && Minecraft.getMinecraft().theWorld.getBlockTileEntity(wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z) instanceof AbstractWireTileEntity){ if(wireEntity.outputs[it].wire != null && wireEntity.outputs[it].wire.isMade){
this.renderLineBetweenTwoPoints( this.renderLineBetweenTwoPoints(
wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord,
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,
@ -252,7 +252,6 @@ public class TERWire extends TileEntitySpecialRenderer {
GL11.glEnd(); GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true); GL11.glDepthMask(true);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

@ -5,11 +5,7 @@
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"MixinEntityPlayerSP", "MixinEntityPlayerSP",
"MixinEntityPlayerMP", "MixinBlockRenderer"
"MixinBlockRenderer",
"MixinNetClientHandler",
"MixinNetServerHandler",
"AccessorPacket"
], ],
"client": [ "client": [
], ],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

@ -1,26 +0,0 @@
[ids]
[ids.tile]
chipTile = 905
linkTileInactive = 906
linkTileActive = 907
displayTile = 908
[ids.item]
programmingTool = 909
wiringTool = 910
redSilica = 911
chipDie = 912
chipDieOvercooked = 913
[ids.packet]
programming = 109
programmerGui = 110
wiring = 111
wiringGui = 112
wiringSettingsGui = 113
sync = 114
chipSettingsGui = 115
[misc]
scrollrate = 5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

@ -33,9 +33,7 @@
"custom": { "custom": {
"loom:injected_interfaces": { "loom:injected_interfaces": {
"net/minecraft/src/EntityPlayerSP": ["net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer"], "net/minecraft/src/EntityPlayerSP": ["net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer"],
"net/minecraft/src/EntityPlayerMP": ["net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer"], "net/minecraft/src/EntityPlayerMP": ["net/brokenmoon/afloydwiremod/mixinInterfaces/IEntityPlayer"]
"net/minecraft/src/NetClientHandler": ["net/brokenmoon/afloydwiremod/mixinInterfaces/INetHandler"],
"net/minecraft/src/NetServerHandler": ["net/brokenmoon/afloydwiremod/mixinInterfaces/INetHandler"]
} }
} }
} }

@ -2,15 +2,7 @@ item.afloydwiremod.toolProgrammer.name=Programming Tool
item.afloydwiremod.toolProgrammer.desc=Used to program chips. item.afloydwiremod.toolProgrammer.desc=Used to program chips.
item.afloydwiremod.toolWiring.name=Wiring Tool item.afloydwiremod.toolWiring.name=Wiring Tool
item.afloydwiremod.toolWiring.desc=Used to connect outputs to inputs. item.afloydwiremod.toolWiring.desc=Used to connect outputs to inputs.
item.afloydwiremod.redSilica.name=Red Silica
item.afloydwiremod.redSilica.desc=Smeltable into logical products.
item.afloydwiremod.chipDie.name=Silicon Die
item.afloydwiremod.chipDie.desc=Too fragile to use unpackaged.
item.afloydwiremod.chipDieBroken.name=Broken Die
item.afloydwiremod.chipDieBroken.desc=Destroyed by the temperatures of the Blast Furnace.
tile.afloydwiremod.chipTile.name=Chip tile.afloydwiremod.chipTile.name=Chip
tile.afloydwiremod.chipTile.desc=Used to preform mathematical calculations. tile.afloydwiremod.chipTile.desc=Used to preform mathematical calculations.
tile.afloydwiremod.linkTile.name=Redstone Link tile.afloydwiremod.linkTile.name=Redstone Link
tile.afloydwiremod.linkTile.desc=Used to interface chips with redstone devices. tile.afloydwiremod.linkTile.desc=Used to interface chips with redstone devices.
tile.afloydwiremod.displayTile.name=Display
tile.afloydwiremod.displayTile.desc=Used to output values from wires.
Loading…
Cancel
Save