Skip to content

Commit bcbcc3a

Browse files
committed
2.3.4 Release
1 parent 48aefe2 commit bcbcc3a

File tree

13 files changed

+285
-151
lines changed

13 files changed

+285
-151
lines changed

changelog.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
# 2.3.3.6 MoLang Additions
2-
3-
### We will be gradually releasing Minor versions with a ton of MoLang additions.
4-
5-
**Feel Free to Suggest MoLangs that you would like to see added in the future.**
1+
# 2.3.4 MoLang Additions
62

73
## Warning:
84

9-
* **This is a major update series with extensive changes. While everything has been tested privately, the sheer size means bugs
5+
* **This is a major update series with extensive changes. While everything has been tested privately, the sheer size
6+
means bugs
107
may still occur. Please report any issues on GitHub or message `@me_alam` on Discord.**
118
* **The version will remain minor until stability and feature completeness are confirmed.**
129

1310
## Added
1411

1512
* Added all the MoLang for:
16-
* PatrollingMonster
13+
* Saddleable
14+
* Ownable
15+
16+
## Changed
17+
18+
* Refactored some shared Entity Rendering code to reduce duplication.
19+
20+
### From Previous Beta's
21+
22+
* Added a TypeAdapter for the Animation Controllers.
23+
* Made the JSONMerger Static, so it can be used without instantiation.
24+
* Minor Cleanup in the EntityMoLang Registration.
25+
* And a lot of MoLang!!!!
1726

1827
## Epilogue
1928

changelog_molang.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# {VERSION} MoLang Additions
2+
3+
### We will be gradually releasing Minor versions with a ton of MoLang additions.
4+
5+
**Feel Free to Suggest MoLangs that you would like to see added in the future.**
6+
7+
## Warning:
8+
9+
* **This is a major update series with extensive changes. While everything has been tested privately, the sheer size means bugs
10+
may still occur. Please report any issues on GitHub or message `@me_alam` on Discord.**
11+
* **The version will remain minor until stability and feature completeness are confirmed.**
12+
13+
## Added
14+
15+
* Added all the MoLang for:
16+
*
17+
18+
## Epilogue
19+
20+
* Thank you for your continued support and patience.
21+
* Please keep reporting your issues so we can finalize these features and ensure a BugFree Experience.
22+
* If you have any questions or need assistance, feel free to reach out on Discord (@me_alam) or GitHub (MeAlam1)

