Skip to content

Commit

Permalink
Merge pull request #93 from Hojosa/development
Browse files Browse the repository at this point in the history
add knives tag & cheese slices now require a knive
  • Loading branch information
Alatyami authored Apr 7, 2024
2 parents 0f86044 + aba9209 commit c99e5d6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"growthcraft_rice:knife"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ protected void addTags(HolderLookup.Provider provider) {
.add(GrowthcraftRiceItems.RICE_STALK.get());
tag(GrowthcraftRiceTags.Items.TAG_GRAIN_RICE)
.add(GrowthcraftRiceItems.RICE.get());
tag(GrowthcraftTags.Items.TAG_KNIFE)
.add(GrowthcraftRiceItems.KNIFE.get());
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/growthcraft/core/init/GrowthcraftTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private static void init(){

public static final TagKey<Item> SALT = tag(Reference.UnlocalizedName.TAG_SALT);
public static final TagKey<Item> DUSTS_SALT = forgeTag(Reference.UnlocalizedName.DUSTS_SALT);
public static final TagKey<Item> TAG_KNIFE = forgeTag(Reference.UnlocalizedName.TAG_KNIVES);

private static TagKey<Item> tag(String name) {
return ItemTags.create(new ResourceLocation(Reference.MODID, name));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/growthcraft/core/shared/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static class UnlocalizedName {
public static final String TAG_CROPS_RICE = "crops/rice";
public static final String TAG_GRAIN_RICE = "grain/rice";
public static final String DUSTS_SALT = "dusts/salt";
public static final String TAG_KNIVES = "tools/knives";

private UnlocalizedName() { /* Disable default public constructor. */ }

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/growthcraft/milk/block/CheeseWheelBlock.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package growthcraft.milk.block;

import growthcraft.core.init.GrowthcraftTags;
import growthcraft.milk.block.entity.CheeseWheelBlockEntity;
import growthcraft.milk.init.GrowthcraftMilkBlockEntities;
import growthcraft.rice.init.GrowthcraftRiceTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand Down Expand Up @@ -131,7 +133,7 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP
// Allow the stackage of cheese beyond 1 block high
return InteractionResult.PASS;
}
} else if(!player.isCrouching() && player.getItemInHand(interactionHand).isEmpty()) {
} else if(!player.isCrouching() && player.getItemInHand(interactionHand).is(GrowthcraftTags.Items.TAG_KNIFE)) {
if(blockEntity.canTakeSlice()) {
player.getInventory().add(blockEntity.takeSlice());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package growthcraft.milk.block;

import growthcraft.core.init.GrowthcraftTags;
import growthcraft.milk.block.entity.CheeseWheelBlockEntity;
import growthcraft.rice.init.GrowthcraftRiceTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -21,9 +23,9 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP

CheeseWheelBlockEntity entity = (CheeseWheelBlockEntity) level.getBlockEntity(blockPos);
assert entity != null;

System.out.println(player.getItemInHand(interactionHand).getTags().toList());
// handle taking slices
if (!player.isCrouching() && player.getItemInHand(interactionHand).isEmpty()) {
if (!player.isCrouching() && player.getItemInHand(interactionHand).is(GrowthcraftTags.Items.TAG_KNIFE)) {
entity.takeSlice(1);
player.getInventory().add(getVariant().getSlices(1));
if (entity.getSliceCount() == 0) level.destroyBlock(blockPos, false);
Expand Down

0 comments on commit c99e5d6

Please sign in to comment.