|
|
|
@ -6,6 +6,8 @@ import com.thebrokenrail.energonrelics.block.SwitchBlock;
|
|
|
|
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
|
|
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
|
|
|
|
public SwitchBlockEntity(BlockEntityType<?> type) {
|
|
|
|
|
super(type);
|
|
|
|
@ -13,7 +15,11 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void energyTick() {
|
|
|
|
|
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.SWITCH_ENERGY_REQUIRED, SwitchBlock.POWERED, true, false));
|
|
|
|
|
if (getCachedState().get(SwitchBlock.ACTIVE)) {
|
|
|
|
|
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.SWITCH_ENERGY_REQUIRED, SwitchBlock.POWERED, true, false));
|
|
|
|
|
} else if (getCachedState().get(SwitchBlock.POWERED)) {
|
|
|
|
|
Objects.requireNonNull(getWorld()).setBlockState(getPos(), getCachedState().with(SwitchBlock.POWERED, false));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|