-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
18 changed files
with
618 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/java/dan200/computercraft/shared/peripheral/common/BlockWiredModemFull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
*/ | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/dan200/computercraft/shared/peripheral/common/ItemWiredModemFull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.