Fix solar panel loading NPE
This commit is contained in:
parent
f28462a9e6
commit
d76d637781
1 changed files with 13 additions and 10 deletions
|
@ -57,8 +57,19 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
public boolean isSunOut() {
|
||||
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaylight();
|
||||
}
|
||||
|
||||
private void updatePanel(){
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
Block panelBlock = world.getBlockState(pos).getBlock();
|
||||
if (panelBlock instanceof BlockSolarPanel) {
|
||||
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
|
||||
panel = solarPanelBlock.panelType;
|
||||
}
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
// PowerAcceptorBlockEntity
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
@ -150,20 +161,12 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
super.fromTag(tag);
|
||||
}
|
||||
|
||||
// TileMachineBase
|
||||
// MachineBaseBlockEntity
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
updatePanel();
|
||||
}
|
||||
|
||||
private void updatePanel(){
|
||||
Block panelBlock = world.getBlockState(pos).getBlock();
|
||||
if (panelBlock instanceof BlockSolarPanel) {
|
||||
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
|
||||
panel = solarPanelBlock.panelType;
|
||||
}
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue