Skip to content

Commit

Permalink
some tweaks/fixes
Browse files Browse the repository at this point in the history
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+
  • Loading branch information
Thutmose committed Feb 18, 2021
1 parent 842f59a commit 790b5e2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ public ActionResultType interactInternal(final PlayerEntity player, final BlockP
public ActionResultType processInitialInteract(final PlayerEntity player, @Nullable ItemStack stack,
final Hand hand)
{

final boolean isElevatorItemOrStick = stack.getItem() == Items.STICK || stack.getItem() == TechCore.LIFT.get();
final boolean isLinker = stack.getItem() == TechCore.LINKER.get();

final boolean canEdit = this.lift.owner != null && player.getUniqueID().equals(this.lift.owner)
|| player.abilities.isCreativeMode;
final boolean canEdit = player.getUniqueID().equals(this.lift.owner) || player.abilities.isCreativeMode;

final boolean shouldLinkLift = player.isSneaking() && isLinker && canEdit;
final boolean shouldKillLiftUnowned = this.lift.owner == null;
Expand Down
26 changes: 9 additions & 17 deletions src/main/java/thut/tech/common/items/ItemLinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,16 @@ public ActionResultType onItemUse(final ItemUseContext context)
return ActionResultType.SUCCESS;
}
}
else if (playerIn.isSneaking() && state.getBlock() == TechCore.LIFTCONTROLLER.get())
else if (playerIn.isSneaking() && state.getBlock() == TechCore.LIFTCONTROLLER.get() && face != Direction.UP
&& face != Direction.DOWN)
{
if (face != Direction.UP && face != Direction.DOWN)
{
final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos);
te.editFace[face.ordinal()] = !te.editFace[face.ordinal()];
te.setSidePage(face, 0);
final String message = "msg.editMode";
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, te.editFace[face
.ordinal()]), Util.DUMMY_UUID);
return ActionResultType.SUCCESS;
}
}
else if (playerIn.isSneaking())
{
stack.setTag(new CompoundNBT());
final String message = "msg.linker.reset";
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message), Util.DUMMY_UUID);
final ControllerTile te = (ControllerTile) worldIn.getTileEntity(pos);
te.editFace[face.ordinal()] = !te.editFace[face.ordinal()];
te.setSidePage(face, 0);
final String message = "msg.editMode";
if (!worldIn.isRemote) playerIn.sendMessage(new TranslationTextComponent(message, te.editFace[face
.ordinal()]), Util.DUMMY_UUID);
return ActionResultType.SUCCESS;
}
}
return ActionResultType.PASS;
Expand Down
47 changes: 45 additions & 2 deletions src/main/java/thut/tech/common/items/RecipeReset.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,57 @@ public ItemStack getCraftingResult(final CraftingInventory inv)
{
int n = 0;
boolean matched = false;

// Try to match a device linker
ItemStack linker = ItemStack.EMPTY;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
final ItemStack stack = inv.getStackInSlot(i);
if (stack.getItem() == TechCore.LINKER.get()) matched = true;
if (stack.isEmpty()) continue;
link:
if (stack.getItem() == TechCore.LINKER.get())
{
if (!stack.hasTag()) break link;
if (!stack.getTag().contains("lift")) break link;
matched = true;
linker = stack;
}
n++;
}
if (n != 1) matched = false;
if (matched) return new ItemStack(TechCore.LINKER.get());
if (matched)
{
final ItemStack ret = linker.copy();
ret.getTag().remove("lift");
return ret;
}

// Try to match an elevator item
n = 0;
linker = ItemStack.EMPTY;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
final ItemStack stack = inv.getStackInSlot(i);
if (stack.isEmpty()) continue;
link:
if (stack.getItem() == TechCore.LIFT.get())
{
if (!stack.hasTag()) break link;
if (!stack.getTag().contains("min")) break link;
matched = true;
linker = stack;
}
n++;
}
if (n != 1) matched = false;
if (matched)
{
final ItemStack ret = linker.copy();
ret.getTag().remove("min");
ret.getTag().remove("time");
return ret;
}

return ItemStack.EMPTY;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/data/thuttech/recipes/reset_linker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "thuttech:resetlinker"
}

0 comments on commit 790b5e2

Please sign in to comment.