mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +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.IModel;
|
||||
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.item.AmuletItem;
|
||||
|
||||
import net.minecraft.client.model.Dilation;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
@ -23,8 +25,6 @@ class AmuletGear extends AmuletModel implements IGear {
|
|||
|
||||
private final Map<Identifier, Identifier> textures = new HashMap<>();
|
||||
|
||||
private IModel model;
|
||||
|
||||
public AmuletGear() {
|
||||
super(AmuletModel.getData(new Dilation(0.3F)).createModel());
|
||||
}
|
||||
|
@ -45,9 +45,14 @@ class AmuletGear extends AmuletModel implements IGear {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setModelAttributes(IModel model, Entity entity) {
|
||||
this.model = model;
|
||||
public <M extends EntityModel<?> & IPonyModel<?>> void transform(M model, MatrixStack matrices) {
|
||||
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) {
|
||||
setAngles((LivingEntity)entity, biped);
|
||||
}
|
||||
|
@ -55,10 +60,6 @@ class AmuletGear extends AmuletModel implements IGear {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
|||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.IModel;
|
||||
import com.minelittlepony.api.model.gear.IGear;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
||||
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.render.VertexConsumer;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
@ -31,8 +33,6 @@ class BangleGear implements IGear {
|
|||
private final BraceletModel steveModel;
|
||||
private final BraceletModel alexModel;
|
||||
|
||||
private IModel model;
|
||||
|
||||
private final Identifier slot;
|
||||
|
||||
public BangleGear(Identifier slot) {
|
||||
|
@ -58,8 +58,13 @@ class BangleGear implements IGear {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setModelAttributes(IModel model, Entity entity) {
|
||||
this.model = model;
|
||||
public <M extends EntityModel<?> & IPonyModel<?>> void transform(M model, MatrixStack matrices) {
|
||||
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");
|
||||
FriendshipBraceletItem.getWornBangles((LivingEntity)entity, slot).findFirst().ifPresent(bracelet -> {
|
||||
color = ((DyeableItem)bracelet.getItem()).getColor(bracelet);
|
||||
|
@ -76,23 +81,7 @@ class BangleGear implements IGear {
|
|||
|
||||
@Override
|
||||
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;
|
||||
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.item.enchantment.UEnchantments;
|
||||
import com.minelittlepony.unicopia.item.group.ItemGroupRegistry;
|
||||
import com.minelittlepony.unicopia.item.group.UItemGroups;
|
||||
import com.minelittlepony.unicopia.item.toxin.UFoodComponents;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.minelittlepony.unicopia.item.group;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.cache.*;
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
|
@ -16,21 +14,15 @@ import net.minecraft.registry.Registries;
|
|||
import net.minecraft.registry.tag.TagKey;
|
||||
|
||||
public interface ItemGroupRegistry {
|
||||
LoadingCache<Item, List<ItemStack>> STACK_VARIANCES_CACHE = CacheBuilder.newBuilder()
|
||||
.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();
|
||||
}));
|
||||
Map<ItemGroup, Set<Item>> REGISTRY = new HashMap<>();
|
||||
|
||||
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) {
|
||||
REGISTRY.computeIfAbsent(group, g -> new HashSet<>()).add(item);
|
||||
return item;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.minelittlepony.unicopia.item;
|
||||
package com.minelittlepony.unicopia.item.group;
|
||||
|
||||
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.ToxicHolder;
|
||||
|
||||
|
@ -11,10 +12,12 @@ import net.minecraft.registry.Registries;
|
|||
|
||||
public interface UItemGroups {
|
||||
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, () -> {
|
||||
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);
|
||||
|
@ -24,6 +27,6 @@ public interface UItemGroups {
|
|||
ItemGroup CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.LOVE_BOTTLE::getDefaultStack);
|
||||
|
||||
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",
|
||||
"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() {
|
||||
return isLavaAffine() ? FluidTags.LAVA : FluidTags.WATER;
|
||||
|
|
|
@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.mixin;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
|
@ -133,6 +132,7 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck {
|
|||
get().tick();
|
||||
}
|
||||
|
||||
@Dynamic("Compiler-generated class-init() method")
|
||||
@Inject(method = "<clinit>()V", at = @At("RETURN"), remap = false)
|
||||
private static void clinit(CallbackInfo info) {
|
||||
Creature.boostrap();
|
||||
|
|
|
@ -41,7 +41,7 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
|
|||
+ "Lnet/minecraft/client/render/Camera;"
|
||||
+ "Lnet/minecraft/client/render/GameRenderer;"
|
||||
+ "Lnet/minecraft/client/render/LightmapTextureManager;"
|
||||
+ "Lnet/minecraft/util/math/Matrix4f;"
|
||||
+ "Lorg/joml/Matrix4f;"
|
||||
+ ")V",
|
||||
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)
|
||||
abstract class MixinTrinketItem {
|
||||
// overwrite with a max-count aware version (fixes inserting)
|
||||
/**
|
||||
* @reason Overwrite with a max-count aware version (fixes inserting)
|
||||
* @author _
|
||||
*/
|
||||
@Overwrite
|
||||
public static boolean equipItem(PlayerEntity user, ItemStack stack) {
|
||||
return TrinketsDelegateImpl.INSTANCE.getInventories(user)
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface RegistryUtils {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue