Skip to content

Commit

Permalink
ref: update linkable api, remoteactivator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeronimo97 committed Aug 6, 2024
1 parent 9fc51e9 commit 81dffc6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
34 changes: 17 additions & 17 deletions src/main/java/com/troblecodings/tcredstone/init/GIRCInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,40 @@

public class GIRCInit {

public static final DeferredRegister<Item> ITEM_REGISTRY = DeferredRegister
.create(ForgeRegistries.ITEMS, GIRCRedstoneMain.MODID);
public static final DeferredRegister<Block> BLOCK_REGISTRY = DeferredRegister
.create(ForgeRegistries.BLOCKS, GIRCRedstoneMain.MODID);
public static final DeferredRegister<BlockEntityType<?>> TILEENTITY_REGISTRY = DeferredRegister
.create(ForgeRegistries.BLOCK_ENTITY_TYPES, GIRCRedstoneMain.MODID);
public static final DeferredRegister<Item> ITEM_REGISTRY =
DeferredRegister.create(ForgeRegistries.ITEMS, GIRCRedstoneMain.MODID);
public static final DeferredRegister<Block> BLOCK_REGISTRY =
DeferredRegister.create(ForgeRegistries.BLOCKS, GIRCRedstoneMain.MODID);
public static final DeferredRegister<BlockEntityType<?>> TILEENTITY_REGISTRY =
DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, GIRCRedstoneMain.MODID);

public static final RegistryObject<Block> 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<Block> 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<Block> 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<Item> RS_LINKER = ITEM_REGISTRY.register("linker",
() -> new Linkingtool(null, GIRCInit::acceptAcceptor));
public static final RegistryObject<Item> RS_LINKER =
ITEM_REGISTRY.register("linker", () -> new Linkingtool(null, GIRCInit::acceptAcceptor));
public static final RegistryObject<Item> RS_MULTILINKER = ITEM_REGISTRY.register("multilinker",
() -> new MultiLinkingTool(null, GIRCInit::acceptAcceptor));
public static final RegistryObject<Item> REMOTE_ACTIVATOR = ITEM_REGISTRY.register("activator",
() -> new RemoteActivator());
() -> new RemoteActivator(null, GIRCInit::acceptAcceptor));

public static final RegistryObject<BlockEntityType<?>> EMITER_TILE = TILEENTITY_REGISTRY
.register("emitter", () -> BlockEntityType.Builder
public static final RegistryObject<BlockEntityType<?>> EMITER_TILE =
TILEENTITY_REGISTRY.register("emitter", () -> BlockEntityType.Builder
.of(TileRedstoneEmitter::new, RS_EMITTER.get()).build(null));

public static final RegistryObject<BlockEntityType<?>> MULTI_EMITER_TILE = TILEENTITY_REGISTRY
.register("multiemitter", () -> BlockEntityType.Builder
public static final RegistryObject<BlockEntityType<?>> MULTI_EMITER_TILE =
TILEENTITY_REGISTRY.register("multiemitter", () -> BlockEntityType.Builder
.of(TileRedstoneMultiEmitter::new, RS_MULTI_EMITTER.get()).build(null));

private static final RegistryObject<Block> internalRegisterBlock(final String name,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Level, BlockPos> predicate) {
super(tab, predicate, _u -> false);
}

@Override
public InteractionResultHolder<ItemStack> 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);
}

Expand Down

0 comments on commit 81dffc6

Please sign in to comment.