Version Alpha One
parent
11b5f4a564
commit
11b5d14ccd
@ -0,0 +1,33 @@
|
||||
package net.brokenmoon.afloydwiremod;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.tile.ChipTile;
|
||||
import net.brokenmoon.afloydwiremod.item.ToolProgrammer;
|
||||
import net.brokenmoon.afloydwiremod.tile.RedstoneLinkTile;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.Material;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import turniplabs.halplibe.helper.BlockHelper;
|
||||
import turniplabs.halplibe.helper.ItemHelper;
|
||||
|
||||
|
||||
public class WireMod implements ModInitializer {
|
||||
public static final String MOD_ID = "afloydwiremod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public static Block ChipTile = BlockHelper.createBlock(MOD_ID, new ChipTile(905, Material.iron), "chipTile", "testTexture.png", Block.soundMetalFootstep,5, 5, 0 );
|
||||
|
||||
public static Item ToolProgrammer = ItemHelper.createItem(MOD_ID, new ToolProgrammer(906), "toolProgrammer", "testTexture.png");
|
||||
public static Item ToolWiring = ItemHelper.createItem(MOD_ID, new ToolWiring(907), "toolWiring", "testTexture.png");
|
||||
|
||||
public static Block LinkTileInactive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(908, Material.iron, false), "linkTile", "testTexture.png", Block.soundStoneFootstep, 5, 5, 0);
|
||||
public static Block LinkTileActive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(909, Material.iron, true), "linkTile", "testTexture.png", Block.soundStoneFootstep, 5, 5, 0);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("WireMod initialized.");
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package net.brokenmoon.afloydwiremod.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IWireConnectable {
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package net.brokenmoon.afloydwiremod.api;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.gui.WiringButton;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class WireConnection {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public int thisslot;
|
||||
public int thatslot;
|
||||
|
||||
public WireConnection(){
|
||||
|
||||
}
|
||||
public WireConnection(int x, int y, int z, int thisslot){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.thisslot = thisslot;
|
||||
}
|
||||
|
||||
public WireConnection(int x, int y, int z, int thisslot, int thatslot){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.thisslot = thisslot;
|
||||
this.thatslot = thatslot;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("wx", this.x);
|
||||
nbttagcompound.setInteger("wy", this.y);
|
||||
nbttagcompound.setInteger("wz", this.z);
|
||||
nbttagcompound.setInteger("wthisslot", thisslot);
|
||||
nbttagcompound.setInteger("wthatslot", thatslot);
|
||||
System.out.println("Writing wires to nbt");
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
this.x = nbttagcompound.getInteger("wx");
|
||||
this.y = nbttagcompound.getInteger("wy");
|
||||
this.z = nbttagcompound.getInteger("wz");
|
||||
this.thisslot = nbttagcompound.getInteger("wthisslot");
|
||||
this.thatslot = nbttagcompound.getInteger("wthatslot");
|
||||
System.out.println("Loading wires from nbt");
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.brokenmoon.afloydwiremod.gui;
|
||||
|
||||
import net.minecraft.src.GuiButton;
|
||||
|
||||
public class GuiButtonExtended extends GuiButton {
|
||||
|
||||
public String type;
|
||||
public int slot;
|
||||
public GuiButtonExtended(int xPosition, int yPosition, String s, String extra, int slot) {
|
||||
super(0, xPosition, yPosition, s);
|
||||
this.type = extra;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public GuiButtonExtended(int xPosition, int yPosition, int width, int height, String s, String extra, int slot) {
|
||||
super(0, xPosition, yPosition, width, height, s);
|
||||
this.type = extra;
|
||||
this.slot = slot;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package net.brokenmoon.afloydwiremod.gui;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class GuiProgrammer extends GuiScreen {
|
||||
|
||||
private ChipTileEntity chip;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
//this.height - 240 is top
|
||||
//This.width / 2
|
||||
this.controlList.add(new GuiButton(1, this.width / 2 - 214, this.height - 240, "Constant"));
|
||||
this.controlList.add(new GuiButton(2, this.width / 2 - 214, this.height - 220, "Count"));
|
||||
}
|
||||
|
||||
public GuiProgrammer(EntityPlayer player, ChipTileEntity chip) {
|
||||
super.initGui();
|
||||
this.chip = chip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
if (guibutton.id == 1) {
|
||||
chip.setMode("constant");
|
||||
} else if(guibutton.id == 2){
|
||||
chip.setMode("count");
|
||||
}
|
||||
this.mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package net.brokenmoon.afloydwiremod.gui;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class GuiWiring extends GuiScreen {
|
||||
private ToolWiring tool;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private ChipTileEntity chip;
|
||||
@Override
|
||||
public void initGui() {
|
||||
//this.height - 240 is top
|
||||
//This.width / 2 - 214 is left
|
||||
//Inputs
|
||||
if(chip.inputs != null && this.tool.type.equals("output")) {
|
||||
for (int i = 0; i < chip.inputs.length; i++) {
|
||||
this.controlList.add(new GuiButtonExtended(this.width / 2 - chip.inputs[i].x, this.height - chip.inputs[i].y, chip.inputs[i].buttonString, "Input", chip.inputs[i].slot));
|
||||
}
|
||||
}
|
||||
//Outputs
|
||||
if(chip.outputs != null && !this.tool.type.equals("output")) {
|
||||
for (int i = 0; i < chip.outputs.length; i++) {
|
||||
this.controlList.add(new GuiButtonExtended(this.width / 2 - chip.outputs[i].x, this.height - chip.outputs[i].y, chip.outputs[i].buttonString, "Output", chip.outputs[i].slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiWiring(EntityPlayer player, ToolWiring tool, ChipTileEntity chip, int x, int y, int z) {
|
||||
super.initGui();
|
||||
this.tool = tool;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.chip = chip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton){
|
||||
this.actionPerformed((GuiButtonExtended)guiButton);
|
||||
}
|
||||
protected void actionPerformed(GuiButtonExtended guibutton) {
|
||||
if(this.tool.type.equals("unpaired")) {
|
||||
if (guibutton.type.equals("Input")) {
|
||||
this.tool.type = "input";
|
||||
this.tool.slot = guibutton.slot;
|
||||
this.tool.x = x;
|
||||
this.tool.y = y;
|
||||
this.tool.z = z;
|
||||
} else if (guibutton.type.equals("Output")) {
|
||||
this.tool.type = "output";
|
||||
this.tool.slot = guibutton.slot;
|
||||
this.tool.x = x;
|
||||
this.tool.y = y;
|
||||
this.tool.z = z;
|
||||
}
|
||||
} else if(this.tool.type.equals("output")) {
|
||||
this.chip.inputs[guibutton.slot].wire = new WireConnection(tool.x, tool.y, tool.z, guibutton.slot, tool.slot);
|
||||
System.out.print(guibutton.slot + " " + tool.slot);
|
||||
tool.type = "unpaired";
|
||||
}
|
||||
this.mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.brokenmoon.afloydwiremod.gui;
|
||||
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class WiringButton {
|
||||
public int x;
|
||||
public int y;
|
||||
public String buttonString;
|
||||
public int slot;
|
||||
public float floatvalue;
|
||||
public String stringvalue = "";
|
||||
public WireConnection wire = new WireConnection();
|
||||
public WiringButton(){
|
||||
|
||||
}
|
||||
public WiringButton(int x, int y, String buttonString, int slot){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.buttonString = buttonString;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("bx", this.x);
|
||||
nbttagcompound.setInteger("by", this.y);
|
||||
nbttagcompound.setString("bbuttonString", buttonString);
|
||||
nbttagcompound.setInteger("bslot", slot);
|
||||
nbttagcompound.setFloat("bfloatvalue", floatvalue);
|
||||
nbttagcompound.setString("bstringvalue", stringvalue);
|
||||
wire.writeToNBT(nbttagcompound);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
this.x = nbttagcompound.getInteger("bx");
|
||||
this.y = nbttagcompound.getInteger("by");
|
||||
this.buttonString = nbttagcompound.getString("bbuttonString");
|
||||
this.slot = nbttagcompound.getInteger("bslot");
|
||||
this.floatvalue = nbttagcompound.getFloat("bfloatvalue");
|
||||
this.stringvalue = nbttagcompound.getString("bstringvalue");
|
||||
wire.readFromNBT(nbttagcompound);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.brokenmoon.afloydwiremod.item;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
|
||||
public class ToolProgrammer extends Item {
|
||||
public ToolProgrammer(int i) {
|
||||
super(i);
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.brokenmoon.afloydwiremod.item;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class ToolWiring extends Item {
|
||||
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int z = 0;
|
||||
public String type = "unpaired";
|
||||
public int slot;
|
||||
public ToolWiring(int i) {
|
||||
super(i);
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, double heightPlaced) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.gui.GuiProgrammer;
|
||||
import net.brokenmoon.afloydwiremod.gui.GuiWiring;
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.EntityPlayerSP;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = EntityPlayerSP.class, remap = false)
|
||||
public class MixinEntityPlayerSP implements IEntityPlayer {
|
||||
@Shadow
|
||||
protected Minecraft mc;
|
||||
public void displayGuiProgrammer(ChipTileEntity chip) {
|
||||
this.mc.displayGuiScreen(new GuiProgrammer(((EntityPlayerSP)(Object)this), chip));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayGuiWiring(ToolWiring tool, ChipTileEntity chip, int x, int y, int z) {
|
||||
this.mc.displayGuiScreen(new GuiWiring(((EntityPlayerSP)(Object)this), tool, chip, x, y, z));
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.RedstoneLinkTileEntity;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = TileEntity.class, remap = false)
|
||||
public class MixinTileEntity {
|
||||
@Shadow
|
||||
private static void addMapping(Class class1, String s) {}
|
||||
|
||||
static {
|
||||
addMapping(ChipTileEntity.class, "Chip");
|
||||
addMapping(RedstoneLinkTileEntity.class, "Link");
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.brokenmoon.afloydwiremod.mixinInterfaces;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
|
||||
public interface IEntityPlayer {
|
||||
public void displayGuiProgrammer(ChipTileEntity chip);
|
||||
|
||||
public void displayGuiWiring(ToolWiring tool, ChipTileEntity chip, int x, int y, int z);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.brokenmoon.afloydwiremod.tile;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.WireMod;
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.RedstoneLinkTileEntity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ChipTile extends BlockContainer {
|
||||
public ChipTile(int i, Material material) {
|
||||
super(i, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockRemoval(World world, int i, int j, int k) {
|
||||
super.onBlockRemoval(world, i, j, k);
|
||||
}
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer player){
|
||||
ChipTileEntity chip = (ChipTileEntity)world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isMultiplayerAndNotHost) {
|
||||
if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().itemID == WireMod.ToolProgrammer.itemID && chip.mode.equals("none")) {
|
||||
this.displayProgrammingGui(player, chip);
|
||||
return true;
|
||||
} else if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().itemID == WireMod.ToolWiring.itemID && !chip.mode.equals("none")) {
|
||||
ToolWiring tool = ((ToolWiring)player.inventory.getCurrentItem().getItem());
|
||||
this.displayWiringGui(player, chip, tool, x, y, z);
|
||||
return true;
|
||||
}
|
||||
if(chip instanceof RedstoneLinkTileEntity)
|
||||
System.out.println(((RedstoneLinkTileEntity)chip).inputs[0].wire.x);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void displayWiringGui(EntityPlayer player, ChipTileEntity chip, ToolWiring tool, int x, int y, int z) {
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayer)player).displayGuiWiring(tool, chip, x, y, z);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
((IEntityPlayer)player).displayGuiWiring(tool, chip, x, y, z);
|
||||
}
|
||||
|
||||
public static void displayProgrammingGui(EntityPlayer player, ChipTileEntity chip){
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayer)player).displayGuiProgrammer(chip);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
((IEntityPlayer)player).displayGuiProgrammer(chip);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new ChipTileEntity();
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package net.brokenmoon.afloydwiremod.tile;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.WireMod;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.RedstoneLinkTileEntity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RedstoneLinkTile extends ChipTile {
|
||||
|
||||
public RedstoneLinkTile(int i, Material material, boolean isActive) {
|
||||
super(i, material);
|
||||
this.isActive = isActive;
|
||||
this.setTickOnLoad(true);
|
||||
}
|
||||
boolean isActive;
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
public static void updateLinkBlockState(boolean flag, World world, int x, int y, int z) {
|
||||
if (flag) {
|
||||
world.setBlockAndMetadataWithNotify(x, y, z, WireMod.LinkTileActive.blockID, 1);
|
||||
System.out.println("activating");
|
||||
}
|
||||
if (!flag) {
|
||||
world.setBlockAndMetadataWithNotify(x, y, z, WireMod.LinkTileInactive.blockID, 1);
|
||||
System.out.println("deactivating");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
if(world.getBlockMetadata(x, y, z) == 0){
|
||||
world.setBlockTileEntity(x, y, z, new RedstoneLinkTileEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockRemoval(World world, int x, int y, int z) {
|
||||
if(world.getBlockTileEntity(x, y, z) != null && !((RedstoneLinkTileEntity)world.getBlockTileEntity(x, y, z)).shouldnotremove)
|
||||
super.onBlockRemoval(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int i, int j, int k, Random random) {
|
||||
RedstoneLinkTileEntity link = (RedstoneLinkTileEntity)world.getBlockTileEntity(i, j, k);
|
||||
if (world.isBlockGettingPowered(i, j, k)) {
|
||||
link.outputs[0].floatvalue = 1.0f;
|
||||
} else {
|
||||
link.outputs[0].floatvalue = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l) {
|
||||
return this.isPoweringTo(world, i, j, k, l);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new RedstoneLinkTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
|
||||
world.scheduleBlockUpdate(i, j, k, this.blockID, this.tickRate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int i, Random random) {
|
||||
return WireMod.LinkTileInactive.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package net.brokenmoon.afloydwiremod.tileentity;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.IWireConnectable;
|
||||
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
||||
import net.brokenmoon.afloydwiremod.gui.WiringButton;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChipTileEntity extends TileEntity implements IWireConnectable {
|
||||
|
||||
public WiringButton[] inputs = null;
|
||||
public WiringButton[] outputs = null;
|
||||
public String mode = "none";
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
updateIO();
|
||||
switch(mode){
|
||||
case "count":
|
||||
doIncrement();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldIncrement = true;
|
||||
public void doIncrement(){
|
||||
if(this.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;
|
||||
System.out.println("Incrementing to " + this.outputs[0].floatvalue);
|
||||
} else if(this.inputs[1].floatvalue == 0.0 && !shouldIncrement){
|
||||
shouldIncrement = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.mode = nbttagcompound.getString("mode");
|
||||
if(nbttagcompound.getBoolean("inputExists")){
|
||||
this.inputs = new WiringButton[nbttagcompound.getInteger("inputLength")];
|
||||
NBTTagList nbttaglistInputs = nbttagcompound.getTagList("Inputs");
|
||||
for (int i = 0; i < nbttaglistInputs.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglistInputs.tagAt(i);
|
||||
this.inputs[i] = new WiringButton();
|
||||
this.inputs[i].readFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
if(nbttagcompound.getBoolean("outputExists")){
|
||||
this.outputs = new WiringButton[nbttagcompound.getInteger("outputLength")];
|
||||
NBTTagList nbttaglistOutputs = nbttagcompound.getTagList("Outputs");
|
||||
for (int i = 0; i < nbttaglistOutputs.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglistOutputs.tagAt(i);
|
||||
this.outputs[i] = new WiringButton();
|
||||
this.outputs[i].readFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setString("mode", mode);
|
||||
if(inputs != null){
|
||||
nbttagcompound.setBoolean("inputExists", true);
|
||||
nbttagcompound.setInteger("inputLength", inputs.length);
|
||||
NBTTagList nbttaglistInputs = new NBTTagList();
|
||||
for(int i = 0; i < this.inputs.length; ++i){
|
||||
NBTTagCompound nbttagInput = new NBTTagCompound();
|
||||
this.inputs[i].writeToNBT(nbttagInput);
|
||||
nbttaglistInputs.setTag(nbttagInput);
|
||||
}
|
||||
nbttagcompound.setTag("Inputs", nbttaglistInputs);
|
||||
} else {
|
||||
nbttagcompound.setBoolean("inputExists", false);
|
||||
}
|
||||
if(outputs != null){
|
||||
nbttagcompound.setBoolean("outputExists", true);
|
||||
nbttagcompound.setInteger("outputLength", outputs.length);
|
||||
NBTTagList nbttaglistOutputs = new NBTTagList();
|
||||
for(int i = 0; i < this.outputs.length; ++i){
|
||||
NBTTagCompound nbttagOutput = new NBTTagCompound();
|
||||
this.outputs[i].writeToNBT(nbttagOutput);
|
||||
nbttaglistOutputs.setTag(nbttagOutput);
|
||||
}
|
||||
nbttagcompound.setTag("Outputs", nbttaglistOutputs);
|
||||
} else {
|
||||
nbttagcompound.setBoolean("outputExists", false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMode(String string){
|
||||
if(mode.equals("none")) {
|
||||
if(string.equals("constant")) {
|
||||
System.out.println(string);
|
||||
mode = string;
|
||||
this.inputs = new WiringButton[0];
|
||||
this.outputs = new WiringButton[1];
|
||||
} else if(string.equals("count")){
|
||||
System.out.println(string);
|
||||
mode = string;
|
||||
this.inputs = new WiringButton[3];
|
||||
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, 200, "Clock", 1);
|
||||
this.inputs[2] = new WiringButton(214, 180, "Reset", 2);
|
||||
System.out.println("ae");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateIO(){
|
||||
if(inputs != null) {
|
||||
for (int i = 0; i < inputs.length; ++i) {
|
||||
if (inputs[i].wire != null && inputs[i].wire.thisslot > -1) {
|
||||
WireConnection wire = inputs[i].wire;
|
||||
ChipTileEntity otherChip = (ChipTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
|
||||
if(otherChip == null) break;
|
||||
if(otherChip.outputs == null) break;
|
||||
if(inputs[i].floatvalue != otherChip.outputs[wire.thatslot].floatvalue) {
|
||||
inputs[i].floatvalue = otherChip.outputs[wire.thatslot].floatvalue;
|
||||
}
|
||||
if(!inputs[i].stringvalue.equals(otherChip.outputs[wire.thatslot].stringvalue)) {
|
||||
inputs[i].stringvalue = otherChip.outputs[wire.thatslot].stringvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.brokenmoon.afloydwiremod.tileentity;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.WireMod;
|
||||
import net.brokenmoon.afloydwiremod.api.IWireConnectable;
|
||||
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
||||
import net.brokenmoon.afloydwiremod.gui.WiringButton;
|
||||
import net.brokenmoon.afloydwiremod.tile.RedstoneLinkTile;
|
||||
import net.minecraft.src.BlockSensor;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class RedstoneLinkTileEntity extends ChipTileEntity {
|
||||
|
||||
public boolean isActive = false;
|
||||
public boolean shouldnotremove = false;
|
||||
public RedstoneLinkTileEntity(){
|
||||
super();
|
||||
this.mode = "rslink";
|
||||
inputs = new WiringButton[1];
|
||||
outputs = new WiringButton[1];
|
||||
outputs[0] = new WiringButton(214, 240, "Output", 0);
|
||||
inputs[0] = new WiringButton(214, 220, "Input", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.isActive = nbttagcompound.getBoolean("activity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setBoolean("activity", this.isActive);
|
||||
}
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
updateIO();
|
||||
if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){
|
||||
this.shouldnotremove = true;
|
||||
RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.shouldnotremove = false;
|
||||
this.isActive = true;
|
||||
} else if(inputs[0].floatvalue == 0 && this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileActive.blockID){
|
||||
this.shouldnotremove = true;
|
||||
RedstoneLinkTile.updateLinkBlockState(false, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.shouldnotremove = false;
|
||||
this.isActive = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package turniplabs.examplemod;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class ExampleMod implements ModInitializer {
|
||||
public static final String MOD_ID = "examplemod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("ExampleMod initialized.");
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "turniplabs.examplemod.mixin",
|
||||
"package": "net.brokenmoon.afloydwiremod.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinTileEntity",
|
||||
"MixinEntityPlayerSP"
|
||||
],
|
||||
"client": [
|
||||
],
|
Binary file not shown.
After Width: | Height: | Size: 579 B |
Binary file not shown.
After Width: | Height: | Size: 579 B |
@ -0,0 +1,4 @@
|
||||
item.afloydwiremod.toolProgrammer.name=Programming Tool
|
||||
item.afloydwiremod.toolProgrammer.disc=Used to program chips.
|
||||
tile.afloydwiremod.chipTile.name=Chip
|
||||
tile.afloydwiremod.chipTile.disc=Used to preform mathematical calculations.
|
Loading…
Reference in New Issue