Bus Progress

main
Astoria 7 months ago
parent 9721848c4e
commit 520c9fe3c2

@ -1,10 +1,28 @@
package net.brokenmoon.redcontrol.api;
import com.simon816.j65el02.Bus;
import com.simon816.j65el02.device.Device;
import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.blockentities.Peripheral;
import java.util.Arrays;
public class RCBus extends Bus {
boolean isValid = true;
Peripheral[] peripherals = new Peripheral[256];
public RCBus(RedBus redBus) {
super(redBus);
}
public void write(int address, int data) {
Peripheral peripheral = peripherals[address];
peripheral.getBus().write(address, data);
}
public int read(int address, boolean cpuAccess) {
Peripheral peripheral = peripherals[address];
return peripheral.getBus().getRedBus().read(address, cpuAccess) & 0xff;
}
}

@ -4,8 +4,12 @@ import net.brokenmoon.redcontrol.api.RCBus;
import net.brokenmoon.redcontrol.blockentities.Peripheral;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public abstract class NetworkCarrier extends Block implements BlockEntityProvider {
public NetworkCarrier(Settings settings) {
@ -19,4 +23,20 @@ public abstract class NetworkCarrier extends Block implements BlockEntityProvide
public void setBus(World world, BlockPos pos, RCBus bus){
((Peripheral)world.getBlockEntity(pos)).setBus(bus);
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.hasBlockEntity() && !state.isOf(newState.getBlock())) {
world.removeBlockEntity(pos);
}
}
public void invalidateBus(World world, BlockPos pos){
}
}

Loading…
Cancel
Save