From 922f424a78a4ecc1854a39ff7c8debe16df181eb Mon Sep 17 00:00:00 2001 From: SquidDev Date: Wed, 21 Feb 2018 15:40:08 +0000 Subject: [PATCH] Add full block wired modems These act similarly to conventional wired modems, but with the advantage that they are a full block. This means they can be attached to peripherals which are not solid (such as chests). Further more, as they do not have a direction, they allow wrapping peripherals on all 6 sides. It's worth noting that wired modems do not require a cable - they will automatically form connections to adjacent network elements when placed. --- .../dan200/computercraft/ComputerCraft.java | 2 + .../proxy/ComputerCraftProxyClient.java | 1 + .../shared/peripheral/PeripheralType.java | 3 +- .../common/BlockWiredModemFull.java | 102 +++++ .../peripheral/common/ItemPeripheralBase.java | 4 +- .../peripheral/common/ItemWiredModemFull.java | 18 + .../common/PeripheralItemFactory.java | 2 + .../peripheral/modem/TileWiredModemFull.java | 416 ++++++++++++++++++ .../proxy/ComputerCraftProxyCommon.java | 15 +- .../advancements/recipes/wired_modem.json | 13 +- .../blockstates/wired_modem_full.json | 9 + .../models/block/wired_modem_full_off.json | 6 + .../wired_modem_full_off_peripheral.json | 6 + .../models/block/wired_modem_full_on.json | 6 + .../block/wired_modem_full_on_peripheral.json | 6 + .../models/item/wired_modem_full.json | 3 + .../recipes/wired_modem_full_from.json | 7 + .../recipes/wired_modem_full_to.json | 7 + 18 files changed, 618 insertions(+), 8 deletions(-) create mode 100644 src/main/java/dan200/computercraft/shared/peripheral/common/BlockWiredModemFull.java create mode 100644 src/main/java/dan200/computercraft/shared/peripheral/common/ItemWiredModemFull.java create mode 100644 src/main/java/dan200/computercraft/shared/peripheral/modem/TileWiredModemFull.java create mode 100644 src/main/resources/assets/computercraft/blockstates/wired_modem_full.json create mode 100644 src/main/resources/assets/computercraft/models/block/wired_modem_full_off.json create mode 100644 src/main/resources/assets/computercraft/models/block/wired_modem_full_off_peripheral.json create mode 100644 src/main/resources/assets/computercraft/models/block/wired_modem_full_on.json create mode 100644 src/main/resources/assets/computercraft/models/block/wired_modem_full_on_peripheral.json create mode 100644 src/main/resources/assets/computercraft/models/item/wired_modem_full.json create mode 100644 src/main/resources/assets/computercraft/recipes/wired_modem_full_from.json create mode 100644 src/main/resources/assets/computercraft/recipes/wired_modem_full_to.json diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 4211e7eea1..013b203ca3 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -47,6 +47,7 @@ import dan200.computercraft.shared.network.PacketHandler; import dan200.computercraft.shared.peripheral.common.BlockCable; import dan200.computercraft.shared.peripheral.common.BlockPeripheral; +import dan200.computercraft.shared.peripheral.common.BlockWiredModemFull; import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; import dan200.computercraft.shared.peripheral.modem.BlockAdvancedModem; import dan200.computercraft.shared.peripheral.modem.WirelessNetwork; @@ -180,6 +181,7 @@ public static class Blocks public static BlockTurtle turtleAdvanced; public static BlockCommandComputer commandComputer; public static BlockAdvancedModem advancedModem; + public static BlockWiredModemFull wiredModemFull; } public static class Items diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 7ce9e97033..305f0bcacb 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -115,6 +115,7 @@ public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack ) registerItemModel( ComputerCraft.Blocks.commandComputer, "command_computer" ); registerItemModel( ComputerCraft.Blocks.advancedModem, "advanced_modem" ); registerItemModel( ComputerCraft.Blocks.peripheral, 5, "speaker" ); + registerItemModel( ComputerCraft.Blocks.wiredModemFull, "wired_modem_full" ); registerItemModel( ComputerCraft.Items.disk, "disk" ); registerItemModel( ComputerCraft.Items.diskExpanded, "disk_expanded" ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java b/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java index 2cfaaf0703..b209a60c2b 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/PeripheralType.java @@ -21,7 +21,8 @@ public enum PeripheralType implements IStringSerializable Cable( "cable" ), WiredModemWithCable( "wired_modem_with_cable" ), AdvancedModem( "advanced_modem" ), - Speaker( "speaker" ); + Speaker( "speaker" ), + WiredModemFull( "wired_modem_full" ); private String m_name; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/BlockWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockWiredModemFull.java new file mode 100644 index 0000000000..6936b12ca2 --- /dev/null +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/BlockWiredModemFull.java @@ -0,0 +1,102 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ + +package dan200.computercraft.shared.peripheral.common; + +import dan200.computercraft.ComputerCraft; +import dan200.computercraft.shared.peripheral.PeripheralType; +import dan200.computercraft.shared.peripheral.modem.TileWiredModemFull; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; + +import javax.annotation.Nonnull; + +public class BlockWiredModemFull extends BlockPeripheralBase +{ + // Statics + + public static class Properties + { + public static final PropertyBool MODEM_ON = PropertyBool.create( "modem" ); + public static final PropertyBool PERIPHERAL_ON = PropertyBool.create( "peripheral" ); + } + + // Members + + public BlockWiredModemFull() + { + setHardness( 1.5f ); + setUnlocalizedName( "computercraft:wired_modem_full" ); + setCreativeTab( ComputerCraft.mainCreativeTab ); + setDefaultState( blockState.getBaseState() + .withProperty( Properties.MODEM_ON, false ) + .withProperty( Properties.PERIPHERAL_ON, false ) + ); + } + + @Override + protected IBlockState getDefaultBlockState( PeripheralType type, EnumFacing placedSide ) + { + return getDefaultState(); + } + + @Nonnull + @Override + protected BlockStateContainer createBlockState() + { + return new BlockStateContainer( this, + Properties.MODEM_ON, + Properties.PERIPHERAL_ON + ); + } + + @Override + public int getMetaFromState( IBlockState state ) + { + return 0; + } + + @Nonnull + @Override + @Deprecated + public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos ) + { + TileEntity te = world.getTileEntity( pos ); + if( te instanceof TileWiredModemFull ) + { + TileWiredModemFull modem = (TileWiredModemFull) te; + int anim = modem.getAnim(); + state = state + .withProperty( Properties.MODEM_ON, (anim & 1) != 0 ) + .withProperty( Properties.PERIPHERAL_ON, (anim & 2) != 0 ); + } + + return state; + } + + @Override + public PeripheralType getPeripheralType( int damage ) + { + return PeripheralType.WiredModemFull; + } + + @Override + public PeripheralType getPeripheralType( IBlockState state ) + { + return PeripheralType.WiredModemFull; + } + + @Override + public TilePeripheralBase createTile( PeripheralType type ) + { + return new TileWiredModemFull(); + } +} diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheralBase.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheralBase.java index cd39a1b0f5..a08bbd5b03 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheralBase.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheralBase.java @@ -11,8 +11,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -102,6 +102,8 @@ public String getUnlocalizedName( @Nonnull ItemStack stack ) { return "tile.computercraft:speaker"; } + case WiredModemFull: + return "tile.computercraft:wired_modem"; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemWiredModemFull.java new file mode 100644 index 0000000000..11e8a399df --- /dev/null +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemWiredModemFull.java @@ -0,0 +1,18 @@ +package dan200.computercraft.shared.peripheral.common; + +import dan200.computercraft.shared.peripheral.PeripheralType; +import net.minecraft.block.Block; + +public class ItemWiredModemFull extends ItemPeripheralBase +{ + public ItemWiredModemFull( Block block ) + { + super( block ); + } + + @Override + public PeripheralType getPeripheralType( int damage ) + { + return PeripheralType.WiredModemFull; + } +} 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 1585521ff2..a9ea01310c 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/PeripheralItemFactory.java @@ -47,6 +47,8 @@ public static ItemStack create( PeripheralType type, String label, int quantity { return advancedModem.create( type, label, quantity ); } + case WiredModemFull: + return new ItemStack( ComputerCraft.Blocks.wiredModemFull, quantity ); } return ItemStack.EMPTY; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/TileWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/TileWiredModemFull.java new file mode 100644 index 0000000000..d46ab6a166 --- /dev/null +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/TileWiredModemFull.java @@ -0,0 +1,416 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ + +package dan200.computercraft.shared.peripheral.modem; + +import com.google.common.base.Objects; +import dan200.computercraft.ComputerCraft; +import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.IWiredElementTile; +import dan200.computercraft.api.network.wired.IWiredNode; +import dan200.computercraft.api.peripheral.IPeripheral; +import dan200.computercraft.shared.peripheral.common.BlockCable; +import dan200.computercraft.shared.peripheral.common.TilePeripheralBase; +import dan200.computercraft.shared.util.IDAssigner; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; + +import javax.annotation.Nonnull; +import java.io.File; +import java.util.*; + +public class TileWiredModemFull extends TilePeripheralBase implements IWiredElementTile +{ + private static class FullElement extends WiredModemElement + { + private final TileWiredModemFull m_entity; + + private FullElement( TileWiredModemFull m_entity ) + { + this.m_entity = m_entity; + } + + @Override + protected void attachPeripheral( String name, IPeripheral peripheral ) + { + for( int i = 0; i < 6; i++ ) + { + WiredModemPeripheral modem = m_entity.m_modems[i]; + if( modem != null && !name.equals( m_entity.getCachedPeripheralName( EnumFacing.VALUES[i] ) ) ) + { + modem.attachPeripheral( name, peripheral ); + } + } + } + + @Override + protected void detachPeripheral( String name ) + { + for( int i = 0; i < 6; i++ ) + { + WiredModemPeripheral modem = m_entity.m_modems[i]; + if( modem != null ) modem.detachPeripheral( name ); + } + } + + @Nonnull + @Override + public World getWorld() + { + return m_entity.getWorld(); + } + + @Nonnull + @Override + public Vec3d getPosition() + { + BlockPos pos = m_entity.getPos(); + return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + } + + @Nonnull + @Override + public Map getPeripherals() + { + return m_entity.getPeripherals(); + } + } + + private WiredModemPeripheral[] m_modems = new WiredModemPeripheral[6]; + + private boolean m_peripheralAccessAllowed = false; + private int[] m_attachedPeripheralIDs = new int[6]; + private String[] m_attachedPeripheralTypes = new String[6]; + + private boolean m_destroyed = false; + private boolean m_connectionsFormed = false; + + private final WiredModemElement m_element = new FullElement( this ); + private final IWiredNode node = m_element.getNode(); + + public TileWiredModemFull() + { + Arrays.fill( m_attachedPeripheralIDs, -1 ); + } + + private void remove() + { + if( world == null || !world.isRemote ) + { + node.remove(); + m_connectionsFormed = false; + } + } + + @Override + public void destroy() + { + if( !m_destroyed ) + { + m_destroyed = true; + remove(); + } + super.destroy(); + } + + @Override + public void onChunkUnload() + { + super.onChunkUnload(); + remove(); + } + + @Override + public void invalidate() + { + super.invalidate(); + remove(); + } + + @Override + public EnumFacing getDirection() + { + return EnumFacing.NORTH; + } + + @Override + public void setDirection( EnumFacing dir ) + { + } + + @Override + public void onNeighbourChange() + { + if( !world.isRemote && m_peripheralAccessAllowed ) + { + Map updated = getPeripherals(); + + if( updated.isEmpty() ) + { + // If there are no peripherals then disable access and update the display state. + m_peripheralAccessAllowed = false; + updateAnim(); + } + + // Always invalidate the node: it's more accurate than checking if the peripherals + // have changed + node.invalidate(); + } + } + + @Nonnull + @Override + public AxisAlignedBB getBounds() + { + return BlockCable.FULL_BLOCK_AABB; + } + + @Override + public boolean onActivate( EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ ) + { + if( !getWorld().isRemote ) + { + // On server, we interacted if a peripheral was found + Set oldPeriphName = getPeripherals().keySet(); + togglePeripheralAccess(); + Set periphName = getPeripherals().keySet(); + + if( !Objects.equal( periphName, oldPeriphName ) ) + { + if( !oldPeriphName.isEmpty() ) + { + List names = new ArrayList<>( oldPeriphName ); + names.sort( Comparator.naturalOrder() ); + + player.sendMessage( + new TextComponentTranslation( "gui.computercraft:wired_modem.peripheral_disconnected", String.join( ", ", names ) ) + ); + } + if( !periphName.isEmpty() ) + { + List names = new ArrayList<>( periphName ); + names.sort( Comparator.naturalOrder() ); + player.sendMessage( + new TextComponentTranslation( "gui.computercraft:wired_modem.peripheral_connected", String.join( ", ", names ) ) + ); + } + } + + return true; + } + else + { + // On client, we can't know this, so we assume so to be safe + // The server will correct us if we're wrong + return true; + } + } + + @Override + public void readFromNBT( NBTTagCompound tag ) + { + super.readFromNBT( tag ); + m_peripheralAccessAllowed = tag.getBoolean( "peripheralAccess" ); + for( int i = 0; i < m_attachedPeripheralIDs.length; i++ ) + { + if( tag.hasKey( "peripheralID_" + i, Constants.NBT.TAG_ANY_NUMERIC ) ) + { + m_attachedPeripheralIDs[i] = tag.getInteger( "peripheralID_" + i ); + } + if( tag.hasKey( "peripheralType_" + i, Constants.NBT.TAG_STRING ) ) + { + m_attachedPeripheralTypes[i] = tag.getString( "peripheralType_" + i ); + } + } + } + + @Nonnull + @Override + public NBTTagCompound writeToNBT( NBTTagCompound tag ) + { + tag = super.writeToNBT( tag ); + tag.setBoolean( "peripheralAccess", m_peripheralAccessAllowed ); + for( int i = 0; i < m_attachedPeripheralIDs.length; i++ ) + { + if( m_attachedPeripheralIDs[i] >= 0 ) + { + tag.setInteger( "peripheralID_" + i, m_attachedPeripheralIDs[i] ); + } + if( m_attachedPeripheralTypes[i] != null ) + { + tag.setString( "peripheralType_" + i, m_attachedPeripheralTypes[i] ); + } + } + return tag; + } + + protected void updateAnim() + { + int anim = 0; + for( WiredModemPeripheral modem : m_modems ) + { + if( modem != null && modem.isActive() ) + { + anim += 1; + break; + } + } + + if( m_peripheralAccessAllowed ) + { + anim += 2; + } + setAnim( anim ); + } + + @Override + public final void readDescription( @Nonnull NBTTagCompound tag ) + { + super.readDescription( tag ); + updateBlock(); + } + + @Override + public void update() + { + if( !getWorld().isRemote ) + { + boolean changed = false; + for( WiredModemPeripheral peripheral : m_modems ) + { + if( peripheral != null && peripheral.pollChanged() ) changed = true; + } + if( changed ) updateAnim(); + + if( !m_connectionsFormed ) + { + networkChanged(); + m_connectionsFormed = true; + } + } + + super.update(); + } + + private void networkChanged() + { + if( getWorld().isRemote ) return; + + World world = getWorld(); + BlockPos current = getPos(); + for( EnumFacing facing : EnumFacing.VALUES ) + { + if( !world.isBlockLoaded( pos ) ) continue; + + IWiredElement element = ComputerCraft.getWiredElementAt( world, current.offset( facing ), facing.getOpposite() ); + if( element == null ) continue; + + // If we can connect to it then do so + node.connectTo( element.getNode() ); + } + + node.invalidate(); + } + + // private stuff + private void togglePeripheralAccess() + { + if( !m_peripheralAccessAllowed ) + { + m_peripheralAccessAllowed = true; + if( getPeripherals().isEmpty() ) + { + m_peripheralAccessAllowed = false; + return; + } + } + else + { + m_peripheralAccessAllowed = false; + } + + updateAnim(); + node.invalidate(); + } + + @Nonnull + private Map getPeripherals() + { + if( !m_peripheralAccessAllowed ) return Collections.emptyMap(); + + Map peripherals = new HashMap<>( 6 ); + for( EnumFacing facing : EnumFacing.VALUES ) + { + BlockPos neighbour = getPos().offset( facing ); + IPeripheral peripheral = TileCable.getPeripheral( getWorld(), neighbour, facing.getOpposite() ); + if( peripheral != null && !(peripheral instanceof WiredModemPeripheral) ) + { + String type = peripheral.getType(); + int id = m_attachedPeripheralIDs[facing.ordinal()]; + String oldType = m_attachedPeripheralTypes[facing.ordinal()]; + if( id < 0 || !type.equals( oldType ) ) + { + m_attachedPeripheralTypes[facing.ordinal()] = type; + id = m_attachedPeripheralIDs[facing.ordinal()] = IDAssigner.getNextIDFromFile( new File( + ComputerCraft.getWorldDir( getWorld() ), + "computer/lastid_" + type + ".txt" + ) ); + } + + peripherals.put( type + "_" + id, peripheral ); + } + } + + return peripherals; + } + + private String getCachedPeripheralName( EnumFacing facing ) + { + if( !m_peripheralAccessAllowed ) return null; + + int id = m_attachedPeripheralIDs[facing.ordinal()]; + String type = m_attachedPeripheralTypes[facing.ordinal()]; + return id < 0 || type == null ? null : type + "_" + id; + } + + // IWiredElementTile + + @Nonnull + @Override + public IWiredElement getWiredElement( @Nonnull EnumFacing side ) + { + return m_element; + } + + // IPeripheralTile + + @Override + public IPeripheral getPeripheral( EnumFacing side ) + { + WiredModemPeripheral peripheral = m_modems[side.ordinal()]; + if( peripheral == null ) + { + peripheral = m_modems[side.ordinal()] = new WiredModemPeripheral( m_element ) + { + @Nonnull + @Override + public Vec3d getPosition() + { + BlockPos pos = getPos().offset( side ); + return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); + } + }; + } + return peripheral; + } +} diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index c4309a2067..a03d90660a 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -35,10 +35,7 @@ import dan200.computercraft.shared.peripheral.common.*; import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; -import dan200.computercraft.shared.peripheral.modem.BlockAdvancedModem; -import dan200.computercraft.shared.peripheral.modem.TileAdvancedModem; -import dan200.computercraft.shared.peripheral.modem.TileCable; -import dan200.computercraft.shared.peripheral.modem.TileWirelessModem; +import dan200.computercraft.shared.peripheral.modem.*; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; import dan200.computercraft.shared.peripheral.printer.TilePrinter; @@ -273,6 +270,10 @@ public void registerBlocks( RegistryEvent.Register event ) // Command Computer ComputerCraft.Blocks.advancedModem = new BlockAdvancedModem(); registry.register( ComputerCraft.Blocks.advancedModem.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "advanced_modem" ) ) ); + + // Full block modem + ComputerCraft.Blocks.wiredModemFull = new BlockWiredModemFull(); + registry.register( ComputerCraft.Blocks.wiredModemFull.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full" ) ) ); } @SubscribeEvent @@ -294,7 +295,10 @@ public void registerItems( RegistryEvent.Register event ) // 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(); @@ -470,6 +474,7 @@ private void registerTileEntities() GameRegistry.registerTileEntity( TileCommandComputer.class, ComputerCraft.LOWER_ID + " : " + "command_computer" ); GameRegistry.registerTileEntity( TileAdvancedModem.class, ComputerCraft.LOWER_ID + " : " + "advanced_modem" ); GameRegistry.registerTileEntity( TileSpeaker.class, ComputerCraft.LOWER_ID + " : " + "speaker" ); + GameRegistry.registerTileEntity( TileWiredModemFull.class, ComputerCraft.LOWER_ID + " : " + "wired_modem_full" ); // Register peripheral providers ComputerCraftAPI.registerPeripheralProvider( new DefaultPeripheralProvider() ); diff --git a/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json b/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json index 88d3a1ea25..8b7110e693 100644 --- a/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json +++ b/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json @@ -1,7 +1,11 @@ { "parent": "minecraft:recipes/root", "rewards": { - "recipes": [ "computercraft:wired_modem" ] + "recipes": [ + "computercraft:wired_modem", + "computercraft:wired_modem_full_to", + "computercraft:wired_modem_full_from" + ] }, "criteria": { "has_normal": { @@ -22,6 +26,12 @@ "items": [ { "item": "computercraft:cable", "data": 0 } ] } }, + "has_modem_full": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ { "item": "computercraft:wired_modem_full", "data": 0 } ] + } + }, "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { "recipe": "computercraft:wired_modem" } @@ -32,6 +42,7 @@ "has_normal", "has_advanced", "has_cable", + "has_modem_full", "has_the_recipe" ] ] diff --git a/src/main/resources/assets/computercraft/blockstates/wired_modem_full.json b/src/main/resources/assets/computercraft/blockstates/wired_modem_full.json new file mode 100644 index 0000000000..d2f6fb31ce --- /dev/null +++ b/src/main/resources/assets/computercraft/blockstates/wired_modem_full.json @@ -0,0 +1,9 @@ +{ + "variants": { + "modem=false,peripheral=false": { "model": "computercraft:wired_modem_full_off" }, + "modem=false,peripheral=true": { "model": "computercraft:wired_modem_full_off_peripheral" }, + "modem=true,peripheral=false": { "model": "computercraft:wired_modem_full_on" }, + "modem=true,peripheral=true": { "model": "computercraft:wired_modem_full_on_peripheral" } + } +} + diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_full_off.json b/src/main/resources/assets/computercraft/models/block/wired_modem_full_off.json new file mode 100644 index 0000000000..e6ea77dfa4 --- /dev/null +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_full_off.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "computercraft:blocks/wired_modem_face" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_full_off_peripheral.json b/src/main/resources/assets/computercraft/models/block/wired_modem_full_off_peripheral.json new file mode 100644 index 0000000000..318233585b --- /dev/null +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_full_off_peripheral.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "computercraft:blocks/wired_modem_face_peripheral" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_full_on.json b/src/main/resources/assets/computercraft/models/block/wired_modem_full_on.json new file mode 100644 index 0000000000..241e39ca04 --- /dev/null +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_full_on.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "computercraft:blocks/wired_modem_face_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_full_on_peripheral.json b/src/main/resources/assets/computercraft/models/block/wired_modem_full_on_peripheral.json new file mode 100644 index 0000000000..c8ef3c9d47 --- /dev/null +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_full_on_peripheral.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "computercraft:blocks/wired_modem_face_peripheral_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/wired_modem_full.json b/src/main/resources/assets/computercraft/models/item/wired_modem_full.json new file mode 100644 index 0000000000..77237e07a4 --- /dev/null +++ b/src/main/resources/assets/computercraft/models/item/wired_modem_full.json @@ -0,0 +1,3 @@ +{ + "parent": "computercraft:block/wired_modem_full_off" +} diff --git a/src/main/resources/assets/computercraft/recipes/wired_modem_full_from.json b/src/main/resources/assets/computercraft/recipes/wired_modem_full_from.json new file mode 100644 index 0000000000..9e1a326fa9 --- /dev/null +++ b/src/main/resources/assets/computercraft/recipes/wired_modem_full_from.json @@ -0,0 +1,7 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { "item": "computercraft:wired_modem_full", "data": 0 } + ], + "result": { "item": "computercraft:cable", "data": 1 } +} diff --git a/src/main/resources/assets/computercraft/recipes/wired_modem_full_to.json b/src/main/resources/assets/computercraft/recipes/wired_modem_full_to.json new file mode 100644 index 0000000000..3537e326d0 --- /dev/null +++ b/src/main/resources/assets/computercraft/recipes/wired_modem_full_to.json @@ -0,0 +1,7 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { "item": "computercraft:cable", "data": 1 } + ], + "result": { "item": "computercraft:wired_modem_full", "data": 0 } +}