Fix lamp not shining on north. Closes #2371

This commit is contained in:
drcrazy 2021-03-21 03:22:10 +03:00
parent 81337c3698
commit 585f149c16
2 changed files with 16 additions and 5 deletions

View file

@ -159,10 +159,7 @@ public class CableBlockEntity extends BlockEntity
// Tickable
@Override
public void tick() {
if (world == null) {
return;
}
if (world.isClient) {
if (world == null || world.isClient) {
return;
}

View file

@ -34,6 +34,7 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
import techreborn.blocks.lighting.LampBlock;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
@ -69,7 +70,7 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
@Override
protected boolean canAcceptEnergy(EnergySide side) {
return side == EnergySide.UNKNOWN || getFacing().getOpposite() != Direction.values()[side.ordinal()];
return side == EnergySide.UNKNOWN || getFacing().getOpposite() == Direction.values()[side.ordinal()];
}
@Override
@ -92,9 +93,22 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDr
return 32;
}
//MachineBaseBlockEntity
@Override
public Direction getFacing(){
if (world == null){
return Direction.NORTH;
}
return LampBlock.getFacing(world.getBlockState(pos));
}
// IToolDrop
@Override
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
// I know it is weird. But world is nullable
if (world == null) {
return new ItemStack(TRContent.Machine.LAMP_INCANDESCENT.block);
}
return new ItemStack(world.getBlockState(pos).getBlock());
}
}