Colored Item Definitions

This commit is contained in:
AlgorithmX2 2014-01-24 10:30:57 -06:00
parent db67edffb8
commit 86e11d6e3f
6 changed files with 127 additions and 37 deletions

View file

@ -10,7 +10,8 @@ import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.util.AEItemDefinition;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.texture.ExtraTextures;
@ -92,15 +93,15 @@ public class RenderQNB extends BaseBlockRender
{
if ( tqb.isFormed() )
{
AEItemDefinition cabldef = AEApi.instance().parts().partCableGlass;
Item cable = cabldef.item();
AEColoredItemDefinition cabldef = AEApi.instance().parts().partCableGlass;
Item cable = cabldef.item( AEColor.Transparent );
AEItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
Item ccable = ccabldef.item();
AEColoredItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
Item ccable = ccabldef.item( AEColor.Transparent );
EnumSet<ForgeDirection> sides = tqb.getConnections();
renderCableAt( 0.11D, world, x, y, z, block, renderer, cable.getIconIndex( cabldef.stack( 1 ) ), 0.141D, sides );
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( 1 ) ), 0.1875D, tqb.getConnections() );
renderCableAt( 0.11D, world, x, y, z, block, renderer, cable.getIconIndex( cabldef.stack( AEColor.Transparent, 1 ) ), 0.141D, sides );
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( AEColor.Transparent, 1 ) ), 0.1875D, tqb.getConnections() );
}
float px = 2.0f / 16.0f;
@ -120,12 +121,13 @@ public class RenderQNB extends BaseBlockRender
}
else if ( tqb.isCorner() )
{
// renderCableAt(0.11D, world, x, y, z, block, modelId, renderer,
// renderCableAt(0.11D, world, x, y, z, block, modelId,
// renderer,
// AppEngTextureRegistry.Blocks.MECable.get(), true, 0.0D);
AEItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
Item ccable = ccabldef.item();
AEColoredItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
Item ccable = ccabldef.item( AEColor.Transparent );
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( 1 ) ), 0.05D, tqb.getConnections() );
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( AEColor.Transparent, 1 ) ), 0.05D, tqb.getConnections() );
float px = 4.0f / 16.0f;
float maxpx = 12.0f / 16.0f;

View file

@ -24,6 +24,7 @@ import appeng.api.networking.pathing.IPathingGrid;
import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.util.AEColor;
import appeng.api.util.AEItemDefinition;
import appeng.block.grindstone.BlockCrank;
import appeng.block.grindstone.BlockGrinder;
@ -66,8 +67,10 @@ import appeng.block.storage.BlockDrive;
import appeng.block.storage.BlockIOPort;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.DamagedItemDefinition;
import appeng.core.features.IAEFeature;
import appeng.core.features.registries.P2PTunnelRegistry;
import appeng.core.features.registries.entries.BasicCellHandler;
import appeng.core.features.registries.entries.CreativeCellHandler;
import appeng.core.localization.GuiText;
@ -182,10 +185,17 @@ public class Registration
}
else
{
for (Enum v : varients)
if ( varients[0] instanceof AEColor )
{
ItemStack is = ((ItemPart) partItem.item()).createPart( type, v );
f.set( parts, new DamagedItemDefinition( is ) );
ColoredItemDefinition def = new ColoredItemDefinition();
for (Enum v : varients)
{
ItemStack is = ((ItemPart) partItem.item()).createPart( type, v );
def.add( (AEColor) v, is );
}
f.set( parts, def );
}
}
}
@ -408,6 +418,9 @@ public class Registration
AEApi.instance().registries().matterCannon().registerAmmo( AEApi.instance().materials().materialMatterBall.stack( 1 ), 32.0 );
// default settings..
((P2PTunnelRegistry) AEApi.instance().registries().p2pTunnel()).configure();
NetworkRegistry.instance().registerGuiHandler( AppEng.instance, GuiBridge.GUI_Handler );
}
@ -455,7 +468,7 @@ public class Registration
// partStorageBus
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 1 );
Upgrades.INVERTER.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 1 );
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 3 );
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 5 );
// matter cannon
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 1 );

View file

@ -0,0 +1,65 @@
package appeng.core.features;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
public class ColoredItemDefinition implements AEColoredItemDefinition
{
ItemStack colors[] = new ItemStack[17];
@Override
public Item item(AEColor color)
{
ItemStack is = colors[color.ordinal()];
if ( is == null )
return null;
return is.getItem();
}
@Override
public ItemStack stack(AEColor color, int stackSize)
{
ItemStack is = colors[color.ordinal()];
if ( is == null )
return null;
return new ItemStack( is.getItem(), stackSize, is.getItemDamage() );
}
@Override
public boolean sameAs(AEColor color, ItemStack comparableItem)
{
ItemStack is = colors[color.ordinal()];
if ( comparableItem == null )
return false;
return comparableItem.getItem() == is.getItem() && comparableItem.getItemDamage() == is.getItemDamage();
}
public void add(AEColor v, ItemStack is)
{
colors[v.ordinal()] = is;
}
@Override
public Block block(AEColor color)
{
return null;
}
@Override
public Class<? extends TileEntity> entity(AEColor color)
{
return null;
}
}

View file

@ -141,7 +141,7 @@ public class PartCable extends AEBasePart implements IPartCable
return CableBusTextures.MECovered_Yellow.getIcon();
default:
}
return AEApi.instance().parts().partCableCovered.item().getIconIndex( AEApi.instance().parts().partCableCovered.stack( 1 ) );
return AEApi.instance().parts().partCableCovered.item( AEColor.Transparent ).getIconIndex( AEApi.instance().parts().partCableCovered.stack( AEColor.Transparent, 1 ) );
}
public Icon getSmartTexture(AEColor c)

View file

@ -66,7 +66,7 @@ public class PartDenseCable extends PartCable
public Icon getTexture(AEColor c)
{
if ( c == AEColor.Transparent )
return AEApi.instance().parts().partCableSmart.stack( 1 ).getIconIndex();
return AEApi.instance().parts().partCableSmart.stack( AEColor.Transparent, 1 ).getIconIndex();
return getSmartTexture( c );
}
@ -192,31 +192,40 @@ public class PartDenseCable extends PartCable
boolean isGlass = false;
AEColor myColor = getCableColor();
/*
* ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) == AECableType.GLASS && ccph.getPart(
* of.getOpposite() ) == null ) { isGlass = true; rh.setTexture( getGlassTexture( myColor = ccph.getColor() ) );
* } else if ( ccph == null && ghh != null && ghh.getCableConnectionType( of ) != AECableType.GLASS ) {
* rh.setTexture( getSmartTexture( myColor ) ); switch (of) { case DOWN: rh.setBounds( 3, 0, 3, 13, 4, 13 );
* break; case EAST: rh.setBounds( 12, 3, 3, 16, 13, 13 ); break; case NORTH: rh.setBounds( 3, 3, 0, 13, 13, 4
* ); break; case SOUTH: rh.setBounds( 3, 3, 12, 13, 13, 16 ); break; case UP: rh.setBounds( 3, 12, 3, 13, 16,
* 13 ); break; case WEST: rh.setBounds( 0, 3, 3, 4, 13, 13 ); break; default: return; } rh.renderBlock( x, y,
* z, renderer );
* ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) ==
* AECableType.GLASS && ccph.getPart( of.getOpposite() ) == null ) {
* isGlass = true; rh.setTexture( getGlassTexture( myColor =
* ccph.getColor() ) ); } else if ( ccph == null && ghh != null &&
* ghh.getCableConnectionType( of ) != AECableType.GLASS ) {
* rh.setTexture( getSmartTexture( myColor ) ); switch (of) { case DOWN:
* rh.setBounds( 3, 0, 3, 13, 4, 13 ); break; case EAST: rh.setBounds(
* 12, 3, 3, 16, 13, 13 ); break; case NORTH: rh.setBounds( 3, 3, 0, 13,
* 13, 4 ); break; case SOUTH: rh.setBounds( 3, 3, 12, 13, 13, 16 );
* break; case UP: rh.setBounds( 3, 12, 3, 13, 16, 13 ); break; case
* WEST: rh.setBounds( 0, 3, 3, 4, 13, 13 ); break; default: return; }
* rh.renderBlock( x, y, z, renderer );
*
* if ( true ) { setSmartConnectionRotations( of, renderer ); Icon defa = new TaughtIcon( getChannelTex(
* channels, false ).getIcon(), -0.2f ); Icon defb = new TaughtIcon( getChannelTex( channels, true ).getIcon(),
* -0.2f );
* if ( true ) { setSmartConnectionRotations( of, renderer ); Icon defa
* = new TaughtIcon( getChannelTex( channels, false ).getIcon(), -0.2f
* ); Icon defb = new TaughtIcon( getChannelTex( channels, true
* ).getIcon(), -0.2f );
*
* if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST ) { AEBaseBlock blk = (AEBaseBlock)
* rh.getBlock(); FlipableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); ico.setFlip(
* false, true ); }
* if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST ) {
* AEBaseBlock blk = (AEBaseBlock) rh.getBlock(); FlipableIcon ico =
* blk.getRendererInstance().getTexture( ForgeDirection.EAST );
* ico.setFlip( false, true ); }
*
* Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 ); Tessellator.instance.setColorOpaque_I(
* myColor.mediumVariant ); rh.setTexture( defa, defa, defa, defa, defa, defa ); renderAllFaces( (AEBaseBlock)
* rh.getBlock(), x, y, z, renderer );
* Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
* Tessellator.instance.setColorOpaque_I( myColor.mediumVariant );
* rh.setTexture( defa, defa, defa, defa, defa, defa ); renderAllFaces(
* (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
*
* Tessellator.instance.setColorOpaque_I( myColor.whiteVariant ); rh.setTexture( defb, defb, defb, defb, defb,
* defb ); renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
* Tessellator.instance.setColorOpaque_I( myColor.whiteVariant );
* rh.setTexture( defb, defb, defb, defb, defb, defb ); renderAllFaces(
* (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
*
* renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth =
* renderer.uvRotateBottom = renderer.uvRotateEast =
* renderer.uvRotateNorth = renderer.uvRotateSouth =
* renderer.uvRotateTop = renderer.uvRotateWest = 0; }
*
* rh.setTexture( getTexture( getCableColor() ) ); }

View file

@ -32,6 +32,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
public PartQuartzFiber(ItemStack is) {
super( PartQuartzFiber.class, is );
proxy.setIdlePowerUsage( 0 );
proxy.setFlags( GridFlags.CANNOT_CARRY );
}