Skip to content

Commit

Permalink
Added some checks for transfur animator with #1034
Browse files Browse the repository at this point in the history
  • Loading branch information
LtxProgrammer committed Sep 14, 2024
1 parent a6ec0fb commit 127005b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public void onRenderEntityPre(RenderLivingEvent.Pre<?, ?> event) {
public void onRenderPlayerPre(RenderPlayerEvent.Pre event) {
Player player = event.getPlayer();

if (event.isCanceled())
return;

if (player.isDeadOrDying() && player.getLastDamageSource() instanceof ChangedDamageSources.TransfurDamageSource) {
event.setCanceled(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static ModelPart matchCubeCount(ModelPart to, ModelPart from, ModelPart.
children.put(k, deepCopyPart(to.children.get(k), copyVisibility));
}

ModelPart.Cube copyOverride = to.cubes.size() > 0 ? to.cubes.get(0) : copyWith;
ModelPart.Cube copyOverride = !to.cubes.isEmpty() ? to.cubes.get(0) : copyWith;

for (var k : from.children.keySet()) {
if (to.children.containsKey(k)) {
Expand Down Expand Up @@ -481,7 +481,7 @@ private static void renderCoveringLimb(LivingEntity entity, TransfurVariantInsta
final float shrink = (coverAlpha - 1.0f) * 0.5f;

final ModelPart copiedPart = extendModelPartCubes(deepCopyPart(part, false), shrink, shrink, shrink);
final ModelPose pose = CAPTURED_MODELS.get(part);
final ModelPose pose = CAPTURED_MODELS.getOrDefault(part, NULL_POSE);

stack.pushPose();
((PoseStackExtender)stack).setPose(pose.matrix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.mojang.logging.LogUtils;
import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.ability.AbstractAbility;
import net.ltxprogrammer.changed.ability.GrabEntityAbility;
import net.ltxprogrammer.changed.ability.GrabEntityAbilityInstance;
import net.ltxprogrammer.changed.ability.IAbstractChangedEntity;
import net.ltxprogrammer.changed.entity.*;
import net.ltxprogrammer.changed.entity.beast.SpecialLatex;
Expand Down Expand Up @@ -386,6 +389,11 @@ TransfurVariantInstance<?> setPlayerTransfurVariant(Player player, @Nullable Tra
if (variant != null && !event.isRedundant() && !instance.isTemporaryFromSuit()) {
MinecraftForge.EVENT_BUS.post(new EntityVariantAssigned.ChangedVariant(player, variant, cause));
ChangedFunctionTags.ON_TRANSFUR.execute(ServerLifecycleHooks.getCurrentServer(), player);

if (player instanceof LivingEntityDataExtension ext) {
AbstractAbility.getAbilityInstanceSafe(ext.getGrabbedBy(), ChangedAbilities.GRAB_ENTITY_ABILITY.get())
.ifPresent(GrabEntityAbilityInstance::releaseEntity);
}
}

if (player instanceof ServerPlayer serverPlayer)
Expand Down

0 comments on commit 127005b

Please sign in to comment.