From 83f6815e7e3d63bfe0608ec74cfd04a590c5110c Mon Sep 17 00:00:00 2001 From: sashafiesta <46864270+sashafiesta@users.noreply.github.com> Date: Tue, 14 May 2024 19:51:47 +0700 Subject: [PATCH] Removed encased chain cogwheel and linked transmitter But it works now! --- .../create_connected/CCBlockEntityTypes.java | 10 +- .../hlysine/create_connected/CCBlocks.java | 8 +- .../com/hlysine/create_connected/CCItems.java | 2 +- .../hlysine/create_connected/CCPonders.java | 12 +- .../chaincogwheel/ChainCogwheelBlock.java | 18 -- .../LinkedAnalogLeverBlock.java | 169 ------------ .../LinkedAnalogLeverBlockEntity.java | 85 ------ .../LinkedAnalogLeverRenderer.java | 22 -- .../linkedtransmitter/LinkedButtonBlock.java | 201 -------------- .../linkedtransmitter/LinkedLeverBlock.java | 196 -------------- .../LinkedTransmitterBlock.java | 14 - .../LinkedTransmitterBlockEntity.java | 70 ----- .../LinkedTransmitterFrequencySlot.java | 64 ----- .../LinkedTransmitterItem.java | 62 ----- .../AnalogLeverBlockEntityAccessor.java | 11 - .../AnalogLeverBlockMixin.java | 37 --- .../ButtonBlockAccessor.java | 17 -- .../ponder/ChainCogwheelScenes.java | 104 ------- .../ponder/LinkedTransmitterScenes.java | 256 ------------------ .../resources/create_connected.mixins.json | 3 - 20 files changed, 16 insertions(+), 1345 deletions(-) delete mode 100644 src/main/java/com/hlysine/create_connected/content/chaincogwheel/ChainCogwheelBlock.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlock.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlockEntity.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverRenderer.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedButtonBlock.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedLeverBlock.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlock.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlockEntity.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterFrequencySlot.java delete mode 100644 src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterItem.java delete mode 100644 src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockEntityAccessor.java delete mode 100644 src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockMixin.java delete mode 100644 src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/ButtonBlockAccessor.java delete mode 100644 src/main/java/com/hlysine/create_connected/ponder/ChainCogwheelScenes.java delete mode 100644 src/main/java/com/hlysine/create_connected/ponder/LinkedTransmitterScenes.java diff --git a/src/main/java/com/hlysine/create_connected/CCBlockEntityTypes.java b/src/main/java/com/hlysine/create_connected/CCBlockEntityTypes.java index 1aaae0b..8af4094 100644 --- a/src/main/java/com/hlysine/create_connected/CCBlockEntityTypes.java +++ b/src/main/java/com/hlysine/create_connected/CCBlockEntityTypes.java @@ -22,10 +22,9 @@ import com.hlysine.create_connected.content.parallelgearbox.ParallelGearboxRenderer; import com.hlysine.create_connected.content.shearpin.ShearPinBlockEntity; import com.hlysine.create_connected.content.sequencedpulsegenerator.SequencedPulseGeneratorBlockEntity; -import com.hlysine.create_connected.content.linkedtransmitter.LinkedAnalogLeverBlockEntity; -import com.hlysine.create_connected.content.linkedtransmitter.LinkedAnalogLeverRenderer; -import com.hlysine.create_connected.content.linkedtransmitter.LinkedTransmitterBlockEntity; - +//import com.hlysine.create_connected.content.linkedtransmitter.LinkedAnalogLeverBlockEntity; +//import com.hlysine.create_connected.content.linkedtransmitter.LinkedAnalogLeverRenderer; +//import com.hlysine.create_connected.content.linkedtransmitter.LinkedTransmitterBlockEntity; import static com.hlysine.create_connected.CreateConnected.REGISTRATE; import com.simibubi.create.content.decoration.copycat.CopycatBlockEntity; @@ -120,6 +119,7 @@ public class CCBlockEntityTypes { .validBlocks(CCBlocks.SEQUENCED_PULSE_GENERATOR) .register(); + /* public static final BlockEntityEntry LINKED_TRANSMITTER = REGISTRATE .blockEntity("linked_transmitter", LinkedTransmitterBlockEntity::new) .transform(b -> {CCBlocks.LINKED_BUTTONS.values().forEach(b::validBlock);return b;}) @@ -133,7 +133,7 @@ public class CCBlockEntityTypes { .validBlocks(CCBlocks.LINKED_ANALOG_LEVER) .renderer(() -> LinkedAnalogLeverRenderer::new) .register(); - + */ public static void register() {} } diff --git a/src/main/java/com/hlysine/create_connected/CCBlocks.java b/src/main/java/com/hlysine/create_connected/CCBlocks.java index 37631d1..6e65b33 100644 --- a/src/main/java/com/hlysine/create_connected/CCBlocks.java +++ b/src/main/java/com/hlysine/create_connected/CCBlocks.java @@ -53,13 +53,13 @@ import com.hlysine.create_connected.content.brake.BrakeBlock; import com.hlysine.create_connected.content.brassgearbox.BrassGearboxBlock; import com.hlysine.create_connected.content.centrifugalclutch.CentrifugalClutchBlock; -import com.hlysine.create_connected.content.chaincogwheel.ChainCogwheelBlock; +//import com.hlysine.create_connected.content.chaincogwheel.ChainCogwheelBlock; import com.hlysine.create_connected.content.freewheelclutch.FreewheelClutchBlock; import com.hlysine.create_connected.content.overstressclutch.OverstressClutchBlock; import com.hlysine.create_connected.content.parallelgearbox.ParallelGearboxBlock; import com.hlysine.create_connected.content.shearpin.ShearPinBlock; import com.hlysine.create_connected.content.sequencedpulsegenerator.SequencedPulseGeneratorBlock; -import com.hlysine.create_connected.content.linkedtransmitter.*; +//import com.hlysine.create_connected.content.linkedtransmitter.*; import com.hlysine.create_connected.content.WrenchableBlock; import com.simibubi.create.AllBlocks; @@ -259,7 +259,7 @@ public class CCBlocks { .register(); //////////////////////////////////////////////////////////////// - + /* public static final Map> LINKED_BUTTONS = new HashMap<>(); static { @@ -297,7 +297,7 @@ public class CCBlocks { .onRegister(PreciseItemUseOverrides::addBlock) //.blockstate(CCBlockStateGen.linkedLever(Create.asResource("block/analog_lever/block"),Create.asResource("block/analog_lever/block"))) .register(); - + */ public static final BlockEntry EMPTY_FAN_CATALYST = REGISTRATE.block("empty_fan_catalyst", WrenchableBlock::new) .initialProperties(() -> Blocks.IRON_BLOCK) .properties(p -> p diff --git a/src/main/java/com/hlysine/create_connected/CCItems.java b/src/main/java/com/hlysine/create_connected/CCItems.java index 7777f9b..61cd4a0 100644 --- a/src/main/java/com/hlysine/create_connected/CCItems.java +++ b/src/main/java/com/hlysine/create_connected/CCItems.java @@ -1,6 +1,6 @@ package com.hlysine.create_connected; -import com.hlysine.create_connected.content.linkedtransmitter.LinkedTransmitterItem; +//import com.hlysine.create_connected.content.linkedtransmitter.LinkedTransmitterItem; import com.hlysine.create_connected.content.sixwaygearbox.VerticalSixWayGearboxItem; import com.hlysine.create_connected.content.brassgearbox.VerticalBrassGearboxItem; import com.hlysine.create_connected.content.parallelgearbox.VerticalParallelGearboxItem; diff --git a/src/main/java/com/hlysine/create_connected/CCPonders.java b/src/main/java/com/hlysine/create_connected/CCPonders.java index c57ffda..a223114 100644 --- a/src/main/java/com/hlysine/create_connected/CCPonders.java +++ b/src/main/java/com/hlysine/create_connected/CCPonders.java @@ -17,8 +17,8 @@ public class CCPonders { static final PonderRegistrationHelper HELPER = new PonderRegistrationHelper(CreateConnected.ID); public static void register() { - HELPER.forComponents(CCBlocks.ENCASED_CHAIN_COGWHEEL) - .addStoryBoard("chain_cogwheel", ChainCogwheelScenes::chainCogwheelAsRelay, AllPonderTags.KINETIC_RELAYS); + //HELPER.forComponents(CCBlocks.ENCASED_CHAIN_COGWHEEL) + // .addStoryBoard("chain_cogwheel", ChainCogwheelScenes::chainCogwheelAsRelay, AllPonderTags.KINETIC_RELAYS); HELPER.forComponents(CCBlocks.INVERTED_CLUTCH) .addStoryBoard("inverted_clutch", InvertedClutchScenes::invertedClutch, AllPonderTags.KINETIC_RELAYS); HELPER.forComponents(CCBlocks.INVERTED_GEARSHIFT) @@ -27,16 +27,16 @@ public static void register() { .addStoryBoard("parallel_gearbox", ParallelGearboxScenes::parallelGearbox, AllPonderTags.KINETIC_RELAYS); HELPER.forComponents(CCBlocks.SEQUENCED_PULSE_GENERATOR) .addStoryBoard("sequenced_pulse_generator", SequencedPulseGeneratorScenes::pulseGenerator, AllPonderTags.REDSTONE); - HELPER.forComponents(CCItems.LINKED_TRANSMITTER) - .addStoryBoard("linked_transmitter", LinkedTransmitterScenes::linkedTransmitter, AllPonderTags.REDSTONE); + //HELPER.forComponents(CCItems.LINKED_TRANSMITTER) + // .addStoryBoard("linked_transmitter", LinkedTransmitterScenes::linkedTransmitter, AllPonderTags.REDSTONE); PonderRegistry.TAGS.forTag(AllPonderTags.KINETIC_RELAYS) - .add(CCBlocks.ENCASED_CHAIN_COGWHEEL) + //.add(CCBlocks.ENCASED_CHAIN_COGWHEEL) .add(CCBlocks.INVERTED_CLUTCH) .add(CCBlocks.INVERTED_GEARSHIFT) .add(CCBlocks.PARALLEL_GEARBOX); PonderRegistry.TAGS.forTag(AllPonderTags.REDSTONE) .add(CCBlocks.SEQUENCED_PULSE_GENERATOR) - .add(CCItems.LINKED_TRANSMITTER); + ;//.add(CCItems.LINKED_TRANSMITTER); } } diff --git a/src/main/java/com/hlysine/create_connected/content/chaincogwheel/ChainCogwheelBlock.java b/src/main/java/com/hlysine/create_connected/content/chaincogwheel/ChainCogwheelBlock.java deleted file mode 100644 index 41c6d08..0000000 --- a/src/main/java/com/hlysine/create_connected/content/chaincogwheel/ChainCogwheelBlock.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hlysine.create_connected.content.chaincogwheel; - -import com.hlysine.create_connected.CCBlockEntityTypes; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.content.kinetics.chainDrive.ChainDriveBlock; -import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel; -import net.minecraft.world.level.block.entity.BlockEntityType; - -public class ChainCogwheelBlock extends ChainDriveBlock implements ICogWheel { - public ChainCogwheelBlock(Properties properties) { - super(properties); - } - - @Override - public BlockEntityType getBlockEntityType() { - return CCBlockEntityTypes.ENCASED_CHAIN_COGWHEEL.get(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlock.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlock.java deleted file mode 100644 index 487d41f..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlock.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; -import org.jetbrains.annotations.Nullable; -import com.hlysine.create_connected.CCBlockEntityTypes; -import com.hlysine.create_connected.CCItems; -import com.hlysine.create_connected.CCShapes; -import com.simibubi.create.AllSoundEvents; -import com.simibubi.create.content.equipment.wrench.IWrenchable; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlock; -import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement; -import com.simibubi.create.content.schematics.requirement.ItemRequirement; -import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.storage.loot.LootParams; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.jetbrains.annotations.NotNull; -import net.fabricmc.fabric.api.block.BlockPickInteractionAware; - -import java.util.ArrayList; -import java.util.List; - -public class LinkedAnalogLeverBlock extends AnalogLeverBlock implements ISpecialBlockItemRequirement, IWrenchable, LinkedTransmitterBlock, BlockPickInteractionAware { - public static BooleanProperty LOCKED = BlockStateProperties.LOCKED; - - public static final BooleanProperty POWERED = BlockStateProperties.POWERED; - private final NonNullSupplier baseSupplier; - - public LinkedAnalogLeverBlock(Properties pProperties, NonNullSupplier baseSupplier) { - super(pProperties); - registerDefaultState(defaultBlockState().setValue(POWERED, false).setValue(LOCKED, false)); - this.baseSupplier = baseSupplier; - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { - super.createBlockStateDefinition(pBuilder.add(POWERED, LOCKED)); - } - - @Override - public Block getBlock() { - return this; - } - - @Override - public Block getBase() { - return baseSupplier.get(); - } - - @Override - public @NotNull VoxelShape getShape(@NotNull BlockState state, - @NotNull BlockGetter level, - @NotNull BlockPos pos, - @NotNull CollisionContext context) { - Direction facing = state.getValue(AnalogLeverBlock.FACING); - return Shapes.or(switch (state.getValue(AnalogLeverBlock.FACE)) { - case FLOOR -> CCShapes.FLOOR_LINKED_TRANSMITTER.get(facing); - case WALL -> CCShapes.WALL_LINKED_TRANSMITTER.get(facing); - case CEILING -> CCShapes.CEILING_LINKED_TRANSMITTER.get(facing); - }, super.getShape(state, level, pos, context)); - } - - @SuppressWarnings("deprecation") - @Override - public @NotNull List getDrops(@NotNull BlockState state, LootParams.@NotNull Builder builder) { - return getBase().getDrops(state, builder); - } - - private boolean isHittingBase(BlockState state, BlockGetter level, BlockPos pos, HitResult hit) { - return super.getShape(state, level, pos, CollisionContext.empty()).bounds().inflate(0.01 / 16).move(pos).contains(hit.getLocation()); - } - - @Override - public @NotNull InteractionResult use(@NotNull BlockState state, - @NotNull Level level, - @NotNull BlockPos pos, - @NotNull Player player, - @NotNull InteractionHand hand, - @NotNull BlockHitResult hit) { - if (isHittingBase(state, level, pos, hit)) { - return super.use(state, level, pos, player, hand, hit); - } - if (player.isShiftKeyDown()) { - if (!level.isClientSide()) - level.setBlockAndUpdate(pos, state.cycle(LOCKED)); - return InteractionResult.SUCCESS; - } - if (state.getValue(LOCKED)) - return InteractionResult.CONSUME; - return InteractionResult.PASS; - } - - @Override - public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { - if (!state.is(newState.getBlock()) && !isMoving && getBlockEntityOptional(world, pos).map(be -> ((LinkedAnalogLeverBlockEntity) be).containsBase).orElse(false)) - Block.popResource(world, pos, new ItemStack(CCItems.LINKED_TRANSMITTER)); - getBase().onRemove(state, world, pos, newState, isMoving); - } - - @Override - public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { - onWrenched(state, context); - return IWrenchable.super.onSneakWrenched(state, context); - } - - @Override - public InteractionResult onWrenched(BlockState state, UseOnContext context) { - Player player = context.getPlayer(); - if (!player.isCreative()) { - player.getInventory().placeItemBackInInventory(new ItemStack(CCItems.LINKED_TRANSMITTER)); - } - withBlockEntityDo(context.getLevel(), context.getClickedPos(), be -> ((LinkedAnalogLeverBlockEntity) be).containsBase = false); - replaceWithBase(state, context.getLevel(), context.getClickedPos()); - return InteractionResult.SUCCESS; - } - - @Override - public void replaceBase(BlockState baseState, Level world, BlockPos pos) { - world.setBlockAndUpdate(pos, defaultBlockState() - .setValue(FACING, baseState.getValue(FACING)) - .setValue(FACE, baseState.getValue(FACE)) - ); - AllSoundEvents.CONTROLLER_PUT.playOnServer(world, pos); - } - - public void replaceWithBase(BlockState state, Level world, BlockPos pos) { - AllSoundEvents.CONTROLLER_TAKE.playOnServer(world, pos); - world.setBlockAndUpdate(pos, getBase().defaultBlockState() - .setValue(FACING, state.getValue(FACING)) - .setValue(FACE, state.getValue(FACE))); - } - - @Override - public ItemStack getPickedStack(BlockState state, BlockGetter view, BlockPos pos, @Nullable Player player, @Nullable HitResult result) { - if (isHittingBase(state, view, pos, result)) - return super.getCloneItemStack(view, pos, state); - return new ItemStack(CCItems.LINKED_TRANSMITTER.get()); - } - - @Override - public ItemRequirement getRequiredItems(BlockState state, BlockEntity be) { - ArrayList requiredItems = new ArrayList<>(); - requiredItems.add(new ItemStack(getBase())); - requiredItems.add(new ItemStack(CCItems.LINKED_TRANSMITTER.get())); - return new ItemRequirement(ItemRequirement.ItemUseType.CONSUME, requiredItems); - } - - @Override - public BlockEntityType getBlockEntityType() { - return CCBlockEntityTypes.LINKED_ANALOG_LEVER.get(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlockEntity.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlockEntity.java deleted file mode 100644 index f8930b9..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverBlockEntity.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.hlysine.create_connected.mixin.linkedtransmitter.AnalogLeverBlockEntityAccessor; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlockEntity; -import com.simibubi.create.content.redstone.link.LinkBehaviour; -import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.List; - -public class LinkedAnalogLeverBlockEntity extends AnalogLeverBlockEntity { - - private int transmittedSignal; - /** - * set to false if the module item is already returned to player via wrenching - */ - public boolean containsBase = true; - private LinkBehaviour link; - - public LinkedAnalogLeverBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { - super(type, pos, state); - } - - @Override - public void addBehaviours(List behaviours) { - createLink(); - behaviours.add(link); - } - - @Override - public void initialize() { - super.initialize(); - transmit(getState()); - } - - protected void createLink() { - Pair slots = - ValueBoxTransform.Dual.makeSlots(LinkedTransmitterFrequencySlot::new); - link = LinkBehaviour.transmitter(this, slots, this::getSignal); - } - - public int getSignal() { - return transmittedSignal; - } - - public void transmit(int strength) { - transmittedSignal = strength; - if (link != null) - link.notifySignalChange(); - } - - private int lastChange() { - return ((AnalogLeverBlockEntityAccessor) this).getLastChange(); - } - - @Override - public void tick() { - int prevTick = lastChange(); - super.tick(); - if (prevTick > 0 && lastChange() == 0) { - transmit(getState()); - level.setBlockAndUpdate(getBlockPos(), getBlockState().setValue(BlockStateProperties.POWERED, getState() > 0)); - } - } - - @Override - public void write(CompoundTag compound, boolean clientPacket) { - compound.putInt("Transmit", transmittedSignal); - super.write(compound, clientPacket); - } - - @Override - protected void read(CompoundTag compound, boolean clientPacket) { - super.read(compound, clientPacket); - if (level == null || level.isClientSide || !link.newPosition) - transmittedSignal = compound.getInt("Transmit"); - } - -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverRenderer.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverRenderer.java deleted file mode 100644 index d64dee3..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedAnalogLeverRenderer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlockEntity; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverRenderer; -import com.simibubi.create.content.redstone.link.LinkRenderer; -import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringRenderer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; - -public class LinkedAnalogLeverRenderer extends AnalogLeverRenderer { - public LinkedAnalogLeverRenderer(BlockEntityRendererProvider.Context context) { - super(context); - } - - @Override - protected void renderSafe(AnalogLeverBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - super.renderSafe(be, partialTicks, ms, buffer, light, overlay); - FilteringRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay); - LinkRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay); - } -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedButtonBlock.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedButtonBlock.java deleted file mode 100644 index 1c122d4..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedButtonBlock.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; -import org.jetbrains.annotations.Nullable; -import com.hlysine.create_connected.CCBlockEntityTypes; -import com.hlysine.create_connected.CCItems; -import com.hlysine.create_connected.CCShapes; -import com.simibubi.create.AllSoundEvents; -import com.simibubi.create.content.equipment.wrench.IWrenchable; -import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement; -import com.simibubi.create.content.schematics.requirement.ItemRequirement; -import com.simibubi.create.foundation.block.IBE; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.ButtonBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.storage.loot.LootParams; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.jetbrains.annotations.NotNull; -import net.fabricmc.fabric.api.block.BlockPickInteractionAware; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.world.level.block.state.properties.BlockSetType; -import com.hlysine.create_connected.mixin.linkedtransmitter.ButtonBlockAccessor; - -public class LinkedButtonBlock extends ButtonBlock implements IBE, ISpecialBlockItemRequirement, IWrenchable, LinkedTransmitterBlock, BlockPickInteractionAware { - public static BooleanProperty LOCKED = BlockStateProperties.LOCKED; - - private final ButtonBlock base; - - public LinkedButtonBlock(Properties pProperties, ButtonBlock base) { - super(pProperties, ((ButtonBlockAccessor)base).getType(), ((ButtonBlockAccessor)base).getTicksToStayPressed(), ((ButtonBlockAccessor)base).getArrowsCanPress()); - this.base = base; - registerDefaultState(defaultBlockState().setValue(LOCKED, false)); - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { - super.createBlockStateDefinition(pBuilder.add(LOCKED)); - } - - @Override - public Block getBlock() { - return this; - } - - @Override - public Block getBase() { - return base; - } - - @Override - public @NotNull VoxelShape getShape(@NotNull BlockState state, - @NotNull BlockGetter level, - @NotNull BlockPos pos, - @NotNull CollisionContext context) { - Direction facing = state.getValue(ButtonBlock.FACING); - return Shapes.or(switch (state.getValue(ButtonBlock.FACE)) { - case FLOOR -> CCShapes.FLOOR_LINKED_TRANSMITTER.get(facing); - case WALL -> CCShapes.WALL_LINKED_TRANSMITTER.get(facing); - case CEILING -> CCShapes.CEILING_LINKED_TRANSMITTER.get(facing); - }, super.getShape(state, level, pos, context)); - } - - @SuppressWarnings("deprecation") - @Override - public @NotNull List getDrops(@NotNull BlockState state, LootParams.@NotNull Builder builder) { - return base.getDrops(state, builder); - } - - private boolean isHittingBase(BlockState state, BlockGetter level, BlockPos pos, HitResult hit) { - return super.getShape(state, level, pos, CollisionContext.empty()).bounds().inflate(0.01 / 16).move(pos).contains(hit.getLocation()); - } - - @Override - public @NotNull InteractionResult use(@NotNull BlockState state, - @NotNull Level level, - @NotNull BlockPos pos, - @NotNull Player player, - @NotNull InteractionHand hand, - @NotNull BlockHitResult hit) { - if (isHittingBase(state, level, pos, hit)) { - if (!player.isShiftKeyDown()) - return super.use(state, level, pos, player, hand, hit); - return InteractionResult.CONSUME; - } - if (player.isShiftKeyDown()) { - if (!level.isClientSide()) - level.setBlockAndUpdate(pos, state.cycle(LOCKED)); - return InteractionResult.SUCCESS; - } - if (state.getValue(LOCKED)) - return InteractionResult.CONSUME; - return InteractionResult.PASS; - } - - @Override - public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { - if (!state.is(newState.getBlock()) && !isMoving && getBlockEntityOptional(world, pos).map(be -> be.containsBase).orElse(false)) - Block.popResource(world, pos, new ItemStack(CCItems.LINKED_TRANSMITTER)); - base.onRemove(state, world, pos, newState, isMoving); - } - - @Override - public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { - onWrenched(state, context); - return IWrenchable.super.onSneakWrenched(state, context); - } - - @Override - public InteractionResult onWrenched(BlockState state, UseOnContext context) { - Player player = context.getPlayer(); - if (!player.isCreative()) { - player.getInventory().placeItemBackInInventory(new ItemStack(CCItems.LINKED_TRANSMITTER)); - } - withBlockEntityDo(context.getLevel(), context.getClickedPos(), be -> be.containsBase = false); - replaceWithBase(state, context.getLevel(), context.getClickedPos()); - return InteractionResult.SUCCESS; - } - - @Override - public void replaceBase(BlockState baseState, Level world, BlockPos pos) { - world.setBlockAndUpdate(pos, defaultBlockState() - .setValue(FACING, baseState.getValue(FACING)) - .setValue(FACE, baseState.getValue(FACE)) - .setValue(POWERED, baseState.getValue(POWERED)) - ); - AllSoundEvents.CONTROLLER_PUT.playOnServer(world, pos); - checkPressed(world.getBlockState(pos), world, pos); - } - - public void replaceWithBase(BlockState state, Level world, BlockPos pos) { - AllSoundEvents.CONTROLLER_TAKE.playOnServer(world, pos); - world.setBlockAndUpdate(pos, base.defaultBlockState() - .setValue(FACING, state.getValue(FACING)) - .setValue(FACE, state.getValue(FACE)) - .setValue(POWERED, state.getValue(POWERED))); - super.checkPressed(world.getBlockState(pos), world, pos); - } - - @Override - protected void checkPressed(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { - super.checkPressed(state, level, pos); - updateTransmittedSignal(level, pos); - } - - @Override - public void press(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { - super.press(state, level, pos); - updateTransmittedSignal(level, pos); - } - - public void updateTransmittedSignal(Level worldIn, BlockPos pos) { - if (worldIn.isClientSide) - return; - - BlockState state = worldIn.getBlockState(pos); - int power = state.getSignal(worldIn, pos, state.getValue(FACING)); - - withBlockEntityDo(worldIn, pos, be -> be.transmit(power)); - } - - @Override - public ItemStack getPickedStack(BlockState state, BlockGetter view, BlockPos pos, @Nullable Player player, @Nullable HitResult result) { - if (isHittingBase(state, view, pos, result)) - return super.getCloneItemStack(view, pos, state); - return new ItemStack(CCItems.LINKED_TRANSMITTER.get()); - } - - @Override - public ItemRequirement getRequiredItems(BlockState state, BlockEntity be) { - ArrayList requiredItems = new ArrayList<>(); - requiredItems.add(new ItemStack(base)); - requiredItems.add(new ItemStack(CCItems.LINKED_TRANSMITTER.get())); - return new ItemRequirement(ItemRequirement.ItemUseType.CONSUME, requiredItems); - } - - @Override - public Class getBlockEntityClass() { - return LinkedTransmitterBlockEntity.class; - } - - @Override - public BlockEntityType getBlockEntityType() { - return CCBlockEntityTypes.LINKED_TRANSMITTER.get(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedLeverBlock.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedLeverBlock.java deleted file mode 100644 index 8555539..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedLeverBlock.java +++ /dev/null @@ -1,196 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.hlysine.create_connected.CCBlockEntityTypes; -import com.hlysine.create_connected.CCItems; -import com.hlysine.create_connected.CCShapes; -import com.simibubi.create.AllSoundEvents; -import com.simibubi.create.content.equipment.wrench.IWrenchable; -import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement; -import com.simibubi.create.content.schematics.requirement.ItemRequirement; -import com.simibubi.create.foundation.block.IBE; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.LeverBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.storage.loot.LootParams; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import net.fabricmc.fabric.api.block.BlockPickInteractionAware; - -public class LinkedLeverBlock extends LeverBlock implements IBE, ISpecialBlockItemRequirement, IWrenchable, LinkedTransmitterBlock, BlockPickInteractionAware { - public static BooleanProperty LOCKED = BlockStateProperties.LOCKED; - - private final LeverBlock base; - - public LinkedLeverBlock(Properties pProperties, LeverBlock base) { - super(pProperties); - this.base = base; - registerDefaultState(defaultBlockState().setValue(LOCKED, false)); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { - super.createBlockStateDefinition(pBuilder.add(LOCKED)); - } - - @Override - public Block getBlock() { - return this; - } - - @Override - public Block getBase() { - return base; - } - - @Override - public @NotNull VoxelShape getShape(@NotNull BlockState state, - @NotNull BlockGetter level, - @NotNull BlockPos pos, - @NotNull CollisionContext context) { - Direction facing = state.getValue(LeverBlock.FACING); - return Shapes.or(switch (state.getValue(LeverBlock.FACE)) { - case FLOOR -> CCShapes.FLOOR_LINKED_TRANSMITTER.get(facing); - case WALL -> CCShapes.WALL_LINKED_TRANSMITTER.get(facing); - case CEILING -> CCShapes.CEILING_LINKED_TRANSMITTER.get(facing); - }, super.getShape(state, level, pos, context)); - } - - - - @SuppressWarnings("deprecation") - @Override - public @NotNull List getDrops(@NotNull BlockState state, LootParams.@NotNull Builder builder) { - return base.getDrops(state, builder); - } - - private boolean isHittingBase(BlockState state, BlockGetter level, BlockPos pos, HitResult hit) { - return super.getShape(state, level, pos, CollisionContext.empty()).bounds().inflate(0.01 / 16).move(pos).contains(hit.getLocation()); - } - - @Override - public @NotNull InteractionResult use(@NotNull BlockState state, - @NotNull Level level, - @NotNull BlockPos pos, - @NotNull Player player, - @NotNull InteractionHand hand, - @NotNull BlockHitResult hit) { - if (isHittingBase(state, level, pos, hit)) { - if (!player.isShiftKeyDown()) - return super.use(state, level, pos, player, hand, hit); - return InteractionResult.CONSUME; - } - if (player.isShiftKeyDown()) { - if (!level.isClientSide()) - level.setBlockAndUpdate(pos, state.cycle(LOCKED)); - return InteractionResult.SUCCESS; - } - if (state.getValue(LOCKED)) - return InteractionResult.CONSUME; - return InteractionResult.PASS; - } - - @Override - public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { - if (!state.is(newState.getBlock()) && !isMoving && getBlockEntityOptional(world, pos).map(be -> be.containsBase).orElse(false)) - Block.popResource(world, pos, new ItemStack(CCItems.LINKED_TRANSMITTER)); - base.onRemove(state, world, pos, newState, isMoving); - } - - @Override - public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { - onWrenched(state, context); - return IWrenchable.super.onSneakWrenched(state, context); - } - - @Override - public InteractionResult onWrenched(BlockState state, UseOnContext context) { - Player player = context.getPlayer(); - if (!player.isCreative()) { - player.getInventory().placeItemBackInInventory(new ItemStack(CCItems.LINKED_TRANSMITTER)); - } - withBlockEntityDo(context.getLevel(), context.getClickedPos(), be -> be.containsBase = false); - replaceWithBase(state, context.getLevel(), context.getClickedPos()); - return InteractionResult.SUCCESS; - } - - @Override - public void replaceBase(BlockState baseState, Level world, BlockPos pos) { - world.setBlockAndUpdate(pos, defaultBlockState() - .setValue(FACING, baseState.getValue(FACING)) - .setValue(FACE, baseState.getValue(FACE)) - .setValue(POWERED, baseState.getValue(POWERED)) - ); - AllSoundEvents.CONTROLLER_PUT.playOnServer(world, pos); - } - - public void replaceWithBase(BlockState state, Level world, BlockPos pos) { - AllSoundEvents.CONTROLLER_TAKE.playOnServer(world, pos); - world.setBlockAndUpdate(pos, base.defaultBlockState() - .setValue(FACING, state.getValue(FACING)) - .setValue(FACE, state.getValue(FACE)) - .setValue(POWERED, state.getValue(POWERED))); - } - - @Override - public @NotNull BlockState pull(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { - BlockState newState = super.pull(state, level, pos); - updateTransmittedSignal(level, pos); - return newState; - } - - public void updateTransmittedSignal(Level worldIn, BlockPos pos) { - if (worldIn.isClientSide) - return; - - BlockState state = worldIn.getBlockState(pos); - int power = state.getSignal(worldIn, pos, state.getValue(FACING)); - - withBlockEntityDo(worldIn, pos, be -> be.transmit(power)); - } - - @Override - public ItemStack getPickedStack(BlockState state, BlockGetter view, BlockPos pos, @Nullable Player player, @Nullable HitResult result) { - if (isHittingBase(state, view, pos, result)) - return super.getCloneItemStack(view, pos, state); - return new ItemStack(CCItems.LINKED_TRANSMITTER.get()); - } - - @Override - public ItemRequirement getRequiredItems(BlockState state, BlockEntity be) { - ArrayList requiredItems = new ArrayList<>(); - requiredItems.add(new ItemStack(base)); - requiredItems.add(new ItemStack(CCItems.LINKED_TRANSMITTER.get())); - return new ItemRequirement(ItemRequirement.ItemUseType.CONSUME, requiredItems); - } - - @Override - public Class getBlockEntityClass() { - return LinkedTransmitterBlockEntity.class; - } - - @Override - public BlockEntityType getBlockEntityType() { - return CCBlockEntityTypes.LINKED_TRANSMITTER.get(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlock.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlock.java deleted file mode 100644 index 0ce7813..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlock.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; - -public interface LinkedTransmitterBlock { - Block getBlock(); - - Block getBase(); - - void replaceBase(BlockState baseState, Level world, BlockPos pos); -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlockEntity.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlockEntity.java deleted file mode 100644 index bb6101d..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterBlockEntity.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.simibubi.create.content.redstone.link.LinkBehaviour; -import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; -import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.List; - -public class LinkedTransmitterBlockEntity extends SmartBlockEntity { - - private int transmittedSignal; - /** - * set to false if the module item is already returned to player via wrenching - */ - public boolean containsBase = true; - private LinkBehaviour link; - - public LinkedTransmitterBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { - super(type, pos, state); - } - - @Override - public void addBehaviours(List behaviours) { - createLink(); - behaviours.add(link); - } - - protected void createLink() { - Pair slots = - ValueBoxTransform.Dual.makeSlots(LinkedTransmitterFrequencySlot::new); - link = LinkBehaviour.transmitter(this, slots, this::getSignal); - } - - @Override - public void initialize() { - super.initialize(); - transmit(getBlockState().getSignal(getLevel(), getBlockPos(), getBlockState().getValue(HorizontalDirectionalBlock.FACING))); - } - - public int getSignal() { - return transmittedSignal; - } - - public void transmit(int strength) { - transmittedSignal = strength; - if (link != null) - link.notifySignalChange(); - } - - @Override - public void write(CompoundTag compound, boolean clientPacket) { - compound.putInt("Transmit", transmittedSignal); - super.write(compound, clientPacket); - } - - @Override - protected void read(CompoundTag compound, boolean clientPacket) { - super.read(compound, clientPacket); - if (level == null || level.isClientSide || !link.newPosition) - transmittedSignal = compound.getInt("Transmit"); - } - -} diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterFrequencySlot.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterFrequencySlot.java deleted file mode 100644 index 3ec35ec..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterFrequencySlot.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; -import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.Axis; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.AttachFace; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.phys.Vec3; - -public class LinkedTransmitterFrequencySlot extends ValueBoxTransform.Dual { - - public LinkedTransmitterFrequencySlot(boolean first) { - super(first); - } - - @Override - public boolean shouldRender(BlockState state) { - return !state.getValue(BlockStateProperties.LOCKED) && super.shouldRender(state); - } - - @Override - public boolean testHit(BlockState state, Vec3 localHit) { - return !state.getValue(BlockStateProperties.LOCKED) && super.testHit(state, localHit); - } - - @Override - public Vec3 getLocalOffset(BlockState state) { - Direction facing = state.getValue(LinkedButtonBlock.FACING); - AttachFace face = state.getValue(LinkedButtonBlock.FACE); - - Vec3 location = switch (face) { - case FLOOR -> - VecHelper.voxelSpace(2.5f, 1.1f, 10.5f).add(isFirst() ? Vec3.ZERO : VecHelper.voxelSpace(0, 0, -5)); - case WALL -> - VecHelper.voxelSpace(13.5f, 10.5f, 1.1f).add(isFirst() ? Vec3.ZERO : VecHelper.voxelSpace(0, -5, 0)); - case CEILING -> - VecHelper.voxelSpace(2.5f, 14.9f, 5.5f).add(isFirst() ? Vec3.ZERO : VecHelper.voxelSpace(0, 0, 5)); - }; - location = VecHelper.rotateCentered(location, AngleHelper.horizontalAngle(facing), Axis.Y); - return location; - } - - @Override - public void rotate(BlockState state, PoseStack ms) { - Direction facing = state.getValue(LinkedButtonBlock.FACING); - AttachFace face = state.getValue(LinkedButtonBlock.FACE); - float yRot = AngleHelper.horizontalAngle(facing) + (face != AttachFace.WALL ? 0 : 180); - float xRot = face == AttachFace.FLOOR ? 90 : face == AttachFace.CEILING ? 270 : 0; - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(xRot); - } - - @Override - public float getScale() { - return .4975f; - } -} - diff --git a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterItem.java b/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterItem.java deleted file mode 100644 index 45e88eb..0000000 --- a/src/main/java/com/hlysine/create_connected/content/linkedtransmitter/LinkedTransmitterItem.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.hlysine.create_connected.content.linkedtransmitter; - -import com.tterrag.registrate.builders.BlockBuilder; -import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; - -import java.util.LinkedList; -import java.util.List; - -import io.github.fabricators_of_create.porting_lib.item.UseFirstBehaviorItem; -public class LinkedTransmitterItem extends Item implements UseFirstBehaviorItem { - public static final List MODULE_BLOCKS = new LinkedList<>(); - - public static > NonNullUnaryOperator register() { - return b -> { - b.onRegister(MODULE_BLOCKS::add); - return b; - }; - } - - public LinkedTransmitterItem(Properties pProperties) { - super(pProperties); - } - - @Override - public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) { - Player player = ctx.getPlayer(); - if (player == null) - return InteractionResult.PASS; - Level world = ctx.getLevel(); - BlockPos pos = ctx.getClickedPos(); - BlockState hitState = world.getBlockState(pos); - - if (player.mayBuild()) { - for (LinkedTransmitterBlock moduleBlock : MODULE_BLOCKS) { - if (hitState.is(moduleBlock.getBase())) { - if (!world.isClientSide) { - if (!player.isCreative()) stack.shrink(1); - moduleBlock.replaceBase(hitState, world, pos); - } - return InteractionResult.SUCCESS; - } - } - } - - for (LinkedTransmitterBlock moduleBlock : MODULE_BLOCKS) { - if (hitState.is(moduleBlock.getBlock())) { - return InteractionResult.PASS; - } - } - - return use(world, player, ctx.getHand()).getResult(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockEntityAccessor.java b/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockEntityAccessor.java deleted file mode 100644 index 43eb75e..0000000 --- a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockEntityAccessor.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hlysine.create_connected.mixin.linkedtransmitter; - -import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlockEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(value = AnalogLeverBlockEntity.class, remap = false) -public interface AnalogLeverBlockEntityAccessor { - @Accessor - int getLastChange(); -} diff --git a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockMixin.java b/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockMixin.java deleted file mode 100644 index 6b56105..0000000 --- a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/AnalogLeverBlockMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hlysine.create_connected.mixin.linkedtransmitter; - -import com.hlysine.create_connected.CCBlocks; -import com.hlysine.create_connected.CCItems; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(AnalogLeverBlock.class) -public class AnalogLeverBlockMixin { - @Inject( - cancellable = true, - at = @At("HEAD"), - method = "use(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;" - ) - private void use(BlockState state, - Level worldIn, - BlockPos pos, - Player player, - InteractionHand handIn, - BlockHitResult hit, - CallbackInfoReturnable cir) { - if (player.isHolding(CCItems.LINKED_TRANSMITTER.get()) && !state.is(CCBlocks.LINKED_ANALOG_LEVER.get())) { - cir.setReturnValue(InteractionResult.PASS); - cir.cancel(); - } - } -} diff --git a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/ButtonBlockAccessor.java b/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/ButtonBlockAccessor.java deleted file mode 100644 index d3e05f1..0000000 --- a/src/main/java/com/hlysine/create_connected/mixin/linkedtransmitter/ButtonBlockAccessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hlysine.create_connected.mixin.linkedtransmitter; - -import net.minecraft.world.level.block.ButtonBlock; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.world.level.block.state.properties.BlockSetType; - -@Mixin(value = ButtonBlock.class, remap = true) -public interface ButtonBlockAccessor { - - @Accessor - BlockSetType getType(); - @Accessor - int getTicksToStayPressed(); - @Accessor - boolean getArrowsCanPress(); -} diff --git a/src/main/java/com/hlysine/create_connected/ponder/ChainCogwheelScenes.java b/src/main/java/com/hlysine/create_connected/ponder/ChainCogwheelScenes.java deleted file mode 100644 index 63ce387..0000000 --- a/src/main/java/com/hlysine/create_connected/ponder/ChainCogwheelScenes.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.hlysine.create_connected.ponder; - -import com.simibubi.create.content.kinetics.chainDrive.ChainDriveBlock; -import com.simibubi.create.foundation.ponder.SceneBuilder; -import com.simibubi.create.foundation.ponder.SceneBuildingUtil; -import com.simibubi.create.foundation.ponder.Selection; -import com.simibubi.create.foundation.ponder.element.InputWindowElement; -import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; - -public class ChainCogwheelScenes { - public static void chainCogwheelAsRelay(SceneBuilder scene, SceneBuildingUtil util) { - scene.title("chain_cogwheel_relay", "Relaying rotational force with Chain Cogwheels"); - scene.configureBasePlate(0, 0, 5); - scene.world.showSection(util.select.layer(0), Direction.UP); - BlockPos gaugePos = util.grid.at(0, 1, 3); - Selection gauge = util.select.position(gaugePos); - scene.world.showSection(gauge, Direction.UP); - scene.world.setKineticSpeed(gauge, 0); - - scene.idle(5); - scene.world.showSection(util.select.fromTo(5, 1, 2, 4, 1, 2), Direction.DOWN); - scene.idle(10); - - for (int i = 0; i < 3; i++) { - scene.idle(5); - scene.world.showSection(util.select.position(3, 1, 2 - i), Direction.DOWN); - if (i != 0) - scene.world.showSection(util.select.position(3, 1, 2 + i), Direction.DOWN); - } - - scene.idle(10); - scene.world.showSection(util.select.position(gaugePos.east(2)), Direction.DOWN); - scene.idle(5); - scene.world.showSection(util.select.position(gaugePos.east()), Direction.DOWN); - scene.idle(5); - - scene.world.setKineticSpeed(gauge, 64); - scene.effects.indicateSuccess(gaugePos); - scene.idle(20); - scene.overlay.showText(70) - .text("Chain Cogwheels are Chain Drives with an extra cogwheel") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.blockSurface(util.grid.at(3, 1, 3), Direction.WEST)); - scene.idle(80); - scene.overlay.showText(70) - .text("They connect to other chained components in a row") - .placeNearTarget() - .pointAt(util.vector.blockSurface(util.grid.at(3, 1, 3), Direction.WEST)); - scene.idle(80); - - Selection shafts = util.select.fromTo(2, 1, 0, 2, 1, 1); - BlockPos rotatedECD = util.grid.at(3, 1, 0); - Selection verticalShaft = util.select.fromTo(rotatedECD.above(), rotatedECD.above(2)); - Selection extraLargeCog = util.select.position(3, 2, 4); - Selection extraCog = util.select.position(4, 1, 0); - - scene.world.showSection(shafts, Direction.EAST); - scene.idle(10); - scene.effects.rotationDirectionIndicator(util.grid.at(2, 1, 0)); - scene.effects.rotationDirectionIndicator(util.grid.at(2, 1, 1)); - scene.idle(20); - scene.overlay.showText(80) - .text("All shafts connected like this will rotate in the same direction") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.blockSurface(util.grid.at(2, 1, 1), Direction.WEST)); - scene.idle(80); - scene.world.hideSection(shafts, Direction.WEST); - scene.idle(25); - - scene.world.showSection(extraLargeCog, Direction.DOWN); - scene.idle(10); - scene.overlay.showText(70) - .text("Cogwheels can connect to Chain Cogwheels anywhere in the row") - .attachKeyFrame() - .placeNearTarget() - .pointAt(extraLargeCog.getCenter()); - scene.idle(90); - - scene.addKeyframe(); - scene.overlay.showControls(new InputWindowElement(util.vector.topOf(rotatedECD), Pointing.DOWN).rightClick() - .withWrench(), 30); - scene.idle(7); - scene.world.modifyBlock(rotatedECD, s -> s.setValue(ChainDriveBlock.AXIS, Direction.Axis.Y), true); - scene.idle(40); - - scene.world.showSection(verticalShaft, Direction.DOWN); - scene.world.showSection(extraCog, Direction.DOWN); - scene.idle(10); - - scene.effects.rotationDirectionIndicator(util.grid.at(3, 3, 0)); - scene.idle(10); - scene.overlay.showText(70) - .text("Any part of the row can be rotated by 90 degrees") - .placeNearTarget() - .pointAt(util.vector.centerOf(3, 2, 0)); - scene.idle(80); - - scene.markAsFinished(); - } -} diff --git a/src/main/java/com/hlysine/create_connected/ponder/LinkedTransmitterScenes.java b/src/main/java/com/hlysine/create_connected/ponder/LinkedTransmitterScenes.java deleted file mode 100644 index 31cae18..0000000 --- a/src/main/java/com/hlysine/create_connected/ponder/LinkedTransmitterScenes.java +++ /dev/null @@ -1,256 +0,0 @@ -package com.hlysine.create_connected.ponder; - -import com.hlysine.create_connected.CCBlocks; -import com.hlysine.create_connected.CCItems; -import com.hlysine.create_connected.content.linkedtransmitter.LinkedTransmitterBlockEntity; -import com.simibubi.create.AllItems; -import com.simibubi.create.content.redstone.link.RedstoneLinkBlockEntity; -import com.simibubi.create.foundation.ponder.PonderPalette; -import com.simibubi.create.foundation.ponder.SceneBuilder; -import com.simibubi.create.foundation.ponder.SceneBuildingUtil; -import com.simibubi.create.foundation.ponder.Selection; -import com.simibubi.create.foundation.ponder.element.InputWindowElement; -import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.properties.BlockSetType; -import net.minecraft.world.phys.Vec3; - -import static net.minecraft.world.level.block.state.properties.BlockStateProperties.*; - -public class LinkedTransmitterScenes { - public static void linkedTransmitter(SceneBuilder scene, SceneBuildingUtil util) { - scene.title("linked_transmitter", "Using Linked Transmitters"); - scene.configureBasePlate(0, 0, 5); - - BlockPos button = util.grid.at(1, 1, 1); - BlockPos lever = util.grid.at(2, 1, 1); - BlockPos analogLever = util.grid.at(3, 1, 1); - BlockPos linkLeft = util.grid.at(3, 2, 2); - BlockPos linkRight = util.grid.at(1, 2, 2); - Selection buttonSelect = util.select.position(button); - Selection analogLeverSelect = util.select.position(analogLever); - Selection leverSelect = util.select.position(lever); - Selection linkLeftSelect = util.select.position(linkLeft); - Selection linkRightSelect = util.select.position(linkRight); - Vec3 transmitVec = util.vector.blockSurface(lever, Direction.DOWN) - .add(0, 3 / 16f, 0); - Vec3 linkLeftVec = util.vector.blockSurface(linkLeft, Direction.SOUTH) - .add(0, 0, -3 / 16f); - Vec3 linkRightVec = util.vector.blockSurface(linkRight, Direction.SOUTH) - .add(0, 0, -3 / 16f); - - - scene.world.showSection(util.select.layer(0), Direction.UP); - scene.idle(5); - scene.world.showSection(util.select.fromTo(4, 1, 3, 0, 2, 3), Direction.DOWN); - scene.idle(10); - - scene.world.showSection(leverSelect, Direction.DOWN); - scene.idle(5); - scene.world.showSection(util.select.position(linkRight), Direction.DOWN); - scene.idle(5); - scene.world.showSection(util.select.position(linkLeft), Direction.DOWN); - scene.idle(10); - - scene.overlay.showControls(new InputWindowElement(transmitVec, Pointing.UP) - .rightClick() - .withItem(new ItemStack(CCItems.LINKED_TRANSMITTER)) - , 40); - scene.idle(10); - scene.world.modifyBlock(lever, s -> CCBlocks.LINKED_LEVER.getDefaultState() - .setValue(ATTACH_FACE, s.getValue(ATTACH_FACE)) - .setValue(HORIZONTAL_FACING, s.getValue(HORIZONTAL_FACING)) - .setValue(POWERED, s.getValue(POWERED)) - , true); - scene.idle(10); - scene.overlay.showText(90) - .text("Right-click a redstone input with a Linked Transmitter to attach it to the input") - .attachKeyFrame() - .placeNearTarget() - .pointAt(transmitVec); - scene.idle(110); - - - scene.overlay.showText(50) - .text("Linked Transmitters can transmit input signals wirelessly") - .placeNearTarget() - .pointAt(transmitVec); - scene.idle(60); - - scene.addKeyframe(); - scene.idle(10); - scene.world.toggleRedstonePower(leverSelect); - scene.effects.indicateRedstone(lever); - scene.idle(5); - scene.world.toggleRedstonePower(util.select.fromTo(3, 2, 3, 1, 2, 2)); - scene.effects.indicateRedstone(linkLeft); - scene.effects.indicateRedstone(linkRight); - - scene.idle(10); - scene.overlay.showText(70) - .colored(PonderPalette.GREEN) - .text("Receivers emit the redstone power of transmitters within 128 blocks") - .placeNearTarget() - .pointAt(linkRightVec); - scene.idle(80); - scene.world.toggleRedstonePower(leverSelect); - scene.idle(5); - scene.world.toggleRedstonePower(util.select.fromTo(3, 2, 3, 1, 2, 2)); - scene.idle(20); - - Vec3 frontSlot = transmitVec.add(-0.34375, -0.09375, -.15); - Vec3 backSlot = transmitVec.add(-0.34375, -0.09375, .15); - Vec3 top2Slot = linkRightVec.add(0, .15, 0); - Vec3 bottom2Slot = linkRightVec.add(0, -.2, 0); - Vec3 top3Slot = linkLeftVec.add(0, .15, 0); - Vec3 bottom3Slot = linkLeftVec.add(0, -.2, 0); - - scene.addKeyframe(); - scene.idle(10); - scene.overlay.showFilterSlotInput(frontSlot, Direction.UP, 100); - scene.overlay.showFilterSlotInput(backSlot, Direction.UP, 100); - scene.idle(10); - - scene.overlay.showText(50) - .text("Placing items in the two slots can specify a Frequency") - .placeNearTarget() - .pointAt(backSlot); - scene.idle(60); - - ItemStack iron = new ItemStack(Items.IRON_INGOT); - ItemStack gold = new ItemStack(Items.GOLD_INGOT); - ItemStack sapling = new ItemStack(Items.OAK_SAPLING); - - scene.overlay.showControls(new InputWindowElement(frontSlot, Pointing.UP).withItem(iron), 30); - scene.idle(7); - scene.overlay.showControls(new InputWindowElement(backSlot, Pointing.DOWN).withItem(sapling), 30); - scene.world.modifyBlockEntityNBT(leverSelect, LinkedTransmitterBlockEntity.class, - nbt -> nbt.put("FrequencyLast", iron.save(new CompoundTag()))); - scene.idle(7); - scene.world.modifyBlockEntityNBT(leverSelect, LinkedTransmitterBlockEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); - scene.idle(20); - - scene.overlay.showControls(new InputWindowElement(bottom2Slot, Pointing.UP).withItem(iron), 30); - scene.idle(7); - scene.overlay.showControls(new InputWindowElement(top2Slot, Pointing.DOWN).withItem(sapling), 30); - scene.world.modifyBlockEntityNBT(linkRightSelect, RedstoneLinkBlockEntity.class, - nbt -> nbt.put("FrequencyLast", iron.save(new CompoundTag()))); - scene.idle(7); - scene.world.modifyBlockEntityNBT(linkRightSelect, RedstoneLinkBlockEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); - scene.idle(20); - - scene.overlay.showControls(new InputWindowElement(bottom3Slot, Pointing.UP).withItem(gold), 30); - scene.idle(7); - scene.overlay.showControls(new InputWindowElement(top3Slot, Pointing.DOWN).withItem(sapling), 30); - scene.world.modifyBlockEntityNBT(linkLeftSelect, RedstoneLinkBlockEntity.class, - nbt -> nbt.put("FrequencyLast", gold.save(new CompoundTag()))); - scene.idle(7); - scene.world.modifyBlockEntityNBT(linkLeftSelect, RedstoneLinkBlockEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); - scene.idle(20); - - scene.world.toggleRedstonePower(leverSelect); - scene.effects.indicateRedstone(lever); - scene.idle(2); - scene.world.toggleRedstonePower(util.select.fromTo(1, 2, 2, 1, 2, 3)); - scene.overlay.showText(90) - .attachKeyFrame() - .text("Only the links with matching Frequencies will communicate") - .placeNearTarget() - .pointAt(linkRightVec); - - scene.idle(30); - for (int i = 0; i < 4; i++) { - if (i % 2 == 1) - scene.effects.indicateRedstone(lever); - scene.world.toggleRedstonePower(leverSelect); - scene.idle(2); - scene.world.toggleRedstonePower(util.select.fromTo(1, 2, 2, 1, 2, 3)); - scene.idle(20); - } - - scene.overlay.showText(40) - .text("To avoid misclicks...") - .attachKeyFrame() - .placeNearTarget() - .pointAt(transmitVec); - scene.idle(30); - scene.overlay.showControls(new InputWindowElement(transmitVec, Pointing.DOWN) - .rightClick() - .whileSneaking() - , 40); - scene.idle(20); - scene.world.modifyBlock(lever, s -> s.cycle(LOCKED) - , false); - scene.idle(20); - scene.overlay.showText(80) - .text("...right-click the transmitter while sneaking to lock the frequency slots") - .placeNearTarget() - .pointAt(transmitVec); - - scene.idle(80); - - scene.world.showSection(buttonSelect, Direction.DOWN); - scene.idle(5); - scene.world.showSection(analogLeverSelect, Direction.DOWN); - scene.idle(20); - scene.overlay.showControls(new InputWindowElement(util.vector.blockSurface(analogLever, Direction.DOWN).add(0, 4 / 16.0, 0), Pointing.UP) - .rightClick() - .withItem(new ItemStack(CCItems.LINKED_TRANSMITTER)) - , 40); - scene.idle(5); - scene.overlay.showControls(new InputWindowElement(util.vector.blockSurface(button, Direction.DOWN).add(0, 2 / 16.0, 0), Pointing.DOWN) - .rightClick() - .withItem(new ItemStack(CCItems.LINKED_TRANSMITTER)) - , 40); - scene.idle(20); - scene.world.modifyBlock(analogLever, s -> CCBlocks.LINKED_ANALOG_LEVER.getDefaultState() - .setValue(ATTACH_FACE, s.getValue(ATTACH_FACE)) - .setValue(HORIZONTAL_FACING, s.getValue(HORIZONTAL_FACING)) - , true); - scene.idle(5); - scene.world.modifyBlock(button, s -> CCBlocks.LINKED_BUTTONS.get(BlockSetType.STONE).getDefaultState() - .setValue(ATTACH_FACE, s.getValue(ATTACH_FACE)) - .setValue(HORIZONTAL_FACING, s.getValue(HORIZONTAL_FACING)) - .setValue(POWERED, s.getValue(POWERED)) - , true); - scene.idle(20); - - scene.overlay.showText(70) - .text("Linked Transmitters also work on buttons and analog levers") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.blockSurface(button, Direction.DOWN).add(0, 2 / 16.0, 0)); - scene.idle(80); - - scene.addKeyframe(); - - scene.overlay.showControls(new InputWindowElement(transmitVec, Pointing.DOWN) - .rightClick() - .withItem(new ItemStack(AllItems.WRENCH)) - , 40); - scene.idle(20); - scene.world.modifyBlock(lever, s -> Blocks.LEVER.defaultBlockState() - .setValue(ATTACH_FACE, s.getValue(ATTACH_FACE)) - .setValue(HORIZONTAL_FACING, s.getValue(HORIZONTAL_FACING)) - .setValue(POWERED, s.getValue(POWERED)) - , true); - scene.idle(2); - scene.world.toggleRedstonePower(util.select.fromTo(1, 2, 2, 1, 2, 3)); - scene.idle(20); - - scene.overlay.showText(90) - .text("Right-click the transmitter with a wrench to detach it from the input") - .placeNearTarget() - .pointAt(transmitVec); - scene.idle(100); - scene.markAsFinished(); - } -} diff --git a/src/main/resources/create_connected.mixins.json b/src/main/resources/create_connected.mixins.json index 37ce7ea..97b590a 100644 --- a/src/main/resources/create_connected.mixins.json +++ b/src/main/resources/create_connected.mixins.json @@ -4,9 +4,6 @@ "package": "com.hlysine.create_connected.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "linkedtransmitter.AnalogLeverBlockEntityAccessor", - "linkedtransmitter.AnalogLeverBlockMixin", - "linkedtransmitter.ButtonBlockAccessor" ], "client": [ ],