Reimplemented cable and parts rendering.

This commit is contained in:
Sebastian Hartte
2016-08-29 09:47:17 +02:00
parent 0b756708d4
commit 7e027da804
358 changed files with 5964 additions and 1901 deletions
@@ -25,18 +25,12 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -55,7 +49,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.client.BakingPipeline;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IDefinitions;
import appeng.api.implementations.IUpgradeableHost;
@@ -73,7 +66,6 @@ import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.client.render.model.ModelsCache;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.IPriorityHost;
import appeng.items.parts.ItemMultiPart;
@@ -89,35 +81,6 @@ import appeng.util.SettingsFrom;
public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
{
private static final Pattern PROPERTY_PATTERN = Pattern.compile( "\\$\\{([\\p{Alnum}_\\-\\.]+)\\}" );
public static final ResourceLocation replaceProperties( ResourceLocation location, ImmutableMap<String, String> properties )
{
Matcher m = PROPERTY_PATTERN.matcher( location.getResourcePath() );
StringBuffer buffer = new StringBuffer();
while( m.find() )
{
m.appendReplacement( buffer, properties.get( m.group( 1 ) ) );
}
m.appendTail( buffer );
return new ResourceLocation( location.getResourceDomain(), buffer.toString() );
}
protected static final Function<ResourceLocation, TextureAtlasSprite> propertyTextureGetter( ImmutableMap<String, String> properties )
{
return location -> ModelsCache.DEFAULTTEXTUREGETTER.apply( replaceProperties( location, properties ) );
}
protected static final Function<ResourceLocation, TextureAtlasSprite> propertyTextureGetter( ImmutableMap.Builder<String, String> properties )
{
return propertyTextureGetter( properties.build() );
}
protected static final ResourceLocation withProperties( ResourceLocation location, ImmutableMap.Builder<String, String> properties )
{
return new ResourceLocation( location.getResourceDomain(), location.getResourcePath() + properties.build().toString() );
}
private final AENetworkProxy proxy;
private final ItemStack is;
private TileEntity tile = null;
@@ -567,13 +530,6 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
return false;
}
@Override
@SideOnly( Side.CLIENT )
public List<BakedQuad> getOrBakeQuads( BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand )
{
return rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getDefaultModelLocation(), propertiesForModel( getSide().getFacing() ) ), getDefaultModelLocation(), propertyTextureGetter( propertiesForModel( getSide().getFacing() ) ) ).getQuads( state, side, rand ), null, state, getSide().getFacing(), rand );
}
protected ImmutableMap.Builder<String, String> propertiesForModel( EnumFacing facing )
{
return ImmutableMap.<String, String>builder().put( "color", getColor().name() );
@@ -25,7 +25,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
@@ -63,6 +62,8 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.client.render.cablebus.CableCoreType;
import appeng.core.AELog;
import appeng.facade.FacadeContainer;
import appeng.helpers.AEMultiTile;
@@ -70,6 +71,7 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.ICLApi;
import appeng.me.GridConnection;
import appeng.parts.networking.PartCable;
import appeng.util.Platform;
@@ -1148,4 +1150,95 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
this.requiresDynamicRender = requiresDynamicRender;
}
@Override
public CableBusRenderState getRenderState()
{
// TODO: Inspect whether this is a problem. PartCable is the only implementor of IPartCable, which is not part of the public API
PartCable cable = (PartCable) getCenter();
CableBusRenderState renderState = new CableBusRenderState();
if( cable != null )
{
renderState.setCableColor( cable.getCableColor() );
renderState.setCableType( cable.getCableConnectionType() );
renderState.setCoreType( cable.getCableConnectionType().getCoreType() );
// Check each outgoing connection for the desired characteristics
for( EnumFacing facing : EnumFacing.values() )
{
// Is there a connection?
if( !cable.isConnected( facing ) )
{
continue;
}
// If there is one, check out which type it has, but default to this cable's type
AECableType connectionType = cable.getCableConnectionType();
// Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself
// Dense cables however also respect the adjacent cable-type since their outgoing connection
// point would look too big for other cable types
BlockPos adjacentPos = this.getTile().getPos().offset( facing );
TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos );
if( adjacentTe instanceof IGridHost )
{
if( !( adjacentTe instanceof IPartHost ) || cable.getCableConnectionType() == AECableType.DENSE )
{
IGridHost gridHost = (IGridHost) adjacentTe;
connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) );
}
}
// Check if the adjacent TE is a cable bus or not
if( adjacentTe instanceof IPartHost )
{
renderState.getCableBusAdjacent().add( facing );
}
renderState.getConnectionTypes().put( facing, connectionType );
}
// Collect the number of channels used per side
// We have to do this even for non-smart cables since a glass cable can display a connection as smart if the adjacent tile requires it
for( EnumFacing facing : EnumFacing.values() )
{
int channels = cable.getChannelsOnSide( facing );
renderState.getChannelsOnSide().put( facing, channels );
}
}
for( EnumFacing facing : EnumFacing.values() )
{
IPart part = getPart( facing );
if( part == null )
{
continue;
}
if( part instanceof IGridHost )
{
// Some attachments want a thicker cable than glass, account for that
IGridHost gridHost = (IGridHost) part;
AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL );
if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) )
{
renderState.setCoreType( CableCoreType.COVERED );
}
int length = (int) part.getCableConnectionLength( null );
if( length > 0 && length <= 8 )
{
renderState.getAttachmentConnections().put( facing, length );
}
}
renderState.getAttachments().put( facing, part.getStaticModels() );
}
return renderState;
}
}
@@ -35,6 +35,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
public interface ICableBusContainer
@@ -66,4 +67,7 @@ public interface ICableBusContainer
void randomDisplayTick( World world, BlockPos pos, Random r );
int getLightValue();
CableBusRenderState getRenderState();
}
@@ -33,6 +33,7 @@ import net.minecraft.world.World;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
public class NullCableBusContainer implements ICableBusContainer
@@ -115,4 +116,11 @@ public class NullCableBusContainer implements ICableBusContainer
{
return 0;
}
@Override
public CableBusRenderState getRenderState()
{
return new CableBusRenderState();
}
}
@@ -31,6 +31,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -58,6 +59,7 @@ import appeng.api.util.AEPartLocation;
import appeng.core.settings.TickRates;
import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.hooks.TickHandler;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.PartBasicState;
import appeng.server.ServerHelper;
@@ -69,6 +71,14 @@ import appeng.util.item.AEItemStack;
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable<TickRateModulation>
{
private static final PlaneModels MODELS = new PlaneModels( "part/annihilation_plane_", "part/annihilation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private final BaseActionSource mySrc = new MachineSource( this );
private boolean isAccepting = true;
private boolean breaking = false;
@@ -128,6 +138,78 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
}
/**
* @return An object describing which adjacent planes this plane connects to visually.
*/
public PlaneConnections getConnections()
{
final EnumFacing facingRight, facingUp;
AEPartLocation location = getSide();
switch( location )
{
case UP:
facingRight = EnumFacing.EAST;
facingUp = EnumFacing.NORTH;
break;
case DOWN:
facingRight = EnumFacing.WEST;
facingUp = EnumFacing.NORTH;
break;
case NORTH:
facingRight = EnumFacing.WEST;
facingUp = EnumFacing.UP;
break;
case SOUTH:
facingRight = EnumFacing.EAST;
facingUp = EnumFacing.UP;
break;
case WEST:
facingRight = EnumFacing.SOUTH;
facingUp = EnumFacing.UP;
break;
case EAST:
facingRight = EnumFacing.NORTH;
facingUp = EnumFacing.UP;
break;
default:
case INTERNAL:
return PlaneConnections.of( false, false, false, false );
}
boolean left = false, right = false, down = false, up = false;
final IPartHost host = this.getHost();
if( host != null )
{
final TileEntity te = host.getTile();
final BlockPos pos = te.getPos();
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) )
{
left = true;
}
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) )
{
right = true;
}
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) )
{
down = true;
}
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) )
{
up = true;
}
}
return PlaneConnections.of( up, right, down, left );
}
@Override
public void onNeighborChanged()
{
@@ -235,6 +317,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
* Stores an {@link ItemStack} inside the network.
*
* @param item {@link ItemStack} to store
*
* @return the leftover items, which could not be stored inside the network
*/
private IAEItemStack storeItemStack( final ItemStack item )
@@ -265,6 +348,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
*
* @param entityItem the entity to update or destroy
* @param overflow the leftover {@link IAEItemStack}
*
* @return true, if the entity was changed otherwise false.
*/
private boolean handleOverflow( final EntityItem entityItem, final IAEItemStack overflow )
@@ -496,4 +580,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
this.spawnOverflow( overflow );
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
}
@@ -19,6 +19,8 @@
package appeng.parts.automation;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -26,6 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.config.Actionable;
@@ -51,10 +54,12 @@ import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge;
import appeng.helpers.MultiCraftingTracker;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@@ -63,6 +68,24 @@ import appeng.util.item.AEItemStack;
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_off" )
);
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_on" )
);
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/export_bus_has_channel" )
);
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
private final BaseActionSource mySrc;
private long itemToSend = 1;
@@ -337,4 +360,22 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
this.nextSlot = ( this.nextSlot + x ) % this.availableSlots();
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -37,6 +37,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -73,6 +74,7 @@ import appeng.api.util.IConfigManager;
import appeng.core.AEConfig;
import appeng.core.sync.GuiBridge;
import appeng.helpers.IPriorityHost;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.inventory.AppEngInternalAEInventory;
@@ -84,6 +86,15 @@ import appeng.util.prioitylist.PrecisePriorityList;
public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>
{
private static final PlaneModels MODELS = new PlaneModels( "part/formation_plane_", "part/formation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
private int priority = 0;
@@ -262,6 +273,79 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
}
// TODO: Consolidate this with the impl in PartAnnihilationPlane
/**
* @return An object describing which adjacent planes this plane connects to visually.
*/
public PlaneConnections getConnections()
{
final EnumFacing facingRight, facingUp;
AEPartLocation location = getSide();
switch( location )
{
case UP:
facingRight = EnumFacing.EAST;
facingUp = EnumFacing.NORTH;
break;
case DOWN:
facingRight = EnumFacing.WEST;
facingUp = EnumFacing.NORTH;
break;
case NORTH:
facingRight = EnumFacing.WEST;
facingUp = EnumFacing.UP;
break;
case SOUTH:
facingRight = EnumFacing.EAST;
facingUp = EnumFacing.UP;
break;
case WEST:
facingRight = EnumFacing.SOUTH;
facingUp = EnumFacing.UP;
break;
case EAST:
facingRight = EnumFacing.NORTH;
facingUp = EnumFacing.UP;
break;
default:
case INTERNAL:
return PlaneConnections.of( false, false, false, false );
}
boolean left = false, right = false, down = false, up = false;
final IPartHost host = this.getHost();
if( host != null )
{
final TileEntity te = host.getTile();
final BlockPos pos = te.getPos();
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) )
{
left = true;
}
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) )
{
right = true;
}
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) )
{
down = true;
}
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) )
{
up = true;
}
}
return PlaneConnections.of( up, right, down, left );
}
@Override
public void onNeighborChanged()
{
@@ -525,4 +609,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
{
// nope!
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
}
@@ -26,6 +26,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
@@ -34,11 +35,20 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation;
import appeng.items.parts.PartModels;
public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
{
private static final PlaneModels MODELS = new PlaneModels( "part/identity_annihilation_plane_", "part/identity_annihilation_plane_on_" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private static final float SILK_TOUCH_FACTOR = 16;
public PartIdentityAnnihilationPlane( final ItemStack is )
@@ -93,4 +103,11 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
return super.obtainBlockDrops( w, pos );
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( getConnections(), isPowered(), isActive() );
}
}
@@ -19,9 +19,14 @@
package appeng.parts.automation;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
@@ -43,9 +48,11 @@ import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@@ -55,6 +62,24 @@ import appeng.util.item.AEItemStack;
public class PartImportBus extends PartSharedItemBus implements IInventoryDestination
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/import_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_off" )
);
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_on" )
);
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" )
);
private final BaseActionSource source;
private IMEInventory<IAEItemStack> destination = null;
private IAEItemStack lastItemChecked = null;
@@ -294,4 +319,22 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
{
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -20,8 +20,11 @@ package appeng.parts.automation;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
@@ -30,6 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -67,8 +71,10 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
@@ -78,6 +84,24 @@ import appeng.util.Platform;
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
{
@PartModels
public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_off" );
@PartModels
public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_on" );
@PartModels
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_off" );
@PartModels
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_on" );
@PartModels
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_has_channel" );
public static final List<ResourceLocation> MODEL_OFF_OFF = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODEL_OFF_ON = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODEL_OFF_HAS_CHANNEL = ImmutableList.of( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL );
public static final List<ResourceLocation> MODEL_ON_OFF = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODEL_ON_ON = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODEL_ON_HAS_CHANNEL = ImmutableList.of( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL );
private static final int FLAG_ON = 4;
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 1 );
@@ -142,7 +166,8 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
}
private boolean isLevelEmitterOn()
// TODO: Make private again
public boolean isLevelEmitterOn()
{
if( Platform.isClient() )
{
@@ -534,4 +559,21 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( isActive() && isPowered() )
{
return isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL;
}
else if( isPowered() )
{
return isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON;
}
else
{
return isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF;
}
}
}
@@ -0,0 +1,104 @@
package appeng.parts.automation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.EnumFacing;
import appeng.client.render.cablebus.CubeBuilder;
/**
* Built-in model for annihilation planes that supports connected textures.
*/
public class PlaneBakedModel implements IBakedModel
{
private final TextureAtlasSprite frontTexture;
private final List<BakedQuad> quads;
PlaneBakedModel( VertexFormat format, TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture,
PlaneConnections connections )
{
this.frontTexture = frontTexture;
List<BakedQuad> quads = new ArrayList<>( 4 * 6 );
CubeBuilder builder = new CubeBuilder( format, quads );
builder.setTextures( sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture );
// Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front,
// The X-axis points left
int minX = connections.isRight() ? 0 : 1;
int maxX = connections.isLeft() ? 16 : 15;
int minY = connections.isDown() ? 0 : 1;
int maxY = connections.isUp() ? 16 : 15;
builder.addCube( minX, minY, 0, maxX, maxY, 1 );
this.quads = ImmutableList.copyOf( quads );
}
@Override
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
{
if( side == null )
{
return quads;
}
else
{
return Collections.emptyList();
}
}
@Override
public boolean isAmbientOcclusion()
{
return false;
}
@Override
public boolean isGui3d()
{
return false;
}
@Override
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return frontTexture;
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return ItemCameraTransforms.DEFAULT;
}
@Override
public ItemOverrideList getOverrides()
{
return ItemOverrideList.NONE;
}
}
@@ -0,0 +1,121 @@
package appeng.parts.automation;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Strings;
/**
* Models in which directions - looking at the front face - a plane (annihilation, formation, etc.) is connected to other planes of the same type.
*/
public final class PlaneConnections
{
private final boolean up;
private final boolean right;
private final boolean down;
private final boolean left;
private static final int BITMASK_UP = 8;
private static final int BITMASK_RIGHT = 4;
private static final int BITMASK_DOWN = 2;
private static final int BITMASK_LEFT = 1;
public static final List<PlaneConnections> PERMUTATIONS = generatePermutations();
private static List<PlaneConnections> generatePermutations()
{
List<PlaneConnections> connections = new ArrayList<>( 16 );
for( int i = 0; i < 16; i++ )
{
boolean up = ( i & BITMASK_UP ) != 0;
boolean right = ( i & BITMASK_RIGHT ) != 0;
boolean down = ( i & BITMASK_DOWN ) != 0;
boolean left = ( i & BITMASK_LEFT ) != 0;
connections.add( new PlaneConnections( up, right, down, left ) );
}
return connections;
}
private PlaneConnections( boolean up, boolean right, boolean down, boolean left )
{
this.up = up;
this.right = right;
this.down = down;
this.left = left;
}
public static PlaneConnections of( boolean up, boolean right, boolean down, boolean left )
{
return PERMUTATIONS.get( getIndex( up, right, down, left ) );
}
public boolean isUp()
{
return up;
}
public boolean isRight()
{
return right;
}
public boolean isDown()
{
return down;
}
public boolean isLeft()
{
return left;
}
// The combination of connections expressed as a number ranging from [0,15]
public int getIndex()
{
return getIndex( up, right, down, left );
}
private static int getIndex( boolean up, boolean right, boolean down, boolean left )
{
return ( up ? BITMASK_UP : 0 ) + ( right ? BITMASK_RIGHT : 0 ) + ( left ? BITMASK_LEFT : 0 ) + ( down ? BITMASK_DOWN : 0 );
}
// Returns a suffix that expresses the connection states as a string
public String getFilenameSuffix()
{
String suffix = Integer.toBinaryString( getIndex() );
return Strings.padStart(suffix, 4, '0');
}
@Override
public boolean equals( Object o )
{
if( this == o )
{
return true;
}
if( o == null || getClass() != o.getClass() )
{
return false;
}
PlaneConnections that = (PlaneConnections) o;
return up == that.up && right == that.right && down == that.down && left == that.left;
}
@Override
public int hashCode()
{
int result = ( up ? 1 : 0 );
result = 31 * result + ( right ? 1 : 0 );
result = 31 * result + ( down ? 1 : 0 );
result = 31 * result + ( left ? 1 : 0 );
return result;
}
}
@@ -0,0 +1,66 @@
package appeng.parts.automation;
import java.util.Collection;
import java.util.Collections;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
/**
* Built-in model for annihilation planes that supports connected textures.
*/
public class PlaneModel implements IModel
{
private final ResourceLocation frontTexture;
private final ResourceLocation sidesTexture;
private final ResourceLocation backTexture;
private final PlaneConnections connections;
public PlaneModel( ResourceLocation frontTexture, ResourceLocation sidesTexture, ResourceLocation backTexture, PlaneConnections connections )
{
this.frontTexture = frontTexture;
this.sidesTexture = sidesTexture;
this.backTexture = backTexture;
this.connections = connections;
}
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.emptyList();
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Lists.newArrayList( frontTexture, sidesTexture, backTexture );
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
TextureAtlasSprite frontSprite = bakedTextureGetter.apply( frontTexture );
TextureAtlasSprite sidesSprite = bakedTextureGetter.apply( sidesTexture );
TextureAtlasSprite backSprite = bakedTextureGetter.apply( backTexture );
return new PlaneBakedModel( format, frontSprite, sidesSprite, backSprite, connections );
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
}
}
@@ -0,0 +1,79 @@
package appeng.parts.automation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
/**
* Contains a mapping from a Plane's connections to the models to use for that state.
*/
class PlaneModels
{
public static final ResourceLocation MODEL_CHASSIS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_off" );
public static final ResourceLocation MODEL_CHASSIS_ON = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_on" );
public static final ResourceLocation MODEL_CHASSIS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_has_channel" );
private final Map<PlaneConnections, List<ResourceLocation>> modelsOff;
private final Map<PlaneConnections, List<ResourceLocation>> modelsOn;
private final Map<PlaneConnections, List<ResourceLocation>> modelsHasChannel;
public PlaneModels( String prefixOff, String prefixOn )
{
Map<PlaneConnections, List<ResourceLocation>> modelsOff = new HashMap<>();
Map<PlaneConnections, List<ResourceLocation>> modelsOn = new HashMap<>();
Map<PlaneConnections, List<ResourceLocation>> modelsHasChannel = new HashMap<>();
for( PlaneConnections permutation : PlaneConnections.PERMUTATIONS )
{
ResourceLocation planeOff = new ResourceLocation( AppEng.MOD_ID, prefixOff + permutation.getFilenameSuffix() );
ResourceLocation planeOn = new ResourceLocation( AppEng.MOD_ID, prefixOn + permutation.getFilenameSuffix() );
modelsOff.put( permutation, ImmutableList.of( MODEL_CHASSIS_OFF, planeOff ) );
modelsOn.put( permutation, ImmutableList.of( MODEL_CHASSIS_ON, planeOff ) );
modelsHasChannel.put( permutation, ImmutableList.of( MODEL_CHASSIS_HAS_CHANNEL, planeOn ) );
}
this.modelsOff = ImmutableMap.copyOf( modelsOff );
this.modelsOn = ImmutableMap.copyOf( modelsOn );
this.modelsHasChannel = ImmutableMap.copyOf( modelsHasChannel );
}
public List<ResourceLocation> getModel( PlaneConnections connections, boolean hasPower, boolean hasChannel )
{
if( hasPower && hasChannel )
{
return modelsHasChannel.get( connections );
}
else if( hasPower )
{
return modelsOn.get( connections );
}
else
{
return modelsOff.get( connections );
}
}
public List<ResourceLocation> getModels()
{
List<ResourceLocation> result = new ArrayList<>();
modelsOff.values().forEach( result::addAll );
modelsOn.values().forEach( result::addAll );
modelsHasChannel.values().forEach( result::addAll );
return result;
}
}
@@ -20,30 +20,22 @@ package appeng.parts.misc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.client.BakingPipeline;
import appeng.api.networking.IGridNode;
import appeng.api.parts.BusSupport;
import appeng.api.parts.IPart;
@@ -52,8 +44,6 @@ import appeng.api.parts.IPartHost;
import appeng.api.parts.PartItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.client.render.model.ModelsCache;
import appeng.core.AppEng;
public class PartCableAnchor implements IPart
@@ -238,11 +228,4 @@ public class PartCableAnchor implements IPart
return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE;
}
@Override
@SideOnly( Side.CLIENT )
public List<BakedQuad> getOrBakeQuads( BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand )
{
return rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadBakedModel( new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor" ) ).getQuads( state, side, rand ), null, state, mySide.getFacing(), rand );
}
}
@@ -22,6 +22,7 @@ package appeng.parts.misc;
import java.util.EnumSet;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.EntityPlayer;
@@ -33,6 +34,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
@@ -57,11 +59,13 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.parts.PartBasicState;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
@@ -72,6 +76,23 @@ import appeng.util.inv.IInventoryDestination;
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/interface_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_off" )
);
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_on" )
);
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_has_channel" )
);
private final DualityInterface duality = new DualityInterface( this.getProxy(), this );
@Reflected
@@ -405,4 +426,22 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
{
return null;
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -19,13 +19,27 @@
package appeng.parts.misc;
import net.minecraft.item.ItemStack;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
public class PartInvertedToggleBus extends PartToggleBus
{
@PartModels
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/inverted_toggle_bus_base" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(MODEL_BASE, MODEL_STATUS_OFF);
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(MODEL_BASE, MODEL_STATUS_ON);
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
@Reflected
public PartInvertedToggleBus( final ItemStack is )
{
@@ -41,4 +55,22 @@ public class PartInvertedToggleBus extends PartToggleBus
{
return !super.getIntention();
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( hasRedstoneFlag() && isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( hasRedstoneFlag() && isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -23,12 +23,15 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
@@ -64,12 +67,14 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.stats.Achievements;
import appeng.core.sync.GuiBridge;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEMonitorIInventory;
@@ -88,6 +93,24 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
* IPipeConnection
*/, IPriorityHost
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_off" )
);
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_on" )
);
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" )
);
private final BaseActionSource mySrc;
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
private int priority = 0;
@@ -530,4 +553,22 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
// nope!
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -23,16 +23,14 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.util.ResourceLocation;
import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnection;
@@ -42,7 +40,9 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.PartBasicState;
import appeng.util.Platform;
@@ -50,6 +50,20 @@ import appeng.util.Platform;
public class PartToggleBus extends PartBasicState
{
@PartModels
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_base" );
@PartModels
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_off" );
@PartModels
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_on" );
@PartModels
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_has_channel" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(MODEL_BASE, MODEL_STATUS_OFF);
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(MODEL_BASE, MODEL_STATUS_ON);
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
private static final int REDSTONE_FLAG = 4;
private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
private IGridConnection connection;
@@ -72,6 +86,10 @@ public class PartToggleBus extends PartBasicState
return cf | ( this.getIntention() ? REDSTONE_FLAG : 0 );
}
public boolean hasRedstoneFlag() {
return (getClientFlags() & REDSTONE_FLAG) == REDSTONE_FLAG;
}
protected boolean getIntention()
{
return this.getHost().hasRedstone( this.getSide() );
@@ -202,4 +220,21 @@ public class PartToggleBus extends PartBasicState
{
return this.outerProxy;
}
@Override
public List<ResourceLocation> getStaticModels()
{
if( hasRedstoneFlag() && isActive() && isPowered() )
{
return MODELS_HAS_CHANNEL;
}
else if( hasRedstoneFlag() && isPowered() )
{
return MODELS_ON;
}
else
{
return MODELS_OFF;
}
}
}
@@ -20,31 +20,18 @@ package appeng.parts.networking;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.ImmutableSet;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.client.BakingPipeline;
import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IParts;
import appeng.api.implementations.parts.IPartCable;
@@ -53,7 +40,6 @@ import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.parts.BusSupport;
import appeng.api.parts.ICustomCableConnection;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
@@ -61,10 +47,6 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IReadOnlyCollection;
import appeng.client.render.model.ModelsCache;
import appeng.client.render.model.pipeline.FacingQuadRotator;
import appeng.client.render.model.pipeline.MatVecApplicator;
import appeng.client.render.model.pipeline.TypeTransformer;
import appeng.items.parts.ItemMultiPart;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
@@ -401,86 +383,16 @@ public class PartCable extends AEBasePart implements IPartCable
return !myC.equals( this.getConnections() ) || wasPowered != this.powered || channelsChanged;
}
@Override
@SideOnly( Side.CLIENT )
public List<BakedQuad> getOrBakeQuads( BakingPipeline rotatingPipeline, IBlockState state, EnumFacing side, long rand )
{
List<BakedQuad> elements = new ArrayList<>();
if( isStraight( getHost(), connections ) )
{
EnumFacing facing = getConnections().contains( AEPartLocation.DOWN ) ? EnumFacing.DOWN : getConnections().contains( AEPartLocation.NORTH ) ? EnumFacing.NORTH : getConnections().contains( AEPartLocation.EAST ) ? EnumFacing.EAST : EnumFacing.NORTH;
elements.addAll( rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getStraightModel(), propertiesForModel( facing ) ), getCableConnectionType().getStraightModel(), propertyTextureGetter( propertiesForModel( facing ) ) ).getQuads( state, side, rand ), null, state, connections.contains( AEPartLocation.DOWN ) ? EnumFacing.DOWN : connections.contains( AEPartLocation.NORTH ) ? EnumFacing.NORTH : connections.contains( AEPartLocation.EAST ) ? EnumFacing.EAST : EnumFacing.NORTH, rand ) );
}
else
{
elements.addAll( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getModel(), propertiesForModel( null ) ), getCableConnectionType().getModel(), propertyTextureGetter( propertiesForModel( null ) ) ).getQuads( state, side, rand ) );
for( EnumFacing facing : EnumFacing.values() )
{
if( isConnected( facing ) || getHost().getPart( facing ) != null )
{
float f = 4;
if( getHost().getPart( facing ) != null )
{
f = getHost().getPart( facing ).getCableConnectionLength( this.getCableConnectionType() );
}
else
{
TileEntity to = getHost().getTile().getWorld().getTileEntity( getHost().getTile().getPos().offset( facing ) );
if( to instanceof ICustomCableConnection )
{
f = ( (ICustomCableConnection) to ).getCableConnectionLength( this.getCableConnectionType() );
}
}
if( f != -1 )
{
elements.addAll( new BakingPipeline( TypeTransformer.quads2vecs, new MatVecApplicator( TRSRTransformation.toVecmath( new Matrix4f().scale( new Vector3f( 1, 1, f / 4f ) ) ) ), new FacingQuadRotator( facing ), TypeTransformer.vecs2quads ).pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getConnectionModel(), propertiesForModel( facing ) ), getCableConnectionType().getConnectionModel(), propertyTextureGetter( propertiesForModel( facing ) ) ).getQuads( state, side, rand ), null, state, facing, rand ) );
}
}
}
}
return elements;
}
/**
* A cable connection is considered straight, if there are exactly two connection points on opposite sides,
* and the cable has no attached busses.
*/
protected boolean isStraight( IPartHost host, final EnumSet<AEPartLocation> sides )
{
if (sides.size() != 2) {
return false;
}
Iterator<AEPartLocation> it = sides.iterator();
EnumFacing firstSide = it.next().getFacing();
EnumFacing secondSide = it.next().getFacing();
// Not on opposite sides
if (firstSide.getOpposite() != secondSide) {
return false;
}
// Check any other point for attachments
for( EnumFacing facing : EnumFacing.values() )
{
if( facing != firstSide && facing != secondSide )
{
// Check for an attached part here
if( host.getPart( facing ) != null )
{
return false;
}
}
}
return true;
}
int getChannelsOnSide( final int i )
{
return this.channelsOnSide[i];
}
public int getChannelsOnSide( EnumFacing side )
{
return this.channelsOnSide[side.ordinal()];
}
void setChannelsOnSide( final int i, final int channels )
{
this.channelsOnSide[i] = channels;
@@ -19,7 +19,9 @@
package appeng.parts.networking;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
@@ -27,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import appeng.api.config.Actionable;
import appeng.api.networking.GridFlags;
@@ -37,6 +40,8 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.AEBasePart;
@@ -45,6 +50,9 @@ import appeng.parts.AEBasePart;
public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
{
@PartModels
private static final List<ResourceLocation> MODELS = Collections.singletonList( new ResourceLocation( AppEng.MOD_ID, "part/quartz_fiber" ) );
private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", this.getProxy().getMachineRepresentation(), true );
public PartQuartzFiber( final ItemStack is )
@@ -210,4 +218,10 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
return demand;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS;
}
}
@@ -0,0 +1,60 @@
package appeng.parts.p2p;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
/**
* Helper for maintaining the models used for a variant of the P2P bus.
*/
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" );
private final List<ResourceLocation> modelsOff;
private final List<ResourceLocation> modelsOn;
private final List<ResourceLocation> modelsHasChannel;
public P2PModels( String frontModelPath )
{
ResourceLocation frontModel = new ResourceLocation( AppEng.MOD_ID, frontModelPath );
modelsOff = ImmutableList.of( MODEL_STATUS_OFF, frontModel );
modelsOn = ImmutableList.of( MODEL_STATUS_ON, frontModel );
modelsHasChannel = ImmutableList.of( MODEL_STATUS_HAS_CHANNEL, frontModel );
}
public List<ResourceLocation> getModel( boolean hasPower, boolean hasChannel )
{
if( hasPower && hasChannel )
{
return modelsHasChannel;
}
else if( hasPower )
{
return modelsOn;
}
else
{
return modelsOff;
}
}
public List<ResourceLocation> getModels() {
List<ResourceLocation> result = new ArrayList<>();
result.addAll( modelsOff );
result.addAll( modelsOn );
result.addAll( modelsHasChannel );
return result;
}
}
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import appeng.api.networking.IGridNode;
@@ -43,6 +44,7 @@ import appeng.core.settings.TickRates;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IBuildCraftTransport;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
import appeng.tile.inventory.AppEngNullInventory;
@@ -57,6 +59,14 @@ import appeng.util.inv.WrapperMCISidedInventory;
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPipeConnection, */ISidedInventory, IGridTickable
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_items" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private final LinkedList<IInventory> which = new LinkedList<IInventory>();
private int oldSize = 0;
private boolean requested;
@@ -412,4 +422,11 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
// {
// return this.side == with && type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
// }
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -20,12 +20,14 @@ package appeng.parts.p2p;
import java.io.IOException;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import appeng.api.networking.IGridNode;
@@ -35,12 +37,21 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.core.settings.TickRates;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTickable
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_light" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private int lastValue = 0;
private float opacity = -1;
@@ -213,4 +224,11 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
{
return 0.5f;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -27,17 +27,27 @@ import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_liquids" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
private static final FluidTankInfo[] ACTIVE_TANK = { new FluidTankInfo( null, 10000 ) };
private static final FluidTankInfo[] INACTIVE_TANK = { new FluidTankInfo( null, 0 ) };
@@ -292,4 +302,11 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
}
return INACTIVE_TANK;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -19,12 +19,15 @@
package appeng.parts.p2p;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -32,6 +35,7 @@ import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.util.Platform;
@@ -39,6 +43,14 @@ import appeng.util.Platform;
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_redstone" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private int power;
private boolean recursive = false;
@@ -195,4 +207,11 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
// :P
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -22,12 +22,14 @@ package appeng.parts.p2p;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnection;
@@ -42,6 +44,7 @@ import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.settings.TickRates;
import appeng.hooks.TickHandler;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.Connections;
import appeng.me.cache.helpers.TunnelConnection;
@@ -51,6 +54,14 @@ import appeng.me.helpers.AENetworkProxy;
public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements IGridTickable
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_me" );
@PartModels
public static List<ResourceLocation> getModels()
{
return MODELS.getModels();
}
private final Connections connection = new Connections( this );
private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
@@ -246,4 +257,11 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
}
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -20,6 +20,10 @@ package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
/**
@@ -36,6 +40,18 @@ import net.minecraft.item.ItemStack;
public abstract class AbstractPartDisplay extends AbstractPartReporting
{
// The base chassis of all display parts
@PartModels
protected static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/display_base" );
// Models that contain the status indicator light
@PartModels
protected static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/display_status_off" );
@PartModels
protected static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/display_status_on" );
@PartModels
protected static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/display_status_has_channel" );
public AbstractPartDisplay( final ItemStack is )
{
super( is, true );
@@ -20,22 +20,21 @@ package appeng.parts.reporting;
import java.io.IOException;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
@@ -52,7 +51,6 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation;
import appeng.client.ClientHelper;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
@@ -80,10 +78,6 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
private String lastHumanReadableText;
private boolean isLocked;
private IStackWatcher myWatcher;
@SideOnly( Side.CLIENT )
private boolean updateList;
@SideOnly( Side.CLIENT )
private Integer dspList;
@Reflected
public AbstractPartMonitor( final ItemStack is )
@@ -151,8 +145,6 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.configuredItem = null;
}
this.updateList = true;
return needRedraw;
}
@@ -246,34 +238,26 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
@Override
@SideOnly( Side.CLIENT )
protected void finalize() throws Throwable
public void renderDynamic( double x, double y, double z, float partialTicks, int destroyStage )
{
super.finalize();
if( this.dspList != null )
if( ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) != ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) )
{
GLAllocation.deleteDisplayLists( this.dspList );
return;
}
}
@Override
public boolean requireDynamicRender()
{
return true;
}
final IAEItemStack ais = (IAEItemStack) this.getDisplayed();
@Override
public IAEStack<?> getDisplayed()
{
return this.configuredItem;
}
if( ais == null )
{
return;
}
private void tesrRenderScreen( final VertexBuffer wr, final IAEItemStack ais )
{
// GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GlStateManager.pushMatrix();
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
final AEPartLocation d = this.getSide();
GL11.glTranslated( d.xOffset * 0.77, d.yOffset * 0.77, d.zOffset * 0.77 );
GL11.glTranslated( d.xOffset * 0.50, d.yOffset * 0.50, d.zOffset * 0.50 );
switch( d )
{
@@ -312,46 +296,33 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
break;
}
try
{
final ItemStack sis = ais.getItemStack();
sis.stackSize = 1;
final int br = 16 << 20 | 16 << 4;
final int var11 = br % 65536;
final int var12 = br / 65536;
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
GL11.glDisable( GL11.GL_LIGHTING );
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
// RenderHelper.enableGUIStandardItemLighting();
ClientHelper.proxy.doRenderItem( sis, this.getTile().getWorld() );
}
catch( final Exception e )
{
AELog.debug( e );
}
finally
{
GL11.glEnable( GL11.GL_LIGHTING );
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
}
GL11.glTranslatef( 0.0f, 0.14f, -0.24f );
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
ClientHelper.proxy.doRenderItem( ais.getItemStack() );
final long stackSize = ais.getStackSize();
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
// Render the item count
final FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
final int width = fr.getStringWidth( renderedStackSize );
GL11.glTranslatef( -0.5f * width, 0.0f, -1.0f );
GL11.glTranslatef( 0.0f, 0.17f, 0 );
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
GL11.glTranslatef( -0.5f * width, 0.0f, 0.5f );
fr.drawString( renderedStackSize, 0, 0, 0 );
// GL11.glPopAttrib();
GlStateManager.popMatrix();
}
@Override
public boolean requireDynamicRender()
{
return true;
}
@Override
public IAEStack<?> getDisplayed()
{
return this.configuredItem;
}
@Override
@@ -397,4 +368,42 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
{
return false;
}
protected List<ResourceLocation> selectModel(List<ResourceLocation> off, List<ResourceLocation> on, List<ResourceLocation> hasChannel,
List<ResourceLocation> lockedOff, List<ResourceLocation> lockedOn, List<ResourceLocation> lockedHasChannel) {
if( isActive() )
{
if( isLocked() )
{
return lockedHasChannel;
}
else
{
return hasChannel;
}
}
else if( isPowered() )
{
if( isLocked() )
{
return lockedOn;
}
else
{
return on;
}
}
else
{
if( isLocked() )
{
return lockedOff;
}
else
{
return off;
}
}
}
}
@@ -20,8 +20,11 @@ package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.api.util.AEColor;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
/**
@@ -36,6 +39,10 @@ import appeng.api.util.AEColor;
*/
public abstract class AbstractPartPanel extends AbstractPartReporting
{
@PartModels
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/monitor_base" );
public AbstractPartPanel( final ItemStack is )
{
super( is, false );
@@ -20,6 +20,7 @@ package appeng.parts.reporting;
import java.io.IOException;
import java.util.List;
import io.netty.buffer.ByteBuf;
@@ -28,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@@ -289,6 +291,22 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
}
}
protected List<ResourceLocation> selectModel( List<ResourceLocation> offModels, List<ResourceLocation> onModels, List<ResourceLocation> hasChannelModels )
{
if( isActive() )
{
return hasChannelModels;
}
else if( isPowered() )
{
return onModels;
}
else
{
return offModels;
}
}
public final int getClientFlags()
{
return this.clientFlags;
@@ -22,18 +22,23 @@ package appeng.parts.reporting;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@@ -42,6 +47,23 @@ import appeng.util.item.AEItemStack;
public class PartConversionMonitor extends AbstractPartMonitor
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_on" );
@PartModels
public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_locked_off" );
@PartModels
public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_locked_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public static final List<ResourceLocation> MODELS_LOCKED_OFF = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_LOCKED_ON = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_LOCKED_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_HAS_CHANNEL );
@Reflected
public PartConversionMonitor( final ItemStack is )
{
@@ -160,4 +182,12 @@ public class PartConversionMonitor extends AbstractPartMonitor
}
}
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL,
MODELS_LOCKED_OFF, MODELS_LOCKED_ON, MODELS_LOCKED_HAS_CHANNEL );
}
}
@@ -21,18 +21,33 @@ package appeng.parts.reporting;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.tile.inventory.AppEngInternalInventory;
public class PartCraftingTerminal extends AbstractPartTerminal
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/terminal_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/terminal_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
@Reflected
@@ -98,4 +113,11 @@ public class PartCraftingTerminal extends AbstractPartTerminal
}
return super.getInventoryByName( name );
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
}
}
@@ -19,14 +19,29 @@
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
public class PartDarkPanel extends AbstractPartPanel
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_dark_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_dark_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON );
@Reflected
public PartDarkPanel( final ItemStack is )
{
@@ -38,4 +53,11 @@ public class PartDarkPanel extends AbstractPartPanel
{
return this.getColor().mediumVariant;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return isPowered() ? MODELS_ON : MODELS_OFF;
}
}
@@ -19,17 +19,34 @@
package appeng.parts.reporting;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.items.parts.PartModels;
import appeng.util.Platform;
public class PartInterfaceTerminal extends AbstractPartDisplay
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/interface_terminal_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/interface_terminal_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public PartInterfaceTerminal( final ItemStack is )
{
super( is );
@@ -55,4 +72,11 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
return false;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
}
}
@@ -19,14 +19,29 @@
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
public class PartPanel extends AbstractPartPanel
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_bright_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_bright_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON );
@Reflected
public PartPanel( final ItemStack is )
{
@@ -39,4 +54,10 @@ public class PartPanel extends AbstractPartPanel
return this.getColor().whiteVariant;
}
@Override
public List<ResourceLocation> getStaticModels()
{
return isPowered() ? MODELS_ON : MODELS_OFF;
}
}
@@ -21,22 +21,37 @@ package appeng.parts.reporting;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartPatternTerminal extends AbstractPartTerminal
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/pattern_terminal_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/pattern_terminal_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
@@ -197,4 +212,10 @@ public class PartPatternTerminal extends AbstractPartTerminal
return super.getInventoryByName( name );
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
}
}
@@ -19,13 +19,27 @@
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
public class PartSemiDarkPanel extends AbstractPartPanel
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_medium_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_medium_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON );
@Reflected
public PartSemiDarkPanel( final ItemStack is )
@@ -40,4 +54,11 @@ public class PartSemiDarkPanel extends AbstractPartPanel
final int dark = this.getColor().mediumVariant;
return ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 );
}
@Override
public List<ResourceLocation> getStaticModels()
{
return isPowered() ? MODELS_ON : MODELS_OFF;
}
}
@@ -19,9 +19,16 @@
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
/**
@@ -33,9 +40,33 @@ import appeng.helpers.Reflected;
public class PartStorageMonitor extends AbstractPartMonitor
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_on" );
@PartModels
public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_locked_off" );
@PartModels
public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_locked_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public static final List<ResourceLocation> MODELS_LOCKED_OFF = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_LOCKED_ON = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_LOCKED_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_HAS_CHANNEL );
@Reflected
public PartStorageMonitor( final ItemStack is )
{
super( is );
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL,
MODELS_LOCKED_OFF, MODELS_LOCKED_ON, MODELS_LOCKED_HAS_CHANNEL );
}
}
@@ -19,14 +19,37 @@
package appeng.parts.reporting;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
public class PartTerminal extends AbstractPartTerminal
{
@PartModels
public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/crafting_terminal_off" );
@PartModels
public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/crafting_terminal_on" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public PartTerminal( final ItemStack is )
{
super( is );
}
@Override
public List<ResourceLocation> getStaticModels()
{
return selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
}
}