aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2019-10-01 19:35:59 +0200
committerTec <daniel112092@gmail.com>2019-10-01 19:35:59 +0200
commit33d8a16d3143b43edb174a53ca94f1501abc229e (patch)
treee4c908ae9286e01de0817e03cb5a7b73af537f84 /src/main/java
parentdcb3b15eb849054ff8809fb78e67439efe7a6c02 (diff)
parent3bb13de2fcff5e2c142f424204d74eefbc581eeb (diff)
downloadGT5-Unofficial-33d8a16d3143b43edb174a53ca94f1501abc229e.tar.gz
GT5-Unofficial-33d8a16d3143b43edb174a53ca94f1501abc229e.tar.bz2
GT5-Unofficial-33d8a16d3143b43edb174a53ca94f1501abc229e.zip
Merge branch 'decayGen' into BassAddons
# Conflicts: # src/main/java/com/github/technus/tectech/thing/CustomItemList.java
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/technus/tectech/Converter.java59
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java267
-rw-r--r--src/main/java/com/github/technus/tectech/loader/MainLoader.java8
-rw-r--r--src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java16
-rw-r--r--src/main/java/com/github/technus/tectech/loader/gui/ModGuiHandler.java4
-rw-r--r--src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java36
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java248
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java38
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java57
-rw-r--r--src/main/java/com/github/technus/tectech/thing/CustomItemList.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java3
-rw-r--r--src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java3
-rw-r--r--src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java3
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java215
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java8
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java3
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/gui/ProgrammerScreen.java13
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java187
26 files changed, 1133 insertions, 63 deletions
diff --git a/src/main/java/com/github/technus/tectech/Converter.java b/src/main/java/com/github/technus/tectech/Converter.java
new file mode 100644
index 0000000000..5d1f5c802e
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/Converter.java
@@ -0,0 +1,59 @@
+package com.github.technus.tectech;
+
+import java.io.*;
+
+public final class Converter {
+ private Converter() {}
+
+ public static void writeInts(int [] array,ByteArrayOutputStream byteArrayOutputStream) {
+ try {
+ DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
+ for (int i = 0; i < array.length; i++) {
+ dataOutputStream.writeInt(array[i]);
+ }
+ dataOutputStream.flush();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void readInts(ByteArrayInputStream byteArrayInputStream,int[] array) {
+ try {
+ DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
+ for (int i = 0; i < array.length; i++) {
+ array[i] = dataInputStream.readInt();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static byte[] writeInts(int[] array) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(array.length * 4);
+ DataOutputStream dos = new DataOutputStream(bos);
+ for (int i = 0; i < array.length; i++) {
+ dos.writeInt(array[i]);
+ }
+
+ return bos.toByteArray();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static int[] readInts(byte[] array) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(array);
+ DataInputStream dataInputStream = new DataInputStream(bis);
+ int size = array.length / Integer.BYTES;
+ int[] res = new int[size];
+ for (int i = 0; i < size; i++) {
+ res[i] = dataInputStream.readInt();
+ }
+ return res;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java
new file mode 100644
index 0000000000..fcbb65d609
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java
@@ -0,0 +1,267 @@
+package com.github.technus.tectech.compatibility.openComputers;
+
+import com.github.technus.avrClone.AvrCore;
+import com.github.technus.avrClone.instructions.ExecutionEvent;
+import com.github.technus.avrClone.instructions.InstructionRegistry;
+import com.github.technus.avrClone.instructions.exceptions.DebugEvent;
+import com.github.technus.avrClone.instructions.exceptions.DelayEvent;
+import com.github.technus.avrClone.memory.EepromMemory;
+import com.github.technus.avrClone.memory.RemovableMemory;
+import com.github.technus.avrClone.memory.program.ProgramMemory;
+import com.github.technus.tectech.Converter;
+import com.github.technus.tectech.TecTech;
+import li.cil.oc.Settings;
+import li.cil.oc.api.Driver;
+import li.cil.oc.api.driver.Item;
+import li.cil.oc.api.driver.item.Memory;
+import li.cil.oc.api.machine.Architecture;
+import li.cil.oc.api.machine.ExecutionResult;
+import li.cil.oc.api.machine.Machine;
+import li.cil.oc.api.machine.Signal;
+import li.cil.oc.common.SaveHandler;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import org.apache.commons.io.IOUtils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+@Architecture.Name("AVR 32Bit Clone")
+@Architecture.NoMemoryRequirements
+public class AvrArchitecture implements Architecture {
+ private final Machine machine;
+ private AvrCore core;
+ private boolean debugRun;
+ private int delay;
+ private int[] tempData;
+ private int memSize;
+
+ public AvrArchitecture(Machine machine) {
+ this.machine = machine;
+ }
+
+ @Override
+ public boolean isInitialized() {
+ return core!=null && core.checkValid();
+ }
+
+ @Override
+ public boolean recomputeMemory(Iterable<ItemStack> components) {
+ computeMemory(components);
+ return true;
+ }
+
+ private void computeMemory(Iterable<ItemStack> components) {
+ int memory = 0;
+ for (ItemStack component : components) {
+ Item driver = Driver.driverFor(component);
+ if (driver instanceof Memory) {
+ Memory memoryDriver = (Memory) driver;
+ memory += memoryDriver.amount(component) * 256;//in integers
+ }// else if (driver instanceof DriverEEPROM$) {
+
+ //}
+ }
+ memory = Math.min(Math.max(memory, 0), Settings.get().maxTotalRam());
+ if(memory!=memSize){
+
+ }
+ }
+
+ @Override
+ public boolean initialize() {
+ core=new AvrCore();
+
+ computeMemory(this.machine.host().internalComponents());
+
+ if(isInitialized()) {
+ machine.beep(".");
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void close() {
+ core=null;
+ tempData=null;
+ delay=0;
+ }
+
+ @Override
+ public void runSynchronized() {
+ core.cycle();
+ }
+
+ @Override
+ public ExecutionResult runThreaded(boolean isSynchronizedReturn) {
+ if (core.awoken) {
+ delay=0;
+ for (int load=0; load < 512;) {
+ load+=core.getInstruction().getCost(core);
+ ExecutionEvent executionEvent = core.cpuCycleForce();
+ if (executionEvent != null) {
+ if (executionEvent.throwable instanceof DelayEvent) {
+ delay = executionEvent.data[0];
+ break;
+ } else if (executionEvent.throwable instanceof DebugEvent) {
+ if(debugRun) {
+ //aBaseMetaTileEntity.setActive(false);
+ break;
+ }
+ }
+ }
+ }
+ }else if(delay>0){
+ delay--;
+ if(delay==0){
+ core.awoken=true;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void onSignal() {
+ Signal signal=machine.popSignal();
+
+ core.interruptsHandle();
+ }
+
+ @Override
+ public void onConnect() {
+ //init network components, in case init was called from load logic (pre first tick?)
+ }
+
+ @Override
+ public void load(NBTTagCompound avr) {
+ debugRun = avr.getBoolean("debugRun");
+ delay = avr.getInteger("delay");
+ core.active = avr.getBoolean("active");
+ core.awoken = (avr.getBoolean("awoken"));
+ core.programCounter = avr.getInteger("programCounter");
+ InstructionRegistry registry =
+ InstructionRegistry.REGISTRIES.
+ get(avr.getString("instructionRegistry"));
+ if (registry != null) {
+ byte[] instructions = SaveHandler.load(avr, this.machine.node().address() + "_instructionsMemory");
+ byte[] param0 = SaveHandler.load(avr, this.machine.node().address() + "_param0Memory");
+ byte[] param1 = SaveHandler.load(avr, this.machine.node().address() + "_param1Memory");
+ if (instructions != null && param0 != null && param1 != null &&
+ instructions.length > 0 && param0.length > 0 && param1.length > 0) {
+ int[] instr = null, par0 = null, par1 = null;
+ try {
+ GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(instructions));
+ instr = Converter.readInts(IOUtils.toByteArray(gzis));
+ IOUtils.closeQuietly(gzis);
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to decompress instructions memory from disk.");
+ e.printStackTrace();
+ }
+ try {
+ GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(param0));
+ par0 = Converter.readInts(IOUtils.toByteArray(gzis));
+ IOUtils.closeQuietly(gzis);
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to decompress param0 memory from disk.");
+ e.printStackTrace();
+ }
+ try {
+ GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(param1));
+ par1 = Converter.readInts(IOUtils.toByteArray(gzis));
+ IOUtils.closeQuietly(gzis);
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to decompress param1 memory from disk.");
+ e.printStackTrace();
+ }
+ if (instr != null && par0 != null && par1 != null &&
+ instr.length==par0.length && instr.length==par1.length) {
+ core.setProgramMemory(new ProgramMemory(
+ registry,
+ avr.getBoolean("immersive"),
+ instr,
+ par0,
+ par1));
+ }
+ }
+ }
+ if(avr.hasKey("eepromSize")){
+ core.restoreEepromDefinition(EepromMemory.make(avr.getInteger("eepromSize")));
+ }
+ byte[] data = SaveHandler.load(avr, this.machine.node().address() + "_dataMemory");
+ if(data!=null && data.length > 0) {
+ try {
+ GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(data));
+ tempData = Converter.readInts(IOUtils.toByteArray(gzis));
+ IOUtils.closeQuietly(gzis);
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to decompress data memory from disk.");
+ e.printStackTrace();
+ }
+ }
+ core.checkValid();
+ }
+
+ @Override
+ public void save(NBTTagCompound avr) {
+ avr.setBoolean("debugRun",debugRun);
+ avr.setInteger("delay",delay);
+ avr.setBoolean("active",core.active);
+ avr.setBoolean("awoken",core.awoken);
+ avr.setInteger("programCounter",core.programCounter);
+ ProgramMemory programMemory=core.getProgramMemory();
+ if(programMemory!=null){
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(Converter.writeInts(programMemory.instructions));
+ gzos.close();
+ SaveHandler.scheduleSave(machine.host(), avr, machine.node().address() + "_instructionsMemory", baos.toByteArray());
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to compress instructions memory to disk");
+ e.printStackTrace();
+ }
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(Converter.writeInts(programMemory.param0));
+ gzos.close();
+ SaveHandler.scheduleSave(machine.host(), avr, machine.node().address() + "_param0Memory", baos.toByteArray());
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to compress param0 memory to disk");
+ e.printStackTrace();
+ }
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(Converter.writeInts(programMemory.param1));
+ gzos.close();
+ SaveHandler.scheduleSave(machine.host(), avr, machine.node().address() + "_param1Memory", baos.toByteArray());
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to compress param1 memory to disk");
+ e.printStackTrace();
+ }
+ avr.setBoolean("immersive",programMemory.immersiveOperands);
+ avr.setString("instructionRegistry",programMemory.registry.toString());
+ }
+ RemovableMemory<EepromMemory> eeprom=core.getEepromMemory();
+ if(eeprom!=null){
+ avr.setInteger("eepromSize",eeprom.getDefinition().getSize());
+ }
+ if(core.dataMemory!=null) {
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(Converter.writeInts(core.dataMemory));
+ gzos.close();
+ SaveHandler.scheduleSave(machine.host(), avr, machine.node().address() + "_dataMemory", baos.toByteArray());
+ } catch (IOException e) {
+ TecTech.LOGGER.error("Failed to compress data memory to disk");
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java
index 1c3ec67972..d7d23d7461 100644
--- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java
+++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java
@@ -61,6 +61,7 @@ public final class MainLoader {
}
public static void preLoad(){
+ creativeTabTecTech =new CreativeTabTecTech("TecTech");
//set expanded texture arrays for tiers
try {
@@ -120,7 +121,7 @@ public final class MainLoader {
}
public static void postLoad() {
- ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 6);
+ ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 5);
progressBarPostLoad.step("Dreamcraft Compatibility");
if(Loader.isModLoaded(Reference.DREAMCRAFT)){
@@ -146,13 +147,8 @@ public final class MainLoader {
progressBarPostLoad.step("Recipes");
new RecipeLoader().run();
-
TecTech.LOGGER.info("Recipe Init Done");
- progressBarPostLoad.step("Creative Tab");
- creativeTabTecTech =new CreativeTabTecTech("TecTech");
- TecTech.LOGGER.info("CreativeTab initiation complete");
-
progressBarPostLoad.step("Register Extra Hazmat Suits");
registerExtraHazmats();
TecTech.LOGGER.info("Hazmat additions done");
diff --git a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java
index 295e1aeb7d..d360162fb6 100644
--- a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java
+++ b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java
@@ -1,12 +1,7 @@
package com.github.technus.tectech.loader.gui;
import com.github.technus.tectech.thing.CustomItemList;
-import com.github.technus.tectech.thing.block.QuantumGlassBlock;
-import com.github.technus.tectech.thing.casing.TT_Container_Casings;
-import com.github.technus.tectech.thing.item.ConstructableTriggerItem;
import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM;
-import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM;
-import com.github.technus.tectech.thing.item.ParametrizerMemoryCard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
@@ -20,7 +15,6 @@ public class CreativeTabTecTech extends CreativeTabs {
public CreativeTabTecTech(String name) {
super(name);
- registerThingsInTabs();
}
@SideOnly(Side.CLIENT)
@@ -38,14 +32,4 @@ public class CreativeTabTecTech extends CreativeTabs {
}
super.displayAllReleventItems(stuffToShow);
}
-
- private static void registerThingsInTabs() {
- QuantumGlassBlock.INSTANCE.setCreativeTab(creativeTabTecTech);
- TT_Container_Casings.sBlockCasingsTT.setCreativeTab(creativeTabTecTech);
- TT_Container_Casings.sHintCasingsTT.setCreativeTab(creativeTabTecTech);
- DebugElementalInstanceContainer_EM.INSTANCE.setCreativeTab(creativeTabTecTech);
- ConstructableTriggerItem.INSTANCE.setCreativeTab(creativeTabTecTech);
- ParametrizerMemoryCard.INSTANCE.setCreativeTab(creativeTabTecTech);
- ElementalDefinitionScanStorage_EM.INSTANCE.setCreativeTab(creativeTabTecTech);
- }
}
diff --git a/src/main/java/com/github/technus/tectech/loader/gui/ModGuiHandler.java b/src/main/java/com/github/technus/tectech/loader/gui/ModGuiHandler.java
index 44585d1b91..e555437104 100644
--- a/src/main/java/com/github/technus/tectech/loader/gui/ModGuiHandler.java
+++ b/src/main/java/com/github/technus/tectech/loader/gui/ModGuiHandler.java
@@ -1,5 +1,6 @@
package com.github.technus.tectech.loader.gui;
+import com.github.technus.tectech.thing.item.gui.ProgrammerScreen;
import com.github.technus.tectech.thing.item.gui.ScanDisplayScreen;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
@@ -10,6 +11,7 @@ import net.minecraft.world.World;
*/
public class ModGuiHandler implements IGuiHandler {
public static final int SCAN_DISPLAY_SCREEN_ID =0;
+ public static final int PROGRAMMER_DISPLAY_SCREEN_ID =1;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
@@ -20,6 +22,8 @@ public class ModGuiHandler implements IGuiHandler {
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == SCAN_DISPLAY_SCREEN_ID) {
return new ScanDisplayScreen(player);
+ }else if(ID==PROGRAMMER_DISPLAY_SCREEN_ID){
+ return new ProgrammerScreen(player);
}
return null;
}
diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java
index 856ba8dd13..0f127f9f6f 100644
--- a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java
+++ b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java
@@ -90,6 +90,42 @@ public class MachineLoader implements Runnable {
eM_muffler_UXV.set(new GT_MetaTileEntity_Hatch_OverflowElemental(
15025, "hatch.emmuffler.tier.13", "UXV Overflow Output Hatch", 13, 125e12f).getStackForm(1L));
+
+ // ===================================================================================================
+ // Microcontrollers
+ // ===================================================================================================
+
+ eM_avr_HV.set(new GT_MetaTileEntity_MicroController(
+ 15030, "machine.avr.tier.08", "HV AVR Micro-controller", 3).getStackForm(1L));
+
+ eM_avr_EV.set(new GT_MetaTileEntity_MicroController(
+ 15031, "machine.avr.tier.08", "EV AVR Micro-controller", 4).getStackForm(1L));
+
+ eM_avr_IV.set(new GT_MetaTileEntity_MicroController(
+ 15032, "machine.avr.tier.08", "IV AVR Micro-controller", 5).getStackForm(1L));
+
+ eM_avr_LuV.set(new GT_MetaTileEntity_MicroController(
+ 15033, "machine.avr.tier.08", "LuV AVR Micro-controller", 6).getStackForm(1L));
+
+ eM_avr_ZPM.set(new GT_MetaTileEntity_MicroController(
+ 15034, "machine.avr.tier.08", "ZPM AVR Micro-controller", 7).getStackForm(1L));
+
+ eM_avr_UV.set(new GT_MetaTileEntity_MicroController(
+ 15035, "machine.avr.tier.08", "UV AVR Micro-controller", 8).getStackForm(1L));
+
+ eM_avr_UHV.set(new GT_MetaTileEntity_MicroController(
+ 15036, "machine.avr.tier.09", "UHV AVR Micro-controller", 9).getStackForm(1L));
+
+ eM_avr_UEV.set(new GT_MetaTileEntity_MicroController(
+ 15037, "machine.avr.tier.10", "UEV AVR Micro-controller", 10).getStackForm(1L));
+
+ eM_avr_UIV.set(new GT_MetaTileEntity_MicroController(
+ 15038, "machine.avr.tier.11", "UIV AVR Micro-controller", 11).getStackForm(1L));
+
+ eM_avr_UMV.set(new GT_MetaTileEntity_MicroController(
+ 15039, "machine.avr.tier.12", "UMV AVR Micro-controller", 12).getStackForm(1L));
+
+
// ===================================================================================================
// Multi AMP Power INPUTS
// ===================================================================================================
diff --git a/src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java b/src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java
new file mode 100644
index 0000000000..fd351631f3
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java
@@ -0,0 +1,248 @@
+package com.github.technus.tectech.mechanics.avr;
+
+import com.github.technus.avrClone.AvrCore;
+import com.github.technus.avrClone.registerPackages.*;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public class SidedRedstone extends RegisterPackageSync<IGregTechTileEntity> {
+ public static final RSINT RSINT =new RSINT();
+
+ public SidedRedstone(int offset) {
+ super(offset, Register.values().length);
+ addRegisters(Register.values());
+ addBits(RegisterBitsPCMSK.values());
+ addBits(RegisterBitsPCFR.values());
+ addBits(RegisterBitsPCINT.values());
+ addBits(RegisterBitsPNEW.values());
+ addBits(RegisterBitsPOLD.values());
+ addInterrupts(RSINT);
+ }
+
+ @Override
+ public void preSync(AvrCore core,IGregTechTileEntity iGregTechTileEntity) {
+ int addr=this.getOffset();
+ int sides=0;
+ for(byte i=0;i<6;i++){
+ int val=iGregTechTileEntity.getInternalInputRedstoneSignal(i);
+ sides|=(val > 0?1:0)<<i;
+ core.setDataValue(addr++,iGregTechTileEntity.getInputRedstoneSignal(i));
+ core.setDataValue(addr++,val);
+ addr++;
+ }
+ int sidesOld = core.getDataValue(Register.PNEW.getAddress(this));
+ core.setDataValue(Register.POLD.getAddress(this),sidesOld);
+ core.setDataValue(Register.PNEW.getAddress(this),sides);
+
+ if(core.getInterruptEnable()) {
+ int pcint=core.getDataValue(Register.PCINT.getAddress(this));
+ int changesDetected=0;
+ switch (pcint&0b1100){//PCISC1 PCISC0
+ case 0b0000://low
+ changesDetected= ~sides & core.getDataValue(Register.PCMSK.getAddress(this));
+ break;
+ case 0b0100://any
+ changesDetected= (sides ^ sidesOld) & core.getDataValue(Register.PCMSK.getAddress(this));
+ break;
+ case 0b1000://falling
+ changesDetected= ~sides & sidesOld & core.getDataValue(Register.PCMSK.getAddress(this));
+ break;
+ case 0b1100://rising
+ changesDetected= sides & ~sidesOld & core.getDataValue(Register.PCMSK.getAddress(this));
+ break;
+ }
+
+ core.setDataValue(Register.PCFR.getAddress(this),
+ core.getDataValue(Register.PCFR.getAddress(this) | changesDetected));
+
+ if (changesDetected > 0) {
+ if (core.getDataBitsOr(Register.PCINT.getAddress(this), RegisterBitsPCINT.PCEN.mask)) {
+ core.setDataBits(Register.PCINT.getAddress(this), RegisterBitsPCINT.PCIF.mask);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void postSync(AvrCore core,IGregTechTileEntity iGregTechTileEntity) {
+ int addr=this.getOffset();
+ for(byte i=0;i<6;i++){
+ iGregTechTileEntity.setOutputRedstoneSignal(i,(byte)core.getDataValue(addr));//allows edge detection hack?
+ addr+=3;
+ }
+ }
+
+ public enum Register implements IRegister<SidedRedstone>{
+ PIN0,PINT0,PORT0,
+ PIN1,PINT1,PORT1,
+ PIN2,PINT2,PORT2,
+ PIN3,PINT3,PORT3,
+ PIN4,PINT4,PORT4,
+ PIN5,PINT5,PORT5,
+ PCMSK,PCFR,PCINT,PNEW,POLD;
+
+ public final int relativeOffset;
+
+ Register(){
+ this.relativeOffset =ordinal();
+ }
+
+ @Override
+ public int getAddress(SidedRedstone registerPackage) {
+ return registerPackage.getOffset()+relativeOffset;
+ }
+ }
+
+ public enum RegisterBitsPCMSK implements IRegisterBit<SidedRedstone>{
+ PCINT0,PCINT1,PCINT2,PCINT3,PCINT4,PCINT5;
+
+ private final int bit,mask;
+
+ RegisterBitsPCMSK(){
+ bit=ordinal();
+ mask=1<<bit;
+ }
+
+ @Override
+ public int getBitPosition() {
+ return bit;
+ }
+
+ @Override
+ public int getBitMask() {
+ return mask;
+ }
+
+ @Override
+ public int getOffset(SidedRedstone registerPackage) {
+ return 18;
+ }
+ }
+
+ public enum RegisterBitsPCFR implements IRegisterBit<SidedRedstone>{
+ PCF0,PCF1,PCF2,PCF3,PCF4,PCF5;
+
+ private final int bit,mask;
+
+ RegisterBitsPCFR(){
+ bit=ordinal();
+ mask=1<<bit;
+ }
+
+ @Override
+ public int getBitPosition() {
+ return bit;
+ }
+
+ @Override
+ public int getBitMask() {
+ return mask;
+ }
+
+ @Override
+ public int getOffset(SidedRedstone registerPackage) {
+ return 19;
+ }
+ }
+
+ public enum RegisterBitsPCINT implements IRegisterBit<SidedRedstone>{
+ PCIF,PCEN,PCISC0,PCISC1;
+
+ private final int bit,mask;
+
+ RegisterBitsPCINT(){
+ bit=ordinal();
+ mask=1<<bit;
+ }
+
+ @Override
+ public int getBitPosition() {
+ return bit;
+ }
+
+ @Override
+ public int getBitMask() {
+ return mask;
+ }
+
+ @Override
+ public int getOffset(SidedRedstone registerPackage) {
+ return 20;
+ }
+ }
+
+ public enum RegisterBitsPNEW implements IRegisterBit<SidedRedstone>{
+ PNEW0,PNEW1,PNEW2,PNEW3,PNEW4,PNEW5;
+
+ private final int bit,mask;
+
+ RegisterBitsPNEW(){
+ bit=ordinal();
+ mask=1<<bit;
+ }
+
+ @Override
+ public int getBitPosition() {
+ return bit;
+ }
+
+ @Override
+ public int getBitMask() {
+ return mask;
+ }
+
+ @Override
+ public int getOffset(SidedRedstone registerPackage) {
+ return 21;
+ }
+ }
+
+ public enum RegisterBitsPOLD implements IRegisterBit<SidedRedstone>{
+ POLD0,POLD1,POLD2,POLD3,POLD4,POLD5;
+
+ private final int bit,mask;
+
+ RegisterBitsPOLD(){
+ bit=ordinal();
+ mask=1<<bit;
+ }
+
+ @Override
+ public int getBitPosition() {
+ return bit;
+ }
+
+ @Override
+ public int getBitMask() {
+ return mask;
+ }
+
+ @Override
+ public int getOffset(SidedRedstone registerPackage) {
+ return 22;
+ }
+ }
+
+ public static class RSINT implements IInterrupt<SidedRedstone>{
+ @Override
+ public int getVector() {
+ return 1;
+ }
+
+ @Override
+ public boolean getTrigger(AvrCore core, SidedRedstone registerPackage) {
+ return (core.getDataValue(Register.PCINT.getAddress(registerPackage))&1)==1;
+ }
+
+ @Override
+ public void setTrigger(AvrCore core, SidedRedstone registerPackage, boolean value) {
+ int val=core.getDataValue(Register.PCINT.getAddress(registerPackage));
+ core.setDataValue(Register.PCINT.getAddress(registerPackage),
+ value?val|RegisterBitsPCINT.PCIF.mask:val&~RegisterBitsPCINT.PCIF.mask);
+ }
+
+ @Override
+ public String name() {
+ return "RSINT";
+ }
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java
index 63642d6dbd..24033ba945 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java
@@ -18,7 +18,7 @@ import java.util.Map;
import static com.github.technus.tectech.Util.areBitsSet;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__;
-import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.stacksRegistered;
+import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED;
import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*;
/**
@@ -68,7 +68,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition {
if (bindsBO.put(ID, this) != null) {
Minecraft.getMinecraft().crashed(new CrashReport("Primitive definition", new tElementalException("Duplicate ID")));
}
- stacksRegistered.add(this);
+ STACKS_REGISTERED.add(this);
}
//
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java
index d0c0bf04aa..c23894d6b1 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java
@@ -11,7 +11,7 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.HashMap;
-import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.stacksRegistered;
+import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED;
/**
* Created by Tec on 26.05.2017.
@@ -41,22 +41,22 @@ public class bTransformationInfo {
public void addFluid(iHasElementalDefinition em, FluidStack fluidStack){
fluidQuantization.put(fluidStack.getFluidID(),new aFluidQuantizationInfo(fluidStack,em));
fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidStack));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addFluid(iHasElementalDefinition em ,int fluidID,int fluidAmount) {
fluidQuantization.put(fluidID,new aFluidQuantizationInfo(fluidID,fluidAmount,em));
fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidID,fluidAmount));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addFluid(iHasElementalDefinition em, Fluid fluid, int fluidAmount){
fluidQuantization.put(fluid.getID(),new aFluidQuantizationInfo(fluid,fluidAmount,em));
fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluid,fluidAmount));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
private void addItemQuantization(aItemQuantizationInfo aIQI){
@@ -66,42 +66,42 @@ public class bTransformationInfo {
public void addItem(iHasElementalDefinition em, ItemStack itemStack, boolean skipNBT){
addItemQuantization(new aItemQuantizationInfo(itemStack,skipNBT,em));
itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,itemStack));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addItem(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){
addItemQuantization(new aItemQuantizationInfo(prefix,material,amount,skipNBT,em));
itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,prefix,material,amount));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addOredict(iHasElementalDefinition em, int id, int qty){
oredictQuantization.put(id,new aOredictQuantizationInfo(id,qty,em));
oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,id,qty));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addOredict(iHasElementalDefinition em, String name, int qty){
oredictQuantization.put(OreDictionary.getOreID(name),new aOredictQuantizationInfo(name,qty,em));
oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,name,qty));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int qty){
oredictQuantization.put(OreDictionary.getOreID(prefix.name() + material.mName),new aOredictQuantizationInfo(prefix,material,qty,em));
oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,material,qty));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, String materialName, int qty){
oredictQuantization.put(OreDictionary.getOreID(prefix.name() + materialName),new aOredictQuantizationInfo(prefix,materialName,qty,em));
oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,materialName,qty));
- stacksRegistered.add(em.getDefinition());
- stacksRegistered.add(em.getDefinition().getAnti());
+ STACKS_REGISTERED.add(em.getDefinition());
+ STACKS_REGISTERED.add(em.getDefinition().getAnti());
}
}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java
index a1380526eb..404f116adf 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java
@@ -12,12 +12,16 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElem
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.*;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition;
+import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
@@ -34,6 +38,8 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi
private static final byte nbtType = (byte) 'h';
//Helpers
+ public static final Map<dHadronDefinition,String> SYMBOL_MAP =new HashMap<>();
+ public static final Map<dHadronDefinition,String> NAME_MAP =new HashMap<>();
public static dHadronDefinition hadron_p, hadron_n, hadron_p_, hadron_n_;
public static cElementalDefinitionStack hadron_p1, hadron_n1, hadron_p2, hadron_n2, hadron_p3, hadron_n3, hadron_p5;
private static float protonMass = 0F;
@@ -137,8 +143,13 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi
public String getName() {
StringBuilder name= new StringBuilder(getSimpleName());
name.append(':');
- for (cElementalDefinitionStack quark : quarkStacks.values()) {
- name.append(' ').append(quark.definition.getSymbol()).append(quark.amount);
+ String sym= NAME_MAP.get(this);
+ if(sym!=null){
+ name.append(' ').append(sym);
+ }else {
+ for (cElementalDefinitionStack quark : quarkStacks.values()) {
+ name.append(' ').append(quark.definition.getSymbol()).append(quark.amount);
+ }
}
return name.toString();
}
@@ -162,24 +173,34 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi
@Override
public String getSymbol() {
- StringBuilder symbol = new StringBuilder(8);
- for (cElementalDefinitionStack quark : quarkStacks.values()) {
- for (int i = 0; i < quark.amount; i++) {
- symbol.append(quark.definition.getSymbol());
+ String sym=SYMBOL_MAP.get(this);
+ if(sym!=null){
+ return sym;
+ }else {
+ StringBuilder symbol = new StringBuilder(8);
+ for (cElementalDefinitionStack quark : quarkStacks.values()) {
+ for (int i = 0; i < quark.amount; i++) {
+ symbol.append(quark.definition.getSymbol());
+ }
}
+ return symbol.toString();
}
- return symbol.toString();
}
@Override
public String getShortSymbol() {
- StringBuilder symbol = new StringBuilder(8);
- for (cElementalDefinitionStack quark : quarkStacks.values()) {
- for (int i = 0; i < quark.amount; i++) {
- symbol.append(quark.definition.getShortSymbol());
+ String sym=SYMBOL_MAP.get(this);
+ if(sym!=null){
+ return sym;
+ }else {
+ StringBuilder symbol = new StringBuilder(8);
+ for (cElementalDefinitionStack quark : quarkStacks.values()) {
+ for (int i = 0; i < quark.amount; i++) {
+ symbol.append(quark.definition.getShortSymbol());
+ }
}
+ return symbol.toString();
}
- return symbol.toString();
}
@Override
@@ -391,12 +412,24 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi
protonMass = hadron_p.mass;
//redefine the proton with proper lifetime (the lifetime is based on mass comparison)
hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1)));
+ SYMBOL_MAP.put(hadron_p,"p");
+ NAME_MAP.put(hadron_p,"Proton");
+ DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p);
hadron_p_ = (dHadronDefinition) hadron_p.getAnti();
+ SYMBOL_MAP.put(hadron_p_,"~p");
+ NAME_MAP.put(hadron_p_,"Anti Proton");
+ DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p_);
hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2)));
neutronMass = hadron_n.mass;
//redefine the neutron with proper lifetime (the lifetime is based on mass comparison)
hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2)));
+ SYMBOL_MAP.put(hadron_n, "n");
+ NAME_MAP.put(hadron_n, "Neutron");
+ DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n);
hadron_n_ = (dHadronDefinition) hadron_n.getAnti();
+ SYMBOL_MAP.put(hadron_n_,"~n");
+ NAME_MAP.put(hadron_n_,"Anti Neutron");
+ DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n_);
} catch (tElementalException e) {
if (DEBUG_MODE) {
e.printStackTrace();
diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
index c86dcee0b0..5265ad25c6 100644
--- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
+++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
@@ -92,6 +92,8 @@ public enum CustomItemList implements IItemContainer {
Machine_Multi_BHG,
hint_0, hint_1, hint_2, hint_3, hint_4, hint_5, hint_6, hint_7, hint_8, hint_9, hint_10, hint_11, hint_general, hint_air, hint_noAir, hint_error,
+ eM_avr_HV, eM_avr_EV, eM_avr_IV, eM_avr_LuV, eM_avr_ZPM, eM_avr_UV, eM_avr_UHV, eM_avr_UEV, eM_avr_UIV, eM_avr_UMV,
+
scanContainer, parametrizerMemory, teslaCapacitor, teslaCover, teslaComponent, teslaStaff,
Machine_TeslaCoil_1by1_LV, Machine_TeslaCoil_1by1_MV, Machine_TeslaCoil_1by1_HV, Machine_TeslaCoil_1by1_EV, Machine_TeslaCoil_1by1_IV,
@@ -255,4 +257,4 @@ public enum CustomItemList implements IItemContainer {
}
return this;
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java
index 1a08bdbeec..d34d12c754 100644
--- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java
+++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java
@@ -13,6 +13,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by danie_000 on 17.12.2016.
@@ -32,6 +33,7 @@ public final class QuantumGlassBlock extends BlockBase {
setLightOpacity(0);
setStepSound(Block.soundTypeMetal);
setBlockTextureName(MODID + ":blockQuantumGlass");
+ setCreativeTab(creativeTabTecTech);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java
index 78b0a2a6a9..bac2dfb9ac 100644
--- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java
+++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java
@@ -10,6 +10,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
import static com.github.technus.tectech.thing.metaTileEntity.Textures.*;
/**
@@ -21,6 +22,8 @@ public class GT_Block_CasingsNH
public GT_Block_CasingsNH() {
super(GT_Item_CasingsNH.class, "gt.blockcasingsNH", GT_Material_Casings.INSTANCE);
+ setCreativeTab(creativeTabTecTech);
+
for (byte b = 0; b < 16; b = (byte) (b + 1)) {
Textures.BlockIcons.casingTexturePages[8][b+64] = new GT_CopiedBlockTexture(this, 6, b);
/*IMPORTANT for block recoloring*/
diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java
index 639e68fef6..eb590ab2e2 100644
--- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java
+++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java
@@ -18,6 +18,7 @@ import net.minecraft.world.IBlockAccess;
import java.util.List;
import static com.github.technus.tectech.TecTech.tectechTexturePage1;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by danie_000 on 03.10.2016.
@@ -30,6 +31,8 @@ public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract {
public GT_Block_CasingsTT() {
super(GT_Item_CasingsTT.class, "gt.blockcasingsTT", GT_Material_Casings.INSTANCE);
+ setCreativeTab(creativeTabTecTech);
+
for (byte b = 0; b < 16; b = (byte) (b + 1)) {
Textures.BlockIcons.casingTexturePages[texturePage][b] = new GT_CopiedBlockTexture(this, 6, b);
/*IMPORTANT for block recoloring**/
diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java
index dc9e809b46..c65870eeb7 100644
--- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java
+++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java
@@ -16,6 +16,8 @@ import net.minecraft.world.IBlockAccess;
import java.util.List;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
+
/**
* Created by danie_000 on 03.10.2016.
*/
@@ -24,6 +26,7 @@ public class GT_Block_HintTT extends GT_Block_Casings_Abstract {
public GT_Block_HintTT() {
super(GT_Item_HintTT.class, "gt.blockhintTT", GT_Material_Casings.INSTANCE);
+ setCreativeTab(creativeTabTecTech);
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Hint 1 dot");//id is -1
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Hint 2 dots");
diff --git a/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java b/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java
new file mode 100644
index 0000000000..277c2de355
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java
@@ -0,0 +1,215 @@
+package com.github.technus.tectech.thing.item;
+
+import com.github.technus.avrClone.AvrCore;
+import com.github.technus.avrClone.instructions.InstructionRegistry;
+import com.github.technus.avrClone.memory.program.ProgramMemory;
+import com.github.technus.tectech.TecTech;
+import com.github.technus.tectech.loader.gui.ModGuiHandler;
+import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_MicroController;
+import cpw.mods.fml.common.Optional;
+import dan200.computercraft.api.filesystem.IMount;
+import dan200.computercraft.api.filesystem.IWritableMount;
+import dan200.computercraft.api.media.IMedia;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.FakePlayer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
+
+@Optional.InterfaceList(
+ {@Optional.Interface(iface="dan200.computercraft.api.media.IMedia",modid = "ComputerCraft"),
+ @Optional.Interface(iface="li.cil.oc.api.fs.FileSystem",modid="OpenComputers")})
+public class AvrProgrammer extends Item implements IMedia {
+ public static AvrProgrammer INSTANCE=new AvrProgrammer();
+
+ private AvrProgrammer(){
+ setMaxStackSize(1);
+ setHasSubtypes(true);
+ setUnlocalizedName("em.programmer");
+ setTextureName(MODID + ":itemProgrammer");
+ setCreativeTab(creativeTabTecTech);
+ }
+
+ @Override
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if(tTileEntity==null || aPlayer instanceof FakePlayer) {
+ return aPlayer instanceof EntityPlayerMP;
+ }
+ if (aPlayer instanceof EntityPlayerMP) {
+ if (tTileEntity instanceof IGregTechTileEntity) {
+ IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
+ if (metaTE instanceof GT_MetaTileEntity_MicroController) {
+ if (aPlayer.isSneaking()) {
+ if(stack.stackTagCompound.hasKey("pgm")) {
+ NBTTagCompound pgm = stack.stackTagCompound.getCompoundTag("pgm");
+ if (pgm.hasKey("instructions")) {
+ AvrCore core = ((GT_MetaTileEntity_MicroController) metaTE).core;
+ InstructionRegistry registry = InstructionRegistry.REGISTRIES.
+ get(pgm.getString("instructionRegistry"));
+ if (registry != null) {
+ core.setProgramMemory(new ProgramMemory(
+ registry,
+ pgm.getBoolean("immersive"),
+ pgm.getIntArray("instructions"),
+ pgm.getIntArray("param0"),
+ pgm.getIntArray("param1")));
+ }
+ }
+ }
+ } else {
+ NBTTagCompound tag=new NBTTagCompound();
+ metaTE.saveNBTData(tag);
+ stack.stackTagCompound.setTag("avr",tag.getCompoundTag("avr"));
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public void writeToProgrammer(ItemStack stack,InstructionRegistry registry, boolean immersive, List<String> strings) throws Exception{
+ writeToProgrammer(stack,new ProgramMemory(registry,immersive,strings));
+ }
+
+ public void writeToProgrammer(ItemStack stack,InstructionRegistry registry, boolean immersive, String... strings)throws Exception{
+ writeToProgrammer(stack,new ProgramMemory(registry,immersive,strings));
+ }
+
+ public void writeToProgrammer(ItemStack stack, ProgramMemory programMemory) {
+ NBTTagCompound pgm=new NBTTagCompound();
+ pgm.setIntArray("instructions",programMemory.instructions);
+ pgm.setIntArray("param0",programMemory.param0);
+ pgm.setIntArray("param1",programMemory.param1);
+ pgm.setBoolean("immersive",programMemory.immersiveOperands);
+ pgm.setString("instructionRegistry",programMemory.registry.toString());
+ stack.stackTagCompound.setTag("pgm",pgm);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
+ if(world.isRemote){
+ player.openGui(TecTech.instance, ModGuiHandler.PROGRAMMER_DISPLAY_SCREEN_ID, world, 0, 0, 0);
+ }
+ return itemStack;
+ }
+
+ @Override
+ public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) {
+ if(aStack.stackTagCompound.hasKey("avr")) {
+ NBTTagCompound avr=aStack.stackTagCompound.getCompoundTag("avr");
+ aList.add("Current PC: " +avr.getInteger("programCounter"));
+ aList.add("Awoken: " +avr.getBoolean("awoken"));
+ aList.add("Active: " +avr.getBoolean("active"));
+ aList.add("Debug: " +avr.getBoolean("debugRun"));
+ aList.add("Delay: " +avr.getBoolean("delay"));
+ }
+ }
+
+ @Override
+ @Optional.Method(modid = "ComputerCraft")
+ public String getLabel(ItemStack itemStack) {
+ return itemStack.getDisplayName();
+ }
+
+ @Override
+ @Optional.Method(modid = "ComputerCraft")
+ public boolean setLabel(ItemStack itemStack, String s) {
+ itemStack.setStackDisplayName(s);
+ return true;
+ }
+
+ @Override
+ @Optional.Method(modid = "ComputerCraft")
+ public String getAudioTitle(ItemStack itemStack) {
+ return null;
+ }
+
+ @Override
+ @Optional.Method(modid = "ComputerCraft")
+ public String getAudioRecordName(ItemStack itemStack) {
+ return null;
+ }
+
+ @Override
+ @Optional.Method(modid = "ComputerCraft")
+ public IMount createDataMount(ItemStack itemStack, World world) {
+ return new IWritableMount() {
+ @Override
+ public void makeDirectory(String s) throws IOException {
+ throw new IOException("Cannot make dir!");
+ }
+
+ @Override
+ public void delete(String s) throws IOException {
+ if("avr".equals(s)) {
+ itemStack.stackTagCompound.removeTag("avr");
+ }else {
+ throw new IOException("Cannot remove file!");
+ }
+ }
+
+ @Override
+ public OutputStream openForWrite(String s) throws IOException {
+ return null;
+ }
+
+ @Override
+ public OutputStream openForAppend(String s) throws IOException {
+ return null;
+ }
+
+ @Override
+ public long getRemainingSpace() throws IOException {
+ return 1024000-getSize("avr");
+ }
+
+ @Override
+ public boolean exists(String s) throws IOException {
+ return "avr".equals(s) && itemStack.getTagCompound().hasKey(s);
+ }
+
+ @Override
+ public boolean isDirectory(String s) throws IOException {
+ return false;
+ }
+
+ @Override
+ public void list(String s, List<String> list) throws IOException {
+
+ }
+
+ @Override
+ public long getSize(String s) throws IOException {
+ return "avr".equals(s)?1:0;
+ }
+
+ @Override
+ public InputStream openForRead(String s) throws IOException {
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public void getSubItems(Item item, CreativeTabs tab, List list) {
+ ItemStack stack=new ItemStack(item, 1, 0);
+ stack.setTagCompound(new NBTTagCompound());
+ list.add(stack);
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
index 33f0d34ad5..57f3bbade1 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
@@ -24,6 +24,7 @@ import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
import static com.github.technus.tectech.Util.StructureBuilder;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
import static gregtech.api.GregTech_API.sBlockCasings1;
/**
@@ -37,6 +38,7 @@ public final class ConstructableTriggerItem extends Item {
private ConstructableTriggerItem() {
setUnlocalizedName("em.constructable");
setTextureName(MODID + ":itemConstructable");
+ setCreativeTab(creativeTabTecTech);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
index 3eb71abca1..61c6e3114a 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
@@ -29,12 +29,13 @@ import java.util.TreeSet;
import static com.github.technus.tectech.Reference.MODID;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by Tec on 15.03.2017.
*/
public final class DebugElementalInstanceContainer_EM extends Item implements IElementalItem {
- public static final TreeSet<iElementalDefinition> stacksRegistered=new TreeSet<>();
+ public static final TreeSet<iElementalDefinition> STACKS_REGISTERED =new TreeSet<>();
public static DebugElementalInstanceContainer_EM INSTANCE;
@@ -42,6 +43,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE
setMaxStackSize(1);
setUnlocalizedName("em.debugContainer");
setTextureName(MODID + ":itemDebugContainer");
+ setCreativeTab(creativeTabTecTech);
}
@Override
@@ -135,7 +137,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE
ItemStack that = new ItemStack(this, 1);
that.setTagCompound(new NBTTagCompound());
list.add(that);
- for(iElementalDefinition defintion:stacksRegistered){
+ for(iElementalDefinition defintion: STACKS_REGISTERED){
list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1))));
list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+144),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,144))));
list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1000),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1000))));
@@ -159,6 +161,6 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE
@Override
public FontRenderer getFontRenderer(ItemStack stack) {
- return (FontRenderer) (Object) TecTechFontRender.INSTANCE;
+ return TecTechFontRender.INSTANCE;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java
index 8de3d1540c..b5a9eacf68 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java
@@ -19,6 +19,7 @@ import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by Tec on 15.03.2017.
@@ -30,6 +31,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem
setMaxStackSize(1);
setUnlocalizedName("em.definitionContainer");
setTextureName(MODID + ":itemDefinitionContainer");
+ setCreativeTab(creativeTabTecTech);
}
//return previous thing
@@ -146,6 +148,6 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem
@Override
public FontRenderer getFontRenderer(ItemStack stack) {
- return (FontRenderer) (Object) TecTechFontRender.INSTANCE;
+ return TecTechFontRender.INSTANCE;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
index 564209062a..eb8663e1c2 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
@@ -25,6 +25,7 @@ import net.minecraft.world.World;
import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by Tec on 15.03.2017.
@@ -37,6 +38,7 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl
setMaxStackSize(1);
setUnlocalizedName("em.definitionScanStorage");
setTextureName(MODID + ":itemDefinitionScanStorage");
+ setCreativeTab(creativeTabTecTech);
}
//return previous thing
@@ -150,6 +152,6 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl
@Override
public FontRenderer getFontRenderer(ItemStack stack) {
- return (FontRenderer) (Object) TecTechFontRender.INSTANCE;
+ return TecTechFontRender.INSTANCE;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
index 3f9562f23a..4ff7c6991b 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
@@ -21,14 +21,16 @@ import java.util.ArrayList;
import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
public class EuMeterGT extends Item {
public static EuMeterGT INSTANCE;
private EuMeterGT() {
+ setMaxStackSize(1);
setUnlocalizedName("em.EuMeterGT");
setTextureName(MODID + ":itemEuMeterGT");
- setMaxStackSize(1);
+ setCreativeTab(creativeTabTecTech);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
index 15567bc477..014c8b6721 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
@@ -17,6 +17,7 @@ import net.minecraftforge.common.util.FakePlayer;
import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
/**
* Created by Tec on 15.03.2017.
@@ -25,8 +26,10 @@ public final class FrontRotationTriggerItem extends Item {
public static FrontRotationTriggerItem INSTANCE;
private FrontRotationTriggerItem() {
+ setMaxStackSize(1);
setUnlocalizedName("em.frontRotate");
setTextureName(MODID + ":itemFrontRotate");
+ setCreativeTab(creativeTabTecTech);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java
index d875fe6545..92215af921 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java
@@ -25,6 +25,7 @@ import net.minecraft.world.World;
import java.util.List;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech;
import static com.github.technus.tectech.thing.CustomItemList.parametrizerMemory;
/**
@@ -39,6 +40,7 @@ public final class ParametrizerMemoryCard extends Item {
setHasSubtypes(true);
setUnlocalizedName("em.parametrizerMemoryCard");
setTextureName(MODID + ":itemParametrizerMemoryCardUnlocked");
+ setCreativeTab(creativeTabTecTech);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ProgrammerScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ProgrammerScreen.java
new file mode 100644
index 0000000000..8584f28d45
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ProgrammerScreen.java
@@ -0,0 +1,13 @@
+package com.github.technus.tectech.thing.item.gui;
+
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ProgrammerScreen extends GuiScreen {
+ private NBTTagCompound tag;
+
+ public ProgrammerScreen(EntityPlayer player){
+ tag=player.getHeldItem().getTagCompound();
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java
index d8b230995f..6d594512bd 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java
@@ -39,7 +39,7 @@ import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem;
*/
public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine {
private static final HashMap<Util.ItemStack_NoNBT,ArrayList<IDataRender>> RENDER_REGISTRY =new HashMap<>();
- private static GT_RenderedTexture READER_ONLINE, READER_OFFLINE;
+ public static GT_RenderedTexture READER_ONLINE, READER_OFFLINE;
public GT_MetaTileEntity_DataReader(int aID, String aName, String aNameRegional, int aTier) {
super(aID,aName,aNameRegional,aTier,1,"Reads Data Sticks and Orbs",1,1,"dataReader.png","");
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java
new file mode 100644
index 0000000000..ef5426a272
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java
@@ -0,0 +1,187 @@
+package com.github.technus.tectech.thing.metaTileEntity.single;
+
+import com.github.technus.avrClone.AvrCore;
+import com.github.technus.avrClone.instructions.ExecutionEvent;
+import com.github.technus.avrClone.instructions.Instruction;
+import com.github.technus.avrClone.instructions.InstructionRegistry;
+import com.github.technus.avrClone.instructions.exceptions.DebugEvent;
+import com.github.technus.avrClone.instructions.exceptions.DelayEvent;
+import com.github.technus.avrClone.memory.EepromMemory;
+import com.github.technus.avrClone.memory.RemovableMemory;
+import com.github.technus.avrClone.memory.program.ProgramMemory;
+import com.github.technus.tectech.TecTech;
+import com.github.technus.tectech.Util;
+import com.github.technus.tectech.mechanics.avr.SidedRedstone;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.objects.GT_RenderedTexture;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+import static com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DataReader.READER_OFFLINE;
+import static com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DataReader.READER_ONLINE;
+
+public class GT_MetaTileEntity_MicroController extends GT_MetaTileEntity_TieredMachineBlock {
+ public static final int OPS_PER_TICK_MAX =512;
+
+ static {
+ Instruction.random= TecTech.RANDOM;
+ }
+ public AvrCore core;
+ private int[] tempData;
+ public boolean debugRun;
+ private int delay;
+ private int maxLoad;
+
+ public static final SidedRedstone sidedRedstone=new SidedRedstone(0x16);
+
+ public GT_MetaTileEntity_MicroController(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 0, "AVR Micro-controller");
+ Util.setTier(aTier,this);
+ }
+
+ public GT_MetaTileEntity_MicroController(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 0, aDescription, aTextures);
+ Util.setTier(aTier,this);
+ core=new AvrCore();
+ core.setUsingImmersiveOperands(false);
+ core.setInstructionRegistry(InstructionRegistry.INSTRUCTION_REGISTRY_OP);
+ core.setDataMemory(Math.max(64,1<<aTier),Math.max(64,1<<aTier));
+ core.setCpuRegisters(0x30);
+ core.putDataBindings(sidedRedstone);
+ maxLoad=Math.min(1 << mTier, OPS_PER_TICK_MAX);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) {
+ return new GT_MetaTileEntity_MicroController(mName, mTier, mDescription, mTextures);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound tag) {
+ NBTTagCompound avr=tag.getCompoundTag("avr");
+ debugRun=avr.getBoolean("debugRun");
+ delay=avr.getInteger("delay");
+ core.active =avr.getBoolean("active");
+ core.awoken=(avr.getBoolean("awoken"));
+ core.programCounter=avr.getInteger("programCounter");
+ if(avr.hasKey("instructions")){
+ InstructionRegistry registry=
+ InstructionRegistry.REGISTRIES.
+ get(avr.getString("instructionRegistry"));
+ if(registry!=null) {
+ core.setProgramMemory(new ProgramMemory(
+ registry,
+ avr.getBoolean("immersive"),
+ avr.getIntArray("instructions"),
+ avr.getIntArray("param0"),
+ avr.getIntArray("param1")));
+ }
+ }
+ if(avr.hasKey("eepromSize")){
+ core.restoreEepromDefinition(EepromMemory.make(avr.getInteger("eepromSize")));
+ }
+ if(avr.hasKey("dataMemory")){
+ tempData=avr.getIntArray("dataMemory");
+ }
+ core.checkValid();
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound tag) {
+ NBTTagCompound avr=new NBTTagCompound();
+ avr.setBoolean("debugRun",debugRun);
+ avr.setInteger("delay",delay);
+ avr.setBoolean("active",core.active);
+ avr.setBoolean("awoken",core.awoken);
+ avr.setInteger("programCounter",core.programCounter);
+ ProgramMemory programMemory=core.getProgramMemory();
+ if(programMemory!=null){
+ avr.setIntArray("instructions",programMemory.instructions);
+ avr.setIntArray("param0",programMemory.param0);
+ avr.setIntArray("param1",programMemory.param1);
+ avr.setBoolean("immersive",programMemory.immersiveOperands);
+ avr.setString("instructionRegistry",programMemory.registry.toString());
+ }
+ RemovableMemory<EepromMemory> eeprom=core.getEepromMemory();
+ if(eeprom!=null){
+ avr.setInteger("eepromSize",eeprom.getDefinition().getSize());
+ }
+ if(core.dataMemory!=null){
+ avr.setIntArray("dataMemory",core.dataMemory);
+ }
+ tag.setTag("avr",avr);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (tempData != null) {
+ //todo discovery of components
+ core.dataMemory = tempData;
+ tempData = null;
+ }
+ if (aBaseMetaTileEntity.isActive()) {
+ sidedRedstone.preSync(core,aBaseMetaTileEntity);
+ core.interruptsHandle();
+ if (core.awoken) {
+ delay=0;
+ for (int load=0; load < maxLoad;) {
+ load+=core.getInstruction().getCost(core);
+ ExecutionEvent executionEvent = core.cpuCycleForce();
+ if (executionEvent != null) {
+ if (executionEvent.throwable instanceof DelayEvent) {
+ delay = executionEvent.data[0];
+ break;
+ } else if (executionEvent.throwable instanceof DebugEvent) {
+ if(debugRun) {
+ aBaseMetaTileEntity.setActive(false);
+ break;
+ }
+ }
+ }
+ }
+ }else if(delay>0){
+ delay--;
+ if(delay==0){
+ core.awoken=true;
+ }
+ }
+ sidedRedstone.postSync(core,aBaseMetaTileEntity);
+ }
+ core.active=aBaseMetaTileEntity.isActive();
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) {
+ return true;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) {
+ return true;
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if(aBaseMetaTileEntity.getWorld()==null){
+ if(aSide==aFacing){
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], aActive ? READER_ONLINE : READER_OFFLINE};
+ }
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ }
+ if(aSide==aBaseMetaTileEntity.getFrontFacing()){
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], aActive ? READER_ONLINE : READER_OFFLINE};
+ }else if(aSide==aFacing){
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ }
+
+ @Override
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ return null;
+ }
+}