-
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
43 changed files
with
801 additions
and
32 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
src/generated/resources/.cache/3640dae69333058667d0ac745c9dd53ff5162a43
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
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/b53530ffe8f641d659e694e00e12c85c2c363439
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,2 +1,2 @@ | ||
// 1.21 2024-07-28T12:41:42.2679323 Languages: zh_cn for mod: celebrations | ||
41a69f30d929b996cf86dac65b1e01f6796b4830 assets/celebrations/lang/zh_cn.json | ||
// 1.21 2024-08-31T20:50:35.7179308 Languages: zh_cn for mod: celebrations | ||
3ccff4f74ebb1700a8e119a2e5bbd87eaa20a7fb assets/celebrations/lang/zh_cn.json |
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/fb495bcf374953a513aaf0fcc5c297e346a4f26b
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,2 +1,2 @@ | ||
// 1.21 2024-07-28T12:41:42.2689501 Languages: en_us for mod: celebrations | ||
def096f772a649bde461c0ea664485395b5c3d3e assets/celebrations/lang/en_us.json | ||
// 1.21 2024-08-31T20:50:35.7179308 Languages: en_us for mod: celebrations | ||
43f1aa404e8ae53e01195d659f596b2e9f695869 assets/celebrations/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
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
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/celebrations/models/item/balloon.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,7 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "celebrations:item/balloon_leash", | ||
"layer1": "celebrations:item/balloon" | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
src/main/java/team/leomc/celebrations/client/event/CClientEvents.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,121 @@ | ||
package team.leomc.celebrations.client.event; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap; | ||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.HumanoidArm; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.api.distmarker.OnlyIn; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent; | ||
import org.joml.Matrix4f; | ||
import team.leomc.celebrations.Celebrations; | ||
import team.leomc.celebrations.entity.Balloon; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
@EventBusSubscriber(modid = Celebrations.ID, value = Dist.CLIENT) | ||
public class CClientEvents { | ||
public static final int FULL_BRIGHT = 0xf000f0; | ||
public static final Int2ObjectArrayMap<Vec3> PLAYER_LEFT_HAND_POS = new Int2ObjectArrayMap<>(); | ||
public static final Int2ObjectArrayMap<Vec3> PLAYER_RIGHT_HAND_POS = new Int2ObjectArrayMap<>(); | ||
public static final Int2IntArrayMap BALLOON_LIGHT = new Int2IntArrayMap(); | ||
|
||
@SubscribeEvent | ||
private static void onRenderLevelStage(RenderLevelStageEvent event) { | ||
ClientLevel level = Minecraft.getInstance().level; | ||
EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher(); | ||
PoseStack stack = event.getPoseStack(); | ||
MultiBufferSource buffer = event.getLevelRenderer().renderBuffers.bufferSource(); | ||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); | ||
Vec3 cameraPos = camera.getPosition(); | ||
|
||
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_SKY) { | ||
PLAYER_LEFT_HAND_POS.clear(); | ||
PLAYER_RIGHT_HAND_POS.clear(); | ||
BALLOON_LIGHT.clear(); | ||
} | ||
|
||
if (level != null && event.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { | ||
stack.pushPose(); | ||
stack.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z()); | ||
float partialTicks = Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(Minecraft.getInstance().level != null && Minecraft.getInstance().level.tickRateManager().runsNormally()); | ||
for (Entity entity : level.entitiesForRendering()) { | ||
if (entity instanceof Balloon balloon) { | ||
LivingEntity owner = balloon.getOwner(); | ||
if (owner instanceof Player player) { | ||
HumanoidArm arm = balloon.isMainHand() ? player.getMainArm() : player.getMainArm().getOpposite(); | ||
Vec3 handPos = arm == HumanoidArm.RIGHT ? PLAYER_RIGHT_HAND_POS.get(player.getId()) : PLAYER_LEFT_HAND_POS.get(player.getId()); | ||
if (entityRenderDispatcher.options.getCameraType().isFirstPerson() && owner == Minecraft.getInstance().player) { | ||
int hand = owner.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; | ||
if (!balloon.isMainHand()) { | ||
hand = -hand; | ||
} | ||
Vec3 vec3 = entityRenderDispatcher.camera.getNearPlane().getPointOnPlane(hand * 1.2f, -1.2f).scale(960.0 / (double) entityRenderDispatcher.options.fov().get()); | ||
handPos = owner.getEyePosition(partialTicks).add(vec3); | ||
} | ||
if (handPos != null) { | ||
stack.pushPose(); | ||
Vec3 entityPos = balloon.getPosition(partialTicks); | ||
stack.translate(entityPos.x, entityPos.y, entityPos.z); | ||
renderLeash(handPos, entityPos, BALLOON_LIGHT.getOrDefault(balloon.getId(), FULL_BRIGHT), stack, buffer); | ||
stack.popPose(); | ||
} | ||
} | ||
} | ||
} | ||
stack.popPose(); | ||
} | ||
} | ||
|
||
private static void renderLeash(Vec3 from, Vec3 to, int light, PoseStack poseStack, MultiBufferSource bufferSource) { | ||
poseStack.pushPose(); | ||
double d3 = to.x; | ||
double d4 = to.y; | ||
double d5 = to.z; | ||
float f = (float) (from.x - d3); | ||
float f1 = (float) (from.y - d4); | ||
float f2 = (float) (from.z - d5); | ||
VertexConsumer vertexconsumer = bufferSource.getBuffer(RenderType.leash()); | ||
Matrix4f matrix4f = poseStack.last().pose(); | ||
float f4 = Mth.invSqrt(f * f + f2 * f2) * 0.025F / 2.0F; | ||
float f5 = f2 * f4; | ||
float f6 = f * f4; | ||
|
||
int j1; | ||
for (j1 = 0; j1 <= 24; ++j1) { | ||
addVertexPair(vertexconsumer, matrix4f, f, f1, f2, light, 0.025F, 0.025F, f5, f6, j1, false); | ||
} | ||
|
||
for (j1 = 24; j1 >= 0; --j1) { | ||
addVertexPair(vertexconsumer, matrix4f, f, f1, f2, light, 0.025F, 0.0F, f5, f6, j1, true); | ||
} | ||
|
||
poseStack.popPose(); | ||
} | ||
|
||
private static void addVertexPair(VertexConsumer buffer, Matrix4f pose, float startX, float startY, float startZ, int light, float yOffset, float dy, float dx, float dz, int index, boolean reverse) { | ||
float f = (float) index / 24.0F; | ||
float f1 = index % 2 == (reverse ? 1 : 0) ? 0.7F : 1.0F; | ||
float f2 = 0.5F * f1; | ||
float f3 = 0.4F * f1; | ||
float f4 = 0.3F * f1; | ||
float f5 = startX * f; | ||
float f6 = startY > 0.0F ? startY * f * f : startY - startY * (1.0F - f) * (1.0F - f); | ||
float f7 = startZ * f; | ||
buffer.addVertex(pose, f5 - dx, f6 + dy, f7 + dz).setColor(f2, f3, f4, 1.0F).setLight(light); | ||
buffer.addVertex(pose, f5 + dx, f6 + yOffset - dy, f7 - dz).setColor(f2, f3, f4, 1.0F).setLight(light); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/team/leomc/celebrations/client/model/entity/BalloonModel.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,43 @@ | ||
package team.leomc.celebrations.client.model.entity; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.minecraft.client.model.EntityModel; | ||
import net.minecraft.client.model.geom.ModelLayerLocation; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.api.distmarker.OnlyIn; | ||
import team.leomc.celebrations.Celebrations; | ||
import team.leomc.celebrations.entity.Balloon; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class BalloonModel<T extends Balloon> extends EntityModel<T> { | ||
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(Celebrations.id("balloon"), "main"); | ||
private final ModelPart root; | ||
|
||
public BalloonModel(ModelPart root) { | ||
this.root = root.getChild("root"); | ||
} | ||
|
||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
|
||
partdefinition.addOrReplaceChild("root", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -12.0F, -5.0F, 10.0F, 10.0F, 10.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 20).addBox(-3.0F, -2.0F, -3.0F, 6.0F, 2.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); | ||
|
||
return LayerDefinition.create(meshdefinition, 64, 32); | ||
} | ||
|
||
@Override | ||
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | ||
|
||
} | ||
|
||
@Override | ||
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, int color) { | ||
root.render(poseStack, vertexConsumer, packedLight, packedOverlay, color); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ions/client/renderer/CoupletRenderer.java → ...lient/renderer/block/CoupletRenderer.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
2 changes: 1 addition & 1 deletion
2
...ns/client/renderer/FuStickerRenderer.java → ...ent/renderer/block/FuStickerRenderer.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
Oops, something went wrong.