This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
2020-08-04 17:06:11 +00:00
|
|
|
package com.thebrokenrail.energonrelics.api.block.entity.helper;
|
2020-07-13 20:37:21 +00:00
|
|
|
|
2020-08-04 17:06:11 +00:00
|
|
|
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyProviderBlockEntity;
|
|
|
|
import com.thebrokenrail.energonrelics.api.energy.Action;
|
2020-07-13 20:37:21 +00:00
|
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
|
|
|
2020-08-04 17:06:11 +00:00
|
|
|
/**
|
|
|
|
* Simple Implementation Of A Energy Generator
|
|
|
|
*/
|
2020-07-13 20:37:21 +00:00
|
|
|
public abstract class EnergyGeneratorBlockEntity extends EnergyProviderBlockEntity implements EnergyGenerator {
|
|
|
|
public EnergyGeneratorBlockEntity(BlockEntityType<?> type) {
|
|
|
|
super(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
private long energy = 0;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnergyProvider() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getEnergy() {
|
|
|
|
return energy;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEnergy(long value) {
|
2020-07-23 17:39:40 +00:00
|
|
|
if (value < 0) {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
2020-07-13 20:37:21 +00:00
|
|
|
energy = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void handlePropagatedAction(Action.PropagatedAction action) {
|
2020-07-22 23:51:42 +00:00
|
|
|
super.handlePropagatedAction(action);
|
2020-07-13 20:37:21 +00:00
|
|
|
handlePropagatedActionWithGenerator(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public abstract long getDisplayEnergy();
|
|
|
|
}
|