Fix solar panel loading NPE

This commit is contained in:
drcrazy 2019-07-26 15:12:47 +03:00
parent f28462a9e6
commit d76d637781

View file

@ -58,7 +58,18 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaylight();
}
// TilePowerAcceptor
private void updatePanel(){
if (world == null) {
return;
}
Block panelBlock = world.getBlockState(pos).getBlock();
if (panelBlock instanceof BlockSolarPanel) {
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
panel = solarPanelBlock.panelType;
}
}
// PowerAcceptorBlockEntity
@Override
public void tick() {
super.tick();
@ -150,21 +161,13 @@ 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
public ItemStack getToolDrop(final PlayerEntity playerIn) {