1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-27 07:52:18 +00:00

Merge pull request #11 from ga2mer/1.17.1

Wired Modem/Cable breaking and creative picking of sided modem and cable
This commit is contained in:
Merith 2021-10-28 10:10:36 -07:00 committed by GitHub
commit 9fb35b2799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 19 deletions

View File

@ -49,6 +49,7 @@ import dan200.computercraft.shared.turtle.upgrades.*;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
@ -114,8 +115,8 @@ public final class ComputerCraftRegistry
public static final BlockWirelessModem WIRELESS_MODEM_ADVANCED = register( "wireless_modem_advanced",
new BlockWirelessModem( properties(), ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_ADVANCED, ComputerFamily.ADVANCED ) );
public static final BlockWiredModemFull WIRED_MODEM_FULL = register( "wired_modem_full",
new BlockWiredModemFull( emProperties(), ComputerCraftRegistry.ModTiles.WIRED_MODEM_FULL ) );
public static final BlockCable CABLE = register( "cable", new BlockCable( emProperties() ) );
new BlockWiredModemFull( modemProperties(), ComputerCraftRegistry.ModTiles.WIRED_MODEM_FULL ) );
public static final BlockCable CABLE = register( "cable", new BlockCable( modemProperties() ) );
private static Block.Settings properties()
{
@ -133,9 +134,11 @@ public final class ComputerCraftRegistry
.strength( 2.5f );
}
private static Block.Settings emProperties()
private static Block.Settings modemProperties()
{
return FabricBlockSettings.copyOf( Blocks.STONE )
.breakByHand( true )
.breakByTool( FabricToolTags.PICKAXES )
.strength( 1.5f );
}

View File

@ -11,6 +11,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.util.WorldUtil;
import net.fabricmc.fabric.api.block.BlockPickInteractionAware;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@ -37,7 +38,7 @@ import java.util.EnumMap;
import static dan200.computercraft.shared.util.WaterloggableHelpers.*;
public class BlockCable extends BlockGeneric implements Waterloggable
public class BlockCable extends BlockGeneric implements Waterloggable, BlockPickInteractionAware
{
public static final EnumProperty<CableModemVariant> MODEM = EnumProperty.of( "modem", CableModemVariant.class );
public static final BooleanProperty CABLE = BooleanProperty.of( "cable" );
@ -168,21 +169,21 @@ public class BlockCable extends BlockGeneric implements Waterloggable
return true;
}
// TODO Re-implement, likely will need mixin
// @Override
// public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
// Direction modem = state.get( MODEM ).getFacing();
// boolean cable = state.get( CABLE );
//
// // If we've only got one, just use that.
// if( !cable ) return new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM.get() );
// if( modem == null ) return new ItemStack( ComputerCraftRegistry.ModItems.CABLE.get() );
//
// // We've a modem and cable, so try to work out which one we're interacting with
// return hit != null && WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getPos().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
// ? new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM.get() )
// : new ItemStack( ComputerCraftRegistry.ModItems.CABLE.get() );
// }
@Override
public ItemStack getPickedStack( BlockState state, BlockView world, BlockPos pos, @Nullable PlayerEntity player, HitResult hit )
{
Direction modem = state.get( MODEM ).getFacing();
boolean cable = state.get( CABLE );
// If we've only got one, just use that.
if( !cable ) return new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM );
if( modem == null ) return new ItemStack( ComputerCraftRegistry.ModItems.CABLE );
// We've a modem and cable, so try to work out which one we're interacting with
return hit != null && WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getPos().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
? new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM )
: new ItemStack( ComputerCraftRegistry.ModItems.CABLE );
}
@Override
@Deprecated