1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 11:10:29 +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" ),
Cable( "cable" ),
WiredModemWithCable( "wired_modem_with_cable" ),
AdvancedModem( "advanced_modem" );
AdvancedModem( "advanced_modem" ),
Speaker( "speaker" );
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.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:
{

View File

@ -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;

View File

@ -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;
}
}
}
}

View File

@ -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:

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.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() );