-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Iteranya/1.20.1_Built_In_Script
HUMU!!!
- Loading branch information
Showing
17 changed files
with
239 additions
and
30 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/arsparadox/mobtalkerredux/CustomItemUtils.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,38 @@ | ||
package org.arsparadox.mobtalkerredux; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public class CustomItemUtils { | ||
// Basic version - just give a variant | ||
public static void giveCustomItem(Player player, String variantName) { | ||
ItemStack itemStack = new ItemStack(MobTalkerRedux.RegistryEvents.CUSTOM_ITEM.get()); | ||
CompoundTag tag = new CompoundTag(); | ||
tag.putString("CustomName", "item.mobtalkerredux." + variantName); | ||
tag.putString("TextureKey", "custom_item_" + variantName); | ||
tag.putInt("CustomModelData", getVariantId(variantName)); | ||
itemStack.setTag(tag); | ||
|
||
giveItemToPlayer(player, itemStack); | ||
} | ||
|
||
|
||
// Private helper methods | ||
private static void giveItemToPlayer(Player player, ItemStack stack) { | ||
if (!player.getInventory().add(stack)) { | ||
// If inventory is full, spawn item in world | ||
player.drop(stack, false); | ||
} | ||
} | ||
|
||
private static int getVariantId(String variantName) { | ||
// You can expand this method to map variant names to custom model data IDs | ||
return switch (variantName.toLowerCase()) { | ||
case "variant1" -> 1; | ||
case "variant2" -> 2; | ||
case "variant3" -> 3; | ||
default -> 1; | ||
}; | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"item.mobtalkerredux.mob_talker_item": "The Mob Talker" | ||
"item.mobtalkerredux.mob_talker_item": "The Mob Talker", | ||
"item.mobtalkerredux.custom_item": "Custom Item", | ||
"item.mobtalkerredux.variant1": "Variant 1 Item", | ||
"item.mobtalkerredux.variant2": "Variant 2 Item" | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/assets/mobtalkerredux/models/item/custom_item.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,20 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "mobtalkerredux:item/custom_item" | ||
}, | ||
"overrides": [ | ||
{ | ||
"predicate": { | ||
"custom_model_data": 1 | ||
}, | ||
"model": "mobtalkerredux:item/custom_item_variant1" | ||
}, | ||
{ | ||
"predicate": { | ||
"custom_model_data": 2 | ||
}, | ||
"model": "mobtalkerredux:item/custom_item_variant2" | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/mobtalkerredux/models/item/custom_item_variant1.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": "item/generated", | ||
"textures": { | ||
"layer0": "mobtalkerredux:item/custom_item_variant1" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/mobtalkerredux/models/item/custom_item_variant2.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": "item/generated", | ||
"textures": { | ||
"layer0": "mobtalkerredux:item/custom_item_variant2" | ||
} | ||
} |
Binary file added
BIN
+11.8 KB
src/main/resources/assets/mobtalkerredux/textures/item/custom_item_variant1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.9 KB
src/main/resources/assets/mobtalkerredux/textures/item/custom_item_variant2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.