Allow dying pocket computers too
This splits up the pocket computer textures and models into the frame (off, on, blinking), colour layer (normal, advanced, custom) and modem light.
@ -22,6 +22,24 @@ public interface IPocketAccess
|
||||
@Nullable
|
||||
Entity getEntity();
|
||||
|
||||
/**
|
||||
* Get the colour of this pocket computer as a RGB number.
|
||||
*
|
||||
* @return The colour this pocket computer is. This will be a RGB colour between {@code 0x000000} and
|
||||
* {@code 0xFFFFFF} or -1 if it has no colour.
|
||||
* @see #setColour(int)
|
||||
*/
|
||||
int getColour();
|
||||
|
||||
/**
|
||||
* Set the colour of the pocket computer to a RGB number.
|
||||
*
|
||||
* @param colour The colour this pocket computer should be changed to. This should be a RGB colour between
|
||||
* {@code 0x000000} and {@code 0xFFFFFF} or -1 to reset to the default colour.
|
||||
* @see #getColour()
|
||||
*/
|
||||
void setColour( int colour );
|
||||
|
||||
/**
|
||||
* Get the colour of this pocket computer's light as a RGB number.
|
||||
*
|
||||
|
@ -9,6 +9,7 @@ package dan200.computercraft.client.proxy;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.*;
|
||||
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
@ -111,61 +112,66 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
private ModelResourceLocation pocket_computer_off = new ModelResourceLocation( "computercraft:pocket_computer", "inventory" );
|
||||
private ModelResourceLocation pocket_computer_on = new ModelResourceLocation( "computercraft:pocket_computer_on", "inventory" );
|
||||
private ModelResourceLocation pocket_computer_blinking = new ModelResourceLocation( "computercraft:pocket_computer_blinking", "inventory" );
|
||||
private ModelResourceLocation advanced_pocket_computer_off = new ModelResourceLocation( "computercraft:advanced_pocket_computer_off", "inventory" );
|
||||
private ModelResourceLocation advanced_pocket_computer_off = new ModelResourceLocation( "computercraft:advanced_pocket_computer", "inventory" );
|
||||
private ModelResourceLocation advanced_pocket_computer_on = new ModelResourceLocation( "computercraft:advanced_pocket_computer_on", "inventory" );
|
||||
private ModelResourceLocation advanced_pocket_computer_blinking = new ModelResourceLocation( "computercraft:advanced_pocket_computer_blinking", "inventory" );
|
||||
private ModelResourceLocation colour_pocket_computer_off = new ModelResourceLocation( "computercraft:pocket_computer_colour", "inventory" );
|
||||
private ModelResourceLocation colour_pocket_computer_on = new ModelResourceLocation( "computercraft:pocket_computer_colour_on", "inventory" );
|
||||
private ModelResourceLocation colour_pocket_computer_blinking = new ModelResourceLocation( "computercraft:pocket_computer_colour_blinking", "inventory" );
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
ItemPocketComputer itemPocketComputer = (ItemPocketComputer)stack.getItem();
|
||||
ItemPocketComputer itemPocketComputer = (ItemPocketComputer) stack.getItem();
|
||||
ComputerState state = itemPocketComputer.getState( stack );
|
||||
if( itemPocketComputer.getColour( stack ) == -1 )
|
||||
{
|
||||
switch( itemPocketComputer.getFamily( stack ) )
|
||||
{
|
||||
case Advanced:
|
||||
{
|
||||
switch( itemPocketComputer.getState( stack ) )
|
||||
switch( state )
|
||||
{
|
||||
case Off:
|
||||
default:
|
||||
{
|
||||
return advanced_pocket_computer_off;
|
||||
}
|
||||
case On:
|
||||
{
|
||||
return advanced_pocket_computer_on;
|
||||
}
|
||||
case Blinking:
|
||||
{
|
||||
return advanced_pocket_computer_blinking;
|
||||
}
|
||||
}
|
||||
}
|
||||
case Normal:
|
||||
default:
|
||||
{
|
||||
switch( itemPocketComputer.getState( stack ) )
|
||||
switch( state )
|
||||
{
|
||||
case Off:
|
||||
default:
|
||||
{
|
||||
return pocket_computer_off;
|
||||
}
|
||||
case On:
|
||||
{
|
||||
return pocket_computer_on;
|
||||
}
|
||||
case Blinking:
|
||||
{
|
||||
return pocket_computer_blinking;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( state )
|
||||
{
|
||||
case Off:
|
||||
default:
|
||||
return colour_pocket_computer_off;
|
||||
case On:
|
||||
return colour_pocket_computer_on;
|
||||
case Blinking:
|
||||
return colour_pocket_computer_blinking;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new String[] {
|
||||
"pocket_computer", "pocket_computer_on", "pocket_computer_blinking",
|
||||
"advanced_pocket_computer_off", "advanced_pocket_computer_on", "advanced_pocket_computer_blinking",
|
||||
"advanced_pocket_computer", "advanced_pocket_computer_on", "advanced_pocket_computer_blinking",
|
||||
"pocket_computer_colour", "pocket_computer_colour_on", "pocket_computer_colour_blinking",
|
||||
} );
|
||||
|
||||
// Setup client forge handlers
|
||||
@ -188,13 +194,27 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
mc.getItemColors().registerItemColorHandler( new IItemColor()
|
||||
{
|
||||
@Override
|
||||
public int getColorFromItemstack( @Nonnull ItemStack stack, int layout )
|
||||
public int getColorFromItemstack( @Nonnull ItemStack stack, int layer )
|
||||
{
|
||||
if( layout != 1 ) return 0xFFFFFF;
|
||||
|
||||
switch( layer )
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
return 0xFFFFFF;
|
||||
case 1:
|
||||
{
|
||||
// Frame colour
|
||||
int colour = ComputerCraft.Items.pocketComputer.getColour( stack );
|
||||
return colour == -1 ? 0xFFFFFF : colour;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// Light colour
|
||||
int colour = ComputerCraft.Items.pocketComputer.getLightState( stack );
|
||||
return colour == -1 ? Colour.Black.getHex() : colour;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, ComputerCraft.Items.pocketComputer );
|
||||
|
||||
// Setup renderers
|
||||
|
@ -38,6 +38,19 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
return m_entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour()
|
||||
{
|
||||
return ComputerCraft.Items.pocketComputer.getColour( m_stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColour( int colour )
|
||||
{
|
||||
ComputerCraft.Items.pocketComputer.setColourDirect( m_stack, colour );
|
||||
updateUpgradeNBTData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLight()
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
@ -38,7 +39,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
public class ItemPocketComputer extends Item implements IComputerItem, IMedia, IColouredItem
|
||||
{
|
||||
public ItemPocketComputer()
|
||||
{
|
||||
@ -48,7 +49,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
}
|
||||
|
||||
public ItemStack create( int id, String label, ComputerFamily family, IPocketUpgrade upgrade )
|
||||
public ItemStack create( int id, String label, int colour, ComputerFamily family, IPocketUpgrade upgrade )
|
||||
{
|
||||
// Ignore types we can't handle
|
||||
if( family != ComputerFamily.Normal && family != ComputerFamily.Advanced )
|
||||
@ -76,6 +77,14 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
{
|
||||
result.setStackDisplayName( label );
|
||||
}
|
||||
|
||||
if( colour != -1 )
|
||||
{
|
||||
NBTTagCompound tag = result.getTagCompound();
|
||||
if( tag == null ) result.setTagCompound( tag = new NBTTagCompound() );
|
||||
tag.setInteger( "colour", colour );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -88,10 +97,10 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
|
||||
private void getSubItems( List<ItemStack> list, ComputerFamily family )
|
||||
{
|
||||
list.add( PocketComputerItemFactory.create( -1, null, family, null ) );
|
||||
list.add( PocketComputerItemFactory.create( -1, null, -1, family, null ) );
|
||||
for (IPocketUpgrade upgrade : ComputerCraft.getVanillaPocketUpgrades())
|
||||
{
|
||||
list.add( PocketComputerItemFactory.create( -1, null, family, upgrade ) );
|
||||
list.add( PocketComputerItemFactory.create( -1, null, -1, family, upgrade ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -525,4 +534,33 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour( ItemStack stack )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag != null && tag.hasKey( "colour", Constants.NBT.TAG_ANY_NUMERIC ) ? tag.getInteger( "colour" ) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setColour( ItemStack stack, int colour )
|
||||
{
|
||||
ItemStack copy = stack.copy();
|
||||
setColourDirect( copy, colour );
|
||||
return copy;
|
||||
}
|
||||
|
||||
public void setColourDirect( ItemStack stack, int colour )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if( colour == -1 )
|
||||
{
|
||||
if( tag != null ) tag.removeTag( "colour" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( tag == null ) stack.setTagCompound( tag = new NBTTagCompound() );
|
||||
tag.setInteger( "colour", colour );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PocketComputerItemFactory
|
||||
{
|
||||
public static ItemStack create( int id, String label, ComputerFamily family, IPocketUpgrade upgrade )
|
||||
public static ItemStack create( int id, String label, int colour, ComputerFamily family, IPocketUpgrade upgrade )
|
||||
{
|
||||
ItemPocketComputer computer = ComputerCraft.Items.pocketComputer;
|
||||
switch( family )
|
||||
@ -21,7 +21,7 @@ public class PocketComputerItemFactory
|
||||
case Normal:
|
||||
case Advanced:
|
||||
{
|
||||
return computer.create( id, label, family, upgrade );
|
||||
return computer.create( id, label, colour, family, upgrade );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -33,7 +33,7 @@ public class PocketComputerUpgradeRecipe implements IRecipe
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return PocketComputerItemFactory.create( -1, null, ComputerFamily.Normal, null );
|
||||
return PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,7 +111,8 @@ public class PocketComputerUpgradeRecipe implements IRecipe
|
||||
ComputerFamily family = itemComputer.getFamily( computer );
|
||||
int computerID = itemComputer.getComputerID( computer );
|
||||
String label = itemComputer.getLabel( computer );
|
||||
return PocketComputerItemFactory.create( computerID, label, family, upgrade );
|
||||
int colour = itemComputer.getColour( computer );
|
||||
return PocketComputerItemFactory.create( computerID, label, colour, family, upgrade );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -420,7 +420,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( bookPrintout, new ItemStack[]{leather, singlePrintout, string} ) );
|
||||
|
||||
// Pocket Computer
|
||||
ItemStack pocketComputer = PocketComputerItemFactory.create( -1, null, ComputerFamily.Normal, null );
|
||||
ItemStack pocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, null );
|
||||
GameRegistry.addRecipe( pocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
@ -429,7 +429,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
);
|
||||
|
||||
// Advanced Pocket Computer
|
||||
ItemStack advancedPocketComputer = PocketComputerItemFactory.create( -1, null, ComputerFamily.Advanced, null );
|
||||
ItemStack advancedPocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, null );
|
||||
GameRegistry.addRecipe( advancedPocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Items.GOLD_INGOT,
|
||||
@ -452,13 +452,13 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
GameRegistry.addRecipe( new ImpostorRecipe(
|
||||
1, 2,
|
||||
new ItemStack[]{ upgrade.getCraftingItem(), pocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, ComputerFamily.Normal, upgrade )
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, upgrade )
|
||||
) );
|
||||
|
||||
GameRegistry.addRecipe( new ImpostorRecipe(
|
||||
1, 2,
|
||||
new ItemStack[]{ upgrade.getCraftingItem(), advancedPocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, ComputerFamily.Advanced, upgrade )
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, upgrade )
|
||||
) );
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_frame",
|
||||
"layer1": "computercraft:items/pocket_computer_advanced"
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_blink_advanced",
|
||||
"layer1": "computercraft:items/pocket_computer_light"
|
||||
"layer0": "computercraft:items/pocket_computer_blink",
|
||||
"layer1": "computercraft:items/pocket_computer_advanced",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_advanced"
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_on_advanced",
|
||||
"layer1": "computercraft:items/pocket_computer_light"
|
||||
"layer0": "computercraft:items/pocket_computer_on",
|
||||
"layer1": "computercraft:items/pocket_computer_advanced",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer"
|
||||
"layer0": "computercraft:items/pocket_computer_frame",
|
||||
"layer1": "computercraft:items/pocket_computer"
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_blink",
|
||||
"layer1": "computercraft:items/pocket_computer_light"
|
||||
"layer1": "computercraft:items/pocket_computer",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_frame",
|
||||
"layer1": "computercraft:items/pocket_computer_colour"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_blink",
|
||||
"layer1": "computercraft:items/pocket_computer_colour",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_on",
|
||||
"layer1": "computercraft:items/pocket_computer_colour",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "computercraft:items/pocket_computer_on",
|
||||
"layer1": "computercraft:items/pocket_computer_light"
|
||||
"layer1": "computercraft:items/pocket_computer",
|
||||
"layer2": "computercraft:items/pocket_computer_light"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 266 B |
@ -1,6 +0,0 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 8,
|
||||
"frames": [ 0, 1 ]
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 212 B |
After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 243 B |