Paste: 相关代码
Author: | 通哥 |
Mode: | java |
Date: | Mon, 17 Jan 2022 13:06:24 |
Plain Text |
package bruce.ehutils.mixins;
import org.spongepowered.asm.mixin.*;
import bruce.ehutils.api.IElytra;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemElytra;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
@Mixin(EntityLivingBase.class)
public abstract class MixinEntityLivingBase extends Entity
{
@Shadow
private int ticksElytraFlying;
private MixinEntityLivingBase(World worldIn)
{
super(worldIn);
}
@Overwrite
private void updateElytra()
{
boolean flag = this.getFlag(7);
if (flag && !this.onGround && !this.isRiding())
{
ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
boolean isElytraAvailable = false;
if (!isElytraAvailable && itemstack.getItem() instanceof IElytra)
{
IElytra elytra = (IElytra) itemstack.getItem();
if (elytra.isUsableBy(((EntityLivingBase) (Object) this), itemstack))
{
if (!this.world.isRemote && (this.ticksElytraFlying + 1) % 20 == 0)
{
elytra.doDamage(itemstack, 1, ((EntityLivingBase) (Object) this));
}
}
else
{
flag = false;
}
} else
{
flag = false;
}
} else
{
flag = false;
}
if (!this.world.isRemote)
{
this.setFlag(7, flag);
}
}
@Shadow
protected abstract ItemStack getItemStackFromSlot(EntityEquipmentSlot chest);
}
New Annotation