Compare commits

...

5 Commits
uxn ... main

@ -35,6 +35,7 @@ import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType; import net.minecraft.resource.ResourceType;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Style;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -46,6 +47,9 @@ import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static net.minecraft.item.ItemStack.DISPLAY_KEY;
import static net.minecraft.item.ItemStack.NAME_KEY;
public class RedControl implements ModInitializer { public class RedControl implements ModInitializer {
// This logger is used to write text to the console and the log file. // This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name. // It is considered best practice to use your mod id as the logger's name.
@ -70,9 +74,12 @@ public class RedControl implements ModInitializer {
//Item Stacks //Item Stacks
public static final ItemStack BASIC_DISK = new ItemStack(FLOPPY_ITEM); public static final ItemStack BASIC_DISK = new ItemStack(FLOPPY_ITEM);
public static final NbtCompound BASIC_NBT = new NbtCompound(); public static final NbtCompound BASIC_NBT = new NbtCompound();
public static final NbtCompound BASIC_SUB_NBT = new NbtCompound();
public static final ItemStack SLIDESHOW_DISK = new ItemStack(FLOPPY_ITEM); public static final ItemStack SLIDESHOW_DISK = new ItemStack(FLOPPY_ITEM);
public static final NbtCompound SLIDESHOW_NBT = new NbtCompound(); public static final NbtCompound SLIDESHOW_NBT = new NbtCompound();
public static final NbtCompound SLIDESHOW_SUB_NBT = new NbtCompound();
//Item group //Item group
public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder()
@ -95,7 +102,8 @@ public class RedControl implements ModInitializer {
BASIC_NBT.putString("serial", "BASIC"); BASIC_NBT.putString("serial", "BASIC");
BASIC_NBT.putInt("CustomModelData", 1); BASIC_NBT.putInt("CustomModelData", 1);
BASIC_DISK.setNbt(BASIC_NBT); BASIC_DISK.setNbt(BASIC_NBT);
BASIC_DISK.setCustomName(Text.literal("Basic boot disk")); BASIC_SUB_NBT.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal("Basic Disk").setStyle(Style.EMPTY.withItalic(false))));
BASIC_DISK.setSubNbt(DISPLAY_KEY, BASIC_SUB_NBT);
entries.add(BASIC_DISK); entries.add(BASIC_DISK);
//Slideshow //Slideshow
@ -103,7 +111,8 @@ public class RedControl implements ModInitializer {
SLIDESHOW_NBT.putString("serial", "SLIDESHOW"); SLIDESHOW_NBT.putString("serial", "SLIDESHOW");
SLIDESHOW_NBT.putInt("CustomModelData", 2); SLIDESHOW_NBT.putInt("CustomModelData", 2);
SLIDESHOW_DISK.setNbt(SLIDESHOW_NBT); SLIDESHOW_DISK.setNbt(SLIDESHOW_NBT);
SLIDESHOW_DISK.setCustomName(Text.literal("Slideshow disk")); SLIDESHOW_SUB_NBT.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal("Slideshow Disk").setStyle(Style.EMPTY.withItalic(false))));
SLIDESHOW_DISK.setSubNbt(DISPLAY_KEY, SLIDESHOW_SUB_NBT);
entries.add(SLIDESHOW_DISK); entries.add(SLIDESHOW_DISK);
})) }))
.build(); .build();

@ -28,7 +28,7 @@ public class CpuEntity extends Peripheral implements CpuControl {
@Override @Override
public CpuState getCpuState() {return state;} public CpuState getCpuState() {return state;}
private int resetTimer = 5; private int resetTimer = 40;
@ -45,12 +45,12 @@ public class CpuEntity extends Peripheral implements CpuControl {
be.notTicked = false; be.notTicked = false;
} }
if(be.state == CpuState.RUNNING) { if(be.state == CpuState.RUNNING) {
for (int i = 0; i < 1000; i++) for (int i = 0; i < 500; i++)
be.step(); be.step();
} else{ } else{
if (be.state == CpuState.RESET && be.resetTimer > 0){ if (be.state == CpuState.RESET && be.resetTimer > 0){
be.resetTimer--; be.resetTimer--;
} else { } else if(be.state == CpuState.RESET) {
be.core = new Emulator(be.getBus().getRedBus()); be.core = new Emulator(be.getBus().getRedBus());
} }
} }
@ -81,7 +81,7 @@ public class CpuEntity extends Peripheral implements CpuControl {
public void reset() { public void reset() {
this.core.reset(this.defaultDriveId, this.defaultMonitorId); this.core.reset(this.defaultDriveId, this.defaultMonitorId);
state = CpuState.RESET; state = CpuState.RESET;
resetTimer = 5; resetTimer = 40;
markDirty(); markDirty();
world.updateListeners(pos, this.getCachedState(), this.getCachedState(), Block.NOTIFY_LISTENERS); world.updateListeners(pos, this.getCachedState(), this.getCachedState(), Block.NOTIFY_LISTENERS);
} }

@ -9,6 +9,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Style;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@ -18,6 +19,9 @@ import java.net.URI;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.UUID; import java.util.UUID;
import static net.minecraft.item.ItemStack.DISPLAY_KEY;
import static net.minecraft.item.ItemStack.NAME_KEY;
public class DriveEntity extends Peripheral { public class DriveEntity extends Peripheral {
private static final int SECTOR_SIZE = 0x80; private static final int SECTOR_SIZE = 0x80;
@ -92,7 +96,9 @@ public class DriveEntity extends Peripheral {
this.buffer.position(0); this.buffer.position(0);
byte[] diskName = new byte[SECTOR_SIZE]; byte[] diskName = new byte[SECTOR_SIZE];
this.buffer.get(diskName); this.buffer.get(diskName);
this.disk.setCustomName(Text.literal(new String(diskName).trim())); NbtCompound sub_nbt = new NbtCompound();
sub_nbt.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal(new String(diskName).trim()).setStyle(Style.EMPTY.withItalic(false))));
this.disk.setSubNbt(DISPLAY_KEY, sub_nbt);
this.driver.writeDiskName(diskName); this.driver.writeDiskName(diskName);
this.command = 0; this.command = 0;
break; break;

Loading…
Cancel
Save