mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-13 03:30:29 +00:00
Store references to the registered items
This means we can avoid several rather ugly instances of getItemBlock and a cast. We also derive the ItemBlock's registered name from the block's name, which makes the register a little less ugly.
This commit is contained in:
parent
227d5e9e69
commit
e33f852baa
@ -37,15 +37,20 @@ import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
|
||||
import dan200.computercraft.shared.computer.items.ItemCommandComputer;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.media.items.ItemDiskExpanded;
|
||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.ItemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.ItemCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.BlockAdvancedModem;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.ItemAdvancedModem;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
@ -55,6 +60,9 @@ import dan200.computercraft.shared.proxy.ICCTurtleProxy;
|
||||
import dan200.computercraft.shared.proxy.IComputerCraftProxy;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleAdvanced;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleLegacy;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleNormal;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import dan200.computercraft.shared.util.CreativeTabMain;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
@ -63,6 +71,7 @@ import dan200.computercraft.shared.wired.CapabilityWiredElement;
|
||||
import dan200.computercraft.shared.wired.WiredNode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -187,6 +196,13 @@ public class ComputerCraft
|
||||
|
||||
public static class Items
|
||||
{
|
||||
public static ItemComputer computer;
|
||||
public static ItemCommandComputer commandComputer;
|
||||
|
||||
public static ItemTurtleLegacy turtle;
|
||||
public static ItemTurtleNormal turtleExpanded;
|
||||
public static ItemTurtleAdvanced turtleAdvanced;
|
||||
|
||||
public static ItemPocketComputer pocketComputer;
|
||||
|
||||
public static ItemDiskLegacy disk;
|
||||
@ -194,6 +210,11 @@ public class ComputerCraft
|
||||
public static ItemTreasureDisk treasureDisk;
|
||||
|
||||
public static ItemPrintout printout;
|
||||
|
||||
public static ItemPeripheral peripheral;
|
||||
public static ItemAdvancedModem advancedModem;
|
||||
public static ItemCable cable;
|
||||
public static ItemBlock wiredModemFull;
|
||||
}
|
||||
|
||||
public static class TurtleUpgrades
|
||||
|
@ -7,7 +7,6 @@
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
@ -55,22 +54,22 @@ public class ClientRegistry
|
||||
public static void registerModels( ModelRegistryEvent event )
|
||||
{
|
||||
// Register item models
|
||||
registerUniversalItemModel( ComputerCraft.Blocks.computer, "computer" );
|
||||
registerItemModel( ComputerCraft.Blocks.commandComputer, 0, "command_computer" );
|
||||
registerUniversalItemModel( ComputerCraft.Items.computer, "computer" );
|
||||
registerItemModel( ComputerCraft.Items.commandComputer, 0, "command_computer" );
|
||||
|
||||
registerItemModel( ComputerCraft.Items.pocketComputer, 0, "pocket_computer" );
|
||||
registerItemModel( ComputerCraft.Items.pocketComputer, 1, "advanced_pocket_computer" );
|
||||
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 0, "peripheral" );
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 1, "wireless_modem" );
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 2, "monitor" );
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 3, "printer" );
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 4, "advanced_monitor" );
|
||||
registerItemModel( ComputerCraft.Blocks.cable, 0, "cable" );
|
||||
registerItemModel( ComputerCraft.Blocks.cable, 1, "wired_modem" );
|
||||
registerItemModel( ComputerCraft.Blocks.advancedModem, 0, "advanced_modem" );
|
||||
registerItemModel( ComputerCraft.Blocks.peripheral, 5, "speaker" );
|
||||
registerItemModel( ComputerCraft.Blocks.wiredModemFull, 0, "wired_modem_full" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 0, "peripheral" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 1, "wireless_modem" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 2, "monitor" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 3, "printer" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 4, "advanced_monitor" );
|
||||
registerItemModel( ComputerCraft.Items.cable, 0, "cable" );
|
||||
registerItemModel( ComputerCraft.Items.cable, 1, "wired_modem" );
|
||||
registerItemModel( ComputerCraft.Items.advancedModem, 0, "advanced_modem" );
|
||||
registerItemModel( ComputerCraft.Items.peripheral, 5, "speaker" );
|
||||
registerItemModel( ComputerCraft.Items.wiredModemFull, 0, "wired_modem_full" );
|
||||
|
||||
registerUniversalItemModel( ComputerCraft.Items.disk, "disk" );
|
||||
registerItemModel( ComputerCraft.Items.diskExpanded, 0, "disk_expanded" );
|
||||
@ -80,26 +79,10 @@ public class ClientRegistry
|
||||
registerItemModel( ComputerCraft.Items.printout, 1, "pages" );
|
||||
registerItemModel( ComputerCraft.Items.printout, 2, "book" );
|
||||
|
||||
ItemMeshDefinition turtleMeshDefinition = new ItemMeshDefinition()
|
||||
{
|
||||
private ModelResourceLocation turtle_dynamic = new ModelResourceLocation( "computercraft:turtle_dynamic", "inventory" );
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
return turtle_dynamic;
|
||||
}
|
||||
};
|
||||
String[] turtleModelNames = new String[] {
|
||||
"turtle_dynamic",
|
||||
"turtle", "turtle_advanced", "turtle_white",
|
||||
"turtle_elf_overlay"
|
||||
};
|
||||
|
||||
registerUniversalItemModel( ComputerCraft.Blocks.turtle, turtleMeshDefinition, turtleModelNames );
|
||||
registerUniversalItemModel( ComputerCraft.Blocks.turtleExpanded, turtleMeshDefinition, turtleModelNames );
|
||||
registerUniversalItemModel( ComputerCraft.Blocks.turtleAdvanced, turtleMeshDefinition, turtleModelNames );
|
||||
String[] extraTurtleModels = new String[] { "turtle", "turtle_advanced", "turtle_white", "turtle_elf_overlay" };
|
||||
registerUniversalItemModel( ComputerCraft.Items.turtle, "turtle_dynamic", extraTurtleModels );
|
||||
registerUniversalItemModel( ComputerCraft.Items.turtleExpanded, "turtle_dynamic", extraTurtleModels );
|
||||
registerUniversalItemModel( ComputerCraft.Items.turtleAdvanced, "turtle_dynamic", extraTurtleModels );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@ -127,11 +110,6 @@ public class ClientRegistry
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerItemModel( Block block, int damage, String name )
|
||||
{
|
||||
registerItemModel( Item.getItemFromBlock( block ), damage, name );
|
||||
}
|
||||
|
||||
private static void registerItemModel( Item item, int damage, String name )
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation( ComputerCraft.MOD_ID, name );
|
||||
@ -140,39 +118,27 @@ public class ClientRegistry
|
||||
ModelLoader.setCustomModelResourceLocation( item, damage, res );
|
||||
}
|
||||
|
||||
private static void registerUniversalItemModel( Block block, ItemMeshDefinition definition, String[] names )
|
||||
private static void registerUniversalItemModel( Item item, String mainModel, String... extraModels )
|
||||
{
|
||||
registerUniversalItemModel( Item.getItemFromBlock( block ), definition, names );
|
||||
}
|
||||
ResourceLocation mainLocation = new ResourceLocation( ComputerCraft.MOD_ID, mainModel );
|
||||
|
||||
private static void registerUniversalItemModel( Item item, ItemMeshDefinition definition, String[] names )
|
||||
{
|
||||
ResourceLocation[] resources = new ResourceLocation[names.length];
|
||||
for( int i = 0; i < names.length; i++ )
|
||||
ResourceLocation[] modelLocations = new ResourceLocation[extraModels.length + 1];
|
||||
modelLocations[0] = mainLocation;
|
||||
for( int i = 0; i < extraModels.length; i++ )
|
||||
{
|
||||
resources[i] = new ResourceLocation( ComputerCraft.MOD_ID, names[i] );
|
||||
modelLocations[i + 1] = new ResourceLocation( ComputerCraft.MOD_ID, extraModels[i] );
|
||||
}
|
||||
ModelBakery.registerItemVariants( item, resources );
|
||||
ModelLoader.setCustomMeshDefinition( item, definition );
|
||||
}
|
||||
|
||||
private static void registerUniversalItemModel( Block block, String name )
|
||||
{
|
||||
registerUniversalItemModel( Item.getItemFromBlock( block ), name );
|
||||
}
|
||||
ModelBakery.registerItemVariants( item, modelLocations );
|
||||
|
||||
private static void registerUniversalItemModel( Item item, String name )
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation( ComputerCraft.MOD_ID, name );
|
||||
final ModelResourceLocation res = new ModelResourceLocation( location, "inventory" );
|
||||
ModelBakery.registerItemVariants( item, location );
|
||||
final ModelResourceLocation mainModelLocation = new ModelResourceLocation( mainLocation, "inventory" );
|
||||
ModelLoader.setCustomMeshDefinition( item, new ItemMeshDefinition()
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
return res;
|
||||
return mainModelLocation;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
@ -74,9 +75,25 @@ public final class Registry
|
||||
{
|
||||
IForgeRegistry<Block> registry = event.getRegistry();
|
||||
|
||||
// Computer
|
||||
// Computers
|
||||
ComputerCraft.Blocks.computer = new BlockComputer();
|
||||
registry.register( ComputerCraft.Blocks.computer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) );
|
||||
ComputerCraft.Blocks.commandComputer = new BlockCommandComputer();
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Blocks.computer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ),
|
||||
ComputerCraft.Blocks.commandComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ) )
|
||||
);
|
||||
|
||||
// Turtle
|
||||
ComputerCraft.Blocks.turtle = new BlockTurtle();
|
||||
ComputerCraft.Blocks.turtleExpanded = new BlockTurtle();
|
||||
ComputerCraft.Blocks.turtleAdvanced = new BlockTurtle();
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Blocks.turtle.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ),
|
||||
ComputerCraft.Blocks.turtleExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_expanded" ) ),
|
||||
ComputerCraft.Blocks.turtleAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) )
|
||||
);
|
||||
|
||||
// Peripheral
|
||||
ComputerCraft.Blocks.peripheral = new BlockPeripheral();
|
||||
@ -86,11 +103,7 @@ public final class Registry
|
||||
ComputerCraft.Blocks.cable = new BlockCable();
|
||||
registry.register( ComputerCraft.Blocks.cable.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) ) );
|
||||
|
||||
// Command Computer
|
||||
ComputerCraft.Blocks.commandComputer = new BlockCommandComputer();
|
||||
registry.register( ComputerCraft.Blocks.commandComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ) ) );
|
||||
|
||||
// Command Computer
|
||||
// Advanced modem
|
||||
ComputerCraft.Blocks.advancedModem = new BlockAdvancedModem();
|
||||
registry.register( ComputerCraft.Blocks.advancedModem.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "advanced_modem" ) ) );
|
||||
|
||||
@ -98,17 +111,6 @@ public final class Registry
|
||||
ComputerCraft.Blocks.wiredModemFull = new BlockWiredModemFull();
|
||||
registry.register( ComputerCraft.Blocks.wiredModemFull.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ) ) );
|
||||
|
||||
// Turtle
|
||||
ComputerCraft.Blocks.turtle = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtle.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ) );
|
||||
|
||||
ComputerCraft.Blocks.turtleExpanded = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtleExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_expanded" ) ) );
|
||||
|
||||
// Advanced Turtle
|
||||
ComputerCraft.Blocks.turtleAdvanced = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtleAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) ) );
|
||||
|
||||
registerTileEntities();
|
||||
}
|
||||
|
||||
@ -131,52 +133,70 @@ public final class Registry
|
||||
GameRegistry.registerTileEntity( TileWiredModemFull.class, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ) );
|
||||
}
|
||||
|
||||
private static <T extends ItemBlock> T setupItemBlock( T item )
|
||||
{
|
||||
item.setRegistryName( item.getBlock().getRegistryName() );
|
||||
return item;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems( RegistryEvent.Register<Item> event )
|
||||
{
|
||||
IForgeRegistry<Item> registry = event.getRegistry();
|
||||
|
||||
registry.register( new ItemTurtleLegacy( ComputerCraft.Blocks.turtle ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ) );
|
||||
registry.register( new ItemTurtleNormal( ComputerCraft.Blocks.turtleExpanded ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_expanded" ) ) );
|
||||
registry.register( new ItemTurtleAdvanced( ComputerCraft.Blocks.turtleAdvanced ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) ) );
|
||||
// Computers
|
||||
ComputerCraft.Items.computer = new ItemComputer( ComputerCraft.Blocks.computer );
|
||||
ComputerCraft.Items.commandComputer = new ItemCommandComputer( ComputerCraft.Blocks.commandComputer );
|
||||
|
||||
// Computer
|
||||
registry.register( new ItemComputer( ComputerCraft.Blocks.computer ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) );
|
||||
|
||||
// Peripheral
|
||||
registry.register( new ItemPeripheral( ComputerCraft.Blocks.peripheral ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "peripheral" ) ) );
|
||||
|
||||
// Cable
|
||||
registry.register( new ItemCable( ComputerCraft.Blocks.cable ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) ) );
|
||||
|
||||
// Command Computer
|
||||
registry.register( new ItemCommandComputer( ComputerCraft.Blocks.commandComputer ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ) ) );
|
||||
|
||||
// Advanced modem
|
||||
registry.register( new ItemAdvancedModem( ComputerCraft.Blocks.advancedModem ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "advanced_modem" ) ) );
|
||||
|
||||
// Full block modem
|
||||
registry.register( new ItemWiredModemFull( ComputerCraft.Blocks.wiredModemFull ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ) ) );
|
||||
|
||||
// Items
|
||||
// Floppy Disk
|
||||
ComputerCraft.Items.disk = new ItemDiskLegacy();
|
||||
registry.register( ComputerCraft.Items.disk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ) );
|
||||
|
||||
ComputerCraft.Items.diskExpanded = new ItemDiskExpanded();
|
||||
registry.register( ComputerCraft.Items.diskExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_expanded" ) ) );
|
||||
|
||||
// Treasure Disk
|
||||
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk();
|
||||
registry.register( ComputerCraft.Items.treasureDisk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" ) ) );
|
||||
|
||||
// Printout
|
||||
ComputerCraft.Items.printout = new ItemPrintout();
|
||||
registry.register( ComputerCraft.Items.printout.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ) );
|
||||
registry.registerAll(
|
||||
setupItemBlock( ComputerCraft.Items.computer ),
|
||||
setupItemBlock( ComputerCraft.Items.commandComputer )
|
||||
);
|
||||
|
||||
// Pocket computer
|
||||
ComputerCraft.Items.pocketComputer = new ItemPocketComputer();
|
||||
registry.register( ComputerCraft.Items.pocketComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) ) );
|
||||
registry.register(
|
||||
ComputerCraft.Items.pocketComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) )
|
||||
);
|
||||
|
||||
// Turtle
|
||||
ComputerCraft.Items.turtle = new ItemTurtleLegacy( ComputerCraft.Blocks.turtle );
|
||||
ComputerCraft.Items.turtleExpanded = new ItemTurtleNormal( ComputerCraft.Blocks.turtleExpanded );
|
||||
ComputerCraft.Items.turtleAdvanced = new ItemTurtleAdvanced( ComputerCraft.Blocks.turtleAdvanced );
|
||||
|
||||
registry.registerAll(
|
||||
setupItemBlock( ComputerCraft.Items.turtle ),
|
||||
setupItemBlock( ComputerCraft.Items.turtleExpanded ),
|
||||
setupItemBlock( ComputerCraft.Items.turtleAdvanced )
|
||||
);
|
||||
|
||||
// Printouts
|
||||
ComputerCraft.Items.printout = new ItemPrintout();
|
||||
registry.register( ComputerCraft.Items.printout.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ) );
|
||||
|
||||
// Disks
|
||||
ComputerCraft.Items.disk = new ItemDiskLegacy();
|
||||
ComputerCraft.Items.diskExpanded = new ItemDiskExpanded();
|
||||
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk();
|
||||
|
||||
registry.registerAll(
|
||||
ComputerCraft.Items.disk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ),
|
||||
ComputerCraft.Items.diskExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_expanded" ) ),
|
||||
ComputerCraft.Items.treasureDisk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" ) )
|
||||
);
|
||||
|
||||
// Peripherals
|
||||
ComputerCraft.Items.peripheral = new ItemPeripheral( ComputerCraft.Blocks.peripheral );
|
||||
ComputerCraft.Items.advancedModem = new ItemAdvancedModem( ComputerCraft.Blocks.advancedModem );
|
||||
ComputerCraft.Items.cable = new ItemCable( ComputerCraft.Blocks.cable );
|
||||
ComputerCraft.Items.wiredModemFull = new ItemWiredModemFull( ComputerCraft.Blocks.wiredModemFull );
|
||||
|
||||
registry.registerAll(
|
||||
setupItemBlock( ComputerCraft.Items.peripheral ),
|
||||
setupItemBlock( ComputerCraft.Items.advancedModem ),
|
||||
setupItemBlock( ComputerCraft.Items.cable ),
|
||||
setupItemBlock( ComputerCraft.Items.wiredModemFull )
|
||||
);
|
||||
|
||||
registerTurtleUpgrades();
|
||||
registerPocketUpgrades();
|
||||
@ -192,14 +212,14 @@ public final class Registry
|
||||
|
||||
// Turtle upgrades
|
||||
// TODO: Figure out a way to do this in a "nice" way.
|
||||
for( ITurtleUpgrade upgrade : dan200.computercraft.shared.TurtleUpgrades.getVanillaUpgrades() )
|
||||
for( ITurtleUpgrade upgrade : TurtleUpgrades.getVanillaUpgrades() )
|
||||
{
|
||||
ItemStack craftingItem = upgrade.getCraftingItem();
|
||||
|
||||
// A turtle just containing this upgrade
|
||||
for( ComputerFamily family : ComputerFamily.values() )
|
||||
{
|
||||
if( !dan200.computercraft.shared.TurtleUpgrades.suitableForFamily( family, upgrade ) ) continue;
|
||||
if( !TurtleUpgrades.suitableForFamily( family, upgrade ) ) continue;
|
||||
|
||||
ItemStack baseTurtle = TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null );
|
||||
if( !baseTurtle.isEmpty() )
|
||||
@ -277,31 +297,31 @@ public final class Registry
|
||||
{
|
||||
// Upgrades
|
||||
ComputerCraft.TurtleUpgrades.wirelessModem = new TurtleModem( false, new ResourceLocation( "computercraft", "wireless_modem" ), 1 );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.wirelessModem );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.wirelessModem );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.craftingTable = new TurtleCraftingTable( 2 );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.craftingTable );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.craftingTable );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), 3, "upgrade.minecraft:diamond_sword.adjective", Items.DIAMOND_SWORD );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondSword );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondSword );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), 4, "upgrade.minecraft:diamond_shovel.adjective", Items.DIAMOND_SHOVEL );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondShovel );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondShovel );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), 5, "upgrade.minecraft:diamond_pickaxe.adjective", Items.DIAMOND_PICKAXE );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondPickaxe );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondPickaxe );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), 6, "upgrade.minecraft:diamond_axe.adjective", Items.DIAMOND_AXE );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondAxe );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondAxe );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), 7, "upgrade.minecraft:diamond_hoe.adjective", Items.DIAMOND_HOE );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondHoe );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.diamondHoe );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.advancedModem = new TurtleModem( true, new ResourceLocation( "computercraft", "advanced_modem" ), -1 );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.advancedModem );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.advancedModem );
|
||||
|
||||
ComputerCraft.TurtleUpgrades.speaker = new TurtleSpeaker( new ResourceLocation( "computercraft", "speaker" ), 8 );
|
||||
dan200.computercraft.shared.TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.speaker );
|
||||
TurtleUpgrades.registerInternal( ComputerCraft.TurtleUpgrades.speaker );
|
||||
}
|
||||
|
||||
public static void registerPocketUpgrades()
|
||||
@ -328,15 +348,15 @@ public final class Registry
|
||||
String key = mapping.key.getPath();
|
||||
if( key.equalsIgnoreCase( "CC-Computer" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.computer ) );
|
||||
mapping.remap( ComputerCraft.Items.computer );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Peripheral" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.peripheral ) );
|
||||
mapping.remap( ComputerCraft.Items.peripheral );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Cable" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.cable ) );
|
||||
mapping.remap( ComputerCraft.Items.cable );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "diskExpanded" ) )
|
||||
{
|
||||
@ -352,15 +372,15 @@ public final class Registry
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Turtle" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtle ) );
|
||||
mapping.remap( ComputerCraft.Items.turtle );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleExpanded" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtleExpanded ) );
|
||||
mapping.remap( ComputerCraft.Items.turtleExpanded );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleAdvanced" ) )
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtleAdvanced ) );
|
||||
mapping.remap( ComputerCraft.Items.turtleAdvanced );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -131,7 +129,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
@Override
|
||||
public ComputerFamily getFamily( int damage )
|
||||
{
|
||||
return ((ItemComputer) Item.getItemFromBlock( this )).getFamily( damage );
|
||||
return ComputerCraft.Items.computer.getFamily( damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,6 @@ package dan200.computercraft.shared.computer.items;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -31,15 +30,9 @@ public class ComputerItemFactory
|
||||
{
|
||||
case Normal:
|
||||
case Advanced:
|
||||
{
|
||||
ItemComputer computer = ((ItemComputer) Item.getItemFromBlock( ComputerCraft.Blocks.computer ));
|
||||
return computer.create( id, label, family );
|
||||
}
|
||||
return ComputerCraft.Items.computer.create( id, label, family );
|
||||
case Command:
|
||||
{
|
||||
ItemCommandComputer commandComputer = ((ItemCommandComputer) Item.getItemFromBlock( ComputerCraft.Blocks.commandComputer ));
|
||||
return commandComputer.create( id, label, family );
|
||||
}
|
||||
return ComputerCraft.Items.commandComputer.create( id, label, family );
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ public class JEIComputerCraft implements IModPlugin
|
||||
@Override
|
||||
public void registerItemSubtypes( ISubtypeRegistry subtypeRegistry )
|
||||
{
|
||||
subtypeRegistry.registerSubtypeInterpreter( Item.getItemFromBlock( ComputerCraft.Blocks.turtle ), turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Item.getItemFromBlock( ComputerCraft.Blocks.turtleExpanded ), turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( Item.getItemFromBlock( ComputerCraft.Blocks.turtleAdvanced ), turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.turtle, turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.turtleExpanded, turtleSubtype );
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.turtleAdvanced, turtleSubtype );
|
||||
|
||||
subtypeRegistry.registerSubtypeInterpreter( ComputerCraft.Items.pocketComputer, pocketSubtype );
|
||||
|
||||
|
@ -21,7 +21,6 @@ import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
@ -519,7 +518,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
@Override
|
||||
public PeripheralType getPeripheralType( int damage )
|
||||
{
|
||||
return ((ItemPeripheral) Item.getItemFromBlock( this )).getPeripheralType( damage );
|
||||
return ComputerCraft.Items.peripheral.getPeripheralType( damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,9 +8,6 @@ package dan200.computercraft.shared.peripheral.common;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.ItemCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.ItemAdvancedModem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -26,9 +23,6 @@ public class PeripheralItemFactory
|
||||
@Nonnull
|
||||
public static ItemStack create( PeripheralType type, String label, int quantity )
|
||||
{
|
||||
ItemPeripheral peripheral = ((ItemPeripheral) Item.getItemFromBlock( ComputerCraft.Blocks.peripheral ));
|
||||
ItemCable cable = ((ItemCable) Item.getItemFromBlock( ComputerCraft.Blocks.cable ));
|
||||
ItemAdvancedModem advancedModem = ((ItemAdvancedModem) Item.getItemFromBlock( ComputerCraft.Blocks.advancedModem ));
|
||||
switch( type )
|
||||
{
|
||||
case Speaker:
|
||||
@ -37,18 +31,12 @@ public class PeripheralItemFactory
|
||||
case Monitor:
|
||||
case AdvancedMonitor:
|
||||
case WirelessModem:
|
||||
{
|
||||
return peripheral.create( type, label, quantity );
|
||||
}
|
||||
return ComputerCraft.Items.peripheral.create( type, label, quantity );
|
||||
case WiredModem:
|
||||
case Cable:
|
||||
{
|
||||
return cable.create( type, label, quantity );
|
||||
}
|
||||
return ComputerCraft.Items.cable.create( type, label, quantity );
|
||||
case AdvancedModem:
|
||||
{
|
||||
return advancedModem.create( type, label, quantity );
|
||||
}
|
||||
return new ItemStack( ComputerCraft.Blocks.advancedModem, quantity );
|
||||
case WiredModemFull:
|
||||
return new ItemStack( ComputerCraft.Blocks.wiredModemFull, quantity );
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -212,7 +211,7 @@ public class BlockCable extends BlockPeripheralBase
|
||||
@Override
|
||||
public PeripheralType getPeripheralType( int damage )
|
||||
{
|
||||
return ((ItemCable) Item.getItemFromBlock( this )).getPeripheralType( damage );
|
||||
return ComputerCraft.Items.cable.getPeripheralType( damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,30 +27,6 @@ public class ItemAdvancedModem extends ItemPeripheralBase
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack create( PeripheralType type, String label, int quantity )
|
||||
{
|
||||
ItemStack stack;
|
||||
switch( type )
|
||||
{
|
||||
case AdvancedModem:
|
||||
{
|
||||
stack = new ItemStack( this, quantity, 0 );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Ignore types we can't handle
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
if( label != null )
|
||||
{
|
||||
stack.setStackDisplayName( label );
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
|
@ -43,11 +43,6 @@ public class BlockTurtle extends BlockComputerBase
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL );
|
||||
}
|
||||
|
||||
public static BlockTurtle createTurtleBlock()
|
||||
{
|
||||
return new BlockTurtle();
|
||||
}
|
||||
|
||||
// Members
|
||||
|
||||
public BlockTurtle()
|
||||
|
@ -11,7 +11,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.blocks.ITurtleTile;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@ -43,14 +42,14 @@ public class TurtleItemFactory
|
||||
{
|
||||
case Normal:
|
||||
{
|
||||
ItemTurtleBase legacy = ((ItemTurtleBase) Item.getItemFromBlock( ComputerCraft.Blocks.turtle ));
|
||||
ItemTurtleBase normal = ((ItemTurtleBase) Item.getItemFromBlock( ComputerCraft.Blocks.turtleExpanded ));
|
||||
ItemTurtleBase legacy = ComputerCraft.Items.turtle;
|
||||
ItemTurtleBase normal = ComputerCraft.Items.turtleExpanded;
|
||||
ItemStack legacyStack = legacy.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
return (legacyStack != null) ? legacyStack : normal.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
return legacyStack != null ? legacyStack : normal.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
}
|
||||
case Advanced:
|
||||
{
|
||||
ItemTurtleBase advanced = ((ItemTurtleBase) Item.getItemFromBlock( ComputerCraft.Blocks.turtleAdvanced ));
|
||||
ItemTurtleBase advanced = ComputerCraft.Items.turtleAdvanced;
|
||||
return advanced.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user