-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Blank Scroll to re-add bound scroll functionality #847
- Loading branch information
1 parent
6358a24
commit c409370
Showing
12 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
common/src/generated/resources/assets/waystones/models/item/blank_scroll.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/handheld", | ||
"textures": { | ||
"layer0": "waystones:item/blank_scroll" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/generated/resources/data/waystones/advancement/recipes/decorations/blank_scroll.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_paper": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": "minecraft:paper" | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "waystones:blank_scroll" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_the_recipe", | ||
"has_paper" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"waystones:blank_scroll" | ||
] | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
common/src/generated/resources/data/waystones/recipe/blank_scroll.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"type": "minecraft:crafting_shaped", | ||
"category": "misc", | ||
"key": { | ||
"F": "minecraft:feather", | ||
"G": "#c:nuggets/gold", | ||
"P": "minecraft:paper" | ||
}, | ||
"pattern": [ | ||
"GFG", | ||
"PPP" | ||
], | ||
"result": { | ||
"count": 3, | ||
"id": "waystones:blank_scroll" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
common/src/main/java/net/blay09/mods/waystones/item/BlankScrollItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package net.blay09.mods.waystones.item; | ||
|
||
import net.blay09.mods.waystones.api.WaystonesAPI; | ||
import net.blay09.mods.waystones.block.entity.WaystoneBlockEntityBase; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
|
||
import java.util.List; | ||
|
||
public class BlankScrollItem extends Item { | ||
public BlankScrollItem(Properties properties) { | ||
super(properties.stacksTo(64)); | ||
} | ||
|
||
@Override | ||
public InteractionResult useOn(UseOnContext context) { | ||
final var blockEntity = context.getLevel().getBlockEntity(context.getClickedPos()); | ||
if (blockEntity instanceof WaystoneBlockEntityBase waystoneBlockEntityBase) { | ||
final var waystone = waystoneBlockEntityBase.getWaystone(); | ||
final var boundScrollStack = new ItemStack(ModItems.boundScroll); | ||
WaystonesAPI.setBoundWaystone(boundScrollStack, waystone); | ||
final var player = context.getPlayer(); | ||
int emptySlot = player.getInventory().getFreeSlot(); | ||
int stackableSlot = player.getInventory().getSlotWithRemainingSpace(boundScrollStack); | ||
if ((emptySlot != -1 || stackableSlot != -1) || (!player.hasInfiniteMaterials() && context.getItemInHand().getCount() == 1)) { | ||
context.getItemInHand().consume(1, player); | ||
if (!player.addItem(boundScrollStack)) { | ||
player.drop(boundScrollStack, false); | ||
} | ||
return InteractionResult.SUCCESS; | ||
} | ||
return InteractionResult.FAIL; | ||
} | ||
|
||
return super.useOn(context); | ||
} | ||
|
||
@Override | ||
public void appendHoverText(ItemStack itemStack, TooltipContext context, List<Component> list, TooltipFlag flag) { | ||
list.add(Component.translatable("tooltip.waystones.blank_scroll").withStyle(ChatFormatting.GRAY)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+5.29 KB
common/src/main/resources/assets/waystones/textures/item/blank_scroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters