From 81dffc6cc4110f03e471d1fce1fdfe158913fe62 Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 6 Aug 2024 10:40:38 +0200 Subject: [PATCH] ref: update linkable api, remoteactivator --- .github/workflows/gradle.yml | 2 +- build.gradle | 2 +- changelog.md | 5 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- linkableapi | 2 +- .../tcredstone/init/GIRCInit.java | 34 +++++++++---------- .../tcredstone/item/RemoteActivator.java | 29 +++++++++++----- 7 files changed, 46 insertions(+), 30 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index dd80175..5330e8a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,7 +30,7 @@ jobs: if: endswith(github.ref_name, 'master') && github.ref_protected && github.ref_type == 'branch' runs-on: ubuntu-latest env: - APPVEYOR_BUILD_VERSION: '3.2.2' + APPVEYOR_BUILD_VERSION: '3.2.3' CURSETOKEN: ${{ secrets.CURSETOKEN }} steps: - uses: actions/checkout@v3 diff --git a/build.gradle b/build.gradle index 2bccb49..f955479 100644 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,7 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.20.4-49.0.27' + minecraft 'net.minecraftforge:forge:1.20.4-49.1.0' } jar { diff --git a/changelog.md b/changelog.md index a24431e..14e5ab4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # Changelog +## [1.20.4 - 3.2.3] + +* feat: add item damage +* ref: update linkable api + ## [1.20.4 - 3.2.2] * port 1.20.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae0804..fce403e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/linkableapi b/linkableapi index 46583ac..ac3d941 160000 --- a/linkableapi +++ b/linkableapi @@ -1 +1 @@ -Subproject commit 46583ac0aa18f98cfd2fb38e18064e3586e54c4b +Subproject commit ac3d941c78314749be5db533b93cb1feb6aa6e57 diff --git a/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java b/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java index e6b8be8..6cc8a4f 100644 --- a/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java +++ b/src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java @@ -31,40 +31,40 @@ public class GIRCInit { - public static final DeferredRegister ITEM_REGISTRY = DeferredRegister - .create(ForgeRegistries.ITEMS, GIRCRedstoneMain.MODID); - public static final DeferredRegister BLOCK_REGISTRY = DeferredRegister - .create(ForgeRegistries.BLOCKS, GIRCRedstoneMain.MODID); - public static final DeferredRegister> TILEENTITY_REGISTRY = DeferredRegister - .create(ForgeRegistries.BLOCK_ENTITY_TYPES, GIRCRedstoneMain.MODID); + public static final DeferredRegister ITEM_REGISTRY = + DeferredRegister.create(ForgeRegistries.ITEMS, GIRCRedstoneMain.MODID); + public static final DeferredRegister BLOCK_REGISTRY = + DeferredRegister.create(ForgeRegistries.BLOCKS, GIRCRedstoneMain.MODID); + public static final DeferredRegister> TILEENTITY_REGISTRY = + DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, GIRCRedstoneMain.MODID); public static final RegistryObject RS_ACCEPTOR = internalRegisterBlock("acceptor", - () -> new BlockRedstoneAcceptor(BlockBehaviour.Properties.of() //TODO Material.METAL + () -> new BlockRedstoneAcceptor(BlockBehaviour.Properties.of() // TODO Material.METAL .strength(1.5f, 6.0f).requiresCorrectToolForDrops())); public static final RegistryObject RS_EMITTER = internalRegisterBlock("emitter", - () -> new BlockRedstoneEmitter(BlockBehaviour.Properties.of() //TODO Material.METAL + () -> new BlockRedstoneEmitter(BlockBehaviour.Properties.of() // TODO Material.METAL .strength(1.5f, 6.0f).requiresCorrectToolForDrops())); public static final RegistryObject RS_MULTI_EMITTER = internalRegisterBlock( - "multiemitter", () -> new BlockRedstoneMultiEmitter(BlockBehaviour.Properties - .of().strength(1.5f, 6.0f).requiresCorrectToolForDrops())); //TODO Material.METAL + "multiemitter", () -> new BlockRedstoneMultiEmitter(BlockBehaviour.Properties.of() + .strength(1.5f, 6.0f).requiresCorrectToolForDrops())); // TODO Material.METAL public static boolean acceptAcceptor(final Level level, final BlockPos pos) { return level.getBlockState(pos).getBlock() instanceof BlockRedstoneAcceptor; } - public static final RegistryObject RS_LINKER = ITEM_REGISTRY.register("linker", - () -> new Linkingtool(null, GIRCInit::acceptAcceptor)); + public static final RegistryObject RS_LINKER = + ITEM_REGISTRY.register("linker", () -> new Linkingtool(null, GIRCInit::acceptAcceptor)); public static final RegistryObject RS_MULTILINKER = ITEM_REGISTRY.register("multilinker", () -> new MultiLinkingTool(null, GIRCInit::acceptAcceptor)); public static final RegistryObject REMOTE_ACTIVATOR = ITEM_REGISTRY.register("activator", - () -> new RemoteActivator()); + () -> new RemoteActivator(null, GIRCInit::acceptAcceptor)); - public static final RegistryObject> EMITER_TILE = TILEENTITY_REGISTRY - .register("emitter", () -> BlockEntityType.Builder + public static final RegistryObject> EMITER_TILE = + TILEENTITY_REGISTRY.register("emitter", () -> BlockEntityType.Builder .of(TileRedstoneEmitter::new, RS_EMITTER.get()).build(null)); - public static final RegistryObject> MULTI_EMITER_TILE = TILEENTITY_REGISTRY - .register("multiemitter", () -> BlockEntityType.Builder + public static final RegistryObject> MULTI_EMITER_TILE = + TILEENTITY_REGISTRY.register("multiemitter", () -> BlockEntityType.Builder .of(TileRedstoneMultiEmitter::new, RS_MULTI_EMITTER.get()).build(null)); private static final RegistryObject internalRegisterBlock(final String name, diff --git a/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java b/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java index 7136ca3..444775c 100644 --- a/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java +++ b/src/main/java/com/troblecodings/tcredstone/item/RemoteActivator.java @@ -1,7 +1,8 @@ package com.troblecodings.tcredstone.item; +import java.util.function.BiPredicate; + import com.troblecodings.linkableapi.Linkingtool; -import com.troblecodings.tcredstone.init.GIRCInit; import com.troblecodings.tcredstone.tile.TileRedstoneEmitter; import net.minecraft.core.BlockPos; @@ -10,25 +11,35 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; public class RemoteActivator extends Linkingtool { - public RemoteActivator() { - super(null, GIRCInit::acceptAcceptor, _u1 -> false); + public RemoteActivator(final CreativeModeTab tab, + final BiPredicate predicate) { + super(tab, predicate, _u -> false); } @Override public InteractionResultHolder use(final Level level, final Player player, final InteractionHand hand) { final ItemStack itemstack = player.getItemInHand(hand); - if (!hand.equals(InteractionHand.MAIN_HAND) || level.isClientSide) - return InteractionResultHolder.pass(itemstack); - final CompoundTag comp = itemstack.getTag(); - final BlockPos linkpos = NbtUtils.readBlockPos(comp); - final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos, level); - message(player, "ra.state", String.valueOf(state)); + final CompoundTag tag = itemstack.getOrCreateTag(); + if (tag.contains(LINKINGTOOL_TAG)) { + if (!hand.equals(InteractionHand.MAIN_HAND) || level.isClientSide) + return InteractionResultHolder.pass(itemstack); + final CompoundTag comp = tag.getCompound(LINKINGTOOL_TAG); + final boolean containsPos = + comp.contains("X") && comp.contains("Y") && comp.contains("Z"); + if (containsPos) { + final BlockPos linkpos = NbtUtils.readBlockPos(comp); + final boolean state = TileRedstoneEmitter.redstoneUpdate(linkpos, level); + message(player, "ra.state", String.valueOf(state)); + return InteractionResultHolder.success(itemstack); + } + } return InteractionResultHolder.success(itemstack); }