mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-27 16:02:17 +00:00
fix: wired modem direction
This commit is contained in:
parent
960d79803d
commit
67b7cd7a14
@ -232,9 +232,8 @@ public class BlockCable extends BlockGeneric implements Waterloggable
|
||||
public void onPlaced( World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, @Nonnull ItemStack stack )
|
||||
{
|
||||
BlockEntity tile = world.getBlockEntity( pos );
|
||||
if( tile instanceof TileCable )
|
||||
if( tile instanceof TileCable cable )
|
||||
{
|
||||
TileCable cable = (TileCable) tile;
|
||||
if( cable.hasCable() )
|
||||
{
|
||||
cable.connectionsChanged();
|
||||
|
@ -56,9 +56,8 @@ public abstract class ItemBlockCable extends BlockItem
|
||||
world.playSound( null, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F );
|
||||
|
||||
BlockEntity tile = world.getBlockEntity( pos );
|
||||
if( tile instanceof TileCable )
|
||||
if( tile instanceof TileCable cable )
|
||||
{
|
||||
TileCable cable = (TileCable) tile;
|
||||
cable.modemChanged();
|
||||
cable.connectionsChanged();
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
private final IWiredNode node = cable.getNode();
|
||||
private boolean peripheralAccessAllowed;
|
||||
private boolean destroyed = false;
|
||||
private Direction modemDirection = Direction.NORTH;
|
||||
private final WiredModemPeripheral modem = new WiredModemPeripheral( new ModemState( () -> TickScheduler.schedule( this ) ), cable )
|
||||
{
|
||||
@Nonnull
|
||||
@ -60,7 +59,7 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
{
|
||||
BlockPos pos = getPos().offset( modemDirection );
|
||||
BlockPos pos = getPos().offset( getDirection() );
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@ -71,7 +70,6 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
return TileCable.this;
|
||||
}
|
||||
};
|
||||
private boolean hasModemDirection = false;
|
||||
private boolean connectionsFormed = false;
|
||||
|
||||
public TileCable( BlockEntityType<? extends TileCable> type, BlockPos pos, BlockState state )
|
||||
@ -176,8 +174,8 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
@Nonnull
|
||||
private Direction getDirection()
|
||||
{
|
||||
refreshDirection();
|
||||
return modemDirection == null ? Direction.NORTH : modemDirection;
|
||||
Direction direction = getMaybeDirection();
|
||||
return direction == null ? Direction.NORTH : direction;
|
||||
}
|
||||
|
||||
public boolean hasModem()
|
||||
@ -312,8 +310,6 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
return;
|
||||
}
|
||||
|
||||
refreshDirection();
|
||||
|
||||
if( modem.getModemState()
|
||||
.pollChanged() )
|
||||
{
|
||||
@ -327,7 +323,7 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
connectionsChanged();
|
||||
if( peripheralAccessAllowed )
|
||||
{
|
||||
peripheral.attach( world, pos, modemDirection );
|
||||
peripheral.attach( world, pos, getDirection() );
|
||||
updateConnectedPeripherals();
|
||||
}
|
||||
}
|
||||
@ -360,20 +356,7 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
@Nullable
|
||||
private Direction getMaybeDirection()
|
||||
{
|
||||
refreshDirection();
|
||||
return modemDirection;
|
||||
}
|
||||
|
||||
private void refreshDirection()
|
||||
{
|
||||
if( hasModemDirection )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasModemDirection = true;
|
||||
modemDirection = getCachedState().get( BlockCable.MODEM )
|
||||
.getFacing();
|
||||
return getCachedState().get( BlockCable.MODEM ).getFacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -412,7 +395,6 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
{
|
||||
super.setCachedState( state );
|
||||
if( state != null ) return;
|
||||
hasModemDirection = false;
|
||||
if( !world.isClient )
|
||||
{
|
||||
world.getBlockTickScheduler()
|
||||
|
Loading…
x
Reference in New Issue
Block a user