Skip to content

Commit

Permalink
ref: update linkableapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeronimo97 committed Jul 28, 2024
1 parent 8c37be6 commit f580834
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ public RemoteActivator(final ItemGroup tab, final BiPredicate<World, BlockPos> p
public ActionResult<ItemStack> use(final World level, final PlayerEntity player,
final Hand hand) {
final ItemStack itemstack = player.getItemInHand(hand);
if (!hand.equals(Hand.MAIN_HAND) || level.isClientSide)
return ActionResult.newResult(ActionResultType.PASS,itemstack);
final CompoundNBT comp = itemstack.getTag();
final BlockPos linkpos = NBTUtil.readBlockPos(comp);
final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos, level);
message(player, "ra.state", String.valueOf(state));
return ActionResult.newResult(ActionResultType.SUCCESS,itemstack);
final CompoundNBT tag = getOrCreateForStack(itemstack);
if (tag.contains(LINKINGTOOL_TAG)) {
if (!hand.equals(Hand.MAIN_HAND) || level.isClientSide)
return ActionResult.newResult(ActionResultType.PASS, itemstack);
final CompoundNBT comp = tag.getCompound(LINKINGTOOL_TAG);
final boolean containsPos =
comp.contains("X") && comp.contains("Y") && comp.contains("Z");
if (containsPos) {
final BlockPos linkpos = NBTUtil.readBlockPos(comp);
final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos, level);
message(player, "ra.state", String.valueOf(state));
return ActionResult.newResult(ActionResultType.SUCCESS, itemstack);
}
}
return ActionResult.newResult(ActionResultType.PASS, itemstack);
}

}

0 comments on commit f580834

Please sign in to comment.