Skip to content

Commit

Permalink
mc1.21.3 preciseItemEntityModelYawSnap carry the yaw info from the …
Browse files Browse the repository at this point in the history
…ItemEntityRenderState
  • Loading branch information
Fallen-Breath committed Nov 14, 2024
1 parent 29ca591 commit 3e940eb
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.impl.mc_tweaks.preciseItemEntityModel;

public interface ItemEntityRenderStateExtra
{
float getEntityYaw$TKM();

void setEntityYaw$TKM(float yaw);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.preciseItemEntityModel;

import me.fallenbreath.tweakermore.util.mixin.DummyClass;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(DummyClass.class)
public abstract class ItemEntityRenderStateMixin
{
// impl in mc1.21.3+
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

//#if MC >= 12103
//$$ import me.fallenbreath.tweakermore.impl.mc_tweaks.preciseItemEntityModel.ItemEntityRenderStateExtra;
//$$ import net.minecraft.client.render.entity.state.ItemEntityRenderState;
//$$ import net.minecraft.entity.ItemEntity;
//$$ import org.spongepowered.asm.mixin.injection.Inject;
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#endif

@Mixin(ItemEntityRenderer.class)
public abstract class ItemEntityRendererMixin
{
Expand Down Expand Up @@ -127,9 +135,11 @@ private double preciseItemEntityModel_adjustHeightShiftTo0(double y)
index = 0
)
private float preciseItemEntityModel_tweakItemEntityRotation(
float rotation
//#if MC < 12103
, @Local(argsOnly = true) ItemEntity itemEntity,
float rotation,
//#if MC >= 12103
//$$ @Local(argsOnly = true) ItemEntityRenderState itemEntityRenderState
//#else
@Local(argsOnly = true) ItemEntity itemEntity,
@Local(
argsOnly = true,
//#if MC >= 11500
Expand All @@ -148,7 +158,11 @@ private float preciseItemEntityModel_tweakItemEntityRotation(
if (TweakerMoreConfigs.PRECISE_ITEM_ENTITY_MODEL_YAW_SNAP.getBooleanValue())
{
//#if MC >= 12103
//$$ float yaw = 0; // FIXME: carry the yaw info from the ItemEntityRenderState
//$$ float yaw = 0;
//$$ if (itemEntityRenderState instanceof ItemEntityRenderStateExtra itemEntityRenderStateExtra)
//$$ {
//$$ yaw = itemEntityRenderStateExtra.getEntityYaw$TKM();
//$$ }
//#else
float yaw = itemEntity.getYaw(tickDelta);
//#endif
Expand Down Expand Up @@ -227,4 +241,21 @@ private void preciseItemEntityModel_transformOverrideOff(CallbackInfo ci)
PreciseItemEntityModelUtils.transformOverrideFlag.set(false);
}
}

//#if MC >= 12103
//$$ @Inject(
//$$ method = "updateRenderState(Lnet/minecraft/entity/ItemEntity;Lnet/minecraft/client/render/entity/state/ItemEntityRenderState;F)V",
//$$ at = @At("TAIL")
//$$ )
//$$ private void preciseItemEntityModel_storeTheYawInfo(ItemEntity itemEntity, ItemEntityRenderState itemEntityRenderState, float tickDelta, CallbackInfo ci)
//$$ {
//$$ if (TweakerMoreConfigs.PRECISE_ITEM_ENTITY_MODEL.getBooleanValue())
//$$ {
//$$ if (itemEntityRenderState instanceof ItemEntityRenderStateExtra itemEntityRenderStateExtra)
//$$ {
//$$ itemEntityRenderStateExtra.setEntityYaw$TKM(itemEntity.getYaw(tickDelta));
//$$ }
//$$ }
//$$ }
//#endif
}
1 change: 1 addition & 0 deletions src/main/resources/tweakermore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"tweaks.mc_tweaks.playerSkinBlockingLoading.compat.customskinloader.FakeSkinManagerMixin_Old",
"tweaks.mc_tweaks.potionItemShouldHaveEnchantmentGlint.ItemStackMixin",
"tweaks.mc_tweaks.preciseItemEntityModel.ItemEntityRendererMixin",
"tweaks.mc_tweaks.preciseItemEntityModel.ItemEntityRenderStateMixin",
"tweaks.mc_tweaks.preciseItemEntityModel.ItemRendererMixin",
"tweaks.mc_tweaks.preciseItemEntityModel.ModelTransformationMixin",
"tweaks.mc_tweaks.prioritizedCommandSuggestions.CommandSuggestorMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.preciseItemEntityModel;

import me.fallenbreath.tweakermore.impl.mc_tweaks.preciseItemEntityModel.ItemEntityRenderStateExtra;
import net.minecraft.client.render.entity.state.ItemEntityRenderState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(ItemEntityRenderState.class)
public abstract class ItemEntityRenderStateMixin implements ItemEntityRenderStateExtra
{
@Unique
private float entityYaw$TKM = 0;

@Override
public float getEntityYaw$TKM()
{
return this.entityYaw$TKM;
}

@Override
public void setEntityYaw$TKM(float yaw)
{
this.entityYaw$TKM = yaw;
}
}

0 comments on commit 3e940eb

Please sign in to comment.