mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-12 13:27:58 +01:00
Update mixins
This commit is contained in:
parent
bacfa050bb
commit
84e41bcc88
44 changed files with 424 additions and 454 deletions
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.client;
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -15,6 +16,15 @@ public class BatEyesApplicator {
|
||||||
|
|
||||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
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() {
|
public void enable() {
|
||||||
if (client.world != null) {
|
if (client.world != null) {
|
||||||
PlayerEntity player = client.player;
|
PlayerEntity player = client.player;
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class ModifierTooltipRenderer {
|
||||||
|
|
||||||
appendTooltip(stack, UDataComponentTypes.CHARGES, context, textConsumer, type);
|
appendTooltip(stack, UDataComponentTypes.CHARGES, context, textConsumer, type);
|
||||||
appendTooltip(stack, UDataComponentTypes.ISSUER, 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);
|
EnchantableItem.getSpellEffect(stack).appendTooltip(context, textConsumer, type);
|
||||||
if (GlowableItem.isGlowing(stack)) {
|
if (GlowableItem.isGlowing(stack)) {
|
||||||
lines.add(Text.translatable("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY));
|
lines.add(Text.translatable("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY));
|
||||||
|
|
|
@ -30,11 +30,11 @@ import com.minelittlepony.unicopia.client.render.shader.UShaders;
|
||||||
import com.minelittlepony.unicopia.client.render.spell.SpellRendererFactory;
|
import com.minelittlepony.unicopia.client.render.spell.SpellRendererFactory;
|
||||||
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
||||||
import com.minelittlepony.unicopia.entity.mob.UEntities;
|
import com.minelittlepony.unicopia.entity.mob.UEntities;
|
||||||
import com.minelittlepony.unicopia.item.ButterflyItem;
|
|
||||||
import com.minelittlepony.unicopia.item.EnchantableItem;
|
import com.minelittlepony.unicopia.item.EnchantableItem;
|
||||||
import com.minelittlepony.unicopia.item.FancyBedItem;
|
import com.minelittlepony.unicopia.item.FancyBedItem;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.item.component.Appearance;
|
import com.minelittlepony.unicopia.item.component.Appearance;
|
||||||
|
import com.minelittlepony.unicopia.item.component.BufferflyVariantComponent;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
import com.minelittlepony.unicopia.particle.UParticles;
|
||||||
import com.terraformersmc.terraform.boat.api.client.TerraformBoatClientHelper;
|
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("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.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.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() {
|
ModelPredicateProviderRegistry.register(Unicopia.id("zap_cycle"), new ClampedModelPredicateProvider() {
|
||||||
private double targetAngle;
|
private double targetAngle;
|
||||||
private double lastAngle;
|
private double lastAngle;
|
||||||
private long lastTick;
|
private long lastTick;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float unclampedCall(ItemStack stack, ClientWorld world, LivingEntity e, int var4) {
|
public float unclampedCall(ItemStack stack, ClientWorld world, @Nullable LivingEntity holder, int seed) {
|
||||||
Entity entity = e != null ? e : stack.getHolder();
|
@Nullable
|
||||||
|
Entity entity = holder != null ? holder : stack.getHolder();
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (world == null && entity.getWorld() instanceof ClientWorld) {
|
if (world == null && entity.getWorld() instanceof ClientWorld cw) {
|
||||||
world = (ClientWorld)entity.getWorld();
|
world = cw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.minelittlepony.unicopia.client;
|
package com.minelittlepony.unicopia.client;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
@ -52,33 +50,25 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
return Pony.of(MinecraftClient.getInstance().player);
|
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 tangentalSkyAngle = new Lerp(0, true);
|
||||||
public final Lerp skyAngle = new Lerp(0, true);
|
public final Lerp skyAngle = new Lerp(0, true);
|
||||||
|
|
||||||
private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING;
|
private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING;
|
||||||
|
|
||||||
public static Optional<PlayerCamera> getCamera() {
|
public static PlayerCamera getCamera() {
|
||||||
return Optional.ofNullable(getNullableCamera());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static PlayerCamera getNullableCamera() {
|
|
||||||
PlayerEntity player = MinecraftClient.getInstance().player;
|
PlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
|
||||||
if (player != null && MinecraftClient.getInstance().cameraEntity == player) {
|
if (player != null && MinecraftClient.getInstance().cameraEntity == player) {
|
||||||
return Pony.of(player).getCamera();
|
return Pony.of(player).getCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return PlayerCamera.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Vec3d getAdjustedSoundPosition(Vec3d pos) {
|
public static Vec3d getAdjustedSoundPosition(Vec3d pos) {
|
||||||
PlayerCamera cam = getNullableCamera();
|
PlayerCamera cam = getCamera();
|
||||||
if (cam == null) {
|
if (cam == PlayerCamera.DEFAULT) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
|
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
|
||||||
|
@ -102,10 +92,6 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
return Unicopia.getConfig().preferredRace.get();
|
return Unicopia.getConfig().preferredRace.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getWorldBrightness(float initial) {
|
|
||||||
return 0.6F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnicopiaClient() {
|
public UnicopiaClient() {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.entity.duck.EntityDuck;
|
||||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -22,9 +23,9 @@ public class HudEffects {
|
||||||
private static boolean addedHunger;
|
private static boolean addedHunger;
|
||||||
private static Set<TagKey<Fluid>> originalTags = null;
|
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) {
|
if (player != null) {
|
||||||
apply(Pony.of(player), tickDelta, on);
|
apply(Pony.of(player), tickCounter.getTickDelta(false), on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.hud.InGameHud;
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
@ -71,7 +72,7 @@ public class UHud {
|
||||||
private boolean prevReplacing;
|
private boolean prevReplacing;
|
||||||
private SpellType<?> focusedType = SpellType.empty();
|
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;
|
final int hotbarZ = -90;
|
||||||
|
|
||||||
if (client.player == null) {
|
if (client.player == null) {
|
||||||
|
@ -84,6 +85,8 @@ public class UHud {
|
||||||
|
|
||||||
Pony pony = Pony.of(client.player);
|
Pony pony = Pony.of(client.player);
|
||||||
|
|
||||||
|
float tickDelta = tickCounter.getTickDelta(false);
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(0, 0, hotbarZ - 9800);
|
matrices.translate(0, 0, hotbarZ - 9800);
|
||||||
renderViewEffects(pony, context, scaledWidth, scaledHeight, tickDelta);
|
renderViewEffects(pony, context, scaledWidth, scaledHeight, tickDelta);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -6,25 +6,16 @@ import java.util.Optional;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.entity.effect.FoodPoisoningStatusEffect;
|
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.util.serialization.PacketCodecUtils;
|
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.item.ItemStack;
|
||||||
import net.minecraft.network.RegistryByteBuf;
|
import net.minecraft.network.RegistryByteBuf;
|
||||||
import net.minecraft.network.codec.PacketCodec;
|
import net.minecraft.network.codec.PacketCodec;
|
||||||
import net.minecraft.network.codec.PacketCodecs;
|
import net.minecraft.network.codec.PacketCodecs;
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.Identifier;
|
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());
|
private static PonyDiets INSTANCE = new PonyDiets(Map.of(), Map.of());
|
||||||
|
|
||||||
public static final PacketCodec<RegistryByteBuf, PonyDiets> PACKET_CODEC = PacketCodec.tuple(
|
public static final PacketCodec<RegistryByteBuf, PonyDiets> PACKET_CODEC = PacketCodec.tuple(
|
||||||
|
@ -46,11 +37,6 @@ public class PonyDiets implements DietView {
|
||||||
INSTANCE = diets;
|
INSTANCE = diets;
|
||||||
}
|
}
|
||||||
|
|
||||||
PonyDiets(Map<Race, DietProfile> diets, Map<Identifier, FoodGroup> effects) {
|
|
||||||
this.diets = diets;
|
|
||||||
this.effects = effects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DietProfile getDiet(Pony pony) {
|
public DietProfile getDiet(Pony pony) {
|
||||||
return Optional.ofNullable(diets.get(pony.getObservedSpecies())).orElse(DietProfile.EMPTY);
|
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);
|
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));
|
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
public interface IItemEntity extends Equine.Container<ItemImpl> {
|
public interface IItemEntity extends Equine.Container<ItemImpl> {
|
||||||
|
|
||||||
int getAge();
|
int getAge();
|
||||||
|
|
||||||
int getPickupDelay();
|
int getPickupDelay();
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.*;
|
import com.minelittlepony.unicopia.*;
|
||||||
|
import com.minelittlepony.unicopia.item.ItemDuck;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.EnchantmentUtil;
|
import com.minelittlepony.unicopia.item.enchantment.EnchantmentUtil;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
import com.minelittlepony.unicopia.network.track.DataTracker;
|
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.particle.UParticles;
|
||||||
import com.minelittlepony.unicopia.util.VecHelper;
|
import com.minelittlepony.unicopia.util.VecHelper;
|
||||||
import net.minecraft.entity.*;
|
import net.minecraft.entity.*;
|
||||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||||
import net.minecraft.util.ActionResult;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.random.Random;
|
import net.minecraft.util.math.random.Random;
|
||||||
|
|
||||||
|
@ -68,16 +64,14 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
|
|
||||||
ItemStack stack = entity.getStack();
|
ItemStack stack = entity.getStack();
|
||||||
IItemEntity i = (IItemEntity)entity;
|
IItemEntity i = (IItemEntity)entity;
|
||||||
|
ItemDuck duck = ItemDuck.of(stack);
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
|
|
||||||
Item item = stack.getItem();
|
if (duck.isClingy(stack)) {
|
||||||
ClingyItem clingy = item instanceof ClingyItem ? (ClingyItem)item : ClingyItem.DEFAULT;
|
|
||||||
|
|
||||||
if (clingy.isClingy(stack)) {
|
|
||||||
Random rng = entity.getWorld().random;
|
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.getX() + rng.nextFloat() - 0.5,
|
||||||
entity.getY() + rng.nextFloat() - 0.5,
|
entity.getY() + rng.nextFloat() - 0.5,
|
||||||
entity.getZ() + rng.nextFloat() - 0.5,
|
entity.getZ() + rng.nextFloat() - 0.5,
|
||||||
|
@ -85,19 +79,19 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
);
|
);
|
||||||
|
|
||||||
Vec3d position = entity.getPos();
|
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()
|
.stream()
|
||||||
.sorted((a, b) -> (int)(a.getPos().distanceTo(position) - b.getPos().distanceTo(position)))
|
.sorted((a, b) -> (int)(a.getPos().distanceTo(position) - b.getPos().distanceTo(position)))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(player -> {
|
.ifPresent(player -> {
|
||||||
double distance = player.getPos().distanceTo(entity.getPos());
|
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) {
|
if (entity.horizontalCollision) {
|
||||||
entity.move(MovementType.SELF, new Vec3d(0, entity.verticalCollision ? -0.3 : 0.3, 0));
|
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 duck.onGroundTick(i).isAccepted();
|
||||||
return ((GroundTickCallback)stack.getItem()).onGroundTick(i).isAccepted();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,39 +164,10 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
return entity;
|
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 {
|
public interface ClingyItem {
|
||||||
ClingyItem DEFAULT = stack -> EnchantmentUtil.getLevel(UEnchantments.CLINGY, stack) > 0;
|
default boolean isClingy(ItemStack stack) {
|
||||||
|
return EnchantmentUtil.getLevel(UEnchantments.CLINGY, stack) > 0;
|
||||||
boolean isClingy(ItemStack stack);
|
}
|
||||||
|
|
||||||
default ParticleEffect getParticleEffect(IItemEntity entity) {
|
default ParticleEffect getParticleEffect(IItemEntity entity) {
|
||||||
// TODO: was AMBIENT_ENTITY_EFFECT
|
// TODO: was AMBIENT_ENTITY_EFFECT
|
||||||
|
@ -222,9 +185,5 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
default void interactWithPlayer(IItemEntity entity, PlayerEntity player) {
|
default void interactWithPlayer(IItemEntity entity, PlayerEntity player) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void inFrameTick(ItemFrameEntity entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,6 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
|
||||||
return getAppearance().map(EntityAppearance::getFlightType).orElse(FlightType.UNSET);
|
return getAppearance().map(EntityAppearance::getFlightType).orElse(FlightType.UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default Optional<Float> getTargetEyeHeight(Pony player) {
|
|
||||||
return getAppearance().flatMap(d -> d.getTargetEyeHeight(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default Optional<EntityDimensions> getTargetDimensions(Pony player) {
|
default Optional<EntityDimensions> getTargetDimensions(Pony player) {
|
||||||
return getAppearance().flatMap(d -> d.getTargetDimensions(player));
|
return getAppearance().flatMap(d -> d.getTargetDimensions(player));
|
||||||
|
|
|
@ -54,8 +54,6 @@ import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
|
||||||
public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provider, FlightType.Provider, EntityCollisions.ComplexCollidable, TrackableObject<EntityAppearance> {
|
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
|
@NotNull
|
||||||
private transient String entityId = "";
|
private transient String entityId = "";
|
||||||
|
|
||||||
|
@ -264,18 +262,6 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
||||||
return FlightType.NONE;
|
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() {
|
public float getHeight() {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (entity instanceof FallingBlockEntity) {
|
if (entity instanceof FallingBlockEntity) {
|
||||||
|
@ -287,7 +273,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
||||||
return -1;
|
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));
|
return PehkUtil.ignoreScaleFor(entity, e -> EntityBehaviour.forEntity(e).getCameraDistance(e, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
return a.getType() == b.getType();
|
return a.getType() == b.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Double> getCameraDistance(Entity entity, Pony player) {
|
public Optional<Float> getCameraDistance(Entity entity, Pony player) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
double normalHeight = PlayerEntity.STANDING_DIMENSIONS.height();
|
double normalHeight = PlayerEntity.STANDING_DIMENSIONS.height();
|
||||||
double entityHeight = entity.getDimensions(entity.getPose()).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) {
|
public Optional<EntityDimensions> getDimensions(T entity, Optional<EntityDimensions> current) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
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
|
@Override
|
||||||
public Optional<EntityDimensions> getDimensions(FallingBlockEntity entity, Optional<EntityDimensions> current) {
|
public Optional<EntityDimensions> getDimensions(FallingBlockEntity entity, Optional<EntityDimensions> current) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
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 com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
@ -333,7 +333,7 @@ public class ButterflyEntity extends AmbientEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemEntity dropStack(ItemStack stack, float yOffset) {
|
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
|
@Override
|
||||||
|
|
|
@ -31,10 +31,12 @@ import net.minecraft.inventory.SimpleInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.loot.LootTable;
|
||||||
import net.minecraft.loot.LootTables;
|
import net.minecraft.loot.LootTables;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
import net.minecraft.nbt.NbtOps;
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
@ -43,7 +45,6 @@ import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.ItemScatterer;
|
import net.minecraft.util.ItemScatterer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
@ -62,7 +63,7 @@ public class MimicEntity extends PathAwareEntity {
|
||||||
private int openTicks;
|
private int openTicks;
|
||||||
private final Set<PlayerEntity> observingPlayers = new HashSet<>();
|
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)
|
if (!shouldGenerateMimic(lootTable)
|
||||||
|| !world.getBlockState(pos).isIn(UTags.Blocks.MIMIC_CHESTS)
|
|| !world.getBlockState(pos).isIn(UTags.Blocks.MIMIC_CHESTS)
|
||||||
|| !(world.getBlockEntity(pos) instanceof ChestBlockEntity be)
|
|| !(world.getBlockEntity(pos) instanceof ChestBlockEntity be)
|
||||||
|
@ -97,12 +98,12 @@ public class MimicEntity extends PathAwareEntity {
|
||||||
return mimic;
|
return mimic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldGenerateMimic(@Nullable Identifier lootTable) {
|
public static boolean shouldGenerateMimic(@Nullable RegistryKey<LootTable> lootTable) {
|
||||||
return lootTable != null
|
return lootTable != null
|
||||||
&& lootTable.getPath().indexOf("village") == -1
|
&& lootTable.getValue().getPath().indexOf("village") == -1
|
||||||
&& lootTable.getPath().indexOf("bastion") == -1
|
&& lootTable.getValue().getPath().indexOf("bastion") == -1
|
||||||
&& lootTable.getPath().indexOf("underwater") == -1
|
&& lootTable.getValue().getPath().indexOf("underwater") == -1
|
||||||
&& lootTable.getPath().indexOf("shipwreck") == -1;
|
&& lootTable.getValue().getPath().indexOf("shipwreck") == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MimicEntity(EntityType<? extends MimicEntity> type, World world) {
|
MimicEntity(EntityType<? extends MimicEntity> type, World world) {
|
||||||
|
|
|
@ -1,88 +1,29 @@
|
||||||
package com.minelittlepony.unicopia.entity.player;
|
package com.minelittlepony.unicopia.entity.player;
|
||||||
|
|
||||||
import java.util.Optional;
|
public interface PlayerCamera {
|
||||||
|
PlayerCamera DEFAULT = new PlayerCamera() {};
|
||||||
|
|
||||||
import com.minelittlepony.common.util.animation.MotionCompositor;
|
default float calculateRoll() {
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
return 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calculateRoll() {
|
default float calculateFirstPersonRoll() {
|
||||||
return player.getInterpolator().interpolate("roll", (float)applyModifiers(-getMotionRoll()), 15);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calculateFirstPersonRoll() {
|
default float calculatePitch(float pitch) {
|
||||||
return player.getInterpolator().interpolate("roll_fp", (float)applyModifiers(-getMotionRoll() * getFovScale() * 0.25F), 25);
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getMotionRoll() {
|
default float calculateYaw(float yaw) {
|
||||||
if (!player.getMotion().isFlying() || player.asEntity().hasVehicle() || player.asEntity().isOnGround()) {
|
return yaw;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3d vel = player.asEntity().getVelocity();
|
|
||||||
return calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double applyModifiers(double motionRoll) {
|
default float calculateDistance(float distance) {
|
||||||
if (player.getAcrobatics().isFloppy()) {
|
return distance;
|
||||||
motionRoll += 90;
|
|
||||||
}
|
|
||||||
|
|
||||||
return player.getPhysics().isGravityNegative() ? 180 - motionRoll : motionRoll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calculatePitch(float pitch) {
|
default double calculateFieldOfView(double fov) {
|
||||||
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;
|
|
||||||
return 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,8 +6,9 @@ import net.minecraft.entity.EntityDimensions;
|
||||||
|
|
||||||
public final class PlayerDimensions {
|
public final class PlayerDimensions {
|
||||||
private static final float FLYING_HEIGHT = 0.6F;
|
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<EntityDimensions> FLYING_DIMENSIONS = Optional.of(
|
||||||
private static final Optional<Float> FLYING_EYE_HEIGHT = Optional.of(FLYING_HEIGHT * 0.6F);
|
EntityDimensions.changing(FLYING_HEIGHT, FLYING_HEIGHT).withEyeHeight(FLYING_HEIGHT * 0.6F)
|
||||||
|
);
|
||||||
|
|
||||||
private final PlayerPhysics physics;
|
private final PlayerPhysics physics;
|
||||||
|
|
||||||
|
@ -18,24 +19,18 @@ public final class PlayerDimensions {
|
||||||
this.physics = gravity;
|
this.physics = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Float> calculateActiveEyeHeight(EntityDimensions dimensions) {
|
public EntityDimensions calculateDimensions(EntityDimensions original) {
|
||||||
return getPredicate()
|
EntityDimensions dimensions = 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()
|
|
||||||
.flatMap(e -> e.getTargetDimensions(pony))
|
.flatMap(e -> e.getTargetDimensions(pony))
|
||||||
.or(() -> physics.isFlyingSurvival ? FLYING_DIMENSIONS : Optional.empty())
|
.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() {
|
Optional<Provider> getPredicate() {
|
||||||
|
@ -45,8 +40,6 @@ public final class PlayerDimensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Provider {
|
public interface Provider {
|
||||||
Optional<Float> getTargetEyeHeight(Pony player);
|
|
||||||
|
|
||||||
Optional<EntityDimensions> getTargetDimensions(Pony player);
|
Optional<EntityDimensions> getTargetDimensions(Pony player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
|
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
|
||||||
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
|
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.client.render.PlayerPoser.AnimationInstance;
|
||||||
import com.minelittlepony.unicopia.*;
|
import com.minelittlepony.unicopia.*;
|
||||||
import com.minelittlepony.unicopia.ability.*;
|
import com.minelittlepony.unicopia.ability.*;
|
||||||
|
@ -43,6 +44,7 @@ import com.minelittlepony.common.util.animation.Interpolator;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
import net.minecraft.component.type.FoodComponent;
|
||||||
import net.minecraft.component.type.PotionContentsComponent;
|
import net.minecraft.component.type.PotionContentsComponent;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
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 AbilityDispatcher powers = new AbilityDispatcher(this);
|
||||||
private final PlayerPhysics gravity = addTicker(new PlayerPhysics(this, tracker));
|
private final PlayerPhysics gravity = addTicker(new PlayerPhysics(this, tracker));
|
||||||
private final PlayerCharmTracker charms = new PlayerCharmTracker(this);
|
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 TraitDiscovery discoveries = new TraitDiscovery(this);
|
||||||
private final Acrobatics acrobatics = new Acrobatics(this, tracker);
|
private final Acrobatics acrobatics = new Acrobatics(this, tracker);
|
||||||
private final CorruptionHandler corruptionHandler = new CorruptionHandler(this);
|
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);
|
return Math.max(0, distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEat(ItemStack stack) {
|
public FoodComponent onEat(ItemStack stack, FoodComponent food) {
|
||||||
if (isClient()) {
|
if (isClient()) {
|
||||||
return;
|
return food;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getObservedSpecies() == Race.KIRIN
|
if (getObservedSpecies() == Race.KIRIN
|
||||||
|
@ -748,6 +750,10 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
getMagicalReserves().getCharge().multiply(0.5F);
|
getMagicalReserves().getCharge().multiply(0.5F);
|
||||||
getSpellSlot().get(SpellType.RAGE).ifPresent(RageAbilitySpell::setExtenguishing);
|
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) {
|
public void onKill(Entity killedEntity, DamageSource damage) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ import net.minecraft.world.LocalDifficulty;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.World.ExplosionSourceType;
|
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 Identifier EFFECT_ID = Unicopia.id("alicorn_amulet_modifiers");
|
||||||
private static final Object2FloatMap<RegistryEntry<EntityAttribute>> EFFECT_SCALES = Object2FloatMaps.unmodifiable(new Object2FloatOpenHashMap<>(Map.of(
|
private static final Object2FloatMap<RegistryEntry<EntityAttribute>> EFFECT_SCALES = Object2FloatMaps.unmodifiable(new Object2FloatOpenHashMap<>(Map.of(
|
||||||
EntityAttributes.GENERIC_ATTACK_DAMAGE, 0.2F,
|
EntityAttributes.GENERIC_ATTACK_DAMAGE, 0.2F,
|
||||||
|
@ -78,10 +78,10 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
|
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) {
|
if (pony != null) {
|
||||||
long ticks = iplayer.getArmour().getTicks(this);
|
long ticks = pony.getArmour().getTicks(this);
|
||||||
if (ticks > 0) {
|
if (ticks > 0) {
|
||||||
tooltip.add(Text.literal(ItemTracker.formatTicks(ticks).formatted(Formatting.GRAY)));
|
tooltip.add(Text.literal(ItemTracker.formatTicks(ticks).formatted(Formatting.GRAY)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.entity.IItemEntity;
|
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.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
@ -14,12 +14,12 @@ import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class AppleItem {
|
public class AppleItem {
|
||||||
private static final ItemImpl.GroundTickCallback TICK_CALLBACK = AppleItem::onGroundTick;
|
private static final GroundTickCallback TICK_CALLBACK = AppleItem::onGroundTick;
|
||||||
|
|
||||||
private AppleItem() { }
|
private AppleItem() { }
|
||||||
|
|
||||||
public static <T extends Item> T registerTickCallback(T item) {
|
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) {
|
private static ActionResult onGroundTick(IItemEntity item) {
|
||||||
|
|
|
@ -3,40 +3,21 @@ package com.minelittlepony.unicopia.item;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
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.component.UDataComponentTypes;
|
||||||
import com.minelittlepony.unicopia.item.group.MultiItem;
|
import com.minelittlepony.unicopia.item.group.MultiItem;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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 class ButterflyItem extends Item implements MultiItem {
|
||||||
|
|
||||||
public ButterflyItem(Settings settings) {
|
public ButterflyItem(Settings settings) {
|
||||||
super(settings);
|
super(settings.component(UDataComponentTypes.BUTTERFLY_VARIANT, new BufferflyVariantComponent(ButterflyEntity.Variant.BUTTERFLY, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDefaultStacks() {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
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.block.Block;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
@ -12,44 +9,42 @@ import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
|
||||||
public class EmptyJarItem extends BlockItem implements ItemImpl.GroundTickCallback {
|
public class EmptyJarItem extends BlockItem {
|
||||||
public EmptyJarItem(Block block, Settings settings) {
|
public EmptyJarItem(Block block, Settings settings) {
|
||||||
super(block, settings);
|
super(block, settings);
|
||||||
}
|
TickableItem.registerTickCallback(this, item -> {
|
||||||
|
ItemEntity entity = item.get().asEntity();
|
||||||
|
|
||||||
@Override
|
entity.setInvulnerable(true);
|
||||||
public ActionResult onGroundTick(IItemEntity item) {
|
|
||||||
ItemEntity entity = item.get().asEntity();
|
|
||||||
|
|
||||||
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.remove(RemovalReason.DISCARDED);
|
||||||
&& !entity.isRemoved()
|
entity.getWorld().spawnEntity(lightning);
|
||||||
&& 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);
|
ItemEntity neu = EntityType.ITEM.create(entity.getWorld());
|
||||||
entity.getWorld().spawnEntity(lightning);
|
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());
|
entity.getWorld().spawnEntity(neu);
|
||||||
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);
|
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());
|
entity.getWorld().spawnEntity(copy);
|
||||||
copy.copyPositionAndRotation(entity);
|
}
|
||||||
copy.setInvulnerable(true);
|
return ActionResult.PASS;
|
||||||
copy.setStack(entity.getStack());
|
});
|
||||||
copy.getStack().decrement(1);
|
|
||||||
|
|
||||||
entity.getWorld().spawnEntity(copy);
|
|
||||||
}
|
|
||||||
return ActionResult.PASS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
||||||
import com.minelittlepony.unicopia.entity.mob.UEntities;
|
import com.minelittlepony.unicopia.entity.mob.UEntities;
|
||||||
import com.minelittlepony.unicopia.item.component.Appearance;
|
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.item.component.UDataComponentTypes;
|
||||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||||
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
||||||
|
@ -80,10 +81,11 @@ public class FilledJarItem extends ProjectileItem implements ProjectileDelegate.
|
||||||
@Override
|
@Override
|
||||||
public void onImpact(MagicProjectileEntity projectile) {
|
public void onImpact(MagicProjectileEntity projectile) {
|
||||||
ItemStack stack = Appearance.upwrapAppearance(projectile.getStack());
|
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());
|
ButterflyEntity butterfly = UEntities.BUTTERFLY.create(projectile.getWorld());
|
||||||
butterfly.setVariant(ButterflyItem.getVariant(stack));
|
butterfly.setVariant(butterflyVariant.variant());
|
||||||
butterfly.updatePosition(projectile.getX(), projectile.getY(), projectile.getZ());
|
butterfly.updatePosition(projectile.getX(), projectile.getY(), projectile.getZ());
|
||||||
projectile.getWorld().spawnEntity(butterfly);
|
projectile.getWorld().spawnEntity(butterfly);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl;
|
import com.minelittlepony.unicopia.entity.ItemImpl.ClingyItem;
|
||||||
|
|
||||||
import net.minecraft.item.*;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||||
import com.minelittlepony.unicopia.container.SpellbookState;
|
import com.minelittlepony.unicopia.container.SpellbookState;
|
||||||
import com.minelittlepony.unicopia.diet.DietProfile;
|
import com.minelittlepony.unicopia.diet.DietProfile;
|
||||||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity;
|
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity;
|
||||||
import com.minelittlepony.unicopia.entity.mob.ButterflyEntity;
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.component.ComponentType;
|
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<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<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<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<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<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));
|
ComponentType<Charges> CHARGES = register("charges", builder -> builder.codec(Charges.CODEC).packetCodec(Charges.PACKET_CODEC));
|
||||||
|
|
|
@ -23,8 +23,8 @@ public interface ItemGroupRegistry {
|
||||||
Map<RegistryKey<ItemGroup>, Set<Item>> REGISTRY = new HashMap<>();
|
Map<RegistryKey<ItemGroup>, Set<Item>> REGISTRY = new HashMap<>();
|
||||||
|
|
||||||
static List<ItemStack> getVariations(Item item) {
|
static List<ItemStack> getVariations(Item item) {
|
||||||
if (item instanceof MultiItem) {
|
if (item instanceof MultiItem m) {
|
||||||
return ((MultiItem)item).getDefaultStacks();
|
return m.getDefaultStacks();
|
||||||
}
|
}
|
||||||
return List.of(item.getDefaultStack());
|
return List.of(item.getDefaultStack());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl.ClingyItem;
|
import com.minelittlepony.unicopia.item.ItemDuck;
|
||||||
|
import net.minecraft.entity.decoration.BlockAttachedEntity;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.decoration.AbstractDecorationEntity;
|
|
||||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
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)
|
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
||||||
private void beforeTick(CallbackInfo info) {
|
private void beforeTick(CallbackInfo info) {
|
||||||
final Object _this = this;
|
final Object _this = this;
|
||||||
if (_this instanceof ItemFrameEntity self) {
|
if (_this instanceof ItemFrameEntity self) {
|
||||||
ItemStack stack = self.getHeldItemStack();
|
ItemDuck.of(self.getHeldItemStack()).inFrameTick(self);
|
||||||
if (stack.getItem() instanceof ClingyItem item) {
|
|
||||||
item.inFrameTick(self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,13 @@ package com.minelittlepony.unicopia.mixin;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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 com.minelittlepony.unicopia.item.ItemDuck;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
@Mixin(Item.class)
|
@Mixin(Item.class)
|
||||||
abstract class MixinItem implements ItemDuck {
|
abstract class MixinItem implements ItemDuck {
|
||||||
private final List<ItemImpl.GroundTickCallback> tickCallbacks = new ArrayList<>();
|
private final List<GroundTickCallback> tickCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroundTickCallback> getCallbacks() {
|
public List<GroundTickCallback> getCallbacks() {
|
||||||
|
|
|
@ -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.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
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.DamageChecker;
|
||||||
import com.minelittlepony.unicopia.item.ItemStackDuck;
|
import com.minelittlepony.unicopia.item.ItemStackDuck;
|
||||||
import com.minelittlepony.unicopia.item.component.TransientComponentMap;
|
import com.minelittlepony.unicopia.item.component.TransientComponentMap;
|
||||||
|
|
||||||
|
import net.minecraft.component.ComponentHolder;
|
||||||
import net.minecraft.component.ComponentType;
|
import net.minecraft.component.ComponentType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
@ -46,7 +48,7 @@ abstract class MixinItemStack implements ItemStackDuck {
|
||||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||||
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
||||||
transientComponents.setCarrier(user);
|
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) {
|
if (result.getResult() != ActionResult.PASS) {
|
||||||
info.setReturnValue(result);
|
info.setReturnValue(result);
|
||||||
}
|
}
|
||||||
|
@ -57,12 +59,6 @@ abstract class MixinItemStack implements ItemStackDuck {
|
||||||
transientComponents.setCarrier(null);
|
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"))
|
@Inject(method = "finishUsing", at = @At("RETURN"))
|
||||||
private void afterFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
|
private void afterFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
|
||||||
transientComponents.setCarrier(null);
|
transientComponents.setCarrier(null);
|
||||||
|
@ -93,9 +89,12 @@ abstract class MixinItemStack implements ItemStackDuck {
|
||||||
info.setReturnValue(checker.takesDamageFrom(source));
|
info.setReturnValue(checker.takesDamageFrom(source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mixin(ComponentHolder.class)
|
||||||
|
interface MixinComponentHolder {
|
||||||
@Inject(method = "get", at = @At("RETURN"))
|
@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;
|
Object o = this;
|
||||||
if (o instanceof ItemStack stack) {
|
if (o instanceof ItemStack stack) {
|
||||||
info.setReturnValue(ItemStackDuck.of(stack).getTransientComponents().get(type, stack, info.getReturnValue()));
|
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"))
|
@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;
|
Object o = this;
|
||||||
if (o instanceof ItemStack stack) {
|
if (o instanceof ItemStack stack) {
|
||||||
info.setReturnValue(ItemStackDuck.of(stack).getTransientComponents().get(type, stack, info.getReturnValue()));
|
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"))
|
@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;
|
Object o = this;
|
||||||
if (o instanceof ItemStack stack && ItemStackDuck.of(stack).getTransientComponents().get(type, stack, null) != null) {
|
if (o instanceof ItemStack stack && ItemStackDuck.of(stack).getTransientComponents().get(type, stack, null) != null) {
|
||||||
info.setReturnValue(true);
|
info.setReturnValue(true);
|
||||||
|
|
|
@ -16,19 +16,21 @@ import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.LootableInventory;
|
import net.minecraft.inventory.LootableInventory;
|
||||||
|
import net.minecraft.loot.LootTable;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
@Mixin(LootableContainerBlockEntity.class)
|
@Mixin(LootableContainerBlockEntity.class)
|
||||||
abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockEntity implements MimicEntity.MimicGeneratable {
|
abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockEntity implements MimicEntity.MimicGeneratable {
|
||||||
private Identifier mimicLootTable;
|
@Nullable
|
||||||
|
private RegistryKey<LootTable> mimicLootTable;
|
||||||
private boolean allowMimics = true;
|
private boolean allowMimics = true;
|
||||||
private TriState isMimic = TriState.DEFAULT;
|
private TriState isMimic = TriState.DEFAULT;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Nullable
|
@Nullable
|
||||||
private Identifier lootTableId;
|
protected RegistryKey<LootTable> lootTable;
|
||||||
|
|
||||||
MixinLootableContainerBlockEntity() { super(null, null, null); }
|
MixinLootableContainerBlockEntity() { super(null, null, null); }
|
||||||
|
|
||||||
|
@ -46,8 +48,8 @@ abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureMimic(@Nullable PlayerEntity player) {
|
public void configureMimic(@Nullable PlayerEntity player) {
|
||||||
if (player != null && allowMimics && lootTableId != null) {
|
if (player != null && allowMimics && lootTable != null) {
|
||||||
mimicLootTable = lootTableId;
|
mimicLootTable = lootTable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.mixin;
|
package com.minelittlepony.unicopia.mixin;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.duck.PlayerEntityDuck;
|
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 com.mojang.datafixers.util.Either;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.component.type.FoodComponent;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
@ -53,9 +51,9 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
|
||||||
return get().modifyDamage(source, amount).orElse(amount);
|
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"))
|
@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 void onEatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
|
private FoodComponent onEatFood(FoodComponent initial, World world, ItemStack stack, FoodComponent food, CallbackInfoReturnable<ItemStack> info) {
|
||||||
get().onEat(stack);
|
return get().onEat(stack, food);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;",
|
@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"))
|
@ModifyReturnValue(method = "getBaseDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;", at = @At("RETURN"))
|
||||||
private EntityDimensions modifyEyeHeight(EntityDimensions dimensions, EntityPose pose) {
|
private EntityDimensions modifyEyeHeight(EntityDimensions dimensions, EntityPose pose) {
|
||||||
return get().getMotion().getDimensions().calculateActiveEyeHeight(dimensions).map(eyeHeight -> {
|
return get().getMotion().getDimensions().calculateDimensions(dimensions);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F",
|
@Inject(method = "getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F",
|
||||||
|
|
|
@ -2,35 +2,32 @@ package com.minelittlepony.unicopia.mixin.client;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
|
|
||||||
@Mixin(Camera.class)
|
@Mixin(Camera.class)
|
||||||
abstract class MixinCamera {
|
abstract class MixinCamera {
|
||||||
@ModifyVariable(method = "setRotation(FF)V",
|
@ModifyVariable(method = "setRotation",
|
||||||
at = @At("HEAD"),
|
at = @At("HEAD"),
|
||||||
ordinal = 0,
|
ordinal = 0,
|
||||||
argsOnly = true)
|
argsOnly = true)
|
||||||
private float modifyYaw(float yaw) {
|
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"),
|
at = @At("HEAD"),
|
||||||
ordinal = 1,
|
ordinal = 1,
|
||||||
argsOnly = true)
|
argsOnly = true)
|
||||||
private float modifyPitch(float pitch) {
|
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",
|
@ModifyReturnValue(method = "clipToSpace",
|
||||||
at = @At("RETURN"),
|
at = @At("RETURN"))
|
||||||
cancellable = true)
|
private float modifyCameraDistance(float initial) {
|
||||||
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
|
return UnicopiaClient.getCamera().calculateDistance(initial);
|
||||||
UnicopiaClient.getCamera().flatMap(c -> c.calculateDistance(info.getReturnValueD())).ifPresent(info::setReturnValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
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.BatEyesApplicator;
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
import com.minelittlepony.unicopia.client.render.shader.ViewportShader;
|
import com.minelittlepony.unicopia.client.render.shader.ViewportShader;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.Camera;
|
|
||||||
import net.minecraft.client.render.GameRenderer;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
|
||||||
import net.minecraft.resource.SynchronousResourceReloader;
|
import net.minecraft.resource.SynchronousResourceReloader;
|
||||||
|
|
||||||
@Mixin(value = GameRenderer.class, priority = Integer.MAX_VALUE)
|
@Mixin(value = GameRenderer.class, priority = Integer.MAX_VALUE)
|
||||||
|
@ -26,41 +25,33 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
|
||||||
@Shadow
|
@Shadow
|
||||||
private @Final MinecraftClient client;
|
private @Final MinecraftClient client;
|
||||||
|
|
||||||
@Inject(method = "getFov(Lnet/minecraft/client/render/Camera;FZ)D",
|
@ModifyReturnValue(method = "getFov", at = @At("RETURN"))
|
||||||
at = @At("RETURN"),
|
private double modifyFov(double initial) {
|
||||||
cancellable = true)
|
return UnicopiaClient.getCamera().calculateFieldOfView(initial);
|
||||||
private void onGetFov(Camera camera, float f, boolean z, CallbackInfoReturnable<Double> info) {
|
|
||||||
UnicopiaClient.getCamera().ifPresent(c -> info.setReturnValue(c.calculateFieldOfView(info.getReturnValue())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
|
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||||
at = @At("HEAD"))
|
private void beforeRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
||||||
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
|
||||||
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(c.calculateFirstPersonRoll())));
|
|
||||||
BatEyesApplicator.INSTANCE.enable();
|
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"))
|
at = @At("RETURN"))
|
||||||
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
private void afterRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
||||||
BatEyesApplicator.INSTANCE.disable();
|
BatEyesApplicator.INSTANCE.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
|
@ModifyReturnValue(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F", at = @At("RETURN"))
|
||||||
at = @At("HEAD"),
|
private static float modifyWorldBrightness(float initial, LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
|
||||||
cancellable = true)
|
return BatEyesApplicator.getWorldBrightness(initial, entity, tickDelta);
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "render",
|
@Inject(method = "render",
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.client.gui.HudEffects;
|
||||||
import com.minelittlepony.unicopia.client.gui.UHud;
|
import com.minelittlepony.unicopia.client.gui.UHud;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.hud.InGameHud;
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
@Mixin(InGameHud.class)
|
@Mixin(InGameHud.class)
|
||||||
|
@ -18,15 +19,15 @@ abstract class MixinInGameHud {
|
||||||
@Shadow
|
@Shadow
|
||||||
abstract PlayerEntity getCameraPlayer();
|
abstract PlayerEntity getCameraPlayer();
|
||||||
|
|
||||||
@Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("HEAD"))
|
@Inject(method = "render", at = @At("HEAD"))
|
||||||
private void onRender(DrawContext context, float tickDelta, CallbackInfo info) {
|
private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo info) {
|
||||||
HudEffects.tryApply(getCameraPlayer(), tickDelta, true);
|
HudEffects.tryApply(getCameraPlayer(), tickCounter, true);
|
||||||
UHud.INSTANCE.render((InGameHud)(Object)this, context, tickDelta);
|
UHud.INSTANCE.render((InGameHud)(Object)this, context, tickCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("RETURN"))
|
@Inject(method = "render", at = @At("RETURN"))
|
||||||
private void afterRender(DrawContext context, float tickDelta, CallbackInfo info) {
|
private void afterRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo info) {
|
||||||
HudEffects.tryApply(getCameraPlayer(), tickDelta, false);
|
HudEffects.tryApply(getCameraPlayer(), tickCounter, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ abstract class MixinModelPart implements Hookable {
|
||||||
isHeadPart = true;
|
isHeadPart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V", at = @At("HEAD"))
|
@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, float red, float green, float blue, float alpha, CallbackInfo info) {
|
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color, CallbackInfo info) {
|
||||||
if (visible && isHeadPart) {
|
if (visible && isHeadPart) {
|
||||||
ModelPartHooks.onHeadRendered((ModelPart)(Object)this, matrices);
|
ModelPartHooks.onHeadRendered((ModelPart)(Object)this, matrices);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ abstract class MixinMouse {
|
||||||
@Shadow
|
@Shadow
|
||||||
private double cursorDeltaY;
|
private double cursorDeltaY;
|
||||||
|
|
||||||
@Inject(method = "updateMouse()V", at = @At("HEAD"))
|
@Inject(method = "updateMouse(D)V", at = @At("HEAD"))
|
||||||
private void onUpdateMouse(CallbackInfo info) {
|
private void onUpdateMouse(double tickDelta, CallbackInfo info) {
|
||||||
Pony player = Pony.of(MinecraftClient.getInstance().player);
|
Pony player = Pony.of(MinecraftClient.getInstance().player);
|
||||||
if (player != null && player.getPhysics().isGravityNegative()) {
|
if (player != null && player.getPhysics().isGravityNegative()) {
|
||||||
cursorDeltaX = -cursorDeltaX;
|
cursorDeltaX = -cursorDeltaX;
|
||||||
|
|
|
@ -13,6 +13,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
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.ClientBlockDestructionManager;
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
import com.minelittlepony.unicopia.server.world.WeatherAccess;
|
import com.minelittlepony.unicopia.server.world.WeatherAccess;
|
||||||
|
@ -50,16 +52,10 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
|
||||||
@Accessor("ticks")
|
@Accessor("ticks")
|
||||||
public abstract int getTicks();
|
public abstract int getTicks();
|
||||||
|
|
||||||
@Redirect(method = "render("
|
@Redirect(method = "render", at = @At(
|
||||||
+ "Lnet/minecraft/client/util/math/MatrixStack;"
|
value = "FIELD",
|
||||||
+ "FJZ"
|
target = "Lnet/minecraft/client/render/WorldRenderer;blockBreakingProgressions:Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;"
|
||||||
+ "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;")
|
|
||||||
)
|
|
||||||
private Long2ObjectMap<SortedSet<BlockBreakingInfo>> redirectGetDamagesMap(WorldRenderer sender) {
|
private Long2ObjectMap<SortedSet<BlockBreakingInfo>> redirectGetDamagesMap(WorldRenderer sender) {
|
||||||
return destructions.getCombinedDestructions(blockBreakingProgressions);
|
return destructions.getCombinedDestructions(blockBreakingProgressions);
|
||||||
}
|
}
|
||||||
|
@ -69,24 +65,21 @@ abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCl
|
||||||
destructions.tick(blockBreakingProgressions);
|
destructions.tick(blockBreakingProgressions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderSky("
|
@Inject(method = "renderSky", at = @At(
|
||||||
+ "Lnet/minecraft/client/util/math/MatrixStack;"
|
value = "INVOKE",
|
||||||
+ "Lorg/joml/Matrix4f;"
|
target = "net/minecraft/client/world/ClientWorld.getSkyAngle(F)F",
|
||||||
+ "F"
|
ordinal = 1
|
||||||
+ "Lnet/minecraft/client/render/Camera;"
|
))
|
||||||
+ "Z"
|
private void onRenderSky(Matrix4f matrix4f, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback,
|
||||||
+ "Ljava/lang/Runnable;"
|
CallbackInfo info, @Local LocalRef<MatrixStack> matrices) {
|
||||||
+ ")V", at = @At(
|
matrices.get().multiply(RotationAxis.POSITIVE_X.rotationDegrees(UnicopiaClient.getInstance().getSkyAngleDelta(tickDelta)));
|
||||||
value = "INVOKE",
|
matrices.get().multiply(RotationAxis.POSITIVE_Y.rotationDegrees(UnicopiaClient.getInstance().tangentalSkyAngle.getValue()));
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
private Biome.Precipitation modifyPrecipitation(Biome biome, BlockPos pos) {
|
||||||
Biome.Precipitation precipitation = biome.getPrecipitation(pos);
|
Biome.Precipitation precipitation = biome.getPrecipitation(pos);
|
||||||
if (!((WeatherAccess)world).isBelowClientCloudLayer(pos)) {
|
if (!((WeatherAccess)world).isBelowClientCloudLayer(pos)) {
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
package com.minelittlepony.unicopia.mixin.datafix;
|
package com.minelittlepony.unicopia.mixin.datafix;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
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.DataFixerBuilder;
|
||||||
import com.mojang.datafixers.schemas.Schema;
|
import com.mojang.datafixers.schemas.Schema;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
|
||||||
|
|
||||||
@Mixin(value = DataFixerBuilder.class, remap = false)
|
@Mixin(value = DataFixerBuilder.class, remap = false)
|
||||||
public interface DataFixerBuilderAccessor {
|
public interface DataFixerBuilderAccessor extends SchemasStore {
|
||||||
|
@Override
|
||||||
@Accessor
|
@Accessor
|
||||||
Int2ObjectSortedMap<Schema> getSchemas();
|
Int2ObjectSortedMap<Schema> getSchemas();
|
||||||
|
|
||||||
@Nullable
|
|
||||||
default Schema getSchema(final int version, final int subVersion) {
|
|
||||||
return getSchemas().get(DataFixUtils.makeKey(version, subVersion));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"MixinBlockItem",
|
"MixinBlockItem",
|
||||||
"MixinBoatEntity",
|
"MixinBoatEntity",
|
||||||
"MixinChunkBlockLightProvider",
|
"MixinChunkBlockLightProvider",
|
||||||
|
"MixinComponentHolder",
|
||||||
"MutableBlockLightStorage",
|
"MutableBlockLightStorage",
|
||||||
"MixinDamageSource",
|
"MixinDamageSource",
|
||||||
"MixinEnchantment",
|
"MixinEnchantment",
|
||||||
|
|
Loading…
Reference in a new issue