1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-07 16:00:31 +00:00

Implemented speaker. It's broken though - thinks it's a Disk Drive

~~Damn Tile Entities these days, always with their identity crises~~
This commit is contained in:
Restioson 2017-05-07 17:31:29 +02:00
parent 61dc61d356
commit 61c08afc7f
6 changed files with 53 additions and 10 deletions

View File

@ -20,7 +20,8 @@ public enum PeripheralType implements IStringSerializable
WiredModem( "wired_modem" ), WiredModem( "wired_modem" ),
Cable( "cable" ), Cable( "cable" ),
WiredModemWithCable( "wired_modem_with_cable" ), WiredModemWithCable( "wired_modem_with_cable" ),
AdvancedModem( "advanced_modem" ); AdvancedModem( "advanced_modem" ),
Speaker( "speaker" );
private String m_name; private String m_name;

View File

@ -12,6 +12,7 @@ import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
import dan200.computercraft.shared.peripheral.modem.TileWirelessModem; import dan200.computercraft.shared.peripheral.modem.TileWirelessModem;
import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
import dan200.computercraft.shared.peripheral.printer.TilePrinter; import dan200.computercraft.shared.peripheral.printer.TilePrinter;
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
@ -105,6 +106,10 @@ public class BlockPeripheral extends BlockPeripheralBase
{ {
state = state.withProperty( Properties.VARIANT, BlockPeripheralVariant.AdvancedMonitor ); state = state.withProperty( Properties.VARIANT, BlockPeripheralVariant.AdvancedMonitor );
} }
else if (meta == 13)
{
state = state.withProperty( Properties.VARIANT, BlockPeripheralVariant.Speaker);
}
return state; return state;
} }
@ -164,6 +169,11 @@ public class BlockPeripheral extends BlockPeripheralBase
meta = 12; meta = 12;
break; break;
} }
case Speaker:
{
meta = 13;
break;
}
} }
return meta; return meta;
} }
@ -323,6 +333,9 @@ public class BlockPeripheral extends BlockPeripheralBase
} }
break; break;
} }
case Speaker: {
break;
}
case Monitor: case Monitor:
case AdvancedMonitor: case AdvancedMonitor:
{ {
@ -527,6 +540,10 @@ public class BlockPeripheral extends BlockPeripheralBase
{ {
return new TilePrinter(); return new TilePrinter();
} }
case Speaker:
{
return new TileSpeaker();
}
} }
} }
@ -543,6 +560,7 @@ public class BlockPeripheral extends BlockPeripheralBase
switch( getPeripheralType( state ) ) switch( getPeripheralType( state ) )
{ {
case Speaker:
case DiskDrive: case DiskDrive:
case Printer: case Printer:
{ {

View File

@ -121,7 +121,8 @@ public enum BlockPeripheralVariant implements IStringSerializable
AdvancedMonitorDownLUD( "advanced_monitor_down_lud", PeripheralType.AdvancedMonitor ), AdvancedMonitorDownLUD( "advanced_monitor_down_lud", PeripheralType.AdvancedMonitor ),
AdvancedMonitorDownRU( "advanced_monitor_down_ru", PeripheralType.AdvancedMonitor ), AdvancedMonitorDownRU( "advanced_monitor_down_ru", PeripheralType.AdvancedMonitor ),
AdvancedMonitorDownLRU( "advanced_monitor_down_lru", 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 String m_name;
private PeripheralType m_peripheralType; private PeripheralType m_peripheralType;

View File

@ -56,6 +56,12 @@ public class ItemPeripheral extends ItemPeripheralBase
stack = new ItemStack( this, quantity, 4 ); stack = new ItemStack( this, quantity, 4 );
break; break;
} }
case Speaker:
{
stack = new ItemStack(this, quantity, 5);
break;
}
default: default:
{ {
// Ignore types we can't handle // 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.Monitor, null, 1 ) );
list.add( PeripheralItemFactory.create( PeripheralType.AdvancedMonitor, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.AdvancedMonitor, null, 1 ) );
list.add( PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 ) );
list.add( PeripheralItemFactory.create( PeripheralType.Speaker, null, 1) );
} }
@Override @Override
@ -105,6 +112,10 @@ public class ItemPeripheral extends ItemPeripheralBase
{ {
return PeripheralType.AdvancedMonitor; return PeripheralType.AdvancedMonitor;
} }
case 5:
{
return PeripheralType.Speaker;
}
} }
} }
} }

View File

@ -25,6 +25,7 @@ public class PeripheralItemFactory
ItemAdvancedModem advancedModem = ((ItemAdvancedModem)Item.getItemFromBlock( ComputerCraft.Blocks.advancedModem )); ItemAdvancedModem advancedModem = ((ItemAdvancedModem)Item.getItemFromBlock( ComputerCraft.Blocks.advancedModem ));
switch( type ) switch( type )
{ {
case Speaker:
case DiskDrive: case DiskDrive:
case Printer: case Printer:
case Monitor: case Monitor:

View File

@ -44,6 +44,7 @@ import dan200.computercraft.shared.peripheral.modem.TileWirelessModem;
import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
import dan200.computercraft.shared.peripheral.printer.TilePrinter; 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.inventory.ContainerPocketComputer;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory; import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory;
@ -308,6 +309,15 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
'Y', Items.REDSTONE '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 // Wireless Modem
ItemStack wirelessModem = PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 ); ItemStack wirelessModem = PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 );
GameRegistry.addRecipe( wirelessModem, GameRegistry.addRecipe( wirelessModem,
@ -541,14 +551,15 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
private void registerTileEntities() private void registerTileEntities()
{ {
// Tile Entities // Tile Entities
registerTileEntity( TileComputer.class, "computer" ); GameRegistry.registerTileEntity( TileComputer.class, "computer" );
registerTileEntity( TileDiskDrive.class, "diskdrive" ); GameRegistry.registerTileEntity( TileDiskDrive.class, "diskdrive" );
registerTileEntity( TileWirelessModem.class, "wirelessmodem" ); GameRegistry.registerTileEntity( TileWirelessModem.class, "wirelessmodem" );
registerTileEntity( TileMonitor.class, "monitor" ); GameRegistry.registerTileEntity( TileMonitor.class, "monitor" );
registerTileEntity( TilePrinter.class, "ccprinter" ); GameRegistry.registerTileEntity( TilePrinter.class, "ccprinter" );
registerTileEntity( TileCable.class, "wiredmodem" ); GameRegistry.registerTileEntity( TileCable.class, "wiredmodem" );
registerTileEntity( TileCommandComputer.class, "command_computer" ); GameRegistry.registerTileEntity( TileCommandComputer.class, "command_computer" );
registerTileEntity( TileAdvancedModem.class, "advanced_modem" ); GameRegistry.registerTileEntity( TileAdvancedModem.class, "advanced_modem" );
GameRegistry.registerTileEntity( TileSpeaker.class, "speaker" );
// Register peripheral providers // Register peripheral providers
ComputerCraftAPI.registerPeripheralProvider( new DefaultPeripheralProvider() ); ComputerCraftAPI.registerPeripheralProvider( new DefaultPeripheralProvider() );