P2P tunnel frequency color indicators (#3610)
This commit is contained in:
@@ -1247,6 +1247,8 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
continue;
|
||||
}
|
||||
|
||||
renderState.getPartFlags().put( facing, part.getRenderFlag() );
|
||||
|
||||
// This will add the part's bounding boxes to the render state, which is required for facades
|
||||
final AEPartLocation loc = AEPartLocation.fromFacing( facing );
|
||||
final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true );
|
||||
|
||||
@@ -38,6 +38,7 @@ class P2PModels
|
||||
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_off" );
|
||||
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_on" );
|
||||
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_has_channel" );
|
||||
public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation( AppEng.MOD_ID, "part/builtin/p2p_tunnel_frequency" );
|
||||
|
||||
private final IPartModel modelsOff;
|
||||
private final IPartModel modelsOn;
|
||||
@@ -46,9 +47,10 @@ class P2PModels
|
||||
public P2PModels( String frontModelPath )
|
||||
{
|
||||
ResourceLocation frontModel = new ResourceLocation( AppEng.MOD_ID, frontModelPath );
|
||||
this.modelsOff = new PartModel( MODEL_STATUS_OFF, frontModel );
|
||||
this.modelsOn = new PartModel( MODEL_STATUS_ON, frontModel );
|
||||
this.modelsHasChannel = new PartModel( MODEL_STATUS_HAS_CHANNEL, frontModel );
|
||||
|
||||
this.modelsOff = new PartModel( MODEL_STATUS_OFF, MODEL_FREQUENCY, frontModel );
|
||||
this.modelsOn = new PartModel( MODEL_STATUS_ON, MODEL_FREQUENCY, frontModel );
|
||||
this.modelsHasChannel = new PartModel( MODEL_STATUS_HAS_CHANNEL, MODEL_FREQUENCY, frontModel );
|
||||
}
|
||||
|
||||
public IPartModel getModel( boolean hasPower, boolean hasChannel )
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -134,7 +137,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setOutput( data.getBoolean( "output" ) );
|
||||
this.setFrequency( data.getShort( "freq" ) );
|
||||
this.freq = data.getShort( "freq" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +148,22 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
data.setShort( "freq", this.getFrequency() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final short oldf = this.freq;
|
||||
this.freq = data.readShort();
|
||||
return c || oldf != this.freq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeShort( getFrequency() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCableConnectionLength( AECableType cable )
|
||||
{
|
||||
@@ -381,7 +400,12 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
public void setFrequency( final short freq )
|
||||
{
|
||||
final short oldf = this.freq;
|
||||
this.freq = freq;
|
||||
if( oldf != this.freq )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOutput()
|
||||
@@ -393,4 +417,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRenderFlag()
|
||||
{
|
||||
long ret = Short.toUnsignedLong( this.getFrequency() );
|
||||
|
||||
if( this.isActive() && this.isPowered() )
|
||||
{
|
||||
ret |= 0x10000L;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user