mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
1.19.2 -> 1.19.3 (1.20) [part 3]
This commit is contained in:
parent
68df426f37
commit
002b33081e
11 changed files with 41 additions and 53 deletions
|
@ -7,12 +7,14 @@ import java.util.UUID;
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.model.gear.IGear;
|
import com.minelittlepony.api.model.gear.IGear;
|
||||||
|
import com.minelittlepony.client.model.IPonyModel;
|
||||||
import com.minelittlepony.unicopia.client.render.AmuletFeatureRenderer.AmuletModel;
|
import com.minelittlepony.unicopia.client.render.AmuletFeatureRenderer.AmuletModel;
|
||||||
import com.minelittlepony.unicopia.item.AmuletItem;
|
import com.minelittlepony.unicopia.item.AmuletItem;
|
||||||
|
|
||||||
import net.minecraft.client.model.Dilation;
|
import net.minecraft.client.model.Dilation;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -23,8 +25,6 @@ class AmuletGear extends AmuletModel implements IGear {
|
||||||
|
|
||||||
private final Map<Identifier, Identifier> textures = new HashMap<>();
|
private final Map<Identifier, Identifier> textures = new HashMap<>();
|
||||||
|
|
||||||
private IModel model;
|
|
||||||
|
|
||||||
public AmuletGear() {
|
public AmuletGear() {
|
||||||
super(AmuletModel.getData(new Dilation(0.3F)).createModel());
|
super(AmuletModel.getData(new Dilation(0.3F)).createModel());
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,14 @@ class AmuletGear extends AmuletModel implements IGear {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setModelAttributes(IModel model, Entity entity) {
|
public <M extends EntityModel<?> & IPonyModel<?>> void transform(M model, MatrixStack matrices) {
|
||||||
this.model = model;
|
BodyPart part = getGearLocation();
|
||||||
|
model.transform(part, matrices);
|
||||||
|
matrices.translate(0, 0.25, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
||||||
if (model instanceof BipedEntityModel<?> biped) {
|
if (model instanceof BipedEntityModel<?> biped) {
|
||||||
setAngles((LivingEntity)entity, biped);
|
setAngles((LivingEntity)entity, biped);
|
||||||
}
|
}
|
||||||
|
@ -55,10 +60,6 @@ class AmuletGear extends AmuletModel implements IGear {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void render(MatrixStack stack, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||||
BangleGear.popAndApply(model, BodyPart.BODY, stack);
|
|
||||||
|
|
||||||
stack.translate(0, 0.25, 0);
|
|
||||||
|
|
||||||
render(stack, consumer, light, overlay, red, green, blue, 1);
|
render(stack, consumer, light, overlay, red, green, blue, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.model.gear.IGear;
|
import com.minelittlepony.api.model.gear.IGear;
|
||||||
|
import com.minelittlepony.client.model.IPonyModel;
|
||||||
import com.minelittlepony.common.util.Color;
|
import com.minelittlepony.common.util.Color;
|
||||||
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
||||||
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer.BraceletModel;
|
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer.BraceletModel;
|
||||||
|
@ -16,6 +17,7 @@ import net.minecraft.client.model.Dilation;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -31,8 +33,6 @@ class BangleGear implements IGear {
|
||||||
private final BraceletModel steveModel;
|
private final BraceletModel steveModel;
|
||||||
private final BraceletModel alexModel;
|
private final BraceletModel alexModel;
|
||||||
|
|
||||||
private IModel model;
|
|
||||||
|
|
||||||
private final Identifier slot;
|
private final Identifier slot;
|
||||||
|
|
||||||
public BangleGear(Identifier slot) {
|
public BangleGear(Identifier slot) {
|
||||||
|
@ -58,8 +58,13 @@ class BangleGear implements IGear {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setModelAttributes(IModel model, Entity entity) {
|
public <M extends EntityModel<?> & IPonyModel<?>> void transform(M model, MatrixStack matrices) {
|
||||||
this.model = model;
|
BodyPart part = getGearLocation();
|
||||||
|
model.transform(part, matrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
||||||
alex = entity instanceof ClientPlayerEntity && ((ClientPlayerEntity)entity).getModel().startsWith("slim");
|
alex = entity instanceof ClientPlayerEntity && ((ClientPlayerEntity)entity).getModel().startsWith("slim");
|
||||||
FriendshipBraceletItem.getWornBangles((LivingEntity)entity, slot).findFirst().ifPresent(bracelet -> {
|
FriendshipBraceletItem.getWornBangles((LivingEntity)entity, slot).findFirst().ifPresent(bracelet -> {
|
||||||
color = ((DyeableItem)bracelet.getItem()).getColor(bracelet);
|
color = ((DyeableItem)bracelet.getItem()).getColor(bracelet);
|
||||||
|
@ -76,23 +81,7 @@ class BangleGear implements IGear {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void render(MatrixStack stack, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||||
popAndApply(model, BodyPart.LEGS, stack);
|
|
||||||
|
|
||||||
BraceletModel m = alex ? alexModel : steveModel;
|
BraceletModel m = alex ? alexModel : steveModel;
|
||||||
m.render(stack, consumer, glowing ? 0x0F00F0 : light, overlay, Color.r(color), Color.g(color), Color.b(color), 1);
|
m.render(stack, consumer, glowing ? 0x0F00F0 : light, overlay, Color.r(color), Color.g(color), Color.b(color), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Discards and applies default transformations without body part rotations.
|
|
||||||
* <p>
|
|
||||||
* TODO: this is a workaround to undo the {@code model.getBodyPart(part).rotate(stack)} in GearFeature.
|
|
||||||
* That's useful for things that render on the head or body, but not so much if you're on the legs or tail,
|
|
||||||
* since the default implementation falls to body rotation, which we don't want
|
|
||||||
*/
|
|
||||||
static void popAndApply(IModel model, BodyPart part, MatrixStack matrices) {
|
|
||||||
matrices.pop();
|
|
||||||
matrices.push();
|
|
||||||
// re-apply leg transformation
|
|
||||||
model.transform(part, matrices);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.block.UBlocks;
|
||||||
import com.minelittlepony.unicopia.entity.UEntities;
|
import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
import com.minelittlepony.unicopia.item.group.ItemGroupRegistry;
|
import com.minelittlepony.unicopia.item.group.ItemGroupRegistry;
|
||||||
|
import com.minelittlepony.unicopia.item.group.UItemGroups;
|
||||||
import com.minelittlepony.unicopia.item.toxin.UFoodComponents;
|
import com.minelittlepony.unicopia.item.toxin.UFoodComponents;
|
||||||
|
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.item.group;
|
package com.minelittlepony.unicopia.item.group;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.google.common.cache.*;
|
|
||||||
import com.minelittlepony.unicopia.UTags;
|
import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
|
||||||
|
@ -16,21 +14,15 @@ import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.registry.tag.TagKey;
|
import net.minecraft.registry.tag.TagKey;
|
||||||
|
|
||||||
public interface ItemGroupRegistry {
|
public interface ItemGroupRegistry {
|
||||||
LoadingCache<Item, List<ItemStack>> STACK_VARIANCES_CACHE = CacheBuilder.newBuilder()
|
Map<ItemGroup, Set<Item>> REGISTRY = new HashMap<>();
|
||||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
|
||||||
.build(CacheLoader.from(i -> {
|
|
||||||
if (i instanceof MultiItem m) {
|
|
||||||
return m.getDefaultStacks();
|
|
||||||
}
|
|
||||||
return ItemGroups.SEARCH.getSearchTabStacks().stream().filter(s -> s.getItem() == i).toList();
|
|
||||||
}));
|
|
||||||
|
|
||||||
static List<ItemStack> getVariations(Item item) {
|
static List<ItemStack> getVariations(Item item) {
|
||||||
return STACK_VARIANCES_CACHE.getUnchecked(item);
|
if (item instanceof MultiItem) {
|
||||||
|
return ((MultiItem)item).getDefaultStacks();
|
||||||
|
}
|
||||||
|
return List.of(item.getDefaultStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ItemGroup, Set<Item>> REGISTRY = new HashMap<>();
|
|
||||||
|
|
||||||
static <T extends Item> T register(T item, ItemGroup group) {
|
static <T extends Item> T register(T item, ItemGroup group) {
|
||||||
REGISTRY.computeIfAbsent(group, g -> new HashSet<>()).add(item);
|
REGISTRY.computeIfAbsent(group, g -> new HashSet<>()).add(item);
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item.group;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.item.group.ItemGroupRegistry;
|
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||||
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.item.toxin.Toxic;
|
import com.minelittlepony.unicopia.item.toxin.Toxic;
|
||||||
import com.minelittlepony.unicopia.item.toxin.ToxicHolder;
|
import com.minelittlepony.unicopia.item.toxin.ToxicHolder;
|
||||||
|
|
||||||
|
@ -11,10 +12,12 @@ import net.minecraft.registry.Registries;
|
||||||
|
|
||||||
public interface UItemGroups {
|
public interface UItemGroups {
|
||||||
ItemGroup ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> {
|
ItemGroup ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> {
|
||||||
return Stream.concat(Stream.of(Items.APPLE), UItems.ITEMS.stream().filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised()));
|
return Stream.concat(Stream.of(Items.APPLE), UItems.ITEMS.stream()
|
||||||
|
.filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised()));
|
||||||
});
|
});
|
||||||
ItemGroup HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> {
|
ItemGroup HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> {
|
||||||
return Registries.ITEM.stream().filter(item -> ((ToxicHolder)item).getToxic(item.getDefaultStack()) != Toxic.EMPTY);
|
return Registries.ITEM.stream()
|
||||||
|
.filter(item -> ((ToxicHolder)item).getToxic(item.getDefaultStack()) != Toxic.EMPTY);
|
||||||
});
|
});
|
||||||
|
|
||||||
ItemGroup EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.APPLE_PIE::getDefaultStack);
|
ItemGroup EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.APPLE_PIE::getDefaultStack);
|
||||||
|
@ -24,6 +27,6 @@ public interface UItemGroups {
|
||||||
ItemGroup CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.LOVE_BOTTLE::getDefaultStack);
|
ItemGroup CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.LOVE_BOTTLE::getDefaultStack);
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
UItems.bootstrap();
|
ItemGroupRegistry.bootstrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.item.group;
|
|
|
@ -31,7 +31,7 @@ abstract class MixinBoatEntity extends Entity implements LavaAffine {
|
||||||
"fall",
|
"fall",
|
||||||
"canAddPassenger"
|
"canAddPassenger"
|
||||||
},
|
},
|
||||||
at = @At(value = "FIELD", target = "net/minecraft/tag/FluidTags.WATER:Lnet/minecraft/tag/TagKey;", opcode = Opcodes.GETSTATIC)
|
at = @At(value = "FIELD", target = "net/minecraft/tag/FluidTags.WATER:Lnet/minecraft/registry/tag/TagKey;", opcode = Opcodes.GETSTATIC)
|
||||||
)
|
)
|
||||||
private TagKey<Fluid> redirectFluidTag() {
|
private TagKey<Fluid> redirectFluidTag() {
|
||||||
return isLavaAffine() ? FluidTags.LAVA : FluidTags.WATER;
|
return isLavaAffine() ? FluidTags.LAVA : FluidTags.WATER;
|
||||||
|
|
|
@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.mixin;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Constant;
|
import org.spongepowered.asm.mixin.injection.Constant;
|
||||||
|
@ -133,6 +132,7 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck {
|
||||||
get().tick();
|
get().tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Dynamic("Compiler-generated class-init() method")
|
||||||
@Inject(method = "<clinit>()V", at = @At("RETURN"), remap = false)
|
@Inject(method = "<clinit>()V", at = @At("RETURN"), remap = false)
|
||||||
private static void clinit(CallbackInfo info) {
|
private static void clinit(CallbackInfo info) {
|
||||||
Creature.boostrap();
|
Creature.boostrap();
|
||||||
|
|
|
@ -41,7 +41,7 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
|
||||||
+ "Lnet/minecraft/client/render/Camera;"
|
+ "Lnet/minecraft/client/render/Camera;"
|
||||||
+ "Lnet/minecraft/client/render/GameRenderer;"
|
+ "Lnet/minecraft/client/render/GameRenderer;"
|
||||||
+ "Lnet/minecraft/client/render/LightmapTextureManager;"
|
+ "Lnet/minecraft/client/render/LightmapTextureManager;"
|
||||||
+ "Lnet/minecraft/util/math/Matrix4f;"
|
+ "Lorg/joml/Matrix4f;"
|
||||||
+ ")V",
|
+ ")V",
|
||||||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/WorldRenderer;blockBreakingProgressions:Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;")
|
at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/WorldRenderer;blockBreakingProgressions:Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;")
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,10 @@ import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
@Mixin(TrinketItem.class)
|
@Mixin(TrinketItem.class)
|
||||||
abstract class MixinTrinketItem {
|
abstract class MixinTrinketItem {
|
||||||
// overwrite with a max-count aware version (fixes inserting)
|
/**
|
||||||
|
* @reason Overwrite with a max-count aware version (fixes inserting)
|
||||||
|
* @author _
|
||||||
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static boolean equipItem(PlayerEntity user, ItemStack stack) {
|
public static boolean equipItem(PlayerEntity user, ItemStack stack) {
|
||||||
return TrinketsDelegateImpl.INSTANCE.getInventories(user)
|
return TrinketsDelegateImpl.INSTANCE.getInventories(user)
|
||||||
|
|
|
@ -18,7 +18,7 @@ public interface RegistryUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T> Registry<T> createDefaulted(Identifier id, String def) {
|
static <T> Registry<T> createDefaulted(Identifier id, String def) {
|
||||||
return FabricRegistryBuilder.from(new SimpleDefaultedRegistry<T>(def, RegistryKey.ofRegistry(id), Lifecycle.stable(), true)).buildAndRegister();
|
return FabricRegistryBuilder.from(new SimpleDefaultedRegistry<T>(def, RegistryKey.ofRegistry(id), Lifecycle.stable(), false)).buildAndRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T> RegistryEntryList<T> entriesForTag(World world, TagKey<T> key) {
|
static <T> RegistryEntryList<T> entriesForTag(World world, TagKey<T> key) {
|
||||||
|
|
Loading…
Reference in a new issue