1.16: entities part 2

This commit is contained in:
IzzelAliz 2020-08-23 21:04:51 +08:00
parent f651ff8e7b
commit 1263cf11ea
27 changed files with 346 additions and 237 deletions

View File

@ -13,6 +13,8 @@ public interface MobEntityBridge extends LivingEntityBridge {
boolean bridge$setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent);
boolean bridge$lastGoalTargetResult();
ResourceLocation bridge$getLootTable();
boolean bridge$isPersistenceRequired();

View File

@ -1,34 +1,29 @@
package io.izzel.arclight.common.mixin.core.entity;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import org.bukkit.event.entity.CreatureSpawnEvent;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import javax.annotation.Nullable;
@Mixin(AgeableEntity.class)
public abstract class AgeableEntityMixin extends CreatureEntityMixin {
// @formatter:off
@Shadow public abstract boolean isChild();
@Shadow @Nullable public abstract AgeableEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_);
@Shadow public abstract void setGrowingAge(int age);
// @formatter:on
public boolean ageLocked;
@Inject(method = "processInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$spawnReason(PlayerEntity player, Hand hand, CallbackInfoReturnable<Boolean> cir) {
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
}
@Inject(method = "writeAdditional", at = @At("RETURN"))
private void arclight$writeAgeLocked(CompoundNBT compound, CallbackInfo ci) {
compound.putBoolean("AgeLocked", ageLocked);

View File

@ -27,7 +27,6 @@ import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import javax.annotation.Nullable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -80,9 +79,9 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
int k = j >> 16 & 255;
int l = j >> 8 & 255;
int i1 = j & 255;
this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, (float) k / 255.0F, (float) l / 255.0F, (float) i1 / 255.0F);
this.world.addOptionalParticle(iparticledata, this.getPosX() + (double) f3, this.getPosY(), this.getPosZ() + (double) f4, (float) k / 255.0F, (float) l / 255.0F, (float) i1 / 255.0F);
} else {
this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, 0.0D, 0.0D, 0.0D);
this.world.addOptionalParticle(iparticledata, this.getPosX() + (double) f3, this.getPosY(), this.getPosZ() + (double) f4, 0.0D, 0.0D, 0.0D);
}
}
}
@ -99,9 +98,9 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
int i2 = l1 >> 16 & 255;
int j2 = l1 >> 8 & 255;
int j1 = l1 & 255;
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (float) i2 / 255.0F, (float) j2 / 255.0F, (float) j1 / 255.0F);
this.world.addOptionalParticle(iparticledata, this.getPosX() + (double) f8, this.getPosY(), this.getPosZ() + (double) f9, (float) i2 / 255.0F, (float) j2 / 255.0F, (float) j1 / 255.0F);
} else {
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D);
this.world.addOptionalParticle(iparticledata, this.getPosX() + (double) f8, this.getPosY(), this.getPosZ() + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D);
}
}
}
@ -131,14 +130,8 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
}
if (this.ticksExisted % 5 == 0) {
Iterator<Map.Entry<Entity, Integer>> iterator = this.reapplicationDelayMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Entity, Integer> entry = iterator.next();
if (this.ticksExisted >= entry.getValue()) {
iterator.remove();
}
}
this.reapplicationDelayMap.entrySet().removeIf(entry -> this.ticksExisted >= entry.getValue());
List<EffectInstance> effects = Lists.newArrayList();
@ -155,8 +148,8 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
List<LivingEntity> entities = new java.util.ArrayList<>();
for (LivingEntity livingentity : list) {
if (!this.reapplicationDelayMap.containsKey(livingentity) && livingentity.canBeHitWithPotion()) {
double d0 = livingentity.posX - this.posX;
double d1 = livingentity.posZ - this.posZ;
double d0 = livingentity.getPosX() - this.getPosX();
double d1 = livingentity.getPosZ() - this.getPosZ();
double d2 = d0 * d0 + d1 * d1;
if (d2 <= (double) (f * f)) {
entities.add(livingentity);

View File

@ -0,0 +1,42 @@
package io.izzel.arclight.common.mixin.core.entity;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import net.minecraft.entity.IAngerable;
import net.minecraft.entity.LivingEntity;
import org.bukkit.event.entity.EntityTargetEvent;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.UUID;
@Mixin(IAngerable.class)
public interface IAngerableMixin extends MobEntityBridge {
// @formatter:off
@Shadow void setRevengeTarget(@Nullable LivingEntity livingBase);
@Shadow void setAngerTarget(@Nullable UUID target);
@Shadow void setAttackTarget(@Nullable LivingEntity entitylivingbaseIn);
@Shadow void setAngerTime(int time);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
default void func_241356_K__() {
this.setRevengeTarget(null);
this.setAngerTarget(null);
this.bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.FORGOT_TARGET, true);
this.setAttackTarget(null);
this.setAngerTime(0);
}
default boolean setGoalTarget(LivingEntity livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
this.bridge$pushGoalTargetReason(reason, fireEvent);
this.setAttackTarget(livingEntity);
return this.bridge$lastGoalTargetResult();
}
}

View File

@ -45,7 +45,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import javax.annotation.Nullable;
import java.util.concurrent.atomic.AtomicBoolean;
@Mixin(MobEntity.class)
@Implements(@Interface(iface = MobEntityBridge.Hack.class, prefix = "hack$"))
@ -100,7 +99,7 @@ public abstract class MobEntityMixin extends LivingEntityMixin implements MobEnt
this.aware = true;
}
protected transient AtomicBoolean arclight$targetSuccess;
protected transient boolean arclight$targetSuccess = false;
private transient EntityTargetEvent.TargetReason arclight$reason;
private transient boolean arclight$fireEvent;
@ -128,7 +127,7 @@ public abstract class MobEntityMixin extends LivingEntityMixin implements MobEnt
final EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
if (arclight$targetSuccess != null) arclight$targetSuccess.set(false);
arclight$targetSuccess = false;
return;
}
if (event.getTarget() != null) {
@ -139,7 +138,7 @@ public abstract class MobEntityMixin extends LivingEntityMixin implements MobEnt
}
this.attackTarget = livingEntity;
ForgeHooks.onLivingSetAttackTarget((MobEntity) (Object) this, this.attackTarget);
if (arclight$targetSuccess != null) arclight$targetSuccess.set(true);
arclight$targetSuccess = true;
}
public boolean setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
@ -147,14 +146,16 @@ public abstract class MobEntityMixin extends LivingEntityMixin implements MobEnt
if (getAttackTarget() == livingEntity) {
return false;
} else {
arclight$targetSuccess = new AtomicBoolean();
setAttackTarget(livingEntity);
boolean ret = arclight$targetSuccess.get();
arclight$targetSuccess = null;
return ret;
return arclight$targetSuccess;
}
}
@Override
public boolean bridge$lastGoalTargetResult() {
return arclight$targetSuccess;
}
@Override
public boolean bridge$setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
return setGoalTarget(livingEntity, reason, fireEvent);

