You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB
Java

package net.brokenmoon.redcontrol.blockentities;
import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.api.RCWorldBus;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
public abstract class Peripheral extends BlockEntity implements RedBus.Peripheral {
protected RedBus bus;
protected RCWorldBus worldBus;
protected int id;
public Peripheral(BlockEntityType<?> type, BlockPos pos, BlockState state, int id) {
super(type, pos, state);
this.id = id;
}
public RCWorldBus getBus(){
if (this.worldBus == null || !this.worldBus.getValid()) {
this.worldBus = new RCWorldBus(new RedBus(),world,getPos());
}
return this.worldBus;
}
public void setBus(RCWorldBus bus){
this.bus = bus.getRedBus();
this.bus.setPeripheral(id, this);
this.worldBus = bus;
}
public int getId() {
return id;
}
}