Skip to content

Tag based system for contraption controls #8515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: mc1.20.1/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"values": [
"create:andesite_door",
"create:brass_door",
"create:copper_door",
"create:train_door",
"create:framed_glass_door"
]
}
1 change: 1 addition & 0 deletions src/main/java/com/simibubi/create/AllTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public enum AllItemTags {
BLAZE_BURNER_FUEL_SPECIAL(MOD, "blaze_burner_fuel/special"),
CASING,
CONTRAPTION_CONTROLLED,
TRAIN_CONTROLLED,
CREATE_INGOTS,
CRUSHED_RAW_MATERIALS,
INVALID_FOR_TRACK_PAVING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.List;

import com.simibubi.create.AllTags.AllItemTags;

import org.apache.commons.lang3.tuple.MutablePair;

import com.simibubi.create.AllPackets;
Expand Down Expand Up @@ -33,7 +35,7 @@ public class ContraptionControlsMovingInteraction extends MovingInteractionBehav

@Override
public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos,
AbstractContraptionEntity contraptionEntity) {
AbstractContraptionEntity contraptionEntity) {
Contraption contraption = contraptionEntity.getContraption();

MutablePair<StructureBlockInfo, MovementContext> actor = contraption.getActorAt(localPos);
Expand Down Expand Up @@ -103,10 +105,10 @@ public boolean handlePlayerInteraction(Player player, InteractionHand activeHand

if (!(contraptionEntity instanceof CarriageContraptionEntity cce))
return true;
if (!filter.is(ItemTags.DOORS))
if (!filter.is(AllItemTags.TRAIN_CONTROLLED.tag))
return true;
// Special case: Doors are toggled on all carriages of a train

// Special case: "TRAIN_CONTROLLED" tagged block items are toggled on all carriages of a train
Carriage carriage = cce.getCarriage();
Train train = carriage.train;
for (Carriage c : train.carriages) {
Expand All @@ -128,7 +130,7 @@ private void send(AbstractContraptionEntity contraptionEntity, ItemStack filter,
}

private boolean elevatorInteraction(BlockPos localPos, AbstractContraptionEntity contraptionEntity,
ElevatorContraption contraption, MovementContext ctx) {
ElevatorContraption contraption, MovementContext ctx) {
Level level = contraptionEntity.level();
if (!level.isClientSide()) {
BlockPos pos = BlockPos.containing(contraptionEntity.toGlobalVector(Vec3.atCenterOf(localPos), 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public static <B extends SlidingDoorBlock, P> NonNullUnaryOperator<BlockBuilder<
.loot((lr, block) -> lr.add(block, lr.createDoorTable(block)))
.item()
.tag(ItemTags.DOORS)
.tag(AllItemTags.TRAIN_CONTROLLED.tag)
.tag(AllItemTags.CONTRAPTION_CONTROLLED.tag)
.model((c, p) -> p.blockSprite(c, p.modLoc("item/" + type + "_door")))
.build();
Expand Down