Update mixins

This commit is contained in:
Sollace 2024-10-02 22:50:57 +01:00
parent bacfa050bb
commit 84e41bcc88
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
44 changed files with 424 additions and 454 deletions

View file

@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.client;
import com.minelittlepony.unicopia.EquinePredicates;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
@ -15,6 +16,15 @@ public class BatEyesApplicator {
private final MinecraftClient client = MinecraftClient.getInstance();
public static float getWorldBrightness(float initial, LivingEntity entity, float tickDelta) {
if (EquinePredicates.PLAYER_BAT.test(entity)) {
return 0.6F;
}
return initial;
}
// TODO: Do we need this?
public void enable() {
if (client.world != null) {
PlayerEntity player = client.player;

View file

@ -35,6 +35,7 @@ public class ModifierTooltipRenderer {
appendTooltip(stack, UDataComponentTypes.CHARGES, context, textConsumer, type);
appendTooltip(stack, UDataComponentTypes.ISSUER, context, textConsumer, type);
appendTooltip(stack, UDataComponentTypes.BUTTERFLY_VARIANT, context, textConsumer, type);
EnchantableItem.getSpellEffect(stack).appendTooltip(context, textConsumer, type);
if (GlowableItem.isGlowing(stack)) {
lines.add(Text.translatable("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY));

View file

@ -30,11 +30,11 @@ import com.minelittlepony.unicopia.client.render.shader.UShaders;
import com.minelittlepony.unicopia.client.render.spell.SpellRendererFactory;
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
import com.minelittlepony.unicopia.entity.mob.UEntities;
import com.minelittlepony.unicopia.item.ButterflyItem;
import com.minelittlepony.unicopia.item.EnchantableItem;
import com.minelittlepony.unicopia.item.FancyBedItem;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.item.component.Appearance;
import com.minelittlepony.unicopia.item.component.BufferflyVariantComponent;
import com.minelittlepony.unicopia.particle.UParticles;
import com.terraformersmc.terraform.boat.api.client.TerraformBoatClientHelper;
@ -131,20 +131,21 @@ public interface URenderers {
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, Identifier.ofVanilla("affinity"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getAffinity().getAlignment());
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, Identifier.ofVanilla("shape"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getGemShape().getId());
ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, Identifier.ofVanilla("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount());
ModelPredicateProviderRegistry.register(UItems.BUTTERFLY, Identifier.ofVanilla("variant"), (stack, world, entity, seed) -> (float)ButterflyItem.getVariant(stack).ordinal() / ButterflyEntity.Variant.VALUES.length);
ModelPredicateProviderRegistry.register(UItems.BUTTERFLY, Identifier.ofVanilla("variant"), (stack, world, entity, seed) -> (float)BufferflyVariantComponent.get(stack).variant().ordinal() / ButterflyEntity.Variant.VALUES.length);
ModelPredicateProviderRegistry.register(Unicopia.id("zap_cycle"), new ClampedModelPredicateProvider() {
private double targetAngle;
private double lastAngle;
private long lastTick;
@Override
public float unclampedCall(ItemStack stack, ClientWorld world, LivingEntity e, int var4) {
Entity entity = e != null ? e : stack.getHolder();
public float unclampedCall(ItemStack stack, ClientWorld world, @Nullable LivingEntity holder, int seed) {
@Nullable
Entity entity = holder != null ? holder : stack.getHolder();
if (entity == null) {
return 0;
}
if (world == null && entity.getWorld() instanceof ClientWorld) {
world = (ClientWorld)entity.getWorld();
if (world == null && entity.getWorld() instanceof ClientWorld cw) {
world = cw;
}
if (world == null) {

View file

@ -1,7 +1,5 @@
package com.minelittlepony.unicopia.client;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
@ -52,33 +50,25 @@ public class UnicopiaClient implements ClientModInitializer {
return Pony.of(MinecraftClient.getInstance().player);
}
private final Lerp rainGradient = new Lerp(0);
private final Lerp thunderGradient = new Lerp(0);
public final Lerp tangentalSkyAngle = new Lerp(0, true);
public final Lerp skyAngle = new Lerp(0, true);
private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING;
public static Optional<PlayerCamera> getCamera() {
return Optional.ofNullable(getNullableCamera());
}
@Nullable
private static PlayerCamera getNullableCamera() {
public static PlayerCamera getCamera() {
PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null && MinecraftClient.getInstance().cameraEntity == player) {
return Pony.of(player).getCamera();
}
return null;
return PlayerCamera.DEFAULT;
}
public static Vec3d getAdjustedSoundPosition(Vec3d pos) {
PlayerCamera cam = getNullableCamera();
if (cam == null) {
PlayerCamera cam = getCamera();
if (cam == PlayerCamera.DEFAULT) {
return pos;
}
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
@ -102,10 +92,6 @@ public class UnicopiaClient implements ClientModInitializer {
return Unicopia.getConfig().preferredRace.get();
}
public static float getWorldBrightness(float initial) {
return 0.6F;
}
public UnicopiaClient() {
instance = this;
}

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.entity.duck.EntityDuck;
import com.minelittlepony.unicopia.entity.effect.UEffects;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
@ -22,9 +23,9 @@ public class HudEffects {
private static boolean addedHunger;
private static Set<TagKey<Fluid>> originalTags = null;
public static void tryApply(@Nullable PlayerEntity player, float tickDelta, boolean on) {
public static void tryApply(@Nullable PlayerEntity player, RenderTickCounter tickCounter, boolean on) {
if (player != null) {
apply(Pony.of(player), tickDelta, on);
apply(Pony.of(player), tickCounter.getTickDelta(false), on);
}
}

View file

@ -26,6 +26,7 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.DataComponentTypes;
@ -71,7 +72,7 @@ public class UHud {
private boolean prevReplacing;
private SpellType<?> focusedType = SpellType.empty();
public void render(InGameHud hud, DrawContext context, float tickDelta) {
public void render(InGameHud hud, DrawContext context, RenderTickCounter tickCounter) {
final int hotbarZ = -90;
if (client.player == null) {
@ -84,6 +85,8 @@ public class UHud {
Pony pony = Pony.of(client.player);
float tickDelta = tickCounter.getTickDelta(false);
matrices.push();
matrices.translate(0, 0, hotbarZ - 9800);
renderViewEffects(pony, context, scaledWidth, scaledHeight, tickDelta);

View file

@ -0,0 +1,9 @@
package com.minelittlepony.unicopia.datafixer;
import com.mojang.datafixers.schemas.Schema;
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
public interface SchemasStore {
Int2ObjectSortedMap<Schema> getSchemas();
}

View file

@ -1,14 +0,0 @@
package com.minelittlepony.unicopia.diet;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public interface DietView {
TypedActionResult<ItemStack> startUsing(ItemStack stack, World world, PlayerEntity user, Hand hand);
void finishUsing(ItemStack stack, World world, LivingEntity entity);
}

View file

@ -6,25 +6,16 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.effect.FoodPoisoningStatusEffect;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.serialization.PacketCodecUtils;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class PonyDiets implements DietView {
private final Map<Race, DietProfile> diets;
private final Map<Identifier, FoodGroup> effects;
public record PonyDiets (Map<Race, DietProfile> diets, Map<Identifier, FoodGroup> effects) {
private static PonyDiets INSTANCE = new PonyDiets(Map.of(), Map.of());
public static final PacketCodec<RegistryByteBuf, PonyDiets> PACKET_CODEC = PacketCodec.tuple(
@ -46,11 +37,6 @@ public class PonyDiets implements DietView {
INSTANCE = diets;
}
PonyDiets(Map<Race, DietProfile> diets, Map<Identifier, FoodGroup> effects) {
this.diets = diets;
this.effects = effects;
}
public DietProfile getDiet(Pony pony) {
return Optional.ofNullable(diets.get(pony.getObservedSpecies())).orElse(DietProfile.EMPTY);
}
@ -59,17 +45,7 @@ public class PonyDiets implements DietView {
return effects.values().stream().filter(effect -> effect.test(stack)).findFirst().map(Effect.class::cast).orElse(Effect.EMPTY);
}
private Effect getEffects(ItemStack stack, Pony pony) {
public Effect getEffects(ItemStack stack, Pony pony) {
return getDiet(pony).findEffect(stack).orElseGet(() -> getEffects(stack));
}
@Override
public TypedActionResult<ItemStack> startUsing(ItemStack stack, World world, PlayerEntity user, Hand hand) {
return FoodPoisoningStatusEffect.apply(stack, user);
}
@Override
public void finishUsing(ItemStack stack, World world, LivingEntity entity) {
Pony.of(entity).ifPresent(pony -> getEffects(stack, pony).ailment().effects().afflict(pony.asEntity(), stack));
}
}

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.entity;
public interface IItemEntity extends Equine.Container<ItemImpl> {
int getAge();
int getPickupDelay();

View file

@ -1,8 +1,7 @@
package com.minelittlepony.unicopia.entity;
import java.util.List;
import com.minelittlepony.unicopia.*;
import com.minelittlepony.unicopia.item.ItemDuck;
import com.minelittlepony.unicopia.item.enchantment.EnchantmentUtil;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.network.track.DataTracker;
@ -13,17 +12,14 @@ import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
@ -68,16 +64,14 @@ public class ItemImpl implements Equine<ItemEntity> {
ItemStack stack = entity.getStack();
IItemEntity i = (IItemEntity)entity;
ItemDuck duck = ItemDuck.of(stack);
if (!stack.isEmpty()) {
Item item = stack.getItem();
ClingyItem clingy = item instanceof ClingyItem ? (ClingyItem)item : ClingyItem.DEFAULT;
if (clingy.isClingy(stack)) {
if (duck.isClingy(stack)) {
Random rng = entity.getWorld().random;
entity.getWorld().addParticle(clingy.getParticleEffect((IItemEntity)entity),
entity.getWorld().addParticle(duck.getParticleEffect(i),
entity.getX() + rng.nextFloat() - 0.5,
entity.getY() + rng.nextFloat() - 0.5,
entity.getZ() + rng.nextFloat() - 0.5,
@ -85,19 +79,19 @@ public class ItemImpl implements Equine<ItemEntity> {
);
Vec3d position = entity.getPos();
VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), clingy.getFollowDistance(i), e -> e instanceof PlayerEntity)
VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), duck.getFollowDistance(i), e -> e instanceof PlayerEntity)
.stream()
.sorted((a, b) -> (int)(a.getPos().distanceTo(position) - b.getPos().distanceTo(position)))
.findFirst()
.ifPresent(player -> {
double distance = player.getPos().distanceTo(entity.getPos());
entity.move(MovementType.SELF, player.getPos().subtract(entity.getPos()).multiply(distance < 0.3 ? 1 : clingy.getFollowSpeed(i)));
entity.move(MovementType.SELF, player.getPos().subtract(entity.getPos()).multiply(distance < 0.3 ? 1 : duck.getFollowSpeed(i)));
if (entity.horizontalCollision) {
entity.move(MovementType.SELF, new Vec3d(0, entity.verticalCollision ? -0.3 : 0.3, 0));
}
clingy.interactWithPlayer(i, (PlayerEntity)player);
duck.interactWithPlayer(i, (PlayerEntity)player);
});
}
@ -119,9 +113,7 @@ public class ItemImpl implements Equine<ItemEntity> {
}
}
if (stack.getItem() instanceof GroundTickCallback) {
return ((GroundTickCallback)stack.getItem()).onGroundTick(i).isAccepted();
}
return duck.onGroundTick(i).isAccepted();
}
@ -172,39 +164,10 @@ public class ItemImpl implements Equine<ItemEntity> {
return entity;
}
public static <T extends Item> T registerTickCallback(T item, GroundTickCallback callback) {
((ItemImpl.TickableItem)item).addGroundTickCallback(callback);
return item;
}
public interface TickableItem extends GroundTickCallback {
List<GroundTickCallback> getCallbacks();
default void addGroundTickCallback(GroundTickCallback callback) {
getCallbacks().add(callback);
}
@Override
default ActionResult onGroundTick(IItemEntity entity) {
for (var callback : getCallbacks()) {
ActionResult result = callback.onGroundTick(entity);
if (result.isAccepted()) {
return result;
}
}
return ActionResult.PASS;
}
}
public interface GroundTickCallback {
ActionResult onGroundTick(IItemEntity entity);
}
public interface ClingyItem {
ClingyItem DEFAULT = stack -> EnchantmentUtil.getLevel(UEnchantments.CLINGY, stack) > 0;
boolean isClingy(ItemStack stack);
default boolean isClingy(ItemStack stack) {
return EnchantmentUtil.getLevel(UEnchantments.CLINGY, stack) > 0;
}
default ParticleEffect getParticleEffect(IItemEntity entity) {
// TODO: was AMBIENT_ENTITY_EFFECT
@ -222,9 +185,5 @@ public class ItemImpl implements Equine<ItemEntity> {
default void interactWithPlayer(IItemEntity entity, PlayerEntity player) {
}
default void inFrameTick(ItemFrameEntity entity) {
}
}
}

View file

@ -35,11 +35,6 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
return getAppearance().map(EntityAppearance::getFlightType).orElse(FlightType.UNSET);
}
@Override
default Optional<Float> getTargetEyeHeight(Pony player) {
return getAppearance().flatMap(d -> d.getTargetEyeHeight(player));
}
@Override
default Optional<EntityDimensions> getTargetDimensions(Pony player) {
return getAppearance().flatMap(d -> d.getTargetDimensions(player));

View file

@ -54,8 +54,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provider, FlightType.Provider, EntityCollisions.ComplexCollidable, TrackableObject<EntityAppearance> {
private static final Optional<Float> BLOCK_HEIGHT = Optional.of(0.5F);
@NotNull
private transient String entityId = "";
@ -264,18 +262,6 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
return FlightType.NONE;
}
@Override
public Optional<Float> getTargetEyeHeight(Pony player) {
if (entity != null) {
if (entity instanceof FallingBlockEntity) {
return BLOCK_HEIGHT;
}
return Optional.of(PehkUtil.ignoreScaleFor(entity, Entity::getStandingEyeHeight));
}
return Optional.empty();
}
public float getHeight() {
if (entity != null) {
if (entity instanceof FallingBlockEntity) {
@ -287,7 +273,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
return -1;
}
public Optional<Double> getDistance(Pony player) {
public Optional<Float> getDistance(Pony player) {
return PehkUtil.ignoreScaleFor(entity, e -> EntityBehaviour.forEntity(e).getCameraDistance(e, player));
}

View file

@ -77,7 +77,7 @@ public class EntityBehaviour<T extends Entity> {
return a.getType() == b.getType();
}
public Optional<Double> getCameraDistance(Entity entity, Pony player) {
public Optional<Float> getCameraDistance(Entity entity, Pony player) {
if (entity == null) {
return Optional.empty();
}
@ -85,7 +85,7 @@ public class EntityBehaviour<T extends Entity> {
double normalHeight = PlayerEntity.STANDING_DIMENSIONS.height();
double entityHeight = entity.getDimensions(entity.getPose()).height();
return Optional.of(entityHeight / normalHeight);
return Optional.of((float)(entityHeight / normalHeight));
}
public Optional<EntityDimensions> getDimensions(T entity, Optional<EntityDimensions> current) {

View file

@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
private static final Optional<EntityDimensions> FULL_BLOCK = Optional.of(EntityDimensions.changing(0.6F, 0.9F));
private static final Optional<EntityDimensions> FULL_BLOCK = Optional.of(EntityDimensions.changing(0.6F, 0.9F).withEyeHeight(0.5F));
@Override
public Optional<EntityDimensions> getDimensions(FallingBlockEntity entity, Optional<EntityDimensions> current) {

View file

@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.item.ButterflyItem;
import com.minelittlepony.unicopia.item.component.BufferflyVariantComponent;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import io.netty.buffer.ByteBuf;
@ -333,7 +333,7 @@ public class ButterflyEntity extends AmbientEntity {
@Override
public ItemEntity dropStack(ItemStack stack, float yOffset) {
return super.dropStack(ButterflyItem.setVariant(stack, getVariant()), yOffset);
return super.dropStack(BufferflyVariantComponent.set(stack, new BufferflyVariantComponent(getVariant(), true)), yOffset);
}
@Override

View file

@ -31,10 +31,12 @@ import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtOps;
import net.minecraft.registry.RegistryKey;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
@ -43,7 +45,6 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -62,7 +63,7 @@ public class MimicEntity extends PathAwareEntity {
private int openTicks;
private final Set<PlayerEntity> observingPlayers = new HashSet<>();
public static boolean shouldConvert(World world, BlockPos pos, PlayerEntity player, Identifier lootTable) {
public static boolean shouldConvert(World world, BlockPos pos, PlayerEntity player, RegistryKey<LootTable> lootTable) {
if (!shouldGenerateMimic(lootTable)
|| !world.getBlockState(pos).isIn(UTags.Blocks.MIMIC_CHESTS)
|| !(world.getBlockEntity(pos) instanceof ChestBlockEntity be)
@ -97,12 +98,12 @@ public class MimicEntity extends PathAwareEntity {
return mimic;
}
public static boolean shouldGenerateMimic(@Nullable Identifier lootTable) {
public static boolean shouldGenerateMimic(@Nullable RegistryKey<LootTable> lootTable) {
return lootTable != null
&& lootTable.getPath().indexOf("village") == -1
&& lootTable.getPath().indexOf("bastion") == -1
&& lootTable.getPath().indexOf("underwater") == -1
&& lootTable.getPath().indexOf("shipwreck") == -1;
&& lootTable.getValue().getPath().indexOf("village") == -1
&& lootTable.getValue().getPath().indexOf("bastion") == -1
&& lootTable.getValue().getPath().indexOf("underwater") == -1
&& lootTable.getValue().getPath().indexOf("shipwreck") == -1;
}
MimicEntity(EntityType<? extends MimicEntity> type, World world) {

View file

@ -1,88 +1,29 @@
package com.minelittlepony.unicopia.entity.player;
import java.util.Optional;
public interface PlayerCamera {
PlayerCamera DEFAULT = new PlayerCamera() {};
import com.minelittlepony.common.util.animation.MotionCompositor;
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.client.render.spell.DarkVortexSpellRenderer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class PlayerCamera extends MotionCompositor {
private final Pony player;
public PlayerCamera(Pony player) {
this.player = player;
default float calculateRoll() {
return 0;
}
public float calculateRoll() {
return player.getInterpolator().interpolate("roll", (float)applyModifiers(-getMotionRoll()), 15);
default float calculateFirstPersonRoll() {
return 0;
}
public float calculateFirstPersonRoll() {
return player.getInterpolator().interpolate("roll_fp", (float)applyModifiers(-getMotionRoll() * getFovScale() * 0.25F), 25);
default float calculatePitch(float pitch) {
return pitch;
}
private double getMotionRoll() {
if (!player.getMotion().isFlying() || player.asEntity().hasVehicle() || player.asEntity().isOnGround()) {
return 0;
}
Vec3d vel = player.asEntity().getVelocity();
return calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
default float calculateYaw(float yaw) {
return yaw;
}
private double applyModifiers(double motionRoll) {
if (player.getAcrobatics().isFloppy()) {
motionRoll += 90;
}
return player.getPhysics().isGravityNegative() ? 180 - motionRoll : motionRoll;
default float calculateDistance(float distance) {
return distance;
}
public float calculatePitch(float pitch) {
return pitch + getEnergyAddition();
}
public float calculateYaw(float yaw) {
return yaw + getEnergyAddition();
}
public Optional<Double> calculateDistance(double distance) {
return player.getSpellSlot()
.get(SpellPredicate.IS_DISGUISE)
.map(AbstractDisguiseSpell::getDisguise)
.flatMap(d -> d.getDistance(player))
.map(d -> distance * d);
}
public double calculateFieldOfView(double fov) {
fov += (player.getMagicalReserves().getExertion().get() / 5F) * getFovScale();
fov += getEnergyAddition() * getFovScale();
fov += DarkVortexSpellRenderer.getCameraDistortion() * 2.5F;
default double calculateFieldOfView(double fov) {
return fov;
}
private float getFovScale() {
return MinecraftClient.getInstance().options.getFovEffectScale().getValue().floatValue();
}
protected float getEnergyAddition() {
int maxE = (int)Math.floor(player.getMagicalReserves().getEnergy().get() * 100);
if (maxE <= 0) {
return 0;
}
float energyAddition = (player.asWorld().random.nextInt(maxE) - maxE/2) / 100F;
if (Math.abs(energyAddition) <= 0.001) {
return 0;
}
return energyAddition;
}
}

View file

@ -0,0 +1,92 @@
package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.common.util.animation.MotionCompositor;
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.client.render.spell.DarkVortexSpellRenderer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class PlayerCameraImpl extends MotionCompositor implements PlayerCamera {
private final Pony player;
public PlayerCameraImpl(Pony player) {
this.player = player;
}
@Override
public float calculateRoll() {
return player.getInterpolator().interpolate("roll", (float)applyModifiers(-getMotionRoll()), 15);
}
@Override
public float calculateFirstPersonRoll() {
return player.getInterpolator().interpolate("roll_fp", (float)applyModifiers(-getMotionRoll() * getFovScale() * 0.25F), 25);
}
private double getMotionRoll() {
if (!player.getMotion().isFlying() || player.asEntity().hasVehicle() || player.asEntity().isOnGround()) {
return 0;
}
Vec3d vel = player.asEntity().getVelocity();
return calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
}
private double applyModifiers(double motionRoll) {
if (player.getAcrobatics().isFloppy()) {
motionRoll += 90;
}
return player.getPhysics().isGravityNegative() ? 180 - motionRoll : motionRoll;
}
@Override
public float calculatePitch(float pitch) {
return pitch + getEnergyAddition();
}
@Override
public float calculateYaw(float yaw) {
return yaw + getEnergyAddition();
}
@Override
public float calculateDistance(float distance) {
return player.getSpellSlot()
.get(SpellPredicate.IS_DISGUISE)
.map(AbstractDisguiseSpell::getDisguise)
.flatMap(d -> d.getDistance(player))
.orElse(1F) * distance;
}
@Override
public double calculateFieldOfView(double fov) {
fov += (player.getMagicalReserves().getExertion().get() / 5F) * getFovScale();
fov += getEnergyAddition() * getFovScale();
fov += DarkVortexSpellRenderer.getCameraDistortion() * 2.5F;
return fov;
}
private float getFovScale() {
return MinecraftClient.getInstance().options.getFovEffectScale().getValue().floatValue();
}
protected float getEnergyAddition() {
int maxE = (int)Math.floor(player.getMagicalReserves().getEnergy().get() * 100);
if (maxE <= 0) {
return 0;
}
float energyAddition = (player.asWorld().random.nextInt(maxE) - maxE/2) / 100F;
if (Math.abs(energyAddition) <= 0.001) {
return 0;
}
return energyAddition;
}
}

View file

@ -6,8 +6,9 @@ import net.minecraft.entity.EntityDimensions;
public final class PlayerDimensions {
private static final float FLYING_HEIGHT = 0.6F;
private static final Optional<EntityDimensions> FLYING_DIMENSIONS = Optional.of(EntityDimensions.changing(FLYING_HEIGHT, FLYING_HEIGHT));
private static final Optional<Float> FLYING_EYE_HEIGHT = Optional.of(FLYING_HEIGHT * 0.6F);
private static final Optional<EntityDimensions> FLYING_DIMENSIONS = Optional.of(
EntityDimensions.changing(FLYING_HEIGHT, FLYING_HEIGHT).withEyeHeight(FLYING_HEIGHT * 0.6F)
);
private final PlayerPhysics physics;
@ -18,24 +19,18 @@ public final class PlayerDimensions {
this.physics = gravity;
}
public Optional<Float> calculateActiveEyeHeight(EntityDimensions dimensions) {
return getPredicate()
.flatMap(e -> e.getTargetEyeHeight(pony))
.filter(h -> h > 0)
.or(() -> physics.isFlyingSurvival ? FLYING_EYE_HEIGHT : physics.isGravityNegative() ? Optional.of(dimensions.eyeHeight()) : Optional.empty())
.map(h -> {
if (physics.isGravityNegative()) {
return dimensions.eyeHeight() - h + 0.1F;
}
return h;
});
}
public Optional<EntityDimensions> calculateDimensions() {
return getPredicate()
public EntityDimensions calculateDimensions(EntityDimensions original) {
EntityDimensions dimensions = getPredicate()
.flatMap(e -> e.getTargetDimensions(pony))
.or(() -> physics.isFlyingSurvival ? FLYING_DIMENSIONS : Optional.empty())
.filter(d -> d.height() > 0 && d.width() > 0);
.filter(d -> d.height() > 0 && d.width() > 0)
.orElse(original);
if (physics.isGravityNegative()) {
return dimensions.withEyeHeight(dimensions.eyeHeight() - original.eyeHeight() + 0.1F);
}
return dimensions;
}
Optional<Provider> getPredicate() {
@ -45,8 +40,6 @@ public final class PlayerDimensions {
}
public interface Provider {
Optional<Float> getTargetEyeHeight(Pony player);
Optional<EntityDimensions> getTargetDimensions(Pony player);
}
}

View file

@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
import com.minelittlepony.unicopia.diet.PonyDiets;
import com.minelittlepony.unicopia.client.render.PlayerPoser.AnimationInstance;
import com.minelittlepony.unicopia.*;
import com.minelittlepony.unicopia.ability.*;
@ -43,6 +44,7 @@ import com.minelittlepony.common.util.animation.Interpolator;
import com.mojang.authlib.GameProfile;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.FoodComponent;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.Enchantments;
@ -76,7 +78,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
private final AbilityDispatcher powers = new AbilityDispatcher(this);
private final PlayerPhysics gravity = addTicker(new PlayerPhysics(this, tracker));
private final PlayerCharmTracker charms = new PlayerCharmTracker(this);
private final PlayerCamera camera = new PlayerCamera(this);
private final PlayerCamera camera = new PlayerCameraImpl(this);
private final TraitDiscovery discoveries = new TraitDiscovery(this);
private final Acrobatics acrobatics = new Acrobatics(this, tracker);
private final CorruptionHandler corruptionHandler = new CorruptionHandler(this);
@ -738,9 +740,9 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return Math.max(0, distance);
}
public void onEat(ItemStack stack) {
public FoodComponent onEat(ItemStack stack, FoodComponent food) {
if (isClient()) {
return;
return food;
}
if (getObservedSpecies() == Race.KIRIN
@ -748,6 +750,10 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
getMagicalReserves().getCharge().multiply(0.5F);
getSpellSlot().get(SpellType.RAGE).ifPresent(RageAbilitySpell::setExtenguishing);
}
PonyDiets.getInstance().getEffects(stack, this).ailment().effects().afflict(asEntity(), stack);
return food;
}
public void onKill(Entity killedEntity, DamageSource damage) {

View file

@ -58,7 +58,7 @@ import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.World.ExplosionSourceType;
public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackable, ItemImpl.ClingyItem, ItemImpl.GroundTickCallback, DamageChecker {
public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackable, ItemImpl.ClingyItem, TickableItem, DamageChecker {
private static final Identifier EFFECT_ID = Unicopia.id("alicorn_amulet_modifiers");
private static final Object2FloatMap<RegistryEntry<EntityAttribute>> EFFECT_SCALES = Object2FloatMaps.unmodifiable(new Object2FloatOpenHashMap<>(Map.of(
EntityAttributes.GENERIC_ATTACK_DAMAGE, 0.2F,
@ -78,10 +78,10 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
@Environment(EnvType.CLIENT)
@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
Pony iplayer = Pony.of(MinecraftClient.getInstance().player);
Pony pony = Pony.of(MinecraftClient.getInstance().player);
if (iplayer != null) {
long ticks = iplayer.getArmour().getTicks(this);
if (pony != null) {
long ticks = pony.getArmour().getTicks(this);
if (ticks > 0) {
tooltip.add(Text.literal(ItemTracker.formatTicks(ticks).formatted(Formatting.GRAY)));
}

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.item.TickableItem.GroundTickCallback;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.EntityType;
@ -14,12 +14,12 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.math.MathHelper;
public class AppleItem {
private static final ItemImpl.GroundTickCallback TICK_CALLBACK = AppleItem::onGroundTick;
private static final GroundTickCallback TICK_CALLBACK = AppleItem::onGroundTick;
private AppleItem() { }
public static <T extends Item> T registerTickCallback(T item) {
return ItemImpl.registerTickCallback(item, TICK_CALLBACK);
return TickableItem.registerTickCallback(item, TICK_CALLBACK);
}
private static ActionResult onGroundTick(IItemEntity item) {

View file

@ -3,40 +3,21 @@ package com.minelittlepony.unicopia.item;
import java.util.Arrays;
import java.util.List;
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
import com.minelittlepony.unicopia.item.component.BufferflyVariantComponent;
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
import com.minelittlepony.unicopia.item.group.MultiItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class ButterflyItem extends Item implements MultiItem {
public ButterflyItem(Settings settings) {
super(settings);
super(settings.component(UDataComponentTypes.BUTTERFLY_VARIANT, new BufferflyVariantComponent(ButterflyEntity.Variant.BUTTERFLY, true)));
}
@Override
public List<ItemStack> getDefaultStacks() {
return Arrays.stream(ButterflyEntity.Variant.VALUES).map(variant -> setVariant(getDefaultStack(), variant)).toList();
return Arrays.stream(ButterflyEntity.Variant.VALUES).map(variant -> BufferflyVariantComponent.set(getDefaultStack(), new BufferflyVariantComponent(variant, true))).toList();
}
@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
tooltip.add(Text.literal(getVariant(stack).name()).formatted(Formatting.LIGHT_PURPLE));
}
public static ButterflyEntity.Variant getVariant(ItemStack stack) {
return stack.getOrDefault(UDataComponentTypes.BUTTERFLY_VARIANT, ButterflyEntity.Variant.BUTTERFLY);
}
public static ItemStack setVariant(ItemStack stack, ButterflyEntity.Variant variant) {
if (stack.isOf(UItems.BUTTERFLY)) {
stack.set(UDataComponentTypes.BUTTERFLY_VARIANT, variant);
}
return stack;
}
}

View file

@ -1,8 +1,5 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.entity.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemImpl;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
@ -12,44 +9,42 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
public class EmptyJarItem extends BlockItem implements ItemImpl.GroundTickCallback {
public class EmptyJarItem extends BlockItem {
public EmptyJarItem(Block block, Settings settings) {
super(block, settings);
}
TickableItem.registerTickCallback(this, item -> {
ItemEntity entity = item.get().asEntity();
@Override
public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.get().asEntity();
entity.setInvulnerable(true);
entity.setInvulnerable(true);
if (!entity.getWorld().isClient
&& !entity.isRemoved()
&& entity.getItemAge() > 100
&& entity.getWorld().isThundering()
&& entity.getWorld().isSkyVisible(entity.getBlockPos())
&& entity.getWorld().random.nextInt(130) == 0) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld());
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
if (!entity.getWorld().isClient
&& !entity.isRemoved()
&& entity.getItemAge() > 100
&& entity.getWorld().isThundering()
&& entity.getWorld().isSkyVisible(entity.getBlockPos())
&& entity.getWorld().random.nextInt(130) == 0) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld());
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
entity.remove(RemovalReason.DISCARDED);
entity.getWorld().spawnEntity(lightning);
entity.remove(RemovalReason.DISCARDED);
entity.getWorld().spawnEntity(lightning);
ItemEntity neu = EntityType.ITEM.create(entity.getWorld());
neu.copyPositionAndRotation(entity);
neu.setStack(new ItemStack(this == UItems.RAIN_CLOUD_JAR ? UItems.STORM_CLOUD_JAR : UItems.LIGHTNING_JAR));
neu.setInvulnerable(true);
ItemEntity neu = EntityType.ITEM.create(entity.getWorld());
neu.copyPositionAndRotation(entity);
neu.setStack(new ItemStack(this == UItems.RAIN_CLOUD_JAR ? UItems.STORM_CLOUD_JAR : UItems.LIGHTNING_JAR));
neu.setInvulnerable(true);
entity.getWorld().spawnEntity(neu);
entity.getWorld().spawnEntity(neu);
ItemEntity copy = EntityType.ITEM.create(entity.getWorld());
copy.copyPositionAndRotation(entity);
copy.setInvulnerable(true);
copy.setStack(entity.getStack());
copy.getStack().decrement(1);
ItemEntity copy = EntityType.ITEM.create(entity.getWorld());
copy.copyPositionAndRotation(entity);
copy.setInvulnerable(true);
copy.setStack(entity.getStack());
copy.getStack().decrement(1);
entity.getWorld().spawnEntity(copy);
}
return ActionResult.PASS;
entity.getWorld().spawnEntity(copy);
}
return ActionResult.PASS;
});
}
}

View file

@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
import com.minelittlepony.unicopia.entity.mob.UEntities;
import com.minelittlepony.unicopia.item.component.Appearance;
import com.minelittlepony.unicopia.item.component.BufferflyVariantComponent;
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
@ -80,10 +81,11 @@ public class FilledJarItem extends ProjectileItem implements ProjectileDelegate.
@Override
public void onImpact(MagicProjectileEntity projectile) {
ItemStack stack = Appearance.upwrapAppearance(projectile.getStack());
BufferflyVariantComponent butterflyVariant = stack.get(UDataComponentTypes.BUTTERFLY_VARIANT);
if (stack.isOf(UItems.BUTTERFLY)) {
if (butterflyVariant != null) {
ButterflyEntity butterfly = UEntities.BUTTERFLY.create(projectile.getWorld());
butterfly.setVariant(ButterflyItem.getVariant(stack));
butterfly.setVariant(butterflyVariant.variant());
butterfly.updatePosition(projectile.getX(), projectile.getY(), projectile.getZ());
projectile.getWorld().spawnEntity(butterfly);
} else {

View file

@ -1,7 +1,11 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.entity.ItemImpl.ClingyItem;
import net.minecraft.item.*;
public interface ItemDuck extends ItemConvertible, ItemImpl.TickableItem {
public interface ItemDuck extends ItemConvertible, TickableItem, ClingyItem {
static ItemDuck of(ItemStack stack) {
return (ItemDuck)stack.getItem();
}
}

View file

@ -0,0 +1,42 @@
package com.minelittlepony.unicopia.item;
import java.util.List;
import com.minelittlepony.unicopia.entity.IItemEntity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.item.Item;
import net.minecraft.util.ActionResult;
public interface TickableItem {
static <T extends Item> T registerTickCallback(T item, GroundTickCallback callback) {
((ItemDuck)item).addGroundTickCallback(callback);
return item;
}
default List<GroundTickCallback> getCallbacks() {
throw new RuntimeException("Implemented by mixin");
}
default void addGroundTickCallback(GroundTickCallback callback) {
getCallbacks().add(callback);
}
default ActionResult onGroundTick(IItemEntity entity) {
for (var callback : getCallbacks()) {
ActionResult result = callback.onGroundTick(entity);
if (result.isAccepted()) {
return result;
}
}
return ActionResult.PASS;
}
default void inFrameTick(ItemFrameEntity entity) {
}
public interface GroundTickCallback {
ActionResult onGroundTick(IItemEntity entity);
}
}

View file

@ -0,0 +1,47 @@
package com.minelittlepony.unicopia.item.component;
import java.util.function.Consumer;
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item.TooltipContext;
import net.minecraft.item.tooltip.TooltipAppender;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public record BufferflyVariantComponent (ButterflyEntity.Variant variant, boolean showInTooltip) implements TooltipAppender {
public static final BufferflyVariantComponent DEFAULT = new BufferflyVariantComponent(ButterflyEntity.Variant.BUTTERFLY, false);
public static final Codec<BufferflyVariantComponent> CODEC = RecordCodecBuilder.create(instance -> instance.group(
ButterflyEntity.Variant.CODEC.fieldOf("variant").forGetter(BufferflyVariantComponent::variant),
Codec.BOOL.fieldOf("show_in_tooltip").forGetter(BufferflyVariantComponent::showInTooltip)
).apply(instance, BufferflyVariantComponent::new));
public static final PacketCodec<ByteBuf, BufferflyVariantComponent> PACKET_CODEC = PacketCodec.tuple(
ButterflyEntity.Variant.PACKET_CODEC, BufferflyVariantComponent::variant,
PacketCodecs.BOOL, BufferflyVariantComponent::showInTooltip,
BufferflyVariantComponent::new
);
public static BufferflyVariantComponent get(ItemStack stack) {
return stack.getOrDefault(UDataComponentTypes.BUTTERFLY_VARIANT, DEFAULT);
}
public static ItemStack set(ItemStack stack, BufferflyVariantComponent variant) {
stack.set(UDataComponentTypes.BUTTERFLY_VARIANT, variant);
return stack;
}
@Override
public void appendTooltip(TooltipContext context, Consumer<Text> tooltip, TooltipType type) {
if (showInTooltip()) {
tooltip.accept(Text.literal(variant().name()).formatted(Formatting.LIGHT_PURPLE));
}
}
}

View file

@ -8,7 +8,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.container.SpellbookState;
import com.minelittlepony.unicopia.diet.DietProfile;
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity;
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
import com.mojang.serialization.Codec;
import net.minecraft.component.ComponentType;
@ -21,7 +20,7 @@ public interface UDataComponentTypes {
ComponentType<SpellTraits> SPELL_TRAITS = register("spell_traits", builder -> builder.codec(SpellTraits.CODEC).packetCodec(SpellTraits.PACKET_CODEC).cache());
ComponentType<SpellbookState> SPELLBOOK_STATE = register("spellbook_state", builder -> builder.codec(SpellbookState.CODEC).packetCodec(SpellbookState.PACKET_CODEC).cache());
ComponentType<Boolean> GLOWING = register("glowing", builder -> builder.codec(Codec.BOOL).packetCodec(PacketCodecs.BOOL));
ComponentType<ButterflyEntity.Variant> BUTTERFLY_VARIANT = register("butterfly_variant", builder -> builder.codec(ButterflyEntity.Variant.CODEC).packetCodec(ButterflyEntity.Variant.PACKET_CODEC));
ComponentType<BufferflyVariantComponent> BUTTERFLY_VARIANT = register("butterfly_variant", builder -> builder.codec(BufferflyVariantComponent.CODEC).packetCodec(BufferflyVariantComponent.PACKET_CODEC));
ComponentType<AirBalloonEntity.BalloonDesign> BALLOON_DESIGN = register("balloon_design", builder -> builder.codec(AirBalloonEntity.BalloonDesign.CODEC).packetCodec(AirBalloonEntity.BalloonDesign.PACKET_CODEC));
ComponentType<Issuer> ISSUER = register("issuer", builder -> builder.codec(Issuer.CODEC).packetCodec(Issuer.PACKET_CODEC).cache());
ComponentType<Charges> CHARGES = register("charges", builder -> builder.codec(Charges.CODEC).packetCodec(Charges.PACKET_CODEC));

View file

@ -23,8 +23,8 @@ public interface ItemGroupRegistry {
Map<RegistryKey<ItemGroup>, Set<Item>> REGISTRY = new HashMap<>();
static List<ItemStack> getVariations(Item item) {
if (item instanceof MultiItem) {
return ((MultiItem)item).getDefaultStacks();
if (item instanceof MultiItem m) {
return m.getDefaultStacks();
}
return List.of(item.getDefaultStack());
}

View file

@ -5,25 +5,17 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.entity.ItemImpl.ClingyItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import com.minelittlepony.unicopia.item.ItemDuck;
import net.minecraft.entity.decoration.BlockAttachedEntity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.item.ItemStack;
@Mixin(AbstractDecorationEntity.class)
abstract class MixinAbstractDecorationEntity extends Entity {
MixinAbstractDecorationEntity() { super(null, null); }
@Mixin(BlockAttachedEntity.class)
abstract class MixinAbstractDecorationEntity {
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
private void beforeTick(CallbackInfo info) {
final Object _this = this;
if (_this instanceof ItemFrameEntity self) {
ItemStack stack = self.getHeldItemStack();
if (stack.getItem() instanceof ClingyItem item) {
item.inFrameTick(self);
}
ItemDuck.of(self.getHeldItemStack()).inFrameTick(self);
}
}
}

View file

@ -3,15 +3,13 @@ package com.minelittlepony.unicopia.mixin;
import java.util.ArrayList;
import java.util.List;
import org.spongepowered.asm.mixin.Mixin;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.entity.ItemImpl.GroundTickCallback;
import com.minelittlepony.unicopia.item.ItemDuck;
import net.minecraft.item.Item;
@Mixin(Item.class)
abstract class MixinItem implements ItemDuck {
private final List<ItemImpl.GroundTickCallback> tickCallbacks = new ArrayList<>();
private final List<GroundTickCallback> tickCallbacks = new ArrayList<>();
@Override
public List<GroundTickCallback> getCallbacks() {

View file

@ -11,10 +11,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.diet.PonyDiets;
import com.minelittlepony.unicopia.entity.effect.FoodPoisoningStatusEffect;
import com.minelittlepony.unicopia.item.DamageChecker;
import com.minelittlepony.unicopia.item.ItemStackDuck;
import com.minelittlepony.unicopia.item.component.TransientComponentMap;
import net.minecraft.component.ComponentHolder;
import net.minecraft.component.ComponentType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
@ -46,7 +48,7 @@ abstract class MixinItemStack implements ItemStackDuck {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
transientComponents.setCarrier(user);
TypedActionResult<ItemStack> result = PonyDiets.getInstance().startUsing((ItemStack)(Object)this, world, user, hand);
TypedActionResult<ItemStack> result = FoodPoisoningStatusEffect.apply((ItemStack)(Object)this, user);
if (result.getResult() != ActionResult.PASS) {
info.setReturnValue(result);
}
@ -57,12 +59,6 @@ abstract class MixinItemStack implements ItemStackDuck {
transientComponents.setCarrier(null);
}
@Inject(method = "finishUsing", at = @At("HEAD"))
private void beforeFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
transientComponents.setCarrier(user);
PonyDiets.getInstance().finishUsing((ItemStack)(Object)this, world, user);
}
@Inject(method = "finishUsing", at = @At("RETURN"))
private void afterFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
transientComponents.setCarrier(null);
@ -93,9 +89,12 @@ abstract class MixinItemStack implements ItemStackDuck {
info.setReturnValue(checker.takesDamageFrom(source));
}
}
}
@Mixin(ComponentHolder.class)
interface MixinComponentHolder {
@Inject(method = "get", at = @At("RETURN"))
private <T> void unicopia_onGet(ComponentType<? extends T> type, CallbackInfoReturnable<T> info) {
default <T> void unicopia_onGet(ComponentType<? extends T> type, CallbackInfoReturnable<T> info) {
Object o = this;
if (o instanceof ItemStack stack) {
info.setReturnValue(ItemStackDuck.of(stack).getTransientComponents().get(type, stack, info.getReturnValue()));
@ -103,7 +102,7 @@ abstract class MixinItemStack implements ItemStackDuck {
}
@Inject(method = "getOrDefault", at = @At("RETURN"))
private <T> void unicopia_onGetOrDefault(ComponentType<? extends T> type, T fallback, CallbackInfoReturnable<T> info) {
default <T> void unicopia_onGetOrDefault(ComponentType<? extends T> type, T fallback, CallbackInfoReturnable<T> info) {
Object o = this;
if (o instanceof ItemStack stack) {
info.setReturnValue(ItemStackDuck.of(stack).getTransientComponents().get(type, stack, info.getReturnValue()));
@ -111,7 +110,7 @@ abstract class MixinItemStack implements ItemStackDuck {
}
@Inject(method = "contains", at = @At("RETURN"))
private void unicopia_onContains(ComponentType<?> type, CallbackInfoReturnable<Boolean> info) {
default void unicopia_onContains(ComponentType<?> type, CallbackInfoReturnable<Boolean> info) {
Object o = this;
if (o instanceof ItemStack stack && ItemStackDuck.of(stack).getTransientComponents().get(type, stack, null) != null) {
info.setReturnValue(true);

View file

@ -16,19 +16,21 @@ import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.LootableInventory;
import net.minecraft.loot.LootTable;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryKey;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier;
@Mixin(LootableContainerBlockEntity.class)
abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockEntity implements MimicEntity.MimicGeneratable {
private Identifier mimicLootTable;
@Nullable
private RegistryKey<LootTable> mimicLootTable;
private boolean allowMimics = true;
private TriState isMimic = TriState.DEFAULT;
@Shadow
@Nullable
private Identifier lootTableId;
protected RegistryKey<LootTable> lootTable;
MixinLootableContainerBlockEntity() { super(null, null, null); }
@ -46,8 +48,8 @@ abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockE
@Override
public void configureMimic(@Nullable PlayerEntity player) {
if (player != null && allowMimics && lootTableId != null) {
mimicLootTable = lootTableId;
if (player != null && allowMimics && lootTable != null) {
mimicLootTable = lootTable;
}
}

View file

@ -1,13 +1,10 @@
package com.minelittlepony.unicopia.mixin;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.entity.duck.PlayerEntityDuck;
@ -18,6 +15,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.datafixers.util.Either;
import net.minecraft.block.BlockState;
import net.minecraft.component.type.FoodComponent;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.ItemEntity;
@ -53,9 +51,9 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
return get().modifyDamage(source, amount).orElse(amount);
}
@Inject(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"))
private void onEatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
get().onEat(stack);
@ModifyVariable(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/component/type/FoodComponent;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"), argsOnly = true)
private FoodComponent onEatFood(FoodComponent initial, World world, ItemStack stack, FoodComponent food, CallbackInfoReturnable<ItemStack> info) {
return get().onEat(stack, food);
}
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;",
@ -79,19 +77,7 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
@ModifyReturnValue(method = "getBaseDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;", at = @At("RETURN"))
private EntityDimensions modifyEyeHeight(EntityDimensions dimensions, EntityPose pose) {
return get().getMotion().getDimensions().calculateActiveEyeHeight(dimensions).map(eyeHeight -> {
return dimensions.withEyeHeight(eyeHeight);
}).orElse(dimensions);
}
@Redirect(method = "getDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;",
at = @At(
value = "INVOKE",
target = "Ljava/util/Map;getOrDefault(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
remap = false
))
private Object redirect_onGetDimensions(Map<EntityPose, EntityDimensions> self, Object key, Object def) {
return get().getMotion().getDimensions().calculateDimensions().orElse(self.getOrDefault((EntityPose)key, (EntityDimensions)def));
return get().getMotion().getDimensions().calculateDimensions(dimensions);
}
@Inject(method = "getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F",

View file

@ -2,35 +2,32 @@ package com.minelittlepony.unicopia.mixin.client;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.minelittlepony.unicopia.client.UnicopiaClient;
import net.minecraft.client.render.Camera;
@Mixin(Camera.class)
abstract class MixinCamera {
@ModifyVariable(method = "setRotation(FF)V",
@ModifyVariable(method = "setRotation",
at = @At("HEAD"),
ordinal = 0,
argsOnly = true)
private float modifyYaw(float yaw) {
return UnicopiaClient.getCamera().map(c -> c.calculateYaw(yaw)).orElse(yaw);
return UnicopiaClient.getCamera().calculateYaw(yaw);
}
@ModifyVariable(method = "setRotation(FF)V",
@ModifyVariable(method = "setRotation",
at = @At("HEAD"),
ordinal = 1,
argsOnly = true)
private float modifyPitch(float pitch) {
return UnicopiaClient.getCamera().map(c -> c.calculatePitch(pitch)).orElse(pitch);
return UnicopiaClient.getCamera().calculatePitch(pitch);
}
@Inject(method = "clipToSpace(D)D",
at = @At("RETURN"),
cancellable = true)
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
UnicopiaClient.getCamera().flatMap(c -> c.calculateDistance(info.getReturnValueD())).ifPresent(info::setReturnValue);
@ModifyReturnValue(method = "clipToSpace",
at = @At("RETURN"))
private float modifyCameraDistance(float initial) {
return UnicopiaClient.getCamera().calculateDistance(initial);
}
}

View file

@ -6,18 +6,17 @@ import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.minelittlepony.unicopia.client.BatEyesApplicator;
import com.minelittlepony.unicopia.client.UnicopiaClient;
import com.minelittlepony.unicopia.client.render.shader.ViewportShader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.resource.SynchronousResourceReloader;
@Mixin(value = GameRenderer.class, priority = Integer.MAX_VALUE)
@ -26,41 +25,33 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
@Shadow
private @Final MinecraftClient client;
@Inject(method = "getFov(Lnet/minecraft/client/render/Camera;FZ)D",
at = @At("RETURN"),
cancellable = true)
private void onGetFov(Camera camera, float f, boolean z, CallbackInfoReturnable<Double> info) {
UnicopiaClient.getCamera().ifPresent(c -> info.setReturnValue(c.calculateFieldOfView(info.getReturnValue())));
@ModifyReturnValue(method = "getFov", at = @At("RETURN"))
private double modifyFov(double initial) {
return UnicopiaClient.getCamera().calculateFieldOfView(initial);
}
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
at = @At("HEAD"))
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(c.calculateFirstPersonRoll())));
@Inject(method = "renderWorld", at = @At("HEAD"))
private void beforeRenderWorld(RenderTickCounter counter, CallbackInfo info) {
BatEyesApplicator.INSTANCE.enable();
}
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
@Inject(method = "tiltViewWhenHurt", at = @At("HEAD"))
private void tiltViewWhenHurt(MatrixStack matrices, float tickDelta, CallbackInfo info) {
float roll = UnicopiaClient.getCamera().calculateFirstPersonRoll();
if (roll != 0) {
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(roll));
}
}
@Inject(method = "renderWorld",
at = @At("RETURN"))
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
private void afterRenderWorld(RenderTickCounter counter, CallbackInfo info) {
BatEyesApplicator.INSTANCE.disable();
}
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
at = @At("HEAD"),
cancellable = true)
private static void onGetNightVisionStrengthHead(LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
if (!entity.hasStatusEffect(StatusEffects.NIGHT_VISION)) {
info.setReturnValue(UnicopiaClient.getWorldBrightness(0));
}
}
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
at = @At("RETURN"),
cancellable = true)
private static void onGetNightVisionStrengthReturn(LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
if (entity.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(entity)) {
info.setReturnValue(UnicopiaClient.getWorldBrightness(info.getReturnValueF()));
}
@ModifyReturnValue(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F", at = @At("RETURN"))
private static float modifyWorldBrightness(float initial, LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
return BatEyesApplicator.getWorldBrightness(initial, entity, tickDelta);
}
@Inject(method = "render",

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.client.gui.HudEffects;
import com.minelittlepony.unicopia.client.gui.UHud;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.entity.player.PlayerEntity;
@Mixin(InGameHud.class)
@ -18,15 +19,15 @@ abstract class MixinInGameHud {
@Shadow
abstract PlayerEntity getCameraPlayer();
@Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("HEAD"))
private void onRender(DrawContext context, float tickDelta, CallbackInfo info) {
HudEffects.tryApply(getCameraPlayer(), tickDelta, true);
UHud.INSTANCE.render((InGameHud)(Object)this, context, tickDelta);
@Inject(method = "render", at = @At("HEAD"))
private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo info) {
HudEffects.tryApply(getCameraPlayer(), tickCounter, true);
UHud.INSTANCE.render((InGameHud)(Object)this, context, tickCounter);
}
@Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("RETURN"))
private void afterRender(DrawContext context, float tickDelta, CallbackInfo info) {
HudEffects.tryApply(getCameraPlayer(), tickDelta, false);
@Inject(method = "render", at = @At("RETURN"))
private void afterRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo info) {
HudEffects.tryApply(getCameraPlayer(), tickCounter, false);
}
}

View file

@ -39,8 +39,8 @@ abstract class MixinModelPart implements Hookable {
isHeadPart = true;
}
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V", at = @At("HEAD"))
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha, CallbackInfo info) {
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V", at = @At("HEAD"))
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color, CallbackInfo info) {
if (visible && isHeadPart) {
ModelPartHooks.onHeadRendered((ModelPart)(Object)this, matrices);
}

View file

@ -18,8 +18,8 @@ abstract class MixinMouse {
@Shadow
private double cursorDeltaY;
@Inject(method = "updateMouse()V", at = @At("HEAD"))
private void onUpdateMouse(CallbackInfo info) {
@Inject(method = "updateMouse(D)V", at = @At("HEAD"))
private void onUpdateMouse(double tickDelta, CallbackInfo info) {
Pony player = Pony.of(MinecraftClient.getInstance().player);
if (player != null && player.getPhysics().isGravityNegative()) {
cursorDeltaX = -cursorDeltaX;

View file

@ -13,6 +13,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.minelittlepony.unicopia.client.ClientBlockDestructionManager;
import com.minelittlepony.unicopia.client.UnicopiaClient;
import com.minelittlepony.unicopia.server.world.WeatherAccess;
@ -50,16 +52,10 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
@Accessor("ticks")
public abstract int getTicks();
@Redirect(method = "render("
+ "Lnet/minecraft/client/util/math/MatrixStack;"
+ "FJZ"
+ "Lnet/minecraft/client/render/Camera;"
+ "Lnet/minecraft/client/render/GameRenderer;"
+ "Lnet/minecraft/client/render/LightmapTextureManager;"
+ "Lorg/joml/Matrix4f;"
+ ")V",
at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/WorldRenderer;blockBreakingProgressions:Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;")
)
@Redirect(method = "render", at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/render/WorldRenderer;blockBreakingProgressions:Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;"
))
private Long2ObjectMap<SortedSet<BlockBreakingInfo>> redirectGetDamagesMap(WorldRenderer sender) {
return destructions.getCombinedDestructions(blockBreakingProgressions);
}
@ -69,24 +65,21 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
destructions.tick(blockBreakingProgressions);
}
@Inject(method = "renderSky("
+ "Lnet/minecraft/client/util/math/MatrixStack;"
+ "Lorg/joml/Matrix4f;"
+ "F"
+ "Lnet/minecraft/client/render/Camera;"
+ "Z"
+ "Ljava/lang/Runnable;"
+ ")V", at = @At(
value = "INVOKE",
target = "net/minecraft/client/world/ClientWorld.getSkyAngle(F)F",
ordinal = 1
))
private void onRenderSky(MatrixStack matrices, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback, CallbackInfo info) {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(UnicopiaClient.getInstance().getSkyAngleDelta(tickDelta)));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(UnicopiaClient.getInstance().tangentalSkyAngle.getValue()));
@Inject(method = "renderSky", at = @At(
value = "INVOKE",
target = "net/minecraft/client/world/ClientWorld.getSkyAngle(F)F",
ordinal = 1
))
private void onRenderSky(Matrix4f matrix4f, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback,
CallbackInfo info, @Local LocalRef<MatrixStack> matrices) {
matrices.get().multiply(RotationAxis.POSITIVE_X.rotationDegrees(UnicopiaClient.getInstance().getSkyAngleDelta(tickDelta)));
matrices.get().multiply(RotationAxis.POSITIVE_Y.rotationDegrees(UnicopiaClient.getInstance().tangentalSkyAngle.getValue()));
}
@Redirect(method = "renderWeather", at = @At(value = "INVOKE", target = "net/minecraft/world/biome/Biome.getPrecipitation(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/biome/Biome$Precipitation;"))
@Redirect(method = "renderWeather", at = @At(
value = "INVOKE",
target = "net/minecraft/world/biome/Biome.getPrecipitation(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/biome/Biome$Precipitation;"
))
private Biome.Precipitation modifyPrecipitation(Biome biome, BlockPos pos) {
Biome.Precipitation precipitation = biome.getPrecipitation(pos);
if (!((WeatherAccess)world).isBelowClientCloudLayer(pos)) {

View file

@ -1,22 +1,17 @@
package com.minelittlepony.unicopia.mixin.datafix;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import com.mojang.datafixers.DataFixUtils;
import com.minelittlepony.unicopia.datafixer.SchemasStore;
import com.mojang.datafixers.DataFixerBuilder;
import com.mojang.datafixers.schemas.Schema;
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
@Mixin(value = DataFixerBuilder.class, remap = false)
public interface DataFixerBuilderAccessor {
public interface DataFixerBuilderAccessor extends SchemasStore {
@Override
@Accessor
Int2ObjectSortedMap<Schema> getSchemas();
@Nullable
default Schema getSchema(final int version, final int subVersion) {
return getSchemas().get(DataFixUtils.makeKey(version, subVersion));
}
}

View file

@ -15,6 +15,7 @@
"MixinBlockItem",
"MixinBoatEntity",
"MixinChunkBlockLightProvider",
"MixinComponentHolder",
"MutableBlockLightStorage",
"MixinDamageSource",
"MixinEnchantment",