diff --git a/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java b/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java index ed8510a7d..2cfaaf070 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java @@ -20,7 +20,8 @@ public enum PeripheralType implements IStringSerializable WiredModem( "wired_modem" ), Cable( "cable" ), WiredModemWithCable( "wired_modem_with_cable" ), - AdvancedModem( "advanced_modem" ); + AdvancedModem( "advanced_modem" ), + Speaker( "speaker" ); private String m_name; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheral.java index 9f6758758..ba6f8ad1f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheral.java @@ -12,6 +12,7 @@ import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; import dan200.computercraft.shared.peripheral.modem.TileWirelessModem; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.peripheral.printer.TilePrinter; +import dan200.computercraft.shared.peripheral.speaker.TileSpeaker; import dan200.computercraft.shared.util.DirectionUtil; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; @@ -105,6 +106,10 @@ public class BlockPeripheral extends BlockPeripheralBase { state = state.withProperty( Properties.VARIANT, BlockPeripheralVariant.AdvancedMonitor ); } + else if (meta == 13) + { + state = state.withProperty( Properties.VARIANT, BlockPeripheralVariant.Speaker); + } return state; } @@ -164,6 +169,11 @@ public class BlockPeripheral extends BlockPeripheralBase meta = 12; break; } + case Speaker: + { + meta = 13; + break; + } } return meta; } @@ -323,6 +333,9 @@ public class BlockPeripheral extends BlockPeripheralBase } break; } + case Speaker: { + break; + } case Monitor: case AdvancedMonitor: { @@ -527,6 +540,10 @@ public class BlockPeripheral extends BlockPeripheralBase { return new TilePrinter(); } + case Speaker: + { + return new TileSpeaker(); + } } } @@ -543,6 +560,7 @@ public class BlockPeripheral extends BlockPeripheralBase switch( getPeripheralType( state ) ) { + case Speaker: case DiskDrive: case Printer: { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheralVariant.java b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheralVariant.java index c98f90a5d..e7c6ee910 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheralVariant.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockPeripheralVariant.java @@ -121,7 +121,8 @@ public enum BlockPeripheralVariant implements IStringSerializable AdvancedMonitorDownLUD( "advanced_monitor_down_lud", PeripheralType.AdvancedMonitor ), AdvancedMonitorDownRU( "advanced_monitor_down_ru", PeripheralType.AdvancedMonitor ), AdvancedMonitorDownLRU( "advanced_monitor_down_lru", PeripheralType.AdvancedMonitor ), - AdvancedMonitorDownLU( "advanced_monitor_down_lu", PeripheralType.AdvancedMonitor ); + AdvancedMonitorDownLU( "advanced_monitor_down_lu", PeripheralType.AdvancedMonitor ), + Speaker( "speaker", PeripheralType.Speaker ); private String m_name; private PeripheralType m_peripheralType; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java index afcf44269..59c95f6d4 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java @@ -56,6 +56,12 @@ public class ItemPeripheral extends ItemPeripheralBase stack = new ItemStack( this, quantity, 4 ); break; } + case Speaker: + { + stack = new ItemStack(this, quantity, 5); + break; + } + default: { // Ignore types we can't handle @@ -77,6 +83,7 @@ public class ItemPeripheral extends ItemPeripheralBase list.add( PeripheralItemFactory.create( PeripheralType.Monitor, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.AdvancedMonitor, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 ) ); + list.add( PeripheralItemFactory.create( PeripheralType.Speaker, null, 1) ); } @Override @@ -105,6 +112,10 @@ public class ItemPeripheral extends ItemPeripheralBase { return PeripheralType.AdvancedMonitor; } + case 5: + { + return PeripheralType.Speaker; + } } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java b/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java index 739ae34ee..95952414f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java @@ -25,6 +25,7 @@ public class PeripheralItemFactory ItemAdvancedModem advancedModem = ((ItemAdvancedModem)Item.getItemFromBlock( ComputerCraft.Blocks.advancedModem )); switch( type ) { + case Speaker: case DiskDrive: case Printer: case Monitor: diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 251fd9809..9751914ce 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -44,6 +44,7 @@ import dan200.computercraft.shared.peripheral.modem.TileWirelessModem; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; import dan200.computercraft.shared.peripheral.printer.TilePrinter; +import dan200.computercraft.shared.peripheral.speaker.TileSpeaker; import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory; @@ -308,6 +309,15 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy 'Y', Items.REDSTONE ); + // Speaker + ItemStack speaker = PeripheralItemFactory.create( PeripheralType.Speaker, null, 1); + GameRegistry.addRecipe( speaker, + "XXX", "XYX", "XZX", + 'X', Blocks.STONE, + 'Y', Blocks.NOTEBLOCK, + 'Z', Items.REDSTONE + ); + // Wireless Modem ItemStack wirelessModem = PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 ); GameRegistry.addRecipe( wirelessModem, @@ -541,14 +551,15 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy private void registerTileEntities() { // Tile Entities - registerTileEntity( TileComputer.class, "computer" ); - registerTileEntity( TileDiskDrive.class, "diskdrive" ); - registerTileEntity( TileWirelessModem.class, "wirelessmodem" ); - registerTileEntity( TileMonitor.class, "monitor" ); - registerTileEntity( TilePrinter.class, "ccprinter" ); - registerTileEntity( TileCable.class, "wiredmodem" ); - registerTileEntity( TileCommandComputer.class, "command_computer" ); - registerTileEntity( TileAdvancedModem.class, "advanced_modem" ); + GameRegistry.registerTileEntity( TileComputer.class, "computer" ); + GameRegistry.registerTileEntity( TileDiskDrive.class, "diskdrive" ); + GameRegistry.registerTileEntity( TileWirelessModem.class, "wirelessmodem" ); + GameRegistry.registerTileEntity( TileMonitor.class, "monitor" ); + GameRegistry.registerTileEntity( TilePrinter.class, "ccprinter" ); + GameRegistry.registerTileEntity( TileCable.class, "wiredmodem" ); + GameRegistry.registerTileEntity( TileCommandComputer.class, "command_computer" ); + GameRegistry.registerTileEntity( TileAdvancedModem.class, "advanced_modem" ); + GameRegistry.registerTileEntity( TileSpeaker.class, "speaker" ); // Register peripheral providers ComputerCraftAPI.registerPeripheralProvider( new DefaultPeripheralProvider() );