View File

@ -8,16 +8,16 @@ import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.boss.dragon.phase.IPhase;
import net.minecraft.entity.boss.dragon.phase.PhaseType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.Explosion;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.entity.EntityExplodeEvent;
@ -35,9 +35,9 @@ public abstract class EnderDragonEntityMixin extends MobEntityMixin {
private Explosion explosionSource = new Explosion(null, (EnderDragonEntity) (Object) this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Mode.DESTROY);
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/boss/dragon/phase/IPhase;getTargetLocation()Lnet/minecraft/util/math/Vec3d;"))
private Vec3d arclight$noMoveHovering(IPhase phase) {
Vec3d vec3d = phase.getTargetLocation();
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/boss/dragon/phase/IPhase;getTargetLocation()Lnet/minecraft/util/math/vector/Vector3d;"))
private Vector3d arclight$noMoveHovering(IPhase phase) {
Vector3d vec3d = phase.getTargetLocation();
return vec3d != null && phase.getType() != PhaseType.HOVER ? vec3d : null;
}
@ -106,12 +106,12 @@ public abstract class EnderDragonEntityMixin extends MobEntityMixin {
final BlockPos blockposition2 = craftBlock.getPosition();
final net.minecraft.block.Block nmsBlock = craftBlock.getNMS().getBlock();
if (nmsBlock.canDropFromExplosion(this.explosionSource)) {
final TileEntity tileentity = nmsBlock.hasTileEntity() ? this.world.getTileEntity(blockposition2) : null;
final LootContext.Builder loottableinfo_builder = new LootContext.Builder((ServerWorld) this.world).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockposition2).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withParameter(LootParameters.EXPLOSION_RADIUS, 1.0f / event.getYield()).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
TileEntity tileentity = nmsBlock.hasTileEntity(craftBlock.getNMS()) ? this.world.getTileEntity(blockposition2) : null;
LootContext.Builder loottableinfo_builder = new LootContext.Builder((ServerWorld)this.world).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockposition2)).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withParameter(LootParameters.EXPLOSION_RADIUS, 1.0f / event.getYield()).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
for (ItemStack stack : craftBlock.getNMS().getDrops(loottableinfo_builder)) {
Block.spawnAsEntity(this.world, blockposition2, stack);
}
craftBlock.getNMS().spawnAdditionalDrops(this.world, blockposition2, ItemStack.EMPTY);
craftBlock.getNMS().spawnAdditionalDrops((ServerWorld) this.world, blockposition2, ItemStack.EMPTY);
// net.minecraft.block.Block.spawnDrops(craftBlock.getNMS(), loottableinfo_builder);
}
nmsBlock.onExplosionDestroy(this.world, blockposition2, this.explosionSource);

View File

