mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 19:20:29 +00:00
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.
This commit is contained in:
parent
5c7828dd79
commit
922f424a78
@ -47,6 +47,7 @@ import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||
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 class ComputerCraft
|
||||
public static BlockTurtle turtleAdvanced;
|
||||
public static BlockCommandComputer commandComputer;
|
||||
public static BlockAdvancedModem advancedModem;
|
||||
public static BlockWiredModemFull wiredModemFull;
|
||||
}
|
||||
|
||||
public static class Items
|
||||
|
@ -115,6 +115,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
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" );
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ import net.minecraft.block.Block;
|
||||
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 abstract class ItemPeripheralBase extends ItemBlock implements IPeriphera
|
||||
{
|
||||
return "tile.computercraft:speaker";
|
||||
}
|
||||
case WiredModemFull:
|
||||
return "tile.computercraft:wired_modem";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -47,6 +47,8 @@ public class PeripheralItemFactory
|
||||
{
|
||||
return advancedModem.create( type, label, quantity );
|
||||
}
|
||||
case WiredModemFull:
|
||||
return new ItemStack( ComputerCraft.Blocks.wiredModemFull, quantity );
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -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<String, IPeripheral> 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<String, IPeripheral> 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<String> oldPeriphName = getPeripherals().keySet();
|
||||
togglePeripheralAccess();
|
||||
Set<String> periphName = getPeripherals().keySet();
|
||||
|
||||
if( !Objects.equal( periphName, oldPeriphName ) )
|
||||
{
|
||||
if( !oldPeriphName.isEmpty() )
|
||||
{
|
||||
List<String> 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<String> 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<String, IPeripheral> getPeripherals()
|
||||
{
|
||||
if( !m_peripheralAccessAllowed ) return Collections.emptyMap();
|
||||
|
||||
Map<String, IPeripheral> 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;
|
||||
}
|
||||
}
|
@ -35,10 +35,7 @@ import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeriphera
|
||||
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 abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
// 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
|
||||
@ -295,6 +296,9 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
// 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 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
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() );
|
||||
|
@ -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"
|
||||
]
|
||||
]
|
||||
|
@ -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" }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "computercraft:blocks/wired_modem_face"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "computercraft:blocks/wired_modem_face_peripheral"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "computercraft:blocks/wired_modem_face_on"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "computercraft:blocks/wired_modem_face_peripheral_on"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "computercraft:block/wired_modem_full_off"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "computercraft:wired_modem_full", "data": 0 }
|
||||
],
|
||||
"result": { "item": "computercraft:cable", "data": 1 }
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "computercraft:cable", "data": 1 }
|
||||
],
|
||||
"result": { "item": "computercraft:wired_modem_full", "data": 0 }
|
||||
}
|
Loading…
Reference in New Issue
Block a user