Move Elytra API to BCLib

This commit is contained in:
Frank 2022-06-10 15:10:45 +02:00
parent 3cecb7dd8c
commit 36b75ed25f
5 changed files with 8 additions and 32 deletions

View file

@ -1,6 +1,6 @@
package org.betterx.betterend.client.render; package org.betterx.betterend.client.render;
import org.betterx.betterend.interfaces.BetterEndElytra; import org.betterx.bclib.items.elytra.BCLElytraItem;
import org.betterx.betterend.item.model.ArmoredElytraModel; import org.betterx.betterend.item.model.ArmoredElytraModel;
import org.betterx.betterend.registry.EndEntitiesRenders; import org.betterx.betterend.registry.EndEntitiesRenders;
@ -42,8 +42,8 @@ public class ArmoredElytraLayer<T extends LivingEntity, M extends EntityModel<T>
float l float l
) { ) {
ItemStack itemStack = livingEntity.getItemBySlot(EquipmentSlot.CHEST); ItemStack itemStack = livingEntity.getItemBySlot(EquipmentSlot.CHEST);
if (itemStack.getItem() instanceof BetterEndElytra) { if (itemStack.getItem() instanceof BCLElytraItem) {
ResourceLocation wingsTexture = ((BetterEndElytra) itemStack.getItem()).getModelTexture(); ResourceLocation wingsTexture = ((BCLElytraItem) itemStack.getItem()).getModelTexture();
if (livingEntity instanceof AbstractClientPlayer) { if (livingEntity instanceof AbstractClientPlayer) {
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) livingEntity; AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) livingEntity;
if (abstractClientPlayer.isElytraLoaded() && abstractClientPlayer.getElytraTextureLocation() != null) { if (abstractClientPlayer.isElytraLoaded() && abstractClientPlayer.getElytraTextureLocation() != null) {

View file

@ -1,9 +1,9 @@
package org.betterx.betterend.interfaces; package org.betterx.betterend.interfaces;
import org.betterx.bclib.items.elytra.BCLElytraItem;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
public interface BetterEndElytra { public interface BetterEndElytra extends BCLElytraItem {
ResourceLocation getModelTexture(); ResourceLocation getModelTexture();
double getMovementFactor();
} }

View file

@ -14,10 +14,9 @@ import net.minecraft.world.item.*;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
public class ArmoredElytra extends BaseArmorItem implements MultiModelItem, BetterEndElytra, FabricElytraItem { public class ArmoredElytra extends BaseArmorItem implements MultiModelItem, BetterEndElytra {
private final ResourceLocation wingTexture; private final ResourceLocation wingTexture;
private final Item repairItem; private final Item repairItem;
private final double movementFactor; private final double movementFactor;

View file

@ -15,10 +15,9 @@ import net.minecraft.world.item.Rarity;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
public class CrystaliteElytra extends CrystaliteArmor implements MultiModelItem, BetterEndElytra, FabricElytraItem { public class CrystaliteElytra extends CrystaliteArmor implements MultiModelItem, BetterEndElytra {
private final ResourceLocation wingTexture; private final ResourceLocation wingTexture;
private final double movementFactor; private final double movementFactor;

View file

@ -1,7 +1,6 @@
package org.betterx.betterend.mixin.common; package org.betterx.betterend.mixin.common;
import org.betterx.betterend.BetterEnd; import org.betterx.betterend.BetterEnd;
import org.betterx.betterend.interfaces.BetterEndElytra;
import org.betterx.betterend.interfaces.MobEffectApplier; import org.betterx.betterend.interfaces.MobEffectApplier;
import org.betterx.betterend.item.CrystaliteArmor; import org.betterx.betterend.item.CrystaliteArmor;
import org.betterx.betterend.registry.EndAttributes; import org.betterx.betterend.registry.EndAttributes;
@ -18,16 +17,13 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
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.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
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;
@ -40,9 +36,6 @@ public abstract class LivingEntityMixin extends Entity {
super(entityType, level); super(entityType, level);
} }
@Shadow
public abstract ItemStack getItemBySlot(EquipmentSlot equipmentSlot);
@Shadow @Shadow
public abstract AttributeMap getAttributes(); public abstract AttributeMap getAttributes();
@ -94,21 +87,6 @@ public abstract class LivingEntityMixin extends Entity {
return value; return value;
} }
@ModifyArg(
method = "travel",
slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isFallFlying()Z"),
to = @At(value = "INVOKE:LAST", target = "Lnet/minecraft/world/entity/LivingEntity;setSharedFlag(IZ)V")
),
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")
)
public Vec3 be_travel(Vec3 moveDelta) {
ItemStack itemStack = getItemBySlot(EquipmentSlot.CHEST);
double movementFactor = ((BetterEndElytra) itemStack.getItem()).getMovementFactor();
moveDelta = moveDelta.multiply(movementFactor, 1.0D, movementFactor);
return moveDelta;
}
private double be_getKnockback(Item tool) { private double be_getKnockback(Item tool) {
if (tool == null) return 0.0D; if (tool == null) return 0.0D;
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND) Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND)