1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Derive upgrade adjectives from its ID

This is done in 1.13+ for items and blocks, so we might as well do it
for upgrades now. Note we can't do it for ender pocket modems, as the
upgrade ID is spelled incorrectly there.
This commit is contained in:
SquidDev 2019-01-14 10:42:13 +00:00
parent 61daab910e
commit a838595e1e
13 changed files with 72 additions and 28 deletions

View File

@ -299,29 +299,29 @@ public static void registerTurtleUpgrades()
ComputerCraft.TurtleUpgrades.wirelessModem = new TurtleModem( false, new ResourceLocation( "computercraft", "wireless_modem" ), 1 );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.wirelessModem );
ComputerCraft.TurtleUpgrades.craftingTable = new TurtleCraftingTable( 2 );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.craftingTable );
ComputerCraft.TurtleUpgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), 3, "upgrade.minecraft:diamond_sword.adjective", Items.DIAMOND_SWORD );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondSword );
ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), 4, "upgrade.minecraft:diamond_shovel.adjective", Items.DIAMOND_SHOVEL );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondShovel );
ComputerCraft.TurtleUpgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), 5, "upgrade.minecraft:diamond_pickaxe.adjective", Items.DIAMOND_PICKAXE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondPickaxe );
ComputerCraft.TurtleUpgrades.diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), 6, "upgrade.minecraft:diamond_axe.adjective", Items.DIAMOND_AXE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondAxe );
ComputerCraft.TurtleUpgrades.diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), 7, "upgrade.minecraft:diamond_hoe.adjective", Items.DIAMOND_HOE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondHoe );
ComputerCraft.TurtleUpgrades.advancedModem = new TurtleModem( true, new ResourceLocation( "computercraft", "advanced_modem" ), -1 );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.advancedModem );
ComputerCraft.TurtleUpgrades.speaker = new TurtleSpeaker( new ResourceLocation( "computercraft", "speaker" ), 8 );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.speaker );
ComputerCraft.TurtleUpgrades.craftingTable = new TurtleCraftingTable( new ResourceLocation( "minecraft", "crafting_table" ), 2 );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.craftingTable );
ComputerCraft.TurtleUpgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), 3, Items.DIAMOND_SWORD );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondSword );
ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), 4, Items.DIAMOND_SHOVEL );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondShovel );
ComputerCraft.TurtleUpgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), 5, Items.DIAMOND_PICKAXE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondPickaxe );
ComputerCraft.TurtleUpgrades.diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), 6, Items.DIAMOND_AXE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondAxe );
ComputerCraft.TurtleUpgrades.diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), 7, Items.DIAMOND_HOE );
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondHoe );
}
public static void registerPocketUpgrades()

View File

@ -25,6 +25,11 @@ protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStac
this.stack = stack;
}
protected AbstractPocketUpgrade( ResourceLocation id, ItemStack stack )
{
this( id, "upgrade." + id + ".adjective", stack );
}
@Nonnull
@Override
public final ResourceLocation getUpgradeID()

View File

@ -23,7 +23,6 @@ public PocketSpeaker()
{
super(
new ResourceLocation( "computercraft", "speaker" ),
"upgrade.computercraft:speaker.adjective",
PeripheralItemFactory.create( PeripheralType.Speaker, null, 1 )
);
}

View File

@ -54,6 +54,10 @@ public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemS
if( !isInCreativeTab( tabs ) ) return;
ComputerFamily family = getFamily();
ItemStack normalStack = TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null );
if( !normalStack.isEmpty() && normalStack.getItem() == this ) list.add( normalStack );
for( ITurtleUpgrade upgrade : TurtleUpgrades.getVanillaUpgrades() )
{
if( !TurtleUpgrades.suitableForFamily( family, upgrade ) ) continue;

View File

@ -42,6 +42,21 @@ public AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeTy
this( id, legacyId, type, adjective, new ItemStack( block ) );
}
public AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, ItemStack stack )
{
this( id, legacyId, type, "upgrade." + id + ".adjective", stack );
}
public AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Item item )
{
this( id, legacyId, type, new ItemStack( item ) );
}
public AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Block block )
{
this( id, legacyId, type, new ItemStack( block ) );
}
@Nonnull
@Override
public final ResourceLocation getUpgradeID()

View File

@ -16,6 +16,11 @@ public TurtleAxe( ResourceLocation id, int legacyId, String adjective, Item item
super( id, legacyId, adjective, item );
}
public TurtleAxe( ResourceLocation id, int legacyId, Item item )
{
super( id, legacyId, item );
}
@Override
protected float getDamageMultiplier()
{

View File

@ -31,12 +31,9 @@ public class TurtleCraftingTable extends AbstractTurtleUpgrade
@SideOnly( Side.CLIENT )
private ModelResourceLocation m_rightModel;
public TurtleCraftingTable( int legacyId )
public TurtleCraftingTable( ResourceLocation id, int legacyId )
{
super(
new ResourceLocation( "minecraft", "crafting_table" ), legacyId, TurtleUpgradeType.Peripheral,
"upgrade.minecraft:crafting_table.adjective", Blocks.CRAFTING_TABLE
);
super( id, legacyId, TurtleUpgradeType.Peripheral, Blocks.CRAFTING_TABLE );
}
@Override

View File

@ -30,6 +30,11 @@ public TurtleHoe( ResourceLocation id, int legacyId, String adjective, Item item
super( id, legacyId, adjective, item );
}
public TurtleHoe( ResourceLocation id, int legacyId, Item item )
{
super( id, legacyId, item );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@ -85,9 +85,7 @@ public TurtleModem( boolean advanced, ResourceLocation id, int legacyId )
{
super(
id, legacyId, TurtleUpgradeType.Peripheral,
advanced ? "upgrade.computercraft:advanced_modem.adjective" : "upgrade.computercraft:wireless_modem.adjective",
advanced ? PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) : PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 )
);
this.advanced = advanced;
}

View File

@ -30,6 +30,11 @@ public TurtleShovel( ResourceLocation id, int legacyId, String adjective, Item i
super( id, legacyId, adjective, item );
}
public TurtleShovel( ResourceLocation id, int legacyId, Item item )
{
super( id, legacyId, item );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@ -69,8 +69,8 @@ public boolean equals( IPeripheral other )
public TurtleSpeaker( ResourceLocation id, int legacyId )
{
super( id, legacyId, TurtleUpgradeType.Peripheral,
"upgrade.computercraft:speaker.adjective",
super(
id, legacyId, TurtleUpgradeType.Peripheral,
PeripheralItemFactory.create( PeripheralType.Speaker, null, 1 )
);
}

View File

@ -21,6 +21,11 @@ public TurtleSword( ResourceLocation id, int legacyId, String adjective, Item it
super( id, legacyId, adjective, item );
}
public TurtleSword( ResourceLocation id, int legacyId, Item item )
{
super( id, legacyId, item );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@ -55,6 +55,12 @@ public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item ite
m_item = new ItemStack( item, 1, 0 );
}
public TurtleTool( ResourceLocation id, int legacyID, Item item )
{
super( id, legacyID, TurtleUpgradeType.Tool, item );
m_item = new ItemStack( item, 1, 0 );
}
@Nonnull
@Override
@SideOnly( Side.CLIENT )