@ -79,12 +79,12 @@ public abstract class ArmorStandEntityMixin extends LivingEntityMixin {
arclight$callEntityDeath();
}
@Inject(method = "func_213817_e", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/ArmorStandEntity;remove()V"))
@Inject(method = "damageArmorStand", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/ArmorStandEntity;remove()V"))
private void arclight$deathEvent2(DamageSource p_213817_1_, float p_213817_2_, CallbackInfo ci) {
arclight$callEntityDeath();
}
@Redirect(method = "func_213815_f", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;spawnAsEntity(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)V"))
@Redirect(method = "func_213816_g", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;spawnAsEntity(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)V"))
private void arclight$captureDrops1(World worldIn, BlockPos pos, ItemStack stack) {
arclight$tryCaptureDrops(worldIn, pos, stack);
}
@ -122,7 +122,10 @@ public abstract class ArmorStandEntityMixin extends LivingEntityMixin {
private Collection<ItemEntity> arclight$drops() {
Collection<ItemEntity> drops = this.captureDrops();
return drops == null ? this.captureDrops(new ArrayList<>()) : drops;
if (drops == null) {
this.captureDrops(new ArrayList<>());
}
return this.captureDrops();
}
private void arclight$callEntityDeath() {
@ -138,7 +141,7 @@ public abstract class ArmorStandEntityMixin extends LivingEntityMixin {
CraftEventFactory.callEntityDeathEvent((ArmorStandEntity) (Object) this, drops);
}
@Inject(method = "func_226529_a_", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
@Inject(method = "equipOrSwap", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
public void arclight$manipulateEvent(PlayerEntity playerEntity, EquipmentSlotType slotType, ItemStack itemStack, Hand hand, CallbackInfoReturnable<Boolean> cir) {
ItemStack itemStack1 = this.getItemStackFromSlot(slotType);

View File

@ -49,7 +49,7 @@ public abstract class BoatEntityMixin extends EntityMixin {
}
}
@Inject(method = "attackEntityFrom", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/BoatEntity;getDamageTaken()F"))
@Inject(method = "attackEntityFrom", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/entity/item/BoatEntity;getDamageTaken()F"))
private void arclight$destroyVehicle(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (this.getDamageTaken() > 40.0F) {
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@ -80,7 +80,7 @@ public abstract class BoatEntityMixin extends EntityMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/BoatEntity;updateRocking()V"))
private void arclight$updateVehicle(CallbackInfo ci) {
final org.bukkit.World bworld = ((WorldBridge) this.world).bridge$getWorld();
final Location to = new Location(bworld, this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
final Location to = new Location(bworld, this.getPosX(), this.getPosY(), this.getPosZ(), this.rotationYaw, this.rotationPitch);
final Vehicle vehicle = (Vehicle) this.getBukkitEntity();
Bukkit.getPluginManager().callEvent(new VehicleUpdateEvent(vehicle));
if (this.lastLocation != null && !this.lastLocation.equals(to)) {

View File

@ -12,7 +12,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.IndirectEntityDamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import org.bukkit.Bukkit;
import org.bukkit.entity.Hanging;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
@ -33,7 +33,7 @@ public abstract class HangingEntityMixin extends EntityMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/HangingEntity;remove()V"))
private void arclight$hangingBreak(CallbackInfo ci) {
Material material = this.world.getBlockState(new BlockPos((HangingEntity) (Object) this)).getMaterial();
Material material = this.world.getBlockState(new BlockPos(this.getPosition())).getMaterial();
HangingBreakEvent.RemoveCause cause;
if (!material.equals(Material.AIR)) {
cause = HangingBreakEvent.RemoveCause.OBSTRUCTION;
@ -63,7 +63,7 @@ public abstract class HangingEntityMixin extends EntityMixin {
}
@Inject(method = "move", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/HangingEntity;remove()V"))
private void arclight$hangingBreakByMove(MoverType typeIn, Vec3d pos, CallbackInfo ci) {
private void arclight$hangingBreakByMove(MoverType typeIn, Vector3d pos, CallbackInfo ci) {
if (this.removed) {
ci.cancel();
return;
@ -98,9 +98,7 @@ public abstract class HangingEntityMixin extends EntityMixin {
d0 += d5 * enumdirection.getXOffset();
d3 += d5 * enumdirection.getZOffset();
if (entity != null) {
entity.posX = d0;
entity.posY = d2;
entity.posZ = d3;
entity.setRawPosition(d0, d2, d3);
}
double d7 = width;
double d8 = height;

View File

@ -9,6 +9,7 @@ import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.potion.EffectInstance;
import net.minecraft.world.Explosion;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.event.ForgeEventFactory;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
@ -36,8 +37,8 @@ public abstract class CreeperEntityMixin extends CreatureEntityMixin implements
@Shadow private int timeSinceIgnited;
// @formatter:on
@Inject(method = "onStruckByLightning", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/monster/CreeperEntity;dataManager:Lnet/minecraft/network/datasync/EntityDataManager;"))
private void arclight$lightningBolt(LightningBoltEntity lightningBolt, CallbackInfo ci) {
@Inject(method = "func_241841_a", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/monster/CreeperEntity;dataManager:Lnet/minecraft/network/datasync/EntityDataManager;"))
private void arclight$lightningBolt(ServerWorld world, LightningBoltEntity lightningBolt, CallbackInfo ci) {
if (CraftEventFactory.callCreeperPowerEvent((CreeperEntity) (Object) this, lightningBolt, CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
ci.cancel();
}
@ -56,7 +57,7 @@ public abstract class CreeperEntityMixin extends CreatureEntityMixin implements
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.dead = true;
this.world.createExplosion((CreeperEntity) (Object) this, this.posX, this.posY, this.posZ, event.getRadius(), event.getFire(), explosion_effect);
this.world.createExplosion((CreeperEntity) (Object) this, this.getPosX(), this.getPosY(), this.getPosZ(), event.getRadius(), event.getFire(), explosion_effect);
this.remove();
this.spawnLingeringCloud();
} else {

View File

@ -23,7 +23,7 @@ public class EndermanEntity_PlaceBlockGoalMixin {
// @formatter:on
@Inject(method = "tick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$entityChangeBlock(CallbackInfo ci, Random random, IWorld world, int i, int j, int k, BlockPos blockPos, BlockState blockState, BlockPos blockPos1, BlockState blockState1, BlockState blockState2) {
if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockPos, blockState2).isCancelled()) {
ci.cancel();

View File

@ -1,12 +1,27 @@
package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.passive.AnimalEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.mixin.core.entity.AgeableEntityMixin;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.world.GameRules;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityEnterLoveModeEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@ -14,11 +29,16 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
@Mixin(AnimalEntity.class)
public abstract class AnimalEntityMixin extends AgeableEntityMixin implements AnimalEntityBridge {
// @formatter:off
@Shadow public boolean processInteract(PlayerEntity player, Hand hand) { return false; }
@Shadow public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { return null; }
@Shadow public int inLove;
@Shadow public abstract void resetInLove();
@Shadow @Nullable public abstract ServerPlayerEntity getLoveCause();
// @formatter:on
public ItemStack breedItem;
@ -32,8 +52,21 @@ public abstract class AnimalEntityMixin extends AgeableEntityMixin implements An
return super.attackEntityFrom(source, amount);
}
@Inject(method = "setInLove(Lnet/minecraft/entity/player/PlayerEntity;)V", at = @At("HEAD"))
private void arclight$setBreedItem(PlayerEntity player, CallbackInfo ci) {
@Inject(method = "setInLove(Lnet/minecraft/entity/player/PlayerEntity;)V", cancellable = true, at = @At("HEAD"))
private void arclight$enterLove(PlayerEntity player, CallbackInfo ci) {
EntityEnterLoveModeEvent event = CraftEventFactory.callEntityEnterLoveModeEvent(player, (AnimalEntity) (Object) this, 600);
if (event.isCancelled()) {
ci.cancel();
} else {
arclight$loveTime = event.getTicksInLove();
}
}
private transient int arclight$loveTime;
@Inject(method = "setInLove(Lnet/minecraft/entity/player/PlayerEntity;)V", at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/passive/AnimalEntity;inLove:I"))
private void arclight$inLove(PlayerEntity player, CallbackInfo ci) {
this.inLove = arclight$loveTime;
if (player != null) {
this.breedItem = player.inventory.getCurrentItem();
}
@ -43,4 +76,59 @@ public abstract class AnimalEntityMixin extends AgeableEntityMixin implements An
public ItemStack bridge$getBreedItem() {
return breedItem;
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void func_234177_a_(ServerWorld world, AnimalEntity animalEntity) {
AgeableEntity child = this.func_241840_a(world, animalEntity);
final BabyEntitySpawnEvent event = new BabyEntitySpawnEvent((AnimalEntity) (Object) this, animalEntity, child);
final boolean cancelled = MinecraftForge.EVENT_BUS.post(event);
child = event.getChild();
if (cancelled) {
//Reset the "inLove" state for the animals
this.setGrowingAge(6000);
animalEntity.setGrowingAge(6000);
this.resetInLove();
animalEntity.resetInLove();
return;
}
if (child != null) {
if (child instanceof TameableEntity && ((TameableEntity) child).isTamed()) {
child.persistenceRequired = true;
}
ServerPlayerEntity serverplayerentity = this.getLoveCause();
if (serverplayerentity == null && animalEntity.getLoveCause() != null) {
serverplayerentity = animalEntity.getLoveCause();
}
int experience = this.getRNG().nextInt(7) + 1;
org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = CraftEventFactory.callEntityBreedEvent(child, (AnimalEntity) (Object) this, animalEntity, serverplayerentity, this.breedItem, experience);
if (entityBreedEvent.isCancelled()) {
return;
}
experience = entityBreedEvent.getExperience();
if (serverplayerentity != null) {
serverplayerentity.addStat(Stats.ANIMALS_BRED);
CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity, (AnimalEntity) (Object) this, animalEntity, child);
}
this.setGrowingAge(6000);
animalEntity.setGrowingAge(6000);
this.resetInLove();
animalEntity.resetInLove();
child.setChild(true);
child.setLocationAndAngles(this.getPosX(), this.getPosY(), this.getPosZ(), 0.0F, 0.0F);
((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING);
world.func_242417_l(child);
world.setEntityState((AnimalEntity) (Object) this, (byte) 18);
if (world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
world.addEntity(new ExperienceOrbEntity(world, this.getPosX(), this.getPosY(), this.getPosZ(), experience));
}
}
}
}

View File

@ -4,6 +4,7 @@ import io.izzel.arclight.common.mixin.core.entity.MobEntityMixin;
import net.minecraft.entity.passive.BatEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -11,15 +12,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(BatEntity.class)
public abstract class BatEntityMixin extends MobEntityMixin {
private transient boolean arclight$muteFirst;
// @formatter:off
@Shadow public abstract boolean getIsBatHanging();
// @formatter:on
@Inject(method = "setIsBatHanging", cancellable = true, at = @At("HEAD"))
public void arclight$toggleSleep(boolean isHanging, CallbackInfo ci) {
if (!arclight$muteFirst) {
arclight$muteFirst = true;
return;
}
if (!CraftEventFactory.handleBatToggleSleepEvent((BatEntity) (Object) this, !isHanging)) {
@Inject(method = "updateAITasks", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/BatEntity;setIsBatHanging(Z)V"))
private void arclight$toggleSleep(CallbackInfo ci) {
if (!CraftEventFactory.handleBatToggleSleepEvent((BatEntity) (Object) this, !this.getIsBatHanging())) {
ci.cancel();
}
}

View File

@ -2,17 +2,14 @@ package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.BeeEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DamageSource;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BeeEntity.class)
@ -20,7 +17,6 @@ public abstract class BeeEntityMixin extends AnimalEntityMixin {
// @formatter:off
@Shadow private BeeEntity.PollinateGoal pollinateGoal;
@Shadow public abstract boolean setBeeAttacker(Entity attacker);
// @formatter:on
@Inject(method = "attackEntityAsMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
@ -28,18 +24,21 @@ public abstract class BeeEntityMixin extends AnimalEntityMixin {
((LivingEntityBridge) entityIn).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
}
@Inject(method = "attackEntityAsMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/BeeEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
private void arclight$stungTarget(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.FORGOT_TARGET, true);
}
@Redirect(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AnimalEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
private boolean arclight$attackUpdateTarget(AnimalEntity animalEntity, DamageSource source, float amount) {
boolean result = super.attackEntityFrom(source, amount);
if (result && !this.world.isRemote && source.getTrueSource() instanceof PlayerEntity && !((PlayerEntity) source.getTrueSource()).isCreative() && this.canEntityBeSeen(source.getTrueSource()) && !this.isAIDisabled()) {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isInvulnerableTo(source)) {
return false;
} else {
Entity entity = source.getTrueSource();
boolean ret = super.attackEntityFrom(source, amount);
if (ret && !this.world.isRemote) {
this.pollinateGoal.cancel();
this.setBeeAttacker(source.getTrueSource());
}
return result;
return ret;
}
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.common.mixin.core.entity.passive;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Random;
@Mixin(CatEntity.class)
public abstract class CatEntityMixin extends AnimalEntityMixin {
@Redirect(method = "processInteract", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Random;nextInt(I)I"))
private int arclight$catTame(Random random, int bound, PlayerEntity playerEntity) {
return random.nextInt(bound) == 0 && !CraftEventFactory.callEntityTameEvent((CatEntity) (Object) this, playerEntity).isCancelled() ? 0 : 2;
}
}

View File

@ -4,11 +4,13 @@ import net.minecraft.entity.passive.CowEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DrinkHelper;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -20,23 +22,20 @@ public abstract class CowEntityMixin extends AnimalEntityMixin {
* @reason
*/
@Overwrite
public boolean processInteract(final PlayerEntity entityhuman, final Hand enumhand) {
final ItemStack itemstack = entityhuman.getHeldItem(enumhand);
if (itemstack.getItem() != Items.BUCKET || entityhuman.abilities.isCreativeMode || this.isChild()) {
return super.processInteract(entityhuman, enumhand);
}
final PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman.world, entityhuman, this.getPosition(), this.getPosition(), null, itemstack, Items.MILK_BUCKET);
public ActionResultType func_230254_b_(PlayerEntity playerEntity, Hand hand) {
ItemStack itemstack = playerEntity.getHeldItem(hand);
if (itemstack.getItem() == Items.BUCKET && !this.isChild()) {
playerEntity.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F);
org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerWorld) playerEntity.world, playerEntity, this.getPosition(), this.getPosition(), null, itemstack, Items.MILK_BUCKET);
if (event.isCancelled()) {
return false;
return ActionResultType.PASS;
}
final ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
entityhuman.playSound(SoundEvents.ENTITY_COW_MILK, 1.0f, 1.0f);
itemstack.shrink(1);
if (itemstack.isEmpty()) {
entityhuman.setHeldItem(enumhand, result);
} else if (!entityhuman.inventory.addItemStackToInventory(result)) {
entityhuman.dropItem(result, false);
ItemStack itemstack1 = DrinkHelper.func_242398_a(itemstack, playerEntity, CraftItemStack.asNMSCopy(event.getItemStack()));
playerEntity.setHeldItem(hand, itemstack1);
return ActionResultType.func_233537_a_(this.world.isRemote);
} else {
return super.func_230254_b_(playerEntity, hand);
}
return true;
}
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.passive.AnimalEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.entity.passive.FoxEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.ai.goal.BreedGoalMixin;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.entity.item.ExperienceOrbEntity;
@ -9,12 +9,13 @@ import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.stats.Stats;
import net.minecraft.world.GameRules;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityBreedEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import io.izzel.arclight.common.bridge.entity.passive.FoxEntityBridge;
@Mixin(targets = "net.minecraft.entity.passive.FoxEntity.MateGoal")
public class FoxEntity_MateGoalMixin extends BreedGoalMixin {
@ -25,7 +26,19 @@ public class FoxEntity_MateGoalMixin extends BreedGoalMixin {
*/
@Overwrite
protected void spawnBaby() {
FoxEntity foxentity = (FoxEntity) this.animal.createChild(this.targetMate);
ServerWorld serverworld = (ServerWorld) this.world;
FoxEntity foxentity = (FoxEntity) this.animal.func_241840_a(serverworld, this.targetMate);
final BabyEntitySpawnEvent event = new BabyEntitySpawnEvent(animal, targetMate, foxentity);
final boolean cancelled = MinecraftForge.EVENT_BUS.post(event);
foxentity = (FoxEntity) event.getChild();
if (cancelled) {
//Reset the "inLove" state for the animals
this.animal.setGrowingAge(6000);
this.targetMate.setGrowingAge(6000);
this.animal.resetInLove();
this.targetMate.resetInLove();
return;
}
if (foxentity != null) {
ServerPlayerEntity serverplayerentity = this.animal.getLoveCause();
ServerPlayerEntity serverplayerentity1 = this.targetMate.getLoveCause();
@ -50,19 +63,17 @@ public class FoxEntity_MateGoalMixin extends BreedGoalMixin {
CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity2, this.animal, this.targetMate, foxentity);
}
int i = 6000;
this.animal.setGrowingAge(6000);
this.targetMate.setGrowingAge(6000);
this.animal.resetInLove();
this.targetMate.resetInLove();
foxentity.setGrowingAge(-24000);
foxentity.setLocationAndAngles(this.animal.posX, this.animal.posY, this.animal.posZ, 0.0F, 0.0F);
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING);
this.world.addEntity(foxentity);
foxentity.setLocationAndAngles(this.animal.getPosX(), this.animal.getPosY(), this.animal.getPosZ(), 0.0F, 0.0F);
serverworld.func_242417_l(foxentity);
this.world.setEntityState(this.animal, (byte) 18);
if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
if (experience > 0) {
this.world.addEntity(new ExperienceOrbEntity(this.world, this.animal.posX, this.animal.posY, this.animal.posZ, experience));
this.world.addEntity(new ExperienceOrbEntity(this.world, this.animal.getPosX(), this.animal.getPosY(), this.animal.getPosZ(), experience));
}
}

View File

@ -17,7 +17,6 @@ import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.boss.dragon.EnderDragonPartEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.item.ItemEntity;
@ -49,11 +48,9 @@ import net.minecraft.util.SoundEvents;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.Bukkit;
@ -107,7 +104,6 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
@Shadow public abstract void setLeftShoulderEntity(CompoundNBT tag);
@Shadow public abstract CompoundNBT getRightShoulderEntity();
@Shadow public abstract CompoundNBT getLeftShoulderEntity();
@Shadow @Deprecated public abstract BlockPos getBedLocation();
@Shadow public int experienceLevel;
@Shadow @Final public PlayerInventory inventory;
@Shadow public Container openContainer;
@ -123,16 +119,14 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
@Shadow public abstract Scoreboard getWorldScoreboard();
@Shadow protected EnderChestInventory enterChestInventory;
@Shadow public abstract Either<PlayerEntity.SleepResult, Unit> trySleep(BlockPos at);
@Shadow public abstract void startSleeping(BlockPos p_213342_1_);
@Shadow public int sleepTimer;
// @formatter:on
public boolean fauxSleeping;
public String spawnWorld = "";
public int oldLevel;
@Inject(method = "<init>", at = @At("RETURN"))
private void arclight$init(World worldIn, GameProfile gameProfileIn, CallbackInfo ci) {
private void arclight$init(World p_i241920_1_, BlockPos p_i241920_2_, float p_i241920_3_, GameProfile p_i241920_4_, CallbackInfo ci) {
oldLevel = -1;
((FoodStatsBridge) this.foodStats).bridge$setEntityHuman((PlayerEntity) (Object) this);
((IInventoryBridge) this.enterChestInventory).setOwner(this.getBukkitEntity());

View File

@ -1,19 +1,17 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.PlayerInventoryBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.entity.CraftItem;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.player.PlayerPickupArrowEvent;
@ -25,27 +23,18 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import io.izzel.arclight.common.bridge.entity.player.PlayerInventoryBridge;
import javax.annotation.Nullable;
@Mixin(AbstractArrowEntity.class)
public abstract class AbstractArrowEntityMixin extends EntityMixin {
public abstract class AbstractArrowEntityMixin extends ProjectileEntityMixin {
// @formatter:off
@Shadow public boolean inGround;
@Shadow public abstract boolean getNoClip();
@Shadow public int arrowShake;
@Shadow public AbstractArrowEntity.PickupStatus pickupStatus;
@Shadow @Nullable public abstract Entity getShooter();
@Shadow protected abstract ItemStack getArrowStack();
// @formatter:on
@Inject(method = "onHit", at = @At("HEAD"))
private void arclight$projectileHit(RayTraceResult raytraceResultIn, CallbackInfo ci) {
CraftEventFactory.callProjectileHitEvent((AbstractArrowEntity) (Object) this, raytraceResultIn);
}
@Redirect(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setFire(I)V"))
private void arclight$fireShot(Entity entity, int seconds, EntityRayTraceResult result) {
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), seconds);
@ -60,24 +49,24 @@ public abstract class AbstractArrowEntityMixin extends EntityMixin {
* @reason
*/
@Overwrite
public void onCollideWithPlayer(final PlayerEntity entityhuman) {
public void onCollideWithPlayer(PlayerEntity playerEntity) {
if (!this.world.isRemote && (this.inGround || this.getNoClip()) && this.arrowShake <= 0) {
ItemStack itemstack = this.getArrowStack();
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !itemstack.isEmpty() && ((PlayerInventoryBridge) entityhuman.inventory).bridge$canHold(itemstack) > 0) {
final ItemEntity item = new ItemEntity(this.world, this.posX, this.posY, this.posZ, itemstack);
final PlayerPickupArrowEvent event = new PlayerPickupArrowEvent(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity(), new CraftItem(((CraftServer) Bukkit.getServer()), (AbstractArrowEntity) (Object) this, item), (AbstractArrow) this.getBukkitEntity());
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !itemstack.isEmpty() && ((PlayerInventoryBridge) playerEntity.inventory).bridge$canHold(itemstack) > 0) {
ItemEntity item = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), itemstack);
PlayerPickupArrowEvent event = new PlayerPickupArrowEvent(((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity(), new CraftItem(((CraftServer) Bukkit.getServer()), (AbstractArrowEntity) (Object) this, item), (AbstractArrow) this.getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
itemstack = item.getItem();
}
boolean flag = this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED || (this.pickupStatus == AbstractArrowEntity.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.isCreativeMode) || (this.getNoClip() && this.getShooter().getUniqueID() == entityhuman.getUniqueID());
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !entityhuman.inventory.addItemStackToInventory(itemstack)) {
boolean flag = this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED || (this.pickupStatus == AbstractArrowEntity.PickupStatus.CREATIVE_ONLY && playerEntity.abilities.isCreativeMode) || (this.getNoClip() && this.func_234616_v_().getUniqueID() == playerEntity.getUniqueID());
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !playerEntity.inventory.addItemStackToInventory(itemstack)) {
flag = false;
}
if (flag) {
entityhuman.onItemPickup((AbstractArrowEntity) (Object) this, 1);
playerEntity.onItemPickup((AbstractArrowEntity) (Object) this, 1);
this.remove();
}
}

View File

@ -1,9 +1,7 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.projectile.DamagingProjectileEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.DamagingProjectileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.MathHelper;
@ -19,14 +17,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(DamagingProjectileEntity.class)
public abstract class DamagingProjectileEntityMixin extends EntityMixin implements DamagingProjectileEntityBridge {
public abstract class DamagingProjectileEntityMixin extends ProjectileEntityMixin implements DamagingProjectileEntityBridge {
// @formatter:off
@Shadow public double accelerationX;
@Shadow public double accelerationY;
@Shadow public double accelerationZ;
@Shadow public LivingEntity shootingEntity;
@Shadow protected void onImpact(RayTraceResult result) {}
// @formatter:on
public float bukkitYield;
@ -39,9 +35,6 @@ public abstract class DamagingProjectileEntityMixin extends EntityMixin implemen
}
public void setDirection(double d0, double d1, double d2) {
d0 += this.rand.nextGaussian() * 0.4D;
d1 += this.rand.nextGaussian() * 0.4D;
d2 += this.rand.nextGaussian() * 0.4D;
double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
this.accelerationX = d0 / d3 * 0.1D;
@ -56,7 +49,7 @@ public abstract class DamagingProjectileEntityMixin extends EntityMixin implemen
}
}
@Inject(method = "attackEntityFrom", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getLookVec()Lnet/minecraft/util/math/Vec3d;"))
@Inject(method = "attackEntityFrom", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getLookVec()Lnet/minecraft/util/math/vector/Vector3d;"))
private void arclight$nonLivingAttack(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (CraftEventFactory.handleNonLivingEntityDamageEvent((DamagingProjectileEntity) (Object) this, source, amount)) {
cir.setReturnValue(false);

View File

@ -6,8 +6,6 @@ import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.EggEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -27,10 +25,8 @@ public abstract class EggEntityMixin extends ThrowableEntityMixin {
* @reason
*/
@Overwrite
protected void onImpact(final RayTraceResult movingobjectposition) {
if (movingobjectposition.getType() == RayTraceResult.Type.ENTITY) {
((EntityRayTraceResult) movingobjectposition).getEntity().attackEntityFrom(DamageSource.causeThrownDamage((EggEntity) (Object) this, this.getThrower()), 0.0f);
}
protected void onImpact(final RayTraceResult result) {
super.onImpact(result);
if (!this.world.isRemote) {
boolean hatching = this.rand.nextInt(8) == 0;
byte b0 = 1;
@ -41,9 +37,9 @@ public abstract class EggEntityMixin extends ThrowableEntityMixin {
b0 = 0;
}
org.bukkit.entity.EntityType hatchingType = org.bukkit.entity.EntityType.CHICKEN;
final Entity shooter = this.getThrower();
Entity shooter = this.func_234616_v_();
if (shooter instanceof ServerPlayerEntity) {
final PlayerEggThrowEvent event = new PlayerEggThrowEvent(((ServerPlayerEntityBridge) shooter).bridge$getBukkitEntity(), (Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
PlayerEggThrowEvent event = new PlayerEggThrowEvent(((ServerPlayerEntityBridge) shooter).bridge$getBukkitEntity(), (Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
Bukkit.getPluginManager().callEvent(event);
b0 = event.getNumHatches();
hatching = event.isHatching();
@ -51,12 +47,12 @@ public abstract class EggEntityMixin extends ThrowableEntityMixin {
}
if (hatching) {
for (int i = 0; i < b0; ++i) {
Entity entity = ((CraftEntity) ((WorldBridge) this.world).bridge$getWorld().spawnEntity(new Location(((WorldBridge) this.world).bridge$getWorld(), this.posX, this.posY, this.posZ, this.rotationYaw, 0.0f), hatchingType)).getHandle();
Entity entity = ((CraftEntity) ((WorldBridge) this.world).bridge$getWorld().spawnEntity(new Location(((WorldBridge) this.world).bridge$getWorld(), this.getPosX(), this.getPosY(), this.getPosZ(), this.rotationYaw, 0.0f), hatchingType)).getHandle();
if (((EntityBridge) entity).bridge$getBukkitEntity() instanceof Ageable) {
((Ageable) ((EntityBridge) entity).bridge$getBukkitEntity()).setBaby();
}
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG);
this.world.getWorld().addEntity(entity);
this.world.addEntity(entity);
}
}
this.world.setEntityState((EggEntity) (Object) this, (byte) 3);

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.core.entity.item;
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.entity.projectile.FireworkRocketEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -2,7 +2,6 @@ package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ExperienceOrbEntity;
@ -11,20 +10,18 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameterSets;
import net.minecraft.loot.LootParameters;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.stats.Stats;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameterSets;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.world.storage.loot.LootTables;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemFishedEvent;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.FishHook;
import org.bukkit.event.player.PlayerFishEvent;
import org.spongepowered.asm.mixin.Final;
@ -34,37 +31,30 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Collections;
import java.util.List;
@Mixin(FishingBobberEntity.class)
public abstract class FishingBobberEntityMixin extends EntityMixin {
public abstract class FishingBobberEntityMixin extends ProjectileEntityMixin {
// @formatter:off
@Shadow public PlayerEntity angler;
@Shadow public Entity caughtEntity;
@Shadow private Entity caughtEntity;
@Shadow protected abstract void bringInHookedEntity();
@Shadow private int ticksCatchable;
@Shadow @Final private int luck;
@Shadow private boolean inGround;
@Shadow public abstract PlayerEntity func_234606_i_();
// @formatter:on
@Inject(method = "checkCollision", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/util/math/RayTraceResult;getType()Lnet/minecraft/util/math/RayTraceResult$Type;"))
private void arclight$entityHit(CallbackInfo ci, RayTraceResult result) {
CraftEventFactory.callProjectileHitEvent((FishingBobberEntity) (Object) this, result);
}
@Inject(method = "catchingFish", at = @At(value = "FIELD", shift = At.Shift.AFTER, ordinal = 0, target = "Lnet/minecraft/entity/projectile/FishingBobberEntity;ticksCatchableDelay:I"))
private void arclight$attemptFail(BlockPos blockPos, CallbackInfo ci) {
PlayerFishEvent event = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
PlayerFishEvent event = new PlayerFishEvent(((ServerPlayerEntityBridge) this.func_234606_i_()).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
Bukkit.getPluginManager().callEvent(event);
}
@Inject(method = "catchingFish", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/entity/projectile/FishingBobberEntity;getMotion()Lnet/minecraft/util/math/Vec3d;"))
@Inject(method = "catchingFish", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/projectile/FishingBobberEntity;playSound(Lnet/minecraft/util/SoundEvent;FF)V"))
private void arclight$fishBite(BlockPos blockPos, CallbackInfo ci) {
PlayerFishEvent event = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
PlayerFishEvent event = new PlayerFishEvent(((ServerPlayerEntityBridge) this.func_234606_i_()).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
@ -77,61 +67,61 @@ public abstract class FishingBobberEntityMixin extends EntityMixin {
*/
@Overwrite
public int handleHookRetraction(ItemStack p_146034_1_) {
if (!this.world.isRemote && this.angler != null) {
PlayerEntity playerentity = this.func_234606_i_();
if (!this.world.isRemote && playerentity != null) {
int i = 0;
ItemFishedEvent event = null;
if (this.caughtEntity != null) {
PlayerFishEvent fishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) this.caughtEntity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
PlayerFishEvent fishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerentity).bridge$getBukkitEntity(), ((EntityBridge) this.caughtEntity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
Bukkit.getPluginManager().callEvent(fishEvent);
if (fishEvent.isCancelled()) {
return 0;
}
this.bringInHookedEntity();
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, Collections.emptyList());
this.world.setEntityState((FishingBobberEntity) (Object) this, (byte) 31);
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) playerentity, p_146034_1_, (FishingBobberEntity) (Object) this, Collections.emptyList());
this.world.setEntityState((FishingBobberEntity) (Object)this, (byte) 31);
i = this.caughtEntity instanceof ItemEntity ? 3 : 5;
} else if (this.ticksCatchable > 0) {
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withParameter(LootParameters.POSITION, new BlockPos((FishingBobberEntity) (Object) this)).withParameter(LootParameters.TOOL, p_146034_1_).withRandom(this.rand).withLuck((float) this.luck + this.angler.getLuck());
lootcontext$builder.withParameter(LootParameters.KILLER_ENTITY, this.angler).withParameter(LootParameters.THIS_ENTITY, (FishingBobberEntity) (Object) this);
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withParameter(LootParameters.field_237457_g_, this.getPositionVec()).withParameter(LootParameters.TOOL, p_146034_1_).withParameter(LootParameters.THIS_ENTITY, (FishingBobberEntity) (Object) this).withRandom(this.rand).withLuck((float) this.luck + playerentity.getLuck());
lootcontext$builder.withParameter(LootParameters.KILLER_ENTITY, this.func_234616_v_()).withParameter(LootParameters.THIS_ENTITY, (FishingBobberEntity) (Object) this);
LootTable loottable = this.world.getServer().getLootTableManager().getLootTableFromLocation(LootTables.GAMEPLAY_FISHING);
List<ItemStack> list = loottable.generate(lootcontext$builder.build(LootParameterSets.FISHING));
event = new ItemFishedEvent(list, this.inGround ? 2 : 1, (FishingBobberEntity) (Object) this);
event = new ItemFishedEvent(list, this.onGround ? 2 : 1, (FishingBobberEntity) (Object) this);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
this.remove();
return event.getRodDamage();
}
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, list);
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) playerentity, p_146034_1_, (FishingBobberEntity) (Object) this, list);
for (ItemStack itemstack : list) {
ItemEntity itementity = new ItemEntity(this.world, this.posX, this.posY, this.posZ, itemstack);
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) itementity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
ItemEntity itementity = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), itemstack);
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerentity).bridge$getBukkitEntity(), ((EntityBridge) itementity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
playerFishEvent.setExpToDrop(this.rand.nextInt(6) + 1);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
double d0 = this.angler.posX - this.posX;
double d1 = this.angler.posY - this.posY;
double d2 = this.angler.posZ - this.posZ;
double d0 = playerentity.getPosX() - this.getPosX();
double d1 = playerentity.getPosY() - this.getPosY();
double d2 = playerentity.getPosZ() - this.getPosZ();
double d3 = 0.1D;
itementity.setMotion(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.world.addEntity(itementity);
if (playerFishEvent.getExpToDrop() > 0) {
this.angler.world.addEntity(new ExperienceOrbEntity(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, playerFishEvent.getExpToDrop()));
playerentity.world.addEntity(new ExperienceOrbEntity(playerentity.world, playerentity.getPosX(), playerentity.getPosY() + 0.5D, playerentity.getPosZ() + 0.5D, playerFishEvent.getExpToDrop()));
}
if (itemstack.getItem().isIn(ItemTags.FISHES)) {
this.angler.addStat(Stats.FISH_CAUGHT, 1);
playerentity.addStat(Stats.FISH_CAUGHT, 1);
}
}
i = 1;
}
if (this.inGround) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
if (this.onGround) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerentity).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
@ -141,7 +131,7 @@ public abstract class FishingBobberEntityMixin extends EntityMixin {
}
if (i == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerentity).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;

View File

@ -0,0 +1,41 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.math.RayTraceResult;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.projectiles.ProjectileSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
@Mixin(ProjectileEntity.class)
public abstract class ProjectileEntityMixin extends EntityMixin {
// @formatter:off
@Shadow @Nullable public abstract Entity func_234616_v_();
@Shadow protected void onImpact(RayTraceResult result) { }
// @formatter:on
@Inject(method = "setShooter", at = @At("RETURN"))
private void arclight$updateSource(Entity entityIn, CallbackInfo ci) {
if (entityIn != null) {
CraftEntity entity = ((EntityBridge) entityIn).bridge$getBukkitEntity();
if (entity instanceof ProjectileSource) {
this.projectileSource = ((ProjectileSource) entity);
}
}
}
@Inject(method = "onImpact", at = @At("HEAD"))
private void arclight$onHit(RayTraceResult result, CallbackInfo ci) {
CraftEventFactory.callProjectileHitEvent((ProjectileEntity) (Object) this, result);
}
}

View File

@ -1,7 +1,6 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
@ -9,21 +8,13 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
@Mixin(ThrowableEntity.class)
public abstract class ThrowableEntityMixin extends EntityMixin {
// @formatter:off
@Shadow protected abstract void onImpact(RayTraceResult result);
@Shadow @Nullable public abstract LivingEntity getThrower();
// @formatter:on
public abstract class ThrowableEntityMixin extends ProjectileEntityMixin {
@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/world/World;)V", at = @At("RETURN"))
private void arclight$init(EntityType<? extends ThrowableEntity> type, LivingEntity livingEntityIn, World worldIn, CallbackInfo ci) {

View File

@ -26,6 +26,7 @@ public class EntityTeleportEventDispatcher {
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
}
} else {
CraftEntity entity = ((EntityBridge) event.getEntity()).bridge$getBukkitEntity();
EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(entity, entity.getLocation(), new Location(entity.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()));
@ -36,5 +37,4 @@ public class EntityTeleportEventDispatcher {
event.setTargetZ(bukkitEvent.getTo().getZ());
}
}
}
}

View File

@ -117,6 +117,7 @@
"entity.CreatureEntityMixin",
"entity.EntityMixin",
"entity.EntityTypeMixin",
"entity.IAngerableMixin",
"entity.LivingEntityMixin",
"entity.MobEntityMixin",
"entity.ai.attributes.RangedAttributeMixin",
@ -238,9 +239,11 @@
"entity.projectile.EggEntityMixin",
"entity.projectile.EvokerFangsEntityMixin",
"entity.projectile.FireballEntityMixin",
"entity.projectile.FireworkRocketEntityMixin",
"entity.projectile.FishingBobberEntityMixin",
"entity.projectile.LlamaSpitEntityMixin",
"entity.projectile.PotionEntityMixin",
"entity.projectile.ProjectileEntityMixin",
"entity.projectile.ProjectileItemEntityMixin",
"entity.projectile.ShulkerBulletEntityMixin",
"entity.projectile.SmallFireballEntityMixin",