generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
259 additions
and
12 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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/io/github/tropheusj/its_as_shrimple_as_that/arrow/ShrimpArrowItem.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,26 @@ | ||
package io.github.tropheusj.its_as_shrimple_as_that.arrow; | ||
|
||
import io.github.tropheusj.its_as_shrimple_as_that.ItsAsShrimpleAsThat; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.projectile.AbstractArrow; | ||
import net.minecraft.world.item.ArrowItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class ShrimpArrowItem extends ArrowItem { | ||
public ShrimpArrowItem(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public AbstractArrow createArrow(Level level, ItemStack itemStack, LivingEntity shooter) { | ||
ShrimpArrowEntity arrow = new ShrimpArrowEntity(ItsAsShrimpleAsThat.SHRIMP_ARROW_TYPE, level); | ||
arrow.setPos(shooter.getX(), shooter.getEyeY() - 0.1, shooter.getZ()); | ||
arrow.setOwner(shooter); | ||
return arrow; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/io/github/tropheusj/its_as_shrimple_as_that/arrow/ShrimpArrowRenderer.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,51 @@ | ||
package io.github.tropheusj.its_as_shrimple_as_that.arrow; | ||
|
||
import com.mojang.math.Axis; | ||
|
||
import io.github.tropheusj.its_as_shrimple_as_that.entity.render.ShrimpModel; | ||
import io.github.tropheusj.its_as_shrimple_as_that.entity.render.ShrimpRenderer; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
|
||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
|
||
public class ShrimpArrowRenderer extends EntityRenderer<ShrimpArrowEntity> { | ||
private final ShrimpModel<ShrimpArrowEntity> model; | ||
|
||
public ShrimpArrowRenderer(Context context) { | ||
super(context); | ||
this.model = new ShrimpModel<>(context); | ||
} | ||
|
||
@Override | ||
public void render(ShrimpArrowEntity shrimp, float f, float g, PoseStack matrices, MultiBufferSource buffers, int light) { | ||
matrices.pushPose(); | ||
matrices.mulPose(Axis.YP.rotationDegrees(Mth.lerp(g, shrimp.yRotO, shrimp.getYRot()) - 90.0F)); | ||
matrices.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(g, shrimp.xRotO, shrimp.getXRot()))); | ||
|
||
matrices.mulPose(Axis.ZP.rotationDegrees(90)); | ||
matrices.mulPose(Axis.YP.rotationDegrees(90)); | ||
matrices.mulPose(Axis.XN.rotationDegrees(90)); | ||
matrices.translate(0, -1.4, 0); | ||
|
||
VertexConsumer vertexConsumer = buffers.getBuffer(RenderType.entityCutout(this.getTextureLocation(shrimp))); | ||
|
||
this.model.renderToBuffer(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); | ||
matrices.popPose(); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ResourceLocation getTextureLocation(ShrimpArrowEntity entity) { | ||
return ShrimpRenderer.TEXTURE; | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
src/main/java/io/github/tropheusj/its_as_shrimple_as_that/item/ShrimpCrossbowRenderer.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,61 @@ | ||
package io.github.tropheusj.its_as_shrimple_as_that.item; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Supplier; | ||
|
||
import com.google.common.base.Suppliers; | ||
|
||
import com.mojang.math.Axis; | ||
|
||
import io.github.tropheusj.its_as_shrimple_as_that.ItsAsShrimpleAsThat; | ||
import io.github.tropheusj.its_as_shrimple_as_that.entity.ShrimpEntity; | ||
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
|
||
import net.minecraft.Util; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.renderer.LightTexture; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.renderer.entity.ItemRenderer; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.world.item.ItemDisplayContext; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.component.ChargedProjectiles; | ||
|
||
public class ShrimpCrossbowRenderer implements BuiltinItemRendererRegistry.DynamicItemRenderer { | ||
private static final ItemStack normalCrossbow = Util.make( | ||
new ItemStack(Items.CROSSBOW), | ||
stack -> stack.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.of(new ItemStack(Items.ARROW))) | ||
); | ||
|
||
private static final Supplier<ShrimpEntity> shrimp = Suppliers.memoize(() -> { | ||
ClientLevel level = Minecraft.getInstance().level; | ||
Objects.requireNonNull(level); | ||
return new ShrimpEntity(ItsAsShrimpleAsThat.SHRIMP_TYPE, level); | ||
}); | ||
|
||
@Override | ||
public void render(ItemStack stack, ItemDisplayContext mode, PoseStack matrices, MultiBufferSource buffers, int light, int overlay) { | ||
Minecraft mc = Minecraft.getInstance(); | ||
EntityRenderDispatcher entityRenderer = mc.getEntityRenderDispatcher(); | ||
ItemRenderer itemRenderer = mc.getItemRenderer(); | ||
|
||
matrices.pushPose(); | ||
matrices.translate(0.5, 0.5, 0.5); | ||
|
||
matrices.pushPose(); | ||
itemRenderer.renderStatic(normalCrossbow, mode, light, overlay, matrices, buffers, null, 0); | ||
matrices.popPose(); | ||
|
||
matrices.scale(0.5f, 0.5f, 0.5f); | ||
matrices.mulPose(Axis.YP.rotationDegrees(170)); | ||
matrices.translate(-0.17, 0.5, -0.3); | ||
|
||
entityRenderer.render(shrimp.get(), 0, 0, 0, 0, 1, matrices, buffers, 15728880); | ||
matrices.popPose(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/resources/assets/its_as_shrimple_as_that/lang/en_us.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
3 changes: 3 additions & 0 deletions
3
src/main/resources/assets/its_as_shrimple_as_that/models/item/crossbow_shrimp.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,3 @@ | ||
{ | ||
"parent": "builtin/entity" | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/resources/assets/minecraft/models/item/crossbow.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,70 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "item/crossbow_standby" | ||
}, | ||
"display": { | ||
"thirdperson_righthand": { | ||
"rotation": [ -90, 0, -60 ], | ||
"translation": [ 2, 0.1, -3 ], | ||
"scale": [ 0.9, 0.9, 0.9 ] | ||
}, | ||
"thirdperson_lefthand": { | ||
"rotation": [ -90, 0, 30 ], | ||
"translation": [ 2, 0.1, -3 ], | ||
"scale": [ 0.9, 0.9, 0.9 ] | ||
}, | ||
"firstperson_righthand": { | ||
"rotation": [ -90, 0, -55 ], | ||
"translation": [ 1.13, 3.2, 1.13], | ||
"scale": [ 0.68, 0.68, 0.68 ] | ||
}, | ||
"firstperson_lefthand": { | ||
"rotation": [ -90, 0, 35 ], | ||
"translation": [ 1.13, 3.2, 1.13], | ||
"scale": [ 0.68, 0.68, 0.68 ] | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"predicate": { | ||
"pulling": 1 | ||
}, | ||
"model": "item/crossbow_pulling_0" | ||
}, | ||
{ | ||
"predicate": { | ||
"pulling": 1, | ||
"pull": 0.58 | ||
}, | ||
"model": "item/crossbow_pulling_1" | ||
}, | ||
{ | ||
"predicate": { | ||
"pulling": 1, | ||
"pull": 1.0 | ||
}, | ||
"model": "item/crossbow_pulling_2" | ||
}, | ||
{ | ||
"predicate": { | ||
"charged": 1 | ||
}, | ||
"model": "item/crossbow_arrow" | ||
}, | ||
{ | ||
"predicate": { | ||
"charged": 1, | ||
"firework": 1 | ||
}, | ||
"model": "item/crossbow_firework" | ||
}, | ||
{ | ||
"predicate": { | ||
"charged": 1, | ||
"its_as_shrimple_as_that:shrimp": 1 | ||
}, | ||
"model": "its_as_shrimple_as_that:item/crossbow_shrimp" | ||
} | ||
] | ||
} |