common/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ modrinth {
5252
uploadFile.set(tasks.named<Jar>("jar"))
5353
changelog = rootProject.file("changelog.md").readText(Charsets.UTF_8)
5454
gameVersions.set(listOf(mcVersion, "1.21.2", "1.21.3"))
55-
versionType = "beta"
55+
versionType = "release"
5656
loaders.set(listOf("neoforge", "forge"))
5757
dependencies {
5858
required.project("bluelib")
@@ -69,7 +69,7 @@ tasks.register<TaskPublishCurseForge>("publishToCurseForge") {
6969

7070
val mainFile = upload(1132979, tasks.jar)
7171
mainFile.displayName = "${version}-common-${mcVersion}-${modId}"
72-
mainFile.releaseType = "beta"
72+
mainFile.releaseType = "release"
7373
mainFile.addModLoader("NeoForge", "Fabric", "Forge")
7474
mainFile.addGameVersion(mcVersion, "1.21.2", "1.21.3")
7575
mainFile.addJavaVersion("Java 21")

common/src/main/java/software/bluelib/BlueLibConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static <T> ServiceLoader<T> loadAll(@NotNull Class<T> pClazz) {
5959
public static final String MOD_NAME = "BlueLib";
6060

6161
@NotNull
62-
public static final String VERSION = "2.3.3.6";
62+
public static final String VERSION = "2.3.4";
6363

6464
@Nullable
6565
public static MinecraftServer server;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (C) 2024 BlueLib Contributors
3+
*
4+
* This Source Code Form is subject to the terms of the MIT License.
5+
* If a copy of the MIT License was not distributed with this file,
6+
* You can obtain one at https://opensource.org/licenses/MIT.
7+
*/
8+
package software.bluelib.api.molang.context.entity;
9+
10+
import java.util.function.Supplier;
11+
import net.minecraft.world.entity.OwnableEntity;
12+
import org.jetbrains.annotations.NotNull;
13+
import software.bluelib.api.molang.context.BaseMoLangContext;
14+
15+
public class OwnableMoLang extends BaseMoLangContext {
16+
17+
public OwnableMoLang(@NotNull Supplier<OwnableEntity> pOwnableEntitySup) {
18+
OwnableEntity ownableEntity = pOwnableEntitySup.get();
19+
setVariable("get_owner", ownableEntity.getOwner());
20+
setVariable("level", ownableEntity.level());
21+
setVariable("get_owner_uuid", ownableEntity.getOwnerUUID());
22+
}
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2024 BlueLib Contributors
3+
*
4+
* This Source Code Form is subject to the terms of the MIT License.
5+
* If a copy of the MIT License was not distributed with this file,
6+
* You can obtain one at https://opensource.org/licenses/MIT.
7+
*/
8+
package software.bluelib.api.molang.context.entity;
9+
10+
import java.util.function.Supplier;
11+
import net.minecraft.sounds.SoundSource;
12+
import net.minecraft.world.entity.Saddleable;
13+
import net.minecraft.world.item.ItemStack;
14+
import org.jetbrains.annotations.NotNull;
15+
import software.bluelib.api.molang.context.BaseMoLangContext;
16+
17+
public class SaddleableMoLang extends BaseMoLangContext {
18+
19+
public SaddleableMoLang(@NotNull Supplier<Saddleable> pSaddleableSup) {
20+
Saddleable saddleable = pSaddleableSup.get();
21+
setVariable("is_saddleable", saddleable.isSaddleable());
22+
setVariable("is_saddled", saddleable.isSaddled());
23+
setVariable("get_saddle_sound_event", saddleable.getSaddleSoundEvent());
24+
25+
registerFunction("equip_saddle", (args, runtime) -> {
26+
if (!(args.getFirst() instanceof ItemStack item)) {
27+
return saddleable.isSaddled();
28+
}
29+
SoundSource soundSource = null;
30+
if (args.size() > 1 && args.get(1) instanceof SoundSource) {
31+
soundSource = (SoundSource) args.get(1);
32+
}
33+
saddleable.equipSaddle(item, soundSource);
34+
return saddleable.isSaddled();
35+
});
36+
}
37+
}

common/src/main/java/software/bluelib/api/molang/registry/MoLangEntityRegistry.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public static void init() {
6161
registerEntityContext(hangingEntity -> hangingEntity instanceof HangingEntity ? new HangingEntityMoLang(() -> (HangingEntity) hangingEntity) : null);
6262
registerEntityContext(blockAttachedEntity -> blockAttachedEntity instanceof BlockAttachedEntity ? new BlockAttachedEntityMoLang(() -> (BlockAttachedEntity) blockAttachedEntity) : null);
6363
registerEntityContext(vehicleEntity -> vehicleEntity instanceof VehicleEntity ? new VehicleEntityMoLang(() -> (VehicleEntity) vehicleEntity) : null);
64+
65+
registerEntityContext(saddleableEntity -> saddleableEntity instanceof Saddleable ? new SaddleableMoLang(() -> (Saddleable) saddleableEntity) : null);
66+
registerEntityContext(ownableEntity -> ownableEntity instanceof OwnableEntity ? new OwnableMoLang(() -> (OwnableEntity) ownableEntity) : null);
67+
6468
registerEntityContext(entity -> entity instanceof Entity ? new EntityMoLang(() -> entity) : null);
6569
}
6670
}

common/src/main/java/software/bluelib/loader/renderer/entity/BlueEntityRenderer.java

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -175,84 +175,65 @@ public void render(@NotNull T pEntity, float pEntityYaw, float pPartialTick, @No
175175
@Override
176176
public void actuallyRender(@NotNull IRenderContext<T> pContext) {
177177
if (pContext instanceof FullRenderContext<T> full) {
178-
PoseStack pPoseStack = full.poseStack();
178+
PoseStack poseStack = full.poseStack();
179179
T animatable = full.animatable();
180180
VertexConsumer buffer = full.optionalBuffer();
181-
boolean pIsReRender = full.isReRender();
182-
float pPartialTick = full.partialTick();
181+
boolean isReRender = full.isReRender();
182+
float partialTick = full.partialTick();
183183

184-
pPoseStack.pushPose();
184+
poseStack.pushPose();
185185

186-
LivingEntity livingEntity = animatable instanceof LivingEntity entity ? entity : null;
187-
boolean shouldSit = animatable.isPassenger() && (animatable.getVehicle() != null);
188-
float lerpBodyRot = livingEntity == null ? 0 : Mth.rotLerp(pPartialTick, livingEntity.yBodyRotO, livingEntity.yBodyRot);
189-
float lerpHeadRot = livingEntity == null ? 0 : Mth.rotLerp(pPartialTick, livingEntity.yHeadRotO, livingEntity.yHeadRot);
190-
float netHeadYaw = lerpHeadRot - lerpBodyRot;
186+
LivingEntity livingEntity = animatable instanceof LivingEntity e ? e : null;
187+
boolean shouldSit = animatable.isPassenger() && animatable.getVehicle() != null;
191188

192-
if (shouldSit && animatable.getVehicle() instanceof LivingEntity livingentity) {
193-
lerpBodyRot = Mth.rotLerp(pPartialTick, livingentity.yBodyRotO, livingentity.yBodyRot);
194-
netHeadYaw = lerpHeadRot - lerpBodyRot;
195-
float clampedHeadYaw = Mth.clamp(Mth.wrapDegrees(netHeadYaw), -85, 85);
196-
lerpBodyRot = lerpHeadRot - clampedHeadYaw;
189+
float lerpBodyRot = EntityRenderUtils.getLerpBodyRot(livingEntity, partialTick);
190+
float lerpHeadRot = EntityRenderUtils.getLerpHeadRot(livingEntity, partialTick);
191+
float[] adjusted = EntityRenderUtils.adjustSittingRotations(shouldSit, animatable, lerpHeadRot, lerpBodyRot, partialTick);
192+
lerpBodyRot = adjusted[0];
193+
float netHeadYaw = adjusted[1];
197194

198-
if (clampedHeadYaw * clampedHeadYaw > 2500f)
199-
lerpBodyRot += clampedHeadYaw * 0.2f;
200-
201-
netHeadYaw = lerpHeadRot - lerpBodyRot;
202-
}
203-
204-
if (animatable.getPose() == Pose.SLEEPING && livingEntity != null) {
205-
Direction bedDirection = livingEntity.getBedOrientation();
206-
207-
if (bedDirection != null) {
208-
float eyePosOffset = livingEntity.getEyeHeight(Pose.STANDING) - 0.1F;
209-
pPoseStack.translate(-bedDirection.getStepX() * eyePosOffset, 0, -bedDirection.getStepZ() * eyePosOffset);
210-
}
211-
}
195+
if (livingEntity != null)
196+
EntityRenderUtils.applySleepingTranslation(poseStack, livingEntity);
212197

213198
float nativeScale = livingEntity != null ? livingEntity.getScale() : 1;
214-
float ageInTicks = animatable.tickCount + pPartialTick;
215-
float limbSwingAmount = 0;
216-
float limbSwing = 0;
199+
float ageInTicks = animatable.tickCount + partialTick;
217200

218-
pPoseStack.scale(nativeScale, nativeScale, nativeScale);
219-
applyRotations(animatable, pPoseStack, ageInTicks, lerpBodyRot, pPartialTick, nativeScale);
201+
poseStack.scale(nativeScale, nativeScale, nativeScale);
202+
applyRotations(animatable, poseStack, ageInTicks, lerpBodyRot, partialTick, nativeScale);
220203

221-
if (!shouldSit && animatable.isAlive() && livingEntity != null) {
222-
limbSwingAmount = livingEntity.walkAnimation.speed(pPartialTick);
223-
limbSwing = livingEntity.walkAnimation.position(pPartialTick);
204+
float[] limbSwingData = livingEntity != null
205+
? EntityRenderUtils.computeLimbSwing(livingEntity, shouldSit, partialTick)
206+
: new float[] { 0, 0 };
207+
float limbSwing = limbSwingData[0];
208+
float limbSwingAmount = limbSwingData[1];
224209

225-
if (livingEntity.isBaby())
226-
limbSwing *= 3f;
210+
if (!isReRender) {
211+
float headPitch = Mth.lerp(partialTick, animatable.xRotO, animatable.getXRot());
212+
float motionThreshold = getMotionAnimThreshold(pContext);
227213

228-
if (limbSwingAmount > 1f)
229-
limbSwingAmount = 1f;
230-
}
214+
boolean moving = livingEntity != null
215+
? EntityRenderUtils.isEntityMoving(livingEntity, motionThreshold, limbSwingAmount)
216+
: (Math.abs(limbSwingAmount) >= motionThreshold);
231217

232-
if (!pIsReRender) {
233-
float headPitch = Mth.lerp(pPartialTick, animatable.xRotO, animatable.getXRot());
234-
float motionThreshold = getMotionAnimThreshold(pContext);
235-
Vec3 velocity = animatable.getDeltaMovement();
236-
float avgVelocity = (float) ((Math.abs(velocity.x) + Math.abs(velocity.z)) / 2f);
237-
AnimationState<T> animationState = new AnimationState<>(animatable, limbSwing, limbSwingAmount, pPartialTick, avgVelocity >= motionThreshold && limbSwingAmount != 0);
218+
AnimationState<T> state = new AnimationState<>(animatable, limbSwing, limbSwingAmount, partialTick, moving);
238219
long instanceId = getInstanceId(pContext);
239-
BlueModel<T> currentModel = getBlueModel();
240-
241-
animationState.setData(DataTickets.TICK, animatable.getTick(animatable));
242-
animationState.setData(DataTickets.ENTITY, animatable);
243-
animationState.setData(DataTickets.ENTITY_MODEL_DATA, new EntityModelData(shouldSit, livingEntity != null && livingEntity.isBaby(), -netHeadYaw, -headPitch));
244-
currentModel.addAdditionalStateData(animatable, instanceId, animationState::setData);
245-
currentModel.handleAnimations(animatable, instanceId, animationState, pPartialTick);
220+
BlueModel<T> model = getBlueModel();
221+
222+
state.setData(DataTickets.TICK, animatable.getTick(animatable));
223+
state.setData(DataTickets.ENTITY, animatable);
224+
state.setData(DataTickets.ENTITY_MODEL_DATA,
225+
new EntityModelData(shouldSit, livingEntity != null && livingEntity.isBaby(), -netHeadYaw, -headPitch));
226+
model.addAdditionalStateData(animatable, instanceId, state::setData);
227+
model.handleAnimations(animatable, instanceId, state, partialTick);
246228
}
247229

248-
pPoseStack.translate(0, 0.01f, 0);
249-
250-
this.modelRenderTranslations = new Matrix4f(pPoseStack.last().pose());
230+
poseStack.translate(0, 0.01f, 0);
231+
this.modelRenderTranslations = new Matrix4f(poseStack.last().pose());
251232

252233
if (buffer != null)
253234
BlueRenderer.super.actuallyRender(full);
254235

255-
pPoseStack.popPose();
236+
poseStack.popPose();
256237
} else if (pContext instanceof BaseRenderContext<T> base) {
257238
handleBaseActuallyRenderContext(base, this);
258239
}

0 commit comments

Comments
 (0)