-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
298 additions
and
4 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
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
56 changes: 56 additions & 0 deletions
56
src/client/kotlin/dev/hybridlabs/aquatic/client/model/item/FishingNetItemModel.kt
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,56 @@ | ||
package dev.hybridlabs.aquatic.client.model.item | ||
|
||
import net.minecraft.client.model.Model | ||
import net.minecraft.client.model.ModelData | ||
import net.minecraft.client.model.ModelPart | ||
import net.minecraft.client.model.ModelPartBuilder | ||
import net.minecraft.client.model.ModelTransform | ||
import net.minecraft.client.model.TexturedModelData | ||
import net.minecraft.client.render.RenderLayer | ||
import net.minecraft.client.render.VertexConsumer | ||
import net.minecraft.client.util.math.MatrixStack | ||
|
||
class FishingNetItemModel( | ||
val root: ModelPart | ||
) : Model(RenderLayer::getEntitySolid) { | ||
override fun render( | ||
matrices: MatrixStack, | ||
vertices: VertexConsumer, | ||
light: Int, | ||
overlay: Int, | ||
red: Float, | ||
green: Float, | ||
blue: Float, | ||
alpha: Float | ||
) { | ||
this.root.render(matrices, vertices, light, overlay, red, green, blue, alpha) | ||
} | ||
|
||
companion object { | ||
fun createModelData(): TexturedModelData { | ||
return TexturedModelData.of( | ||
ModelData().apply { | ||
root.addChild( | ||
"fishing_net", | ||
ModelPartBuilder.create() | ||
.uv(0, 0) | ||
.cuboid(0.5f, -8.0f, 1.0f, 1.0f, 1.0f, 16.0f) | ||
.uv(0, 2) | ||
.cuboid(-2.0f, -8.0f, 0.0f, 6.0f, 1.0f, 1.0f) | ||
.uv(20, 22) | ||
.cuboid(4.0f, -8.0f, -7.0f, 1.0f, 1.0f, 8.0f) | ||
.uv(18, 0) | ||
.cuboid(-3.0f, -8.0f, -7.0f, 1.0f, 1.0f, 8.0f) | ||
.uv(0, 0) | ||
.cuboid(-2.0f, -8.0f, -7.0f, 6.0f, 1.0f, 1.0f) | ||
.uv(0, 17) | ||
.cuboid(-2.5f, -7.5f, -6.5f, 7.0f, 6.0f, 7.0f), | ||
ModelTransform.pivot(-1.0f, 23.0f, -9.0f) | ||
) | ||
}, | ||
64, | ||
64 | ||
) | ||
} | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/client/kotlin/dev/hybridlabs/aquatic/client/render/item/FishingNetItemRenderer.kt
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,88 @@ | ||
package dev.hybridlabs.aquatic.client.render.item | ||
|
||
import dev.hybridlabs.aquatic.HybridAquatic | ||
import dev.hybridlabs.aquatic.client.model.HybridAquaticEntityModelLayers | ||
import dev.hybridlabs.aquatic.client.model.item.FishingNetItemModel | ||
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry | ||
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys | ||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener | ||
import net.minecraft.client.MinecraftClient | ||
import net.minecraft.client.render.VertexConsumerProvider | ||
import net.minecraft.client.render.item.ItemRenderer | ||
import net.minecraft.client.render.model.BakedModel | ||
import net.minecraft.client.render.model.json.ModelTransformationMode | ||
import net.minecraft.client.util.ModelIdentifier | ||
import net.minecraft.client.util.math.MatrixStack | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.resource.ResourceManager | ||
import net.minecraft.util.Identifier | ||
|
||
object FishingNetItemRenderer : BuiltinItemRendererRegistry.DynamicItemRenderer, SimpleSynchronousResourceReloadListener { | ||
private val TEXTURE_ID = Identifier(HybridAquatic.MOD_ID, "textures/item/fishing_net.png") | ||
val INVENTORY_MODEL_ID = Identifier(HybridAquatic.MOD_ID, "item/fishing_net_in_inventory") | ||
private val INVENTORY_MODEL_IDENTIFIER = ModelIdentifier(INVENTORY_MODEL_ID, "inventory") | ||
|
||
private val LISTENER_ID = Identifier(HybridAquatic.MOD_ID, "fishing_net_item_model") | ||
|
||
private lateinit var model: FishingNetItemModel | ||
private lateinit var inventoryModel: BakedModel | ||
private lateinit var itemRenderer: ItemRenderer | ||
|
||
override fun render( | ||
stack: ItemStack, | ||
mode: ModelTransformationMode, | ||
matrices: MatrixStack, | ||
vertices: VertexConsumerProvider, | ||
light: Int, | ||
overlay: Int | ||
) { | ||
itemRenderer.let { renderer -> | ||
if (mode == ModelTransformationMode.GUI || mode == ModelTransformationMode.GROUND || mode == ModelTransformationMode.FIXED) { | ||
matrices.push() | ||
renderer.renderItem( | ||
stack, | ||
mode, | ||
false, | ||
matrices, | ||
vertices, | ||
light, | ||
overlay, | ||
inventoryModel | ||
) | ||
matrices.pop() | ||
} else { | ||
matrices.push() | ||
matrices.scale(1.0f, -1.0f, -1.0f) | ||
val vertex = ItemRenderer.getDirectItemGlintConsumer( | ||
vertices, | ||
model.getLayer(TEXTURE_ID), | ||
false, | ||
stack.hasGlint() | ||
) | ||
model.render(matrices, vertex, light, overlay, 1.0f, 1.0f, 1.0f, 1.0f) | ||
matrices.pop() | ||
} | ||
} | ||
} | ||
|
||
override fun reload(manager: ResourceManager) { | ||
val client = MinecraftClient.getInstance() | ||
client.itemRenderer.let { renderer -> | ||
itemRenderer = renderer | ||
|
||
val entityModelLoader = client.entityModelLoader | ||
val bakedModelManager = client.bakedModelManager | ||
|
||
model = FishingNetItemModel(entityModelLoader.getModelPart(HybridAquaticEntityModelLayers.FISHING_NET)) | ||
inventoryModel = bakedModelManager.getModel(INVENTORY_MODEL_IDENTIFIER) | ||
} | ||
} | ||
|
||
override fun getFabricId(): Identifier { | ||
return LISTENER_ID | ||
} | ||
|
||
override fun getFabricDependencies(): Collection<Identifier> { | ||
return listOf(ResourceReloadListenerKeys.MODELS) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...brid-aquatic/models/item/fishing_net.json → ...models/item/fishing_net_in_inventory.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "hybrid-aquatic:item/fishing_net" | ||
"layer0": "hybrid-aquatic:item/fishing_net_in_inventory" | ||
} | ||
} |
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
125 changes: 125 additions & 0 deletions
125
src/main/resources/assets/hybrid-aquatic/models/item/fishing_net.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,125 @@ | ||
{ | ||
"parent": "minecraft:builtin/entity", | ||
"gui_light": "front", | ||
"display": { | ||
"thirdperson_righthand": { | ||
"rotation": [ | ||
0, | ||
60, | ||
0 | ||
], | ||
"translation": [ | ||
11, | ||
17, | ||
-2 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
}, | ||
"thirdperson_lefthand": { | ||
"rotation": [ | ||
0, | ||
60, | ||
0 | ||
], | ||
"translation": [ | ||
3, | ||
17, | ||
12 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
}, | ||
"firstperson_righthand": { | ||
"rotation": [ | ||
0, | ||
-90, | ||
25 | ||
], | ||
"translation": [ | ||
-3, | ||
17, | ||
1 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
}, | ||
"firstperson_lefthand": { | ||
"rotation": [ | ||
0, | ||
90, | ||
-25 | ||
], | ||
"translation": [ | ||
13, | ||
17, | ||
1 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
}, | ||
"gui": { | ||
"rotation": [ | ||
15, | ||
-25, | ||
-5 | ||
], | ||
"translation": [ | ||
2, | ||
3, | ||
0 | ||
], | ||
"scale": [ | ||
0.65, | ||
0.65, | ||
0.65 | ||
] | ||
}, | ||
"fixed": { | ||
"rotation": [ | ||
0, | ||
180, | ||
0 | ||
], | ||
"translation": [ | ||
-2, | ||
4, | ||
-5 | ||
], | ||
"scale": [ | ||
0.5, | ||
0.5, | ||
0.5 | ||
] | ||
}, | ||
"ground": { | ||
"rotation": [ | ||
0, | ||
0, | ||
0 | ||
], | ||
"translation": [ | ||
4, | ||
4, | ||
2 | ||
], | ||
"scale": [ | ||
0.25, | ||
0.25, | ||
0.25 | ||
] | ||
} | ||
} | ||
} |
Binary file modified
BIN
+247 Bytes
(160%)
src/main/resources/assets/hybrid-aquatic/textures/item/fishing_net.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
+429 Bytes
...main/resources/assets/hybrid-aquatic/textures/item/fishing_net_in_inventory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.