Skip to content

Commit

Permalink
issue with texture
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Jun 16, 2024
1 parent 223bee1 commit 6bd7e47
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// 1.21 2024-06-15T17:54:51.685517 Item Models: tutorialmod
// 1.21 2024-06-16T23:35:53.260465 Item Models: tutorialmod
dbe88821c499df623ebb7ff6923d9ba7c904d4d2 assets/tutorialmod/models/item/boots.json
5d0ea2821df43eeadbc82147b8ac34f4eadf454e assets/tutorialmod/models/item/chestplate.json
f0c403b69c925ad55cd36b4c90d185294fe9cee4 assets/tutorialmod/models/item/example_item.json
e2caf2c406fa18a5cff192921f9825964eb46558 assets/tutorialmod/models/item/graphite_shield.json
49d3888aa7ba30796d38660f7ae1740b18b69c11 assets/tutorialmod/models/item/graphite_shield_blocking.json
ad7e28aa62fa2a4cbc97b8e0c4e3fd9f6d43046b assets/tutorialmod/models/item/helmet.json
0c29e43fdd35ecf0cc68cd01c83cf94e7c5523ea assets/tutorialmod/models/item/leggings.json
148ebc0143a22652fd66eeccf1cae2158610b79d assets/tutorialmod/models/item/pickaxe.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"parent": "minecraft:builtin/entity",
"display": {
"firstperson_lefthand": {
"rotation": [
0,
180,
5
],
"scale": [
1.25,
1.25,
1.25
],
"translation": [
10,
0,
-10
]
},
"firstperson_righthand": {
"rotation": [
0,
180,
5
],
"scale": [
1.25,
1.25,
1.25
],
"translation": [
-10,
2,
-10
]
},
"fixed": {
"rotation": [
0,
180,
0
],
"scale": [
0.5,
0.5,
0.5
],
"translation": [
-2,
4,
-5
]
},
"ground": {
"scale": [
0.25,
0.25,
0.25
],
"translation": [
4,
4,
2
]
},
"gui": {
"rotation": [
15,
-25,
-5
],
"scale": [
0.65,
0.65,
0.65
],
"translation": [
2,
3,
0
]
},
"thirdperson_lefthand": {
"rotation": [
0,
90,
0
],
"translation": [
10,
6,
12
]
},
"thirdperson_righthand": {
"rotation": [
0,
90,
0
],
"translation": [
10,
6,
-4
]
}
},
"gui_light": "front",
"overrides": [
{
"model": "tutorialmod:item/graphite_shield_blocking",
"predicate": {
"minecraft:blocking": 1.0
}
}
],
"textures": {
"particle": "tutorialmod:block/example_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"parent": "minecraft:builtin/entity",
"display": {
"firstperson_lefthand": {
"rotation": [
0,
180,
-5
],
"scale": [
1.25,
1.25,
1.25
],
"translation": [
5,
5,
-11
]
},
"firstperson_righthand": {
"rotation": [
0,
180,
-5
],
"scale": [
1.25,
1.25,
1.25
],
"translation": [
-15,
5,
-11
]
},
"gui": {
"rotation": [
15,
-25,
-5
],
"scale": [
0.65,
0.65,
0.65
],
"translation": [
2,
3,
0
]
},
"thirdperson_lefthand": {
"rotation": [
45,
135,
0
],
"translation": [
13.51,
3,
5
]
},
"thirdperson_righthand": {
"rotation": [
45,
135,
0
],
"translation": [
3.51,
11,
-2
]
}
},
"gui_light": "front",
"textures": {
"particle": "tutorialmod:block/example_block"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.realyusufismail.tutorialmod;

import io.github.realyusufismail.tutorialmod.client.TutorialModShieldItemRendererProvider;
import io.github.realyusufismail.tutorialmod.data.DataGenerators;
import io.github.realyusufismail.tutorialmod.events.Events;
import io.github.realyusufismail.tutorialmod.init.*;
Expand All @@ -25,6 +26,7 @@ public TutorialMod(IEventBus bus) {
// bus
bus.addListener(DataGenerators::gatherData);
bus.addListener(Events::clientSetup);
bus.addListener(TutorialModShieldItemRendererProvider::init);

bus.addListener(FMLClientSetupEvent.class, (fmlClientSetupEvent -> {
fmlClientSetupEvent.enqueueWork(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;

import java.util.Locale;
import java.util.function.Function;

public class TutorialModShieldItemRenderer extends ModBlockEntityWithoutLevelRenderer {
private static Material SHIELD_GRAPHITE = new Material(
private static final Material SHIELD_GRAPHITE = new Material(
InventoryMenu.BLOCK_ATLAS, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, "entity/shield/graphite")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ protected void registerModels() {
// tools
tool(ItemInit.SWORD.get());
tool(ItemInit.PICKAXE.get());

// shield
ModelFile builtInEntityModel = new ModelFile.UncheckedModelFile("builtin/entity");

ModelFile graphiteShieldBlocking =
shieldBlockingModel("graphite_shield_blocking", builtInEntityModel, "example_block");
shieldModel("graphite_shield", builtInEntityModel, "example_block", graphiteShieldBlocking);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import net.minecraft.resources.ResourceLocation;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;

import java.util.Objects;

public class Events {

public static void clientSetup(FMLClientSetupEvent event) {
// Register client event listeners here
event.enqueueWork(() -> {
ItemProperties.register(ItemInit.GRAPHITE_SHIELD.get(), ResourceLocation.read("blocking").getOrThrow(),
ItemProperties.register(ItemInit.GRAPHITE_SHIELD.get(), Objects.requireNonNull(ResourceLocation.tryParse("blocking"), "Failed to register blocking property"),
(pItemStack, pClientLevel, pLivingEntity, pPartialTicks) -> pLivingEntity != null && pLivingEntity.isUsingItem() && pLivingEntity.getUseItem() == pItemStack ? 1.0F : 0.0F);
});
}
Expand Down

0 comments on commit 6bd7e47

Please sign in to comment.