mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Tools and weapons now keep their orientation when being held by a unicorn
This commit is contained in:
parent
ff6b3d182d
commit
5524f8c7f1
3 changed files with 21 additions and 5 deletions
|
@ -1,13 +1,16 @@
|
|||
package com.minelittlepony.api.config;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.minelittlepony.api.pony.meta.*;
|
||||
import com.minelittlepony.common.client.gui.VisibilityMode;
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import com.minelittlepony.common.util.settings.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Storage container for MineLP client settings.
|
||||
|
@ -85,8 +88,13 @@ public class PonyConfig extends Config {
|
|||
.addComment("ON - always show")
|
||||
.addComment("OFF - never show");
|
||||
|
||||
public final Setting<HashSet<Identifier>> forwardHoldingItems = value("customisation", "forwardHoldingItems", HashSet::new, Identifier.class)
|
||||
.addComment("Contains a list of item ids that should preserve orientation")
|
||||
.addComment("when held in a unicorn's magical aura in first person");
|
||||
|
||||
public PonyConfig(Path path) {
|
||||
super(HEIRARCHICAL_JSON_ADAPTER, path);
|
||||
super(new HeirarchicalJsonConfigAdapter(new GsonBuilder()
|
||||
.registerTypeAdapter(Identifier.class, new ToStringAdapter<>(Identifier::toString, Identifier::new))), path);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.api.config.PonyConfig;
|
|||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.mson.api.ModelView;
|
||||
|
@ -11,6 +12,7 @@ import com.minelittlepony.mson.api.ModelView;
|
|||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
/**
|
||||
|
@ -89,8 +91,11 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
matrices.translate(0.4F - (0.3F * left), -0.675F, -0.3F);
|
||||
|
||||
UseAction action = getAttributes().heldStack.getUseAction();
|
||||
boolean shouldAimItem =
|
||||
(action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0
|
||||
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(getAttributes().heldStack.getItem()));
|
||||
|
||||
if ((action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0) {
|
||||
if (shouldAimItem) {
|
||||
Arm main = getAttributes().mainArm;
|
||||
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
|
|
|
@ -14,8 +14,8 @@ import net.minecraft.client.render.model.json.ModelTransformationMode;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.CrossbowItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
@ -98,7 +98,10 @@ public class LevitatingItemRenderer {
|
|||
boolean handHeldTool =
|
||||
action == UseAction.BOW
|
||||
|| action == UseAction.CROSSBOW
|
||||
|| action == UseAction.BLOCK;
|
||||
|| action == UseAction.BLOCK
|
||||
|| item.getItem() instanceof ToolItem
|
||||
|| item.getItem() instanceof RangedWeaponItem
|
||||
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(item.getItem()));
|
||||
|
||||
float distanceChange = handHeldTool ? -0.3F : -0.6F;
|
||||
|
||||
|
|
Loading…
Reference in a new issue