diff options
author | Technus <daniel112092@gmail.com> | 2019-07-30 17:54:28 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2019-07-30 17:54:28 +0200 |
commit | 80ea67fd7623535b30424b7618d69767b926c330 (patch) | |
tree | d3a3e8971a3ece609b7e135b434f560dd3ac5948 /src | |
parent | 2bfa7ba4d4782c5490302d737950846afd6fad22 (diff) | |
download | GT5-Unofficial-80ea67fd7623535b30424b7618d69767b926c330.tar.gz GT5-Unofficial-80ea67fd7623535b30424b7618d69767b926c330.tar.bz2 GT5-Unofficial-80ea67fd7623535b30424b7618d69767b926c330.zip |
TEMP WORK
Diffstat (limited to 'src')
12 files changed, 340 insertions, 44 deletions
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 988fd30031..f92f78e4c6 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 index 9488b9280f..fd351631f3 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java +++ b/src/main/java/com/github/technus/tectech/mechanics/avr/SidedRedstone.java @@ -8,7 +8,7 @@ public class SidedRedstone extends RegisterPackageSync<IGregTechTileEntity> { public static final RSINT RSINT =new RSINT(); public SidedRedstone(int offset) { - super(offset, 23); + super(offset, Register.values().length); addRegisters(Register.values()); addBits(RegisterBitsPCMSK.values()); addBits(RegisterBitsPCFR.values()); 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 969283fa15..788edecaab 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -89,6 +89,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; 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..1d61d0744c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java @@ -0,0 +1,216 @@ +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 li.cil.oc.api.fs.FileSystem; +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,FileSystem { + 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/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java index 3b09d37a33..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 @@ -161,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 87b76696bb..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 @@ -152,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 8edcd32bdb..d95b9845bd 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/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_MicroControllerTileEntity.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java index 6692c19cea..ef5426a272 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroControllerTileEntity.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java @@ -24,82 +24,96 @@ 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_MicroControllerTileEntity extends GT_MetaTileEntity_TieredMachineBlock { +public class GT_MetaTileEntity_MicroController extends GT_MetaTileEntity_TieredMachineBlock { + public static final int OPS_PER_TICK_MAX =512; + static { Instruction.random= TecTech.RANDOM; } - private AvrCore core; + public AvrCore core; private int[] tempData; - private boolean debugRun; + public boolean debugRun; private int delay; + private int maxLoad; - public static final SidedRedstone sidedRedstone=new SidedRedstone(0x1b); + public static final SidedRedstone sidedRedstone=new SidedRedstone(0x16); - public GT_MetaTileEntity_MicroControllerTileEntity(int aID, String aName, String aNameRegional, int aTier) { + 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_MicroControllerTileEntity(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + 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(1<<aTier,1<<aTier); + 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_MicroControllerTileEntity(mName, mTier, mDescription, mTextures); + return new GT_MetaTileEntity_MicroController(mName, mTier, mDescription, mTextures); } @Override public void loadNBTData(NBTTagCompound tag) { - debugRun=tag.getBoolean("debugRun"); - delay=tag.getInteger("delay"); - core.active =tag.getBoolean("active"); - core.awoken=(tag.getBoolean("awoken")); - core.programCounter=tag.getInteger("programCounter"); - if(tag.hasKey("instructions")){ - int[] instructions=tag.getIntArray("instructions"); - int[] param0=tag.getIntArray("param0"); - int[] param1=tag.getIntArray("param1"); - core.setProgramMemory(new ProgramMemory( - core.getInstructionRegistry(),core.isUsingImmersiveOperands(), - instructions,param0,param1)); + 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(tag.hasKey("eepromSize")){ - core.setEepromDefinition(EepromMemory.make(tag.getInteger("eepromSize"))); + if(avr.hasKey("eepromSize")){ + core.restoreEepromDefinition(EepromMemory.make(avr.getInteger("eepromSize"))); } - if(tag.hasKey("dataMemory")){ - tempData=tag.getIntArray("dataMemory"); + if(avr.hasKey("dataMemory")){ + tempData=avr.getIntArray("dataMemory"); } core.checkValid(); } @Override public void saveNBTData(NBTTagCompound tag) { - tag.setBoolean("debugRun",debugRun); - tag.setInteger("delay",delay); - tag.setBoolean("active",core.active); - tag.setBoolean("awoken",core.awoken); - tag.setInteger("programCounter",core.programCounter); + 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){ - tag.setIntArray("instructions",programMemory.instructions); - tag.setIntArray("param0",programMemory.param0); - tag.setIntArray("param1",programMemory.param1); + 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){ - tag.setInteger("eepromSize",eeprom.getDefinition().getSize()); + avr.setInteger("eepromSize",eeprom.getDefinition().getSize()); } if(core.dataMemory!=null){ - tag.setIntArray("dataMemory",core.dataMemory); + avr.setIntArray("dataMemory",core.dataMemory); } + tag.setTag("avr",avr); } @Override @@ -109,20 +123,23 @@ public class GT_MetaTileEntity_MicroControllerTileEntity extends GT_MetaTileEnti core.dataMemory = tempData; tempData = null; } - if (core.active) { + if (aBaseMetaTileEntity.isActive()) { sidedRedstone.preSync(core,aBaseMetaTileEntity); core.interruptsHandle(); if (core.awoken) { delay=0; - for (int i = 0, cycles = Math.min(1 << mTier, 512); i < cycles; i++) { + 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 (debugRun && executionEvent.throwable instanceof DebugEvent) { - core.active = false; - break; + } else if (executionEvent.throwable instanceof DebugEvent) { + if(debugRun) { + aBaseMetaTileEntity.setActive(false); + break; + } } } } @@ -134,6 +151,7 @@ public class GT_MetaTileEntity_MicroControllerTileEntity extends GT_MetaTileEnti } sidedRedstone.postSync(core,aBaseMetaTileEntity); } + core.active=aBaseMetaTileEntity.isActive(); } @Override |