pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -52,167 +51,139 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable<Void> {
|
||||
|
||||
public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable<Void>
|
||||
{
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 2);
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new SpatialIOFilter() );
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
public TileSpatialIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
}
|
||||
|
||||
public TileSpatialIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
if (data.contains("lastRedstoneState")) {
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt("lastRedstoneState")];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
if( data.contains("lastRedstoneState") )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )];
|
||||
}
|
||||
}
|
||||
public boolean getRedstoneState() {
|
||||
if (this.lastRedstoneState == YesNo.UNDECIDED) {
|
||||
this.updateRedstoneState();
|
||||
}
|
||||
|
||||
public boolean getRedstoneState()
|
||||
{
|
||||
if( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
{
|
||||
this.updateRedstoneState();
|
||||
}
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
public void updateRedstoneState() {
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors(this.pos) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if (this.lastRedstoneState != currentState) {
|
||||
this.lastRedstoneState = currentState;
|
||||
if (this.lastRedstoneState == YesNo.YES) {
|
||||
this.triggerTransition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
if( this.lastRedstoneState == YesNo.YES )
|
||||
{
|
||||
this.triggerTransition();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void triggerTransition() {
|
||||
if (Platform.isServer()) {
|
||||
final ItemStack cell = this.inv.getStackInSlot(0);
|
||||
if (this.isSpatialCell(cell)) {
|
||||
TickHandler.INSTANCE.addCallable(null, this);// this needs to be cross world synced.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerTransition()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final ItemStack cell = this.inv.getStackInSlot( 0 );
|
||||
if( this.isSpatialCell( cell ) )
|
||||
{
|
||||
TickHandler.INSTANCE.addCallable( null, this );// this needs to be cross world synced.
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean isSpatialCell(final ItemStack cell) {
|
||||
if (!cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell) {
|
||||
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
return sc != null && sc.isSpatialStorage(cell);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSpatialCell( final ItemStack cell )
|
||||
{
|
||||
if( !cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell )
|
||||
{
|
||||
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
return sc != null && sc.isSpatialStorage( cell );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public Void call(final World world) throws Exception {
|
||||
final ItemStack cell = this.inv.getStackInSlot(0);
|
||||
if (this.isSpatialCell(cell) && this.inv.getStackInSlot(1).isEmpty()) {
|
||||
final IGrid gi = this.getProxy().getGrid();
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
|
||||
@Override
|
||||
public Void call( final World world ) throws Exception
|
||||
{
|
||||
final ItemStack cell = this.inv.getStackInSlot( 0 );
|
||||
if( this.isSpatialCell( cell ) && this.inv.getStackInSlot( 1 ).isEmpty() )
|
||||
{
|
||||
final IGrid gi = this.getProxy().getGrid();
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
|
||||
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
final SpatialPylonCache spc = gi.getCache(ISpatialCache.class);
|
||||
if (spc.hasRegion() && spc.isValidRegion()) {
|
||||
final double req = spc.requiredPower();
|
||||
final double pr = energy.extractAEPower(req, Actionable.SIMULATE, PowerMultiplier.CONFIG);
|
||||
if (Math.abs(pr - req) < req * 0.001) {
|
||||
final MENetworkEvent res = gi.postEvent(new MENetworkSpatialEvent(this, req));
|
||||
if (!res.isCanceled()) {
|
||||
int playerId = -1;
|
||||
if (this.getProxy().getSecurity().isAvailable()) {
|
||||
playerId = this.getProxy().getSecurity().getOwner();
|
||||
}
|
||||
|
||||
final SpatialPylonCache spc = gi.getCache( ISpatialCache.class );
|
||||
if( spc.hasRegion() && spc.isValidRegion() )
|
||||
{
|
||||
final double req = spc.requiredPower();
|
||||
final double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
if( Math.abs( pr - req ) < req * 0.001 )
|
||||
{
|
||||
final MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
|
||||
if( !res.isCanceled() )
|
||||
{
|
||||
int playerId = -1;
|
||||
if( this.getProxy().getSecurity().isAvailable() )
|
||||
{
|
||||
playerId = this.getProxy().getSecurity().getOwner();
|
||||
}
|
||||
final TransitionResult tr = sc.doSpatialTransition(cell, this.world, spc.getMin(), spc.getMax(),
|
||||
playerId);
|
||||
if (tr.success) {
|
||||
energy.extractAEPower(req, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.inv.setStackInSlot(0, ItemStack.EMPTY);
|
||||
this.inv.setStackInSlot(1, cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final TransitionResult tr = sc.doSpatialTransition( cell, this.world, spc.getMin(), spc.getMax(), playerId );
|
||||
if( tr.success )
|
||||
{
|
||||
energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
this.inv.setStackInSlot( 1, cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
@Override
|
||||
protected @Nonnull IItemHandler getItemHandlerForSide(@Nonnull Direction side) {
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull Direction side )
|
||||
{
|
||||
return this.invExt;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
private class SpatialIOFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
private class SpatialIOFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return slot == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
return (slot == 0 && TileSpatialIOPort.this.isSpatialCell(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return( slot == 0 && TileSpatialIOPort.this.isSpatialCell( stack ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,17 @@
|
||||
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
@@ -37,234 +41,192 @@ import appeng.me.cluster.implementations.SpatialPylonCluster;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock {
|
||||
|
||||
public static final ModelProperty<Integer> STATE = new ModelProperty<>(value -> {
|
||||
// The lower 6 bits are used
|
||||
return (value & ~0x3F) == 0;
|
||||
});
|
||||
|
||||
public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
{
|
||||
public static final int DISPLAY_END_MIN = 0x01;
|
||||
public static final int DISPLAY_END_MAX = 0x02;
|
||||
public static final int DISPLAY_MIDDLE = 0x01 + 0x02;
|
||||
public static final int DISPLAY_X = 0x04;
|
||||
public static final int DISPLAY_Y = 0x08;
|
||||
public static final int DISPLAY_Z = 0x04 + 0x08;
|
||||
public static final int MB_STATUS = 0x01 + 0x02 + 0x04 + 0x08;
|
||||
|
||||
public static final ModelProperty<Integer> STATE = new ModelProperty<>(value -> {
|
||||
// The lower 6 bits are used
|
||||
return ( value & ~0x3F ) == 0;
|
||||
});
|
||||
public static final int DISPLAY_ENABLED = 0x10;
|
||||
public static final int DISPLAY_POWERED_ENABLED = 0x20;
|
||||
public static final int NET_STATUS = 0x10 + 0x20;
|
||||
|
||||
public static final int DISPLAY_END_MIN = 0x01;
|
||||
public static final int DISPLAY_END_MAX = 0x02;
|
||||
public static final int DISPLAY_MIDDLE = 0x01 + 0x02;
|
||||
public static final int DISPLAY_X = 0x04;
|
||||
public static final int DISPLAY_Y = 0x08;
|
||||
public static final int DISPLAY_Z = 0x04 + 0x08;
|
||||
public static final int MB_STATUS = 0x01 + 0x02 + 0x04 + 0x08;
|
||||
private final SpatialPylonCalculator calc = new SpatialPylonCalculator(this);
|
||||
private int displayBits = 0;
|
||||
private SpatialPylonCluster cluster;
|
||||
private boolean didHaveLight = false;
|
||||
|
||||
public static final int DISPLAY_ENABLED = 0x10;
|
||||
public static final int DISPLAY_POWERED_ENABLED = 0x20;
|
||||
public static final int NET_STATUS = 0x10 + 0x20;
|
||||
public TileSpatialPylon(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK);
|
||||
this.getProxy().setIdlePowerUsage(0.5);
|
||||
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
|
||||
}
|
||||
|
||||
private final SpatialPylonCalculator calc = new SpatialPylonCalculator( this );
|
||||
private int displayBits = 0;
|
||||
private SpatialPylonCluster cluster;
|
||||
private boolean didHaveLight = false;
|
||||
@Override
|
||||
protected AENetworkProxy createProxy() {
|
||||
return new AENetworkProxyMultiblock(this, "proxy", this.getItemFromTile(this), true);
|
||||
}
|
||||
|
||||
public TileSpatialPylon(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
|
||||
this.getProxy().setIdlePowerUsage( 0.5 );
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
}
|
||||
@Override
|
||||
public void onChunkUnloaded() {
|
||||
this.disconnect(false);
|
||||
super.onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AENetworkProxy createProxy()
|
||||
{
|
||||
return new AENetworkProxyMultiblock( this, "proxy", this.getItemFromTile( this ), true );
|
||||
}
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.neighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnloaded();
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
this.disconnect(false);
|
||||
super.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
this.neighborChanged();
|
||||
}
|
||||
public void neighborChanged() {
|
||||
this.calc.calculateMultiblock(this.world, this.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.remove();
|
||||
}
|
||||
@Override
|
||||
public void disconnect(final boolean b) {
|
||||
if (this.cluster != null) {
|
||||
this.cluster.destroy();
|
||||
this.updateStatus(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void neighborChanged()
|
||||
{
|
||||
this.calc.calculateMultiblock( this.world, this.getLocation() );
|
||||
}
|
||||
@Override
|
||||
public SpatialPylonCluster getCluster() {
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect( final boolean b )
|
||||
{
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.destroy();
|
||||
this.updateStatus( null );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpatialPylonCluster getCluster()
|
||||
{
|
||||
return this.cluster;
|
||||
}
|
||||
public void updateStatus(final SpatialPylonCluster c) {
|
||||
this.cluster = c;
|
||||
this.getProxy().setValidSides(c == null ? EnumSet.noneOf(Direction.class) : EnumSet.allOf(Direction.class));
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void recalculateDisplay() {
|
||||
final int oldBits = this.displayBits;
|
||||
|
||||
public void updateStatus( final SpatialPylonCluster c )
|
||||
{
|
||||
this.cluster = c;
|
||||
this.getProxy().setValidSides( c == null ? EnumSet.noneOf( Direction.class ) : EnumSet.allOf( Direction.class ) );
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
this.displayBits = 0;
|
||||
|
||||
public void recalculateDisplay()
|
||||
{
|
||||
final int oldBits = this.displayBits;
|
||||
if (this.cluster != null) {
|
||||
if (this.cluster.getMin().equals(this.getLocation())) {
|
||||
this.displayBits = DISPLAY_END_MIN;
|
||||
} else if (this.cluster.getMax().equals(this.getLocation())) {
|
||||
this.displayBits = DISPLAY_END_MAX;
|
||||
} else {
|
||||
this.displayBits = DISPLAY_MIDDLE;
|
||||
}
|
||||
|
||||
this.displayBits = 0;
|
||||
switch (this.cluster.getCurrentAxis()) {
|
||||
case X:
|
||||
this.displayBits |= DISPLAY_X;
|
||||
break;
|
||||
case Y:
|
||||
this.displayBits |= DISPLAY_Y;
|
||||
break;
|
||||
case Z:
|
||||
this.displayBits |= DISPLAY_Z;
|
||||
break;
|
||||
default:
|
||||
this.displayBits = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if( this.cluster != null )
|
||||
{
|
||||
if( this.cluster.getMin().equals( this.getLocation() ) )
|
||||
{
|
||||
this.displayBits = DISPLAY_END_MIN;
|
||||
}
|
||||
else if( this.cluster.getMax().equals( this.getLocation() ) )
|
||||
{
|
||||
this.displayBits = DISPLAY_END_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.displayBits = DISPLAY_MIDDLE;
|
||||
}
|
||||
try {
|
||||
if (this.getProxy().getEnergy().isNetworkPowered()) {
|
||||
this.displayBits |= DISPLAY_POWERED_ENABLED;
|
||||
}
|
||||
|
||||
switch( this.cluster.getCurrentAxis() )
|
||||
{
|
||||
case X:
|
||||
this.displayBits |= DISPLAY_X;
|
||||
break;
|
||||
case Y:
|
||||
this.displayBits |= DISPLAY_Y;
|
||||
break;
|
||||
case Z:
|
||||
this.displayBits |= DISPLAY_Z;
|
||||
break;
|
||||
default:
|
||||
this.displayBits = 0;
|
||||
break;
|
||||
}
|
||||
if (this.cluster.isValid() && this.getProxy().isActive()) {
|
||||
this.displayBits |= DISPLAY_ENABLED;
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// nothing?
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( this.getProxy().getEnergy().isNetworkPowered() )
|
||||
{
|
||||
this.displayBits |= DISPLAY_POWERED_ENABLED;
|
||||
}
|
||||
if (oldBits != this.displayBits) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if( this.cluster.isValid() && this.getProxy().isActive() )
|
||||
{
|
||||
this.displayBits |= DISPLAY_ENABLED;
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// nothing?
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void markForUpdate() {
|
||||
super.markForUpdate();
|
||||
final boolean hasLight = this.getLightValue() > 0;
|
||||
if (hasLight != this.didHaveLight) {
|
||||
this.didHaveLight = hasLight;
|
||||
this.world.getLightManager().checkBlock(this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
if( oldBits != this.displayBits )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
super.markForUpdate();
|
||||
final boolean hasLight = this.getLightValue() > 0;
|
||||
if( hasLight != this.didHaveLight )
|
||||
{
|
||||
this.didHaveLight = hasLight;
|
||||
this.world.getLightManager().checkBlock( this.pos );
|
||||
}
|
||||
}
|
||||
public int getLightValue() {
|
||||
if ((this.displayBits & DISPLAY_POWERED_ENABLED) == DISPLAY_POWERED_ENABLED) {
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits || c;
|
||||
}
|
||||
|
||||
public int getLightValue()
|
||||
{
|
||||
if( ( this.displayBits & DISPLAY_POWERED_ENABLED ) == DISPLAY_POWERED_ENABLED )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeByte(this.displayBits);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits || c;
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeByte( this.displayBits );
|
||||
}
|
||||
@MENetworkEventSubscribe
|
||||
public void activeRender(final MENetworkChannelsChanged c) {
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
public int getDisplayBits() {
|
||||
return this.displayBits;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void activeRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public int getDisplayBits()
|
||||
{
|
||||
return this.displayBits;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
// FIXME: Must force model data update on changes, should potentially be moved to block state (?)
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(STATE, getDisplayBits())
|
||||
.build();
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
// FIXME: Must force model data update on changes, should potentially be moved
|
||||
// to block state (?)
|
||||
return new ModelDataMap.Builder().withInitial(STATE, getDisplayBits()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user