Add missing shear and elytra game events (#8471)

This commit is contained in:
Sara Freimer authored and GitHub committed 2022-02-22 14:24:14 -08:00
1 parent 117be913da
commit e225dbc8d1
5 files changed
+27 -9

No files matched your search

@@ -30,6 +30,7 @@ import net.minecraft.client.model.PlayerModel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.IEventBus;
@@ -103,10 +104,18 @@ public class CustomElytraTest
@Override
public boolean elytraFlightTick(ItemStack stack, LivingEntity entity, int flightTicks)
{
//Adding 1 to ticksElytraFlying prevents damage on the very first tick.
if (!entity.level.isClientSide && (flightTicks + 1) % 20 == 0)
if (!entity.level.isClientSide)
{
stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(EquipmentSlot.CHEST));
//Adding 1 to flightTicks prevents damage on the very first tick.
int nextFlightTick = flightTicks + 1;
if (nextFlightTick % 10 == 0)
{
if (nextFlightTick % 20 == 0)
{
stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(EquipmentSlot.CHEST));
}
entity.gameEvent(GameEvent.ELYTRA_FREE_FALL);
}
}
return true;
}