Skip to content

Commit 790b5e2

Browse files
committed
some tweaks/fixes
Fixes the clear recipe for linker and elevator item not working Adjusts the criteria for linking the device linker to elevator, to support features in ThutCore 8.2.0+
1 parent 842f59a commit 790b5e2

4 files changed

Lines changed: 58 additions & 22 deletions

File tree

src/main/java/thut/tech/common/entity/LiftInteractHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ public ActionResultType interactInternal(final PlayerEntity player, final BlockP
3939
public ActionResultType processInitialInteract(final PlayerEntity player, @Nullable ItemStack stack,
4040
final Hand hand)
4141
{
42-
4342
final boolean isElevatorItemOrStick = stack.getItem() == Items.STICK || stack.getItem() == TechCore.LIFT.get();
4443
final boolean isLinker = stack.getItem() == TechCore.LINKER.get();
4544

46-
final boolean canEdit = this.lift.owner != null && player.getUniqueID().equals(this.lift.owner)
47-
|| player.abilities.isCreativeMode;
45+
final boolean canEdit = player.getUniqueID().equals(this.lift.owner) || player.abilities.isCreativeMode;
4846

4947
final boolean shouldLinkLift = player.isSneaking() && isLinker && canEdit;
5048
final boolean shouldKillLiftUnowned = this.lift.owner == null;

src/main/java/thut/tech/common/items/ItemLinker.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,16 @@ public ActionResultType onItemUse(final ItemUseContext context)
8080
return ActionResultType.SUCCESS;
8181
}
8282
}
83-
else if (playerIn.isSneaking() && state.getBlock() == TechCore.LIFTCONTROLLER.get())
83+
else if (playerIn.isSneaking() && state.getBlock() == TechCore.LIFTCONTROLLER.get() && face != Direction.UP
84+
&& face != Direction.DOWN)
8485
{
85-
if (face != Direction.UP && face != Direction.DOWN)
86-
{
87-
final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos);
88-
te.editFace[face.ordinal()] = !te.editFace[face.ordinal()];
89-
te.setSidePage(face, 0);
90-
final String message = "msg.editMode";
91-
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, te.editFace[face
92-
.ordinal()]), Util.DUMMY_UUID);
93-
return ActionResultType.SUCCESS;
94-
}
95-
}
96-
else if (playerIn.isSneaking())
97-
{
98-
stack.setTag(new CompoundNBT());
99-
final String message = "msg.linker.reset";
100-
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID);
86+
final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos);
87+
te.editFace[face.ordinal()] = !te.editFace[face.ordinal()];
88+
te.setSidePage(face, 0);
89+
final String message = "msg.editMode";
90+
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, te.editFace[face
91+
.ordinal()]), Util.DUMMY_UUID);
92+
return ActionResultType.SUCCESS;
10193
}
10294
}
10395
return ActionResultType.PASS;

src/main/java/thut/tech/common/items/RecipeReset.java

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,57 @@ public ItemStack getCraftingResult(final CraftingInventory inv)
2121
{
2222
int n = 0;
2323
boolean matched = false;
24+
25+
// Try to match a device linker
26+
ItemStack linker = ItemStack.EMPTY;
2427
for (int i = 0; i < inv.getSizeInventory(); i++)
2528
{
2629
final ItemStack stack = inv.getStackInSlot(i);
27-
if (stack.getItem() == TechCore.LINKER.get()) matched = true;
30+
if (stack.isEmpty()) continue;
31+
link:
32+
if (stack.getItem() == TechCore.LINKER.get())
33+
{
34+
if (!stack.hasTag()) break link;
35+
if (!stack.getTag().contains("lift")) break link;
36+
matched = true;
37+
linker = stack;
38+
}
2839
n++;
2940
}
3041
if (n != 1) matched = false;
31-
if (matched) return new ItemStack(TechCore.LINKER.get());
42+
if (matched)
43+
{
44+
final ItemStack ret = linker.copy();
45+
ret.getTag().remove("lift");
46+
return ret;
47+
}
48+
49+
// Try to match an elevator item
50+
n = 0;
51+
linker = ItemStack.EMPTY;
52+
for (int i = 0; i < inv.getSizeInventory(); i++)
53+
{
54+
final ItemStack stack = inv.getStackInSlot(i);
55+
if (stack.isEmpty()) continue;
56+
link:
57+
if (stack.getItem() == TechCore.LIFT.get())
58+
{
59+
if (!stack.hasTag()) break link;
60+
if (!stack.getTag().contains("min")) break link;
61+
matched = true;
62+
linker = stack;
63+
}
64+
n++;
65+
}
66+
if (n != 1) matched = false;
67+
if (matched)
68+
{
69+
final ItemStack ret = linker.copy();
70+
ret.getTag().remove("min");
71+
ret.getTag().remove("time");
72+
return ret;
73+
}
74+
3275
return ItemStack.EMPTY;
3376
}
3477

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "thuttech:resetlinker"
3+
}

0 commit comments

Comments
 (0)