Skip to content

Commit

Permalink
Fix mixin compatibility with TrickOrTreatMod (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jan 20, 2024
1 parent 0be5502 commit efc0d1c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.izzel.arclight.common.mixin.core.world.entity.projectile;

import io.izzel.arclight.common.bridge.bukkit.EntityTypeBridge;
import io.izzel.arclight.common.bridge.core.entity.EntityBridge;
import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.core.world.WorldBridge;
Expand All @@ -10,7 +11,6 @@
import net.minecraft.world.entity.projectile.ThrownEgg;
import net.minecraft.world.phys.HitResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Egg;
import org.bukkit.event.entity.CreatureSpawnEvent;
Expand Down Expand Up @@ -48,7 +48,10 @@ protected void onHit(final HitResult result) {
}
if (hatching) {
for (int i = 0; i < b0; ++i) {
Entity entity = ((WorldBridge) this.level()).bridge$getWorld().createEntity(new Location(((WorldBridge) this.level()).bridge$getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0f), hatchingType.getEntityClass());
// TrickOrTreatMod compat https://github.com/IzzelAliz/Arclight/issues/1178
// https://github.com/MehVahdJukaar/TrickOrTreatMod/blob/020bc478b8f8de6bfec2191a9e667f423f45d7db/common/src/main/java/net/mehvahdjukaar/hauntedharvest/mixins/ThrownEggEntityMixin.java
var entityType = ((EntityTypeBridge) (Object) hatchingType).bridge$getHandle();
var entity = entityType.create(this.level());
// Let's do: Meadow mixin compatibility https://github.com/IzzelAliz/Arclight/issues/1149
if (entity instanceof Chicken) {
Chicken chicken = (Chicken) entity;
Expand All @@ -58,6 +61,7 @@ protected void onHit(final HitResult result) {
if (((EntityBridge) entity).bridge$getBukkitEntity() instanceof Ageable) {
((Ageable) ((EntityBridge) entity).bridge$getBukkitEntity()).setBaby();
}
entity.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG);
this.level().addFreshEntity(entity);
}
Expand Down

0 comments on commit efc0d1c

Please sign in to comment.