2020-07-13 20:37:21 +00:00
|
|
|
package com.thebrokenrail.energonrelics.block.entity;
|
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.block.SwitchBlock;
|
|
|
|
import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity;
|
2020-08-03 20:36:20 +00:00
|
|
|
import com.thebrokenrail.energonrelics.energy.core.util.Action;
|
2020-07-13 20:37:21 +00:00
|
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
|
|
|
|
|
|
public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
|
|
|
public SwitchBlockEntity(BlockEntityType<?> type) {
|
|
|
|
super(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-27 18:06:46 +00:00
|
|
|
protected void energyTick() {
|
2020-07-13 20:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnergyProvider() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-08-03 20:36:20 +00:00
|
|
|
protected void handlePropagatedAction(Action.PropagatedAction action) {
|
|
|
|
super.handlePropagatedAction(action);
|
|
|
|
// Propagate Action To Energy Providers
|
|
|
|
if (isActive() && !hasSent(action)) {
|
|
|
|
propagateAction(action);
|
|
|
|
} else {
|
|
|
|
action.pay(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isActive() {
|
2020-07-13 20:37:21 +00:00
|
|
|
return getCachedState().get(SwitchBlock.POWERED);
|
|
|
|
}
|
|
|
|
}
|