Fix lamp not shining on north. Closes #2371

This commit is contained in:
drcrazy 2021-03-21 00:22:10 +00:00 committed by modmuss50
parent 268c7fa14b
commit e6459867e4
2 changed files with 16 additions and 5 deletions

View file

@ -161,10 +161,7 @@ public class CableBlockEntity extends BlockEntity
// Tickable
@Override
public void tick(World world, BlockPos pos, BlockState state, CableBlockEntity blockEntity2) {
if (world == null) {
return;
}
if (world.isClient) {
if (world == null || world.isClient) {
return;
}

View file

@ -37,6 +37,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 {
@ -71,7 +72,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
@ -94,9 +95,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());
}
}