1.16: entities part 4
This commit is contained in:
parent
90bf29ed3d
commit
d18632c55c
@ -0,0 +1,10 @@
|
|||||||
|
package io.izzel.arclight.common.bridge.world;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface TrackedEntityBridge {
|
||||||
|
|
||||||
|
void bridge$setTrackedPlayers(Set<ServerPlayerEntity> trackedPlayers);
|
||||||
|
}
|
||||||
@ -195,6 +195,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
|||||||
@Shadow public abstract boolean isInLava();
|
@Shadow public abstract boolean isInLava();
|
||||||
@Shadow protected abstract void setOnFireFromLava();
|
@Shadow protected abstract void setOnFireFromLava();
|
||||||
@Shadow protected boolean firstUpdate;
|
@Shadow protected boolean firstUpdate;
|
||||||
|
@Shadow public abstract boolean isSilent();
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
private static final int CURRENT_LEVEL = 2;
|
private static final int CURRENT_LEVEL = 2;
|
||||||
|
|||||||
@ -2,23 +2,22 @@ package io.izzel.arclight.common.mixin.core.entity;
|
|||||||
|
|
||||||
import io.izzel.arclight.common.bridge.entity.EntityTypeBridge;
|
import io.izzel.arclight.common.bridge.entity.EntityTypeBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
|
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.MobEntity;
|
|
||||||
import net.minecraft.entity.SpawnReason;
|
import net.minecraft.entity.SpawnReason;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
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.Slice;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -29,17 +28,34 @@ public abstract class EntityTypeMixin<T extends Entity> implements EntityTypeBri
|
|||||||
@Shadow @Nullable public abstract T create(ServerWorld worldIn, @Nullable CompoundNBT compound, @Nullable ITextComponent customName, @Nullable PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220349_7_, boolean p_220349_8_);
|
@Shadow @Nullable public abstract T create(ServerWorld worldIn, @Nullable CompoundNBT compound, @Nullable ITextComponent customName, @Nullable PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220349_7_, boolean p_220349_8_);
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
@Inject(method = "spawn(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;", at = @At("HEAD"))
|
@Inject(method = "spawn(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;",
|
||||||
public void arclight$spawnReason(ServerWorld worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220342_7_, boolean p_220342_8_, CallbackInfoReturnable<T> cir) {
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
|
||||||
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
private void arclight$spawnReason(ServerWorld worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220342_7_, boolean p_220342_8_, CallbackInfoReturnable<T> cir) {
|
||||||
|
CreatureSpawnEvent.SpawnReason spawnReason = ((IWorldWriterBridge) worldIn).bridge$getAddEntityReason();
|
||||||
|
if (spawnReason == null) {
|
||||||
|
((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T spawnCreature(ServerWorld worldIn, @Nullable CompoundNBT compound, @Nullable ITextComponent customName, @Nullable PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean flag, boolean flag1, CreatureSpawnEvent.SpawnReason spawnReason) {
|
@Inject(method = "spawn(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;",
|
||||||
T t = this.create(worldIn, compound, customName, playerIn, pos, reason, flag, flag1);
|
cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At("RETURN"),
|
||||||
if (t instanceof MobEntity && ForgeEventFactory.doSpecialSpawn((MobEntity) t, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, reason)) {
|
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V")))
|
||||||
return null;
|
private void arclight$returnIfSuccess(ServerWorld worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220342_7_, boolean p_220342_8_, CallbackInfoReturnable<T> cir, T t) {
|
||||||
|
if (t != null) {
|
||||||
|
cir.setReturnValue(t.removed ? null : t);
|
||||||
}
|
}
|
||||||
return ((IWorldWriterBridge) worldIn).bridge$addEntity(t, spawnReason) ? t : null;
|
}
|
||||||
|
|
||||||
|
public T spawnCreature(ServerWorld worldIn, @Nullable CompoundNBT compound, @Nullable ITextComponent customName, @Nullable PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean p_220342_7_, boolean p_220342_8_, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||||
|
T t = this.create(worldIn, compound, customName, playerIn, pos, reason, p_220342_7_, p_220342_8_);
|
||||||
|
if (t != null) {
|
||||||
|
if (t instanceof net.minecraft.entity.MobEntity && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.entity.MobEntity) t, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, reason))
|
||||||
|
return null;
|
||||||
|
((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(spawnReason);
|
||||||
|
worldIn.func_242417_l(t);
|
||||||
|
return t.removed ? null : t;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -298,6 +298,12 @@ public abstract class MobEntityMixin extends LivingEntityMixin implements MobEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "func_233656_b_", at = @At("RETURN"))
|
||||||
|
private <T extends MobEntity> void arclight$cleanReason(EntityType<T> p_233656_1_, boolean p_233656_2_, CallbackInfoReturnable<T> cir) {
|
||||||
|
((WorldBridge) this.world).bridge$pushAddEntityReason(null);
|
||||||
|
this.arclight$transform = null;
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends MobEntity> T a(EntityType<T> entityType, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
public <T extends MobEntity> T a(EntityType<T> entityType, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(spawnReason);
|
((WorldBridge) this.world).bridge$pushAddEntityReason(spawnReason);
|
||||||
bridge$pushTransformReason(transformReason);
|
bridge$pushTransformReason(transformReason);
|
||||||
|
|||||||
@ -1,66 +0,0 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.ai.goal;
|
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
|
|
||||||
import io.izzel.arclight.common.bridge.entity.passive.AnimalEntityBridge;
|
|
||||||
import net.minecraft.entity.AgeableEntity;
|
|
||||||
import net.minecraft.entity.ai.goal.BreedGoal;
|
|
||||||
import net.minecraft.entity.passive.AnimalEntity;
|
|
||||||
import net.minecraft.entity.passive.TameableEntity;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
|
||||||
import org.bukkit.event.entity.EntityBreedEvent;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
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.LocalCapture;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Mixin(BreedGoal.class)
|
|
||||||
public class BreedGoalMixin {
|
|
||||||
|
|
||||||
// @formatter:off
|
|
||||||
@Shadow @Final protected AnimalEntity animal;
|
|
||||||
@Shadow protected AnimalEntity targetMate;
|
|
||||||
@Shadow @Final protected World world;
|
|
||||||
// @formatter:on
|
|
||||||
|
|
||||||
private transient int arclight$exp;
|
|
||||||
|
|
||||||
@Inject(method = "spawnBaby", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
|
|
||||||
at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/entity/passive/AnimalEntity;getLoveCause()Lnet/minecraft/entity/player/ServerPlayerEntity;"))
|
|
||||||
public void arclight$persist(CallbackInfo ci, AgeableEntity ageableEntity) {
|
|
||||||
if (ageableEntity instanceof TameableEntity && ((TameableEntity) ageableEntity).isTamed()) {
|
|
||||||
((LivingEntityBridge) ageableEntity).bridge$setPersist(true);
|
|
||||||
}
|
|
||||||
ServerPlayerEntity playerEntity = this.animal.getLoveCause();
|
|
||||||
if (playerEntity == null && this.targetMate.getLoveCause() != null) {
|
|
||||||
playerEntity = this.targetMate.getLoveCause();
|
|
||||||
}
|
|
||||||
arclight$exp = this.animal.getRNG().nextInt(7) + 1;
|
|
||||||
EntityBreedEvent event = CraftEventFactory.callEntityBreedEvent(ageableEntity, this.animal, this.targetMate, playerEntity, ((AnimalEntityBridge) this.animal).bridge$getBreedItem(), arclight$exp);
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
ci.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
arclight$exp = event.getExperience();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "spawnBaby", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Random;nextInt(I)I"))
|
|
||||||
public void arclight$returnIfFail(CallbackInfo ci) {
|
|
||||||
if (arclight$exp <= 0) {
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "spawnBaby", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Random;nextInt(I)I"))
|
|
||||||
public int arclight$setExp(Random random, int bound) {
|
|
||||||
return arclight$exp - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -38,7 +38,7 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
@Shadow public abstract int getWatchedTargetId(int head);
|
@Shadow public abstract int getWatchedTargetId(int head);
|
||||||
@Shadow public abstract void updateWatchedTargetId(int targetOffset, int newId);
|
@Shadow public abstract void updateWatchedTargetId(int targetOffset, int newId);
|
||||||
@Shadow protected abstract void launchWitherSkullToEntity(int p_82216_1_, LivingEntity p_82216_2_);
|
@Shadow protected abstract void launchWitherSkullToEntity(int p_82216_1_, LivingEntity p_82216_2_);
|
||||||
@Shadow @Final private static EntityPredicate field_213798_bB;
|
@Shadow @Final private static EntityPredicate ENEMY_CONDITION;
|
||||||
@Shadow private int blockBreakCounter;
|
@Shadow private int blockBreakCounter;
|
||||||
@Shadow @Final public ServerBossInfo bossInfo;
|
@Shadow @Final public ServerBossInfo bossInfo;
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
@ -56,9 +56,11 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.getPosYEye(), this.posZ, event.getRadius(), event.getFire(), explosion$mode);
|
this.world.createExplosion((WitherEntity) (Object) this, this.getPosX(), this.getPosYEye(), this.getPosZ(), event.getRadius(), event.getFire(), explosion$mode);
|
||||||
|
}
|
||||||
|
if (!this.isSilent()) {
|
||||||
|
this.world.playBroadcastSound(1023, this.getPosition(), 0);
|
||||||
}
|
}
|
||||||
this.world.playBroadcastSound(1023, new BlockPos((WitherEntity) (Object) this), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setInvulTime(j1);
|
this.setInvulTime(j1);
|
||||||
@ -80,9 +82,9 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
if (k3 > 15) {
|
if (k3 > 15) {
|
||||||
float f = 10.0F;
|
float f = 10.0F;
|
||||||
float f1 = 5.0F;
|
float f1 = 5.0F;
|
||||||
double d0 = MathHelper.nextDouble(this.rand, this.posX - 10.0D, this.posX + 10.0D);
|
double d0 = MathHelper.nextDouble(this.rand, this.getPosX() - 10.0D, this.getPosX() + 10.0D);
|
||||||
double d1 = MathHelper.nextDouble(this.rand, this.posY - 5.0D, this.posY + 5.0D);
|
double d1 = MathHelper.nextDouble(this.rand, this.getPosY() - 5.0D, this.getPosY() + 5.0D);
|
||||||
double d2 = MathHelper.nextDouble(this.rand, this.posZ - 10.0D, this.posZ + 10.0D);
|
double d2 = MathHelper.nextDouble(this.rand, this.getPosZ() - 10.0D, this.getPosZ() + 10.0D);
|
||||||
this.launchWitherSkullToCoords(i + 1, d0, d1, d2, true);
|
this.launchWitherSkullToCoords(i + 1, d0, d1, d2, true);
|
||||||
this.idleHeadUpdates[i - 1] = 0;
|
this.idleHeadUpdates[i - 1] = 0;
|
||||||
}
|
}
|
||||||
@ -103,7 +105,7 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
this.updateWatchedTargetId(i, 0);
|
this.updateWatchedTargetId(i, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<LivingEntity> list = this.world.getTargettableEntitiesWithinAABB(LivingEntity.class, field_213798_bB, (WitherEntity) (Object) this, this.getBoundingBox().grow(20.0D, 8.0D, 20.0D));
|
List<LivingEntity> list = this.world.getTargettableEntitiesWithinAABB(LivingEntity.class, ENEMY_CONDITION, (WitherEntity) (Object) this, this.getBoundingBox().grow(20.0D, 8.0D, 20.0D));
|
||||||
|
|
||||||
for (int j2 = 0; j2 < 10 && !list.isEmpty(); ++j2) {
|
for (int j2 = 0; j2 < 10 && !list.isEmpty(); ++j2) {
|
||||||
LivingEntity livingentity = list.get(this.rand.nextInt(list.size()));
|
LivingEntity livingentity = list.get(this.rand.nextInt(list.size()));
|
||||||
@ -137,9 +139,9 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
if (this.blockBreakCounter > 0) {
|
if (this.blockBreakCounter > 0) {
|
||||||
--this.blockBreakCounter;
|
--this.blockBreakCounter;
|
||||||
if (this.blockBreakCounter == 0 && ForgeEventFactory.getMobGriefingEvent(this.world, (WitherEntity) (Object) this)) {
|
if (this.blockBreakCounter == 0 && ForgeEventFactory.getMobGriefingEvent(this.world, (WitherEntity) (Object) this)) {
|
||||||
int i1 = MathHelper.floor(this.posY);
|
int i1 = MathHelper.floor(this.getPosY());
|
||||||
int l1 = MathHelper.floor(this.posX);
|
int l1 = MathHelper.floor(this.getPosX());
|
||||||
int i2 = MathHelper.floor(this.posZ);
|
int i2 = MathHelper.floor(this.getPosZ());
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
||||||
for (int k2 = -1; k2 <= 1; ++k2) {
|
for (int k2 = -1; k2 <= 1; ++k2) {
|
||||||
@ -161,7 +163,7 @@ public abstract class WitherEntityMixin extends CreatureEntityMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.world.playEvent(null, 1022, new BlockPos((WitherEntity) (Object) this), 0);
|
this.world.playEvent(null, 1022, this.getPosition(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.item;
|
package io.izzel.arclight.common.mixin.core.entity.item;
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
||||||
|
import io.izzel.arclight.common.mixin.core.entity.projectile.ThrowableEntityMixin;
|
||||||
import net.minecraft.entity.item.EnderPearlEntity;
|
import net.minecraft.entity.item.EnderPearlEntity;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import io.izzel.arclight.common.mixin.core.entity.projectile.ThrowableEntityMixin;
|
|
||||||
|
|
||||||
@Mixin(EnderPearlEntity.class)
|
@Mixin(EnderPearlEntity.class)
|
||||||
public abstract class EnderPearlEntityMixin extends ThrowableEntityMixin {
|
public abstract class EnderPearlEntityMixin extends ThrowableEntityMixin {
|
||||||
@ -18,14 +17,4 @@ public abstract class EnderPearlEntityMixin extends ThrowableEntityMixin {
|
|||||||
private void arclight$spawnEndermite(RayTraceResult result, CallbackInfo ci) {
|
private void arclight$spawnEndermite(RayTraceResult result, CallbackInfo ci) {
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
|
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onImpact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
|
|
||||||
private void arclight$entityDamage(RayTraceResult result, CallbackInfo ci) {
|
|
||||||
CraftEventFactory.entityDamage = (EnderPearlEntity) (Object) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onImpact", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
|
|
||||||
private void arclight$entityDamageReset(RayTraceResult result, CallbackInfo ci) {
|
|
||||||
CraftEventFactory.entityDamage = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.item;
|
package io.izzel.arclight.common.mixin.core.entity.item;
|
||||||
|
|
||||||
import io.izzel.arclight.api.ArclightVersion;
|
|
||||||
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
|
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
@ -45,11 +44,6 @@ public abstract class TNTEntityMixin extends EntityMixin {
|
|||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (ArclightVersion.lesserThan(ArclightVersion.v1_15)) {
|
|
||||||
this.prevPosX = this.posX;
|
|
||||||
this.prevPosY = this.posY;
|
|
||||||
this.prevPosZ = this.posZ;
|
|
||||||
}
|
|
||||||
if (!this.hasNoGravity()) {
|
if (!this.hasNoGravity()) {
|
||||||
this.setMotion(this.getMotion().add(0.0D, -0.04D, 0.0D));
|
this.setMotion(this.getMotion().add(0.0D, -0.04D, 0.0D));
|
||||||
}
|
}
|
||||||
@ -67,11 +61,12 @@ public abstract class TNTEntityMixin extends EntityMixin {
|
|||||||
}
|
}
|
||||||
this.remove();
|
this.remove();
|
||||||
} else {
|
} else {
|
||||||
this.handleWaterMovement();
|
this.func_233566_aG_();
|
||||||
if (this.world.isRemote) {
|
if (this.world.isRemote) {
|
||||||
this.world.addParticle(ParticleTypes.SMOKE, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
|
this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY() + 0.5D, this.getPosZ(), 0.0D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +78,7 @@ public abstract class TNTEntityMixin extends EntityMixin {
|
|||||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity());
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity());
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.world.createExplosion((TNTEntity) (Object) this, this.posX, this.posY + this.getHeight() / 16.0f, this.posZ, event.getRadius(), event.getFire(), Explosion.Mode.BREAK);
|
this.world.createExplosion((TNTEntity) (Object) this, this.getPosX(), this.getPosY() + this.getHeight() / 16.0f, this.getPosZ(), event.getRadius(), event.getFire(), Explosion.Mode.BREAK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import net.minecraft.entity.merchant.villager.VillagerEntity;
|
|||||||
import net.minecraft.entity.monster.WitchEntity;
|
import net.minecraft.entity.monster.WitchEntity;
|
||||||
import net.minecraft.entity.passive.IronGolemEntity;
|
import net.minecraft.entity.passive.IronGolemEntity;
|
||||||
import net.minecraft.item.MerchantOffer;
|
import net.minecraft.item.MerchantOffer;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
@ -39,17 +40,17 @@ public abstract class VillagerEntityMixin extends AbstractVillagerEntityMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onStruckByLightning", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
@Inject(method = "func_241841_a", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
|
||||||
private void arclight$transformWitch(LightningBoltEntity lightningBolt, CallbackInfo ci, WitchEntity witchEntity) {
|
private void arclight$transformWitch(ServerWorld serverWorld, LightningBoltEntity lightningBolt, CallbackInfo ci, WitchEntity witchEntity) {
|
||||||
if (CraftEventFactory.callEntityTransformEvent((VillagerEntity) (Object) this, witchEntity, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
if (CraftEventFactory.callEntityTransformEvent((VillagerEntity) (Object) this, witchEntity, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
} else {
|
} else {
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
((WorldBridge) serverWorld).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "trySpawnGolem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
@Inject(method = "trySpawnGolem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
|
||||||
private void arclight$ironGolemReason(CallbackInfoReturnable<IronGolemEntity> cir) {
|
private void arclight$ironGolemReason(ServerWorld world, CallbackInfoReturnable<IronGolemEntity> cir) {
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE);
|
((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.monster;
|
package io.izzel.arclight.common.mixin.core.entity.monster;
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
|
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
|
||||||
|
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.monster.AbstractRaiderEntity;
|
import net.minecraft.entity.monster.AbstractRaiderEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@ -15,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
@Mixin(AbstractRaiderEntity.class)
|
@Mixin(AbstractRaiderEntity.class)
|
||||||
public class AbstractRaiderEntityMixin {
|
public abstract class AbstractRaiderEntityMixin extends CreatureEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "onDeath", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
@Inject(method = "onDeath", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
||||||
private void arclight$raid(DamageSource cause, CallbackInfo ci, Entity entity, Raid raid, ItemStack itemStack, PlayerEntity playerEntity) {
|
private void arclight$raid(DamageSource cause, CallbackInfo ci, Entity entity, Raid raid, ItemStack itemStack, PlayerEntity playerEntity) {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.monster;
|
package io.izzel.arclight.common.mixin.core.entity.monster;
|
||||||
|
|
||||||
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
|
|
||||||
import net.minecraft.entity.monster.WitchEntity;
|
import net.minecraft.entity.monster.WitchEntity;
|
||||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -9,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(WitchEntity.class)
|
@Mixin(WitchEntity.class)
|
||||||
public abstract class WitchEntityMixin extends CreatureEntityMixin {
|
public abstract class WitchEntityMixin extends AbstractRaiderEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/WitchEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
@Inject(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/WitchEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
||||||
private void arclight$reason(CallbackInfo ci) {
|
private void arclight$reason(CallbackInfo ci) {
|
||||||
|
|||||||
@ -4,20 +4,22 @@ import io.izzel.arclight.common.bridge.entity.EntityBridge;
|
|||||||
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
|
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
||||||
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
|
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
|
||||||
|
import io.izzel.arclight.mixin.Eject;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ILivingEntityData;
|
import net.minecraft.entity.ILivingEntityData;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.entity.SpawnReason;
|
import net.minecraft.entity.SpawnReason;
|
||||||
import net.minecraft.entity.merchant.villager.VillagerEntity;
|
import net.minecraft.entity.merchant.villager.VillagerEntity;
|
||||||
import net.minecraft.entity.monster.ZombieEntity;
|
import net.minecraft.entity.monster.ZombieEntity;
|
||||||
import net.minecraft.entity.monster.ZombieVillagerEntity;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.world.DifficultyInstance;
|
import net.minecraft.world.DifficultyInstance;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IServerWorld;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
import net.minecraftforge.event.entity.living.ZombieEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
@ -34,20 +36,22 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|||||||
@Mixin(ZombieEntity.class)
|
@Mixin(ZombieEntity.class)
|
||||||
public abstract class ZombieEntityMixin extends CreatureEntityMixin {
|
public abstract class ZombieEntityMixin extends CreatureEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "func_213698_b", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
|
@Inject(method = "func_234341_c_", at = @At("HEAD"))
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
private void arclight$transformReason(EntityType<? extends ZombieEntity> entityType, CallbackInfo ci) {
|
||||||
private void arclight$drown(EntityType<? extends ZombieEntity> p_213698_1_, CallbackInfo ci, ZombieEntity zombieEntity) {
|
this.bridge$pushTransformReason(EntityTransformEvent.TransformReason.DROWNED);
|
||||||
if (CraftEventFactory.callEntityTransformEvent((ZombieEntity) (Object) this, zombieEntity, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) {
|
|
||||||
((Zombie) getBukkitEntity()).setConversionTime(-1);
|
|
||||||
ci.cancel();
|
|
||||||
} else {
|
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.DROWNED);
|
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.DROWNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "func_234341_c_", locals = LocalCapture.CAPTURE_FAILHARD, at = @At("RETURN"))
|
||||||
|
private void arclight$stopConversion(EntityType<? extends ZombieEntity> entityType, CallbackInfo ci, ZombieEntity zombieEntity) {
|
||||||
|
if (zombieEntity == null) {
|
||||||
|
((Zombie) this.bridge$getBukkitEntity()).setConversionTime(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "attackEntityFrom", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
@Inject(method = "attackEntityFrom", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombieEntity;onInitialSpawn(Lnet/minecraft/world/IServerWorld;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/ILivingEntityData;Lnet/minecraft/nbt/CompoundNBT;)Lnet/minecraft/entity/ILivingEntityData;"))
|
||||||
private void arclight$spawnWithReason(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir, LivingEntity livingEntity, int i, int j, int k, net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event, ZombieEntity zombieEntity) {
|
private void arclight$spawnWithReason(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir, ServerWorld world, LivingEntity livingEntity, int i, int j, int k, ZombieEvent.SummonAidEvent event, ZombieEntity zombieEntity) {
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
|
((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
|
||||||
if (livingEntity != null) {
|
if (livingEntity != null) {
|
||||||
((MobEntityBridge) zombieEntity).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
|
((MobEntityBridge) zombieEntity).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
|
||||||
}
|
}
|
||||||
@ -62,22 +66,17 @@ public abstract class ZombieEntityMixin extends CreatureEntityMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "onKillEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/merchant/villager/VillagerEntity;remove()V"))
|
@Eject(method = "func_241847_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/merchant/villager/VillagerEntity;func_233656_b_(Lnet/minecraft/entity/EntityType;Z)Lnet/minecraft/entity/MobEntity;"))
|
||||||
private void arclight$transformPre(VillagerEntity villagerEntity) {
|
private <T extends MobEntity> T arclight$transform(VillagerEntity villagerEntity, EntityType<T> entityType, boolean flag, CallbackInfo ci) {
|
||||||
}
|
T t = this.a(entityType, flag, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION);
|
||||||
|
if (t == null) {
|
||||||
@Inject(method = "onKillEntity", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
|
||||||
private void arclight$transformInfection(LivingEntity entityLivingIn, CallbackInfo ci, VillagerEntity villagerEntity, ZombieVillagerEntity zombieVillagerEntity) {
|
|
||||||
if (CraftEventFactory.callEntityTransformEvent(villagerEntity, zombieVillagerEntity, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
|
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
} else {
|
|
||||||
villagerEntity.remove();
|
|
||||||
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.INFECTION);
|
|
||||||
}
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onInitialSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
@Inject(method = "onInitialSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
||||||
private void arclight$mount(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag, CallbackInfoReturnable<ILivingEntityData> cir) {
|
private void arclight$mount(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag, CallbackInfoReturnable<ILivingEntityData> cir) {
|
||||||
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.MOUNT);
|
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.MOUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.monster;
|
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.MobEntity;
|
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.entity.monster.ZombiePigmanEntity.HurtByAggressorGoal")
|
|
||||||
public class ZombiePigmanEntity_HurtByAggressorGoalMixin {
|
|
||||||
|
|
||||||
@Inject(method = "setAttackTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/MobEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
|
|
||||||
private void arclight$reason(MobEntity mobIn, LivingEntity targetIn, CallbackInfo ci) {
|
|
||||||
((MobEntityBridge) mobIn).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +1,10 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.monster;
|
package io.izzel.arclight.common.mixin.core.entity.monster;
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
|
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
import io.izzel.arclight.mixin.Eject;
|
||||||
import net.minecraft.entity.merchant.villager.VillagerEntity;
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.entity.monster.ZombieVillagerEntity;
|
import net.minecraft.entity.monster.ZombieVillagerEntity;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
|
||||||
import org.bukkit.entity.ZombieVillager;
|
import org.bukkit.entity.ZombieVillager;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||||
@ -13,9 +12,7 @@ import org.bukkit.event.entity.EntityTransformEvent;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -33,19 +30,15 @@ public abstract class ZombieVillagerEntityMixin extends ZombieEntityMixin {
|
|||||||
bridge$pushEffectCause(EntityPotionEffectEvent.Cause.CONVERSION);
|
bridge$pushEffectCause(EntityPotionEffectEvent.Cause.CONVERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "cureZombie", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombieVillagerEntity;remove()V"))
|
@Eject(method = "cureZombie", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombieVillagerEntity;func_233656_b_(Lnet/minecraft/entity/EntityType;Z)Lnet/minecraft/entity/MobEntity;"))
|
||||||
private void arclight$transformPre(ZombieVillagerEntity zombieVillagerEntity) {
|
private <T extends MobEntity> T arclight$cure(ZombieVillagerEntity zombieVillagerEntity, EntityType<T> entityType, boolean flag, CallbackInfo ci) {
|
||||||
}
|
T t = this.a(entityType, flag, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
|
||||||
|
if (t == null) {
|
||||||
@Inject(method = "cureZombie", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
|
((ZombieVillager) this.bridge$getBukkitEntity()).setConversionTime(-1);
|
||||||
private void arclight$transform(ServerWorld world, CallbackInfo ci, VillagerEntity villagerEntity) {
|
|
||||||
if (CraftEventFactory.callEntityTransformEvent((ZombieVillagerEntity)(Object)this, villagerEntity, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
|
|
||||||
((ZombieVillager) getBukkitEntity()).setConversionTime(-1);
|
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
} else {
|
} else {
|
||||||
this.remove();
|
((LivingEntityBridge) t).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.CONVERSION);
|
||||||
((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CURED);
|
}
|
||||||
((LivingEntityBridge) villagerEntity).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.CONVERSION);
|
return t;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package io.izzel.arclight.common.mixin.core.entity.passive;
|
|||||||
import io.izzel.arclight.common.bridge.entity.passive.TurtleEntityBridge;
|
import io.izzel.arclight.common.bridge.entity.passive.TurtleEntityBridge;
|
||||||
import net.minecraft.entity.effect.LightningBoltEntity;
|
import net.minecraft.entity.effect.LightningBoltEntity;
|
||||||
import net.minecraft.entity.passive.TurtleEntity;
|
import net.minecraft.entity.passive.TurtleEntity;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
@ -31,13 +32,13 @@ public abstract class TurtleEntityMixin extends AnimalEntityMixin implements Tur
|
|||||||
forceDrops = false;
|
forceDrops = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onStruckByLightning", at = @At("HEAD"))
|
@Inject(method = "func_241841_a", at = @At("HEAD"))
|
||||||
private void arclight$lightning(LightningBoltEntity lightningBolt, CallbackInfo ci) {
|
private void arclight$lightning(ServerWorld p_241841_1_, LightningBoltEntity lightningBolt, CallbackInfo ci) {
|
||||||
CraftEventFactory.entityDamage = lightningBolt;
|
CraftEventFactory.entityDamage = lightningBolt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onStruckByLightning", at = @At("RETURN"))
|
@Inject(method = "func_241841_a", at = @At("RETURN"))
|
||||||
private void arclight$lightningReset(LightningBoltEntity lightningBolt, CallbackInfo ci) {
|
private void arclight$lightningReset(ServerWorld p_241841_1_, LightningBoltEntity lightningBolt, CallbackInfo ci) {
|
||||||
CraftEventFactory.entityDamage = null;
|
CraftEventFactory.entityDamage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public abstract class TurtleEntity_LayEggGoalMixin extends MoveToBlockGoal {
|
|||||||
@Overwrite
|
@Overwrite
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
BlockPos blockpos = new BlockPos(this.turtle);
|
BlockPos blockpos = this.turtle.getPosition();
|
||||||
if (!this.turtle.isInWater() && this.getIsAboveDestination()) {
|
if (!this.turtle.isInWater() && this.getIsAboveDestination()) {
|
||||||
if (((TurtleEntityBridge) this.turtle).bridge$getDigging() < 1) {
|
if (((TurtleEntityBridge) this.turtle).bridge$getDigging() < 1) {
|
||||||
((TurtleEntityBridge) this.turtle).bridge$setDigging(true);
|
((TurtleEntityBridge) this.turtle).bridge$setDigging(true);
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.entity.passive;
|
package io.izzel.arclight.common.mixin.core.entity.passive;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.ai.goal.SitGoal;
|
|
||||||
import net.minecraft.entity.passive.WolfEntity;
|
import net.minecraft.entity.passive.WolfEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@ -19,38 +16,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
@Mixin(WolfEntity.class)
|
@Mixin(WolfEntity.class)
|
||||||
public abstract class WolfEntityMixin extends TameableEntityMixin {
|
public abstract class WolfEntityMixin extends TameableEntityMixin {
|
||||||
|
|
||||||
// @formatter:off
|
@Redirect(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;func_233687_w_(Z)V"))
|
||||||
@Shadow public abstract void setAngry(boolean angry);
|
private void arclight$handledBy(WolfEntity wolfEntity, boolean p_233687_1_) {
|
||||||
@Shadow public abstract boolean isAngry();
|
|
||||||
// @formatter:on
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setGoalTarget(LivingEntity entityliving, EntityTargetEvent.TargetReason reason, boolean fire) {
|
|
||||||
if (!super.setGoalTarget(entityliving, reason, fire)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
entityliving = getAttackingEntity();
|
|
||||||
if (entityliving == null) {
|
|
||||||
this.setAngry(false);
|
|
||||||
} else if (!this.isTamed()) {
|
|
||||||
this.setAngry(true);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "readAdditional", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;contains(Ljava/lang/String;I)Z"))
|
|
||||||
private void arclight$angry(CompoundNBT compound, CallbackInfo ci) {
|
|
||||||
if (this.getAttackTarget() == null && this.isAngry()) {
|
|
||||||
this.setAngry(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;setAngry(Z)V"))
|
|
||||||
private void arclight$fixError(WolfEntity wolfEntity, boolean angry) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/goal/SitGoal;setSitting(Z)V"))
|
|
||||||
private void arclight$handledBy(SitGoal sitGoal, boolean sitting) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "setTamed", at = @At("RETURN"))
|
@Inject(method = "setTamed", at = @At("RETURN"))
|
||||||
@ -60,13 +27,13 @@ public abstract class WolfEntityMixin extends TameableEntityMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "processInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;heal(F)V"))
|
@Inject(method = "func_230254_b_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;heal(F)V"))
|
||||||
private void arclight$healReason(PlayerEntity player, Hand hand, CallbackInfoReturnable<Boolean> cir) {
|
private void arclight$healReason(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResultType> cir) {
|
||||||
bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.EATING);
|
bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.EATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "processInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
|
@Inject(method = "func_230254_b_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
|
||||||
private void arclight$attackReason(PlayerEntity player, Hand hand, CallbackInfoReturnable<Boolean> cir) {
|
private void arclight$attackReason(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResultType> cir) {
|
||||||
bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.FORGOT_TARGET, true);
|
bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.FORGOT_TARGET, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.projectile.WitherSkullEntity;
|
import net.minecraft.entity.projectile.WitherSkullEntity;
|
||||||
import net.minecraft.util.math.EntityRayTraceResult;
|
import net.minecraft.util.math.EntityRayTraceResult;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.world.Explosion;
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -20,14 +19,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(WitherSkullEntity.class)
|
@Mixin(WitherSkullEntity.class)
|
||||||
public abstract class WitherSkullEntityMixin extends DamagingProjectileEntityMixin {
|
public abstract class WitherSkullEntityMixin extends DamagingProjectileEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "onImpact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;heal(F)V"))
|
@Inject(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;heal(F)V"))
|
||||||
private void arclight$heal(RayTraceResult result, CallbackInfo ci) {
|
private void arclight$heal(EntityRayTraceResult result, CallbackInfo ci) {
|
||||||
((LivingEntityBridge) this.shootingEntity).bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.WITHER);
|
((LivingEntityBridge) this.func_234616_v_()).bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.WITHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onImpact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
@Inject(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
|
||||||
private void arclight$effect(RayTraceResult result, CallbackInfo ci) {
|
private void arclight$effect(EntityRayTraceResult result, CallbackInfo ci) {
|
||||||
((LivingEntityBridge) ((EntityRayTraceResult) result).getEntity()).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
|
((LivingEntityBridge) result.getEntity()).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "onImpact", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/Explosion$Mode;)Lnet/minecraft/world/Explosion;"))
|
@Redirect(method = "onImpact", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/Explosion$Mode;)Lnet/minecraft/world/Explosion;"))
|
||||||
|
|||||||
@ -39,4 +39,14 @@ public interface IServerWorldMixin extends IWorld, IWorldBridge, WorldBridge {
|
|||||||
this.addEntity(next);
|
this.addEntity(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean addAllEntities(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||||
|
Iterator<Entity> iterator = entity.getSelfAndPassengers().iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Entity next = iterator.next();
|
||||||
|
bridge$pushAddEntityReason(reason);
|
||||||
|
this.addEntity(next);
|
||||||
|
}
|
||||||
|
return !entity.removed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package io.izzel.arclight.common.mixin.core.world;
|
package io.izzel.arclight.common.mixin.core.world;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
|
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
|
||||||
|
import io.izzel.arclight.common.bridge.world.TrackedEntityBridge;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.MobEntity;
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeMap;
|
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
|
||||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||||
@ -27,7 +29,7 @@ import net.minecraft.network.play.server.SSetPassengersPacket;
|
|||||||
import net.minecraft.network.play.server.SSpawnMobPacket;
|
import net.minecraft.network.play.server.SSpawnMobPacket;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.potion.EffectInstance;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.TrackedEntity;
|
import net.minecraft.world.TrackedEntity;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraft.world.storage.MapData;
|
import net.minecraft.world.storage.MapData;
|
||||||
@ -45,6 +47,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -52,7 +55,7 @@ import java.util.Set;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Mixin(TrackedEntity.class)
|
@Mixin(TrackedEntity.class)
|
||||||
public abstract class TrackedEntityMixin {
|
public abstract class TrackedEntityMixin implements TrackedEntityBridge {
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
@Shadow @Final private Entity trackedEntity;
|
@Shadow @Final private Entity trackedEntity;
|
||||||
@ -72,7 +75,7 @@ public abstract class TrackedEntityMixin {
|
|||||||
@Shadow private long encodedPosZ;
|
@Shadow private long encodedPosZ;
|
||||||
@Shadow private boolean onGround;
|
@Shadow private boolean onGround;
|
||||||
@Shadow @Final private boolean sendVelocityUpdates;
|
@Shadow @Final private boolean sendVelocityUpdates;
|
||||||
@Shadow private Vec3d velocity;
|
@Shadow private Vector3d velocity;
|
||||||
@Shadow private int encodedRotationYawHead;
|
@Shadow private int encodedRotationYawHead;
|
||||||
@Shadow protected abstract void sendPacket(IPacket<?> p_219451_1_);
|
@Shadow protected abstract void sendPacket(IPacket<?> p_219451_1_);
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
@ -93,6 +96,11 @@ public abstract class TrackedEntityMixin {
|
|||||||
this.trackedPlayers = set;
|
this.trackedPlayers = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bridge$setTrackedPlayers(Set<ServerPlayerEntity> trackedPlayers) {
|
||||||
|
this.trackedPlayers = trackedPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author IzzelAliz
|
* @author IzzelAliz
|
||||||
* @reason
|
* @reason
|
||||||
@ -105,15 +113,15 @@ public abstract class TrackedEntityMixin {
|
|||||||
this.sendPacket(new SSetPassengersPacket(this.trackedEntity));
|
this.sendPacket(new SSetPassengersPacket(this.trackedEntity));
|
||||||
}
|
}
|
||||||
if (this.trackedEntity instanceof ItemFrameEntity) {
|
if (this.trackedEntity instanceof ItemFrameEntity) {
|
||||||
ItemFrameEntity entityitemframe = (ItemFrameEntity) this.trackedEntity;
|
ItemFrameEntity itemframeentity = (ItemFrameEntity) this.trackedEntity;
|
||||||
ItemStack itemstack = entityitemframe.getDisplayedItem();
|
ItemStack itemstack = itemframeentity.getDisplayedItem();
|
||||||
if (this.updateCounter % 10 == 0 && itemstack.getItem() instanceof FilledMapItem) {
|
MapData mapdata = FilledMapItem.getMapData(itemstack, this.world);
|
||||||
MapData worldmap = FilledMapItem.getMapData(itemstack, this.world);
|
if (this.updateCounter % 10 == 0 && mapdata != null) {
|
||||||
for (ServerPlayerEntity entityplayer : this.trackedPlayers) {
|
for (ServerPlayerEntity serverplayerentity : this.trackedPlayers) {
|
||||||
worldmap.updateVisiblePlayers(entityplayer, itemstack);
|
mapdata.updateVisiblePlayers(serverplayerentity, itemstack);
|
||||||
IPacket<?> packet = ((FilledMapItem) itemstack.getItem()).getUpdatePacket(itemstack, this.world, entityplayer);
|
IPacket<?> ipacket = ((FilledMapItem) itemstack.getItem()).getUpdatePacket(itemstack, this.world, serverplayerentity);
|
||||||
if (packet != null) {
|
if (ipacket != null) {
|
||||||
entityplayer.connection.sendPacket(packet);
|
serverplayerentity.connection.sendPacket(ipacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,72 +129,72 @@ public abstract class TrackedEntityMixin {
|
|||||||
}
|
}
|
||||||
if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataManager().isDirty()) {
|
if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataManager().isDirty()) {
|
||||||
if (this.trackedEntity.isPassenger()) {
|
if (this.trackedEntity.isPassenger()) {
|
||||||
int i = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0f / 360.0f);
|
int i1 = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
|
||||||
int j = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0f / 360.0f);
|
int l1 = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
|
||||||
boolean flag = Math.abs(i - this.encodedRotationYaw) >= 1 || Math.abs(j - this.encodedRotationPitch) >= 1;
|
boolean flag2 = Math.abs(i1 - this.encodedRotationYaw) >= 1 || Math.abs(l1 - this.encodedRotationPitch) >= 1;
|
||||||
if (flag) {
|
if (flag2) {
|
||||||
this.packetConsumer.accept(new SEntityPacket.LookPacket(this.trackedEntity.getEntityId(), (byte) i, (byte) j, this.trackedEntity.onGround));
|
this.packetConsumer.accept(new SEntityPacket.LookPacket(this.trackedEntity.getEntityId(), (byte) i1, (byte) l1, this.trackedEntity.isOnGround()));
|
||||||
this.encodedRotationYaw = i;
|
this.encodedRotationYaw = i1;
|
||||||
this.encodedRotationPitch = j;
|
this.encodedRotationPitch = l1;
|
||||||
}
|
}
|
||||||
this.updateEncodedPosition();
|
this.updateEncodedPosition();
|
||||||
this.sendMetadata();
|
this.sendMetadata();
|
||||||
this.riding = true;
|
this.riding = true;
|
||||||
} else {
|
} else {
|
||||||
++this.ticksSinceAbsoluteTeleport;
|
++this.ticksSinceAbsoluteTeleport;
|
||||||
int i = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0f / 360.0f);
|
int l = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
|
||||||
int j = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0f / 360.0f);
|
int k1 = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
|
||||||
Vec3d vec3d = this.trackedEntity.getPositionVec().subtract(SEntityPacket.func_218744_a(this.encodedPosX, this.encodedPosY, this.encodedPosZ));
|
Vector3d vector3d = this.trackedEntity.getPositionVec().subtract(SEntityPacket.func_218744_a(this.encodedPosX, this.encodedPosY, this.encodedPosZ));
|
||||||
boolean flag2 = vec3d.lengthSquared() >= 7.62939453125E-6;
|
boolean flag3 = vector3d.lengthSquared() >= (double) 7.6293945E-6F;
|
||||||
IPacket<?> packet2 = null;
|
IPacket<?> ipacket1 = null;
|
||||||
boolean flag3 = flag2 || this.updateCounter % 60 == 0;
|
boolean flag4 = flag3 || this.updateCounter % 60 == 0;
|
||||||
boolean flag4 = Math.abs(i - this.encodedRotationYaw) >= 1 || Math.abs(j - this.encodedRotationPitch) >= 1;
|
boolean flag = Math.abs(l - this.encodedRotationYaw) >= 1 || Math.abs(k1 - this.encodedRotationPitch) >= 1;
|
||||||
if (flag3) {
|
if (flag4) {
|
||||||
this.updateEncodedPosition();
|
this.updateEncodedPosition();
|
||||||
}
|
}
|
||||||
if (flag4) {
|
if (flag) {
|
||||||
this.encodedRotationYaw = i;
|
this.encodedRotationYaw = l;
|
||||||
this.encodedRotationPitch = j;
|
this.encodedRotationPitch = k1;
|
||||||
}
|
}
|
||||||
if (this.updateCounter > 0 || this.trackedEntity instanceof AbstractArrowEntity) {
|
if (this.updateCounter > 0 || this.trackedEntity instanceof AbstractArrowEntity) {
|
||||||
long k = SEntityPacket.func_218743_a(vec3d.x);
|
long i = SEntityPacket.func_218743_a(vector3d.x);
|
||||||
long l = SEntityPacket.func_218743_a(vec3d.y);
|
long j = SEntityPacket.func_218743_a(vector3d.y);
|
||||||
long i2 = SEntityPacket.func_218743_a(vec3d.z);
|
long k = SEntityPacket.func_218743_a(vector3d.z);
|
||||||
boolean flag5 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i2 < -32768L || i2 > 32767L;
|
boolean flag1 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L;
|
||||||
if (!flag5 && this.ticksSinceAbsoluteTeleport <= 400 && !this.riding && this.onGround == this.trackedEntity.onGround) {
|
if (!flag1 && this.ticksSinceAbsoluteTeleport <= 400 && !this.riding && this.onGround == this.trackedEntity.isOnGround()) {
|
||||||
if ((!flag3 || !flag4) && !(this.trackedEntity instanceof AbstractArrowEntity)) {
|
if ((!flag4 || !flag) && !(this.trackedEntity instanceof AbstractArrowEntity)) {
|
||||||
if (flag3) {
|
if (flag4) {
|
||||||
packet2 = new SEntityPacket.RelativeMovePacket(this.trackedEntity.getEntityId(), (short) k, (short) l, (short) i2, this.trackedEntity.onGround);
|
ipacket1 = new SEntityPacket.RelativeMovePacket(this.trackedEntity.getEntityId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.trackedEntity.isOnGround());
|
||||||
} else if (flag4) {
|
} else if (flag) {
|
||||||
packet2 = new SEntityPacket.LookPacket(this.trackedEntity.getEntityId(), (byte) i, (byte) j, this.trackedEntity.onGround);
|
ipacket1 = new SEntityPacket.LookPacket(this.trackedEntity.getEntityId(), (byte) l, (byte) k1, this.trackedEntity.isOnGround());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
packet2 = new SEntityPacket.MovePacket(this.trackedEntity.getEntityId(), (short) k, (short) l, (short) i2, (byte) i, (byte) j, this.trackedEntity.onGround);
|
ipacket1 = new SEntityPacket.MovePacket(this.trackedEntity.getEntityId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), (byte) l, (byte) k1, this.trackedEntity.isOnGround());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.onGround = this.trackedEntity.onGround;
|
this.onGround = this.trackedEntity.isOnGround();
|
||||||
this.ticksSinceAbsoluteTeleport = 0;
|
this.ticksSinceAbsoluteTeleport = 0;
|
||||||
packet2 = new SEntityTeleportPacket(this.trackedEntity);
|
ipacket1 = new SEntityTeleportPacket(this.trackedEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((this.sendVelocityUpdates || this.trackedEntity.isAirBorne || (this.trackedEntity instanceof LivingEntity && ((LivingEntity) this.trackedEntity).isElytraFlying())) && this.updateCounter > 0) {
|
if ((this.sendVelocityUpdates || this.trackedEntity.isAirBorne || this.trackedEntity instanceof LivingEntity && ((LivingEntity) this.trackedEntity).isElytraFlying()) && this.updateCounter > 0) {
|
||||||
Vec3d vec3d2 = this.trackedEntity.getMotion();
|
Vector3d vector3d1 = this.trackedEntity.getMotion();
|
||||||
double d0 = vec3d2.squareDistanceTo(this.velocity);
|
double d0 = vector3d1.squareDistanceTo(this.velocity);
|
||||||
if (d0 > 1.0E-7 || (d0 > 0.0 && vec3d2.lengthSquared() == 0.0)) {
|
if (d0 > 1.0E-7D || d0 > 0.0D && vector3d1.lengthSquared() == 0.0D) {
|
||||||
this.velocity = vec3d2;
|
this.velocity = vector3d1;
|
||||||
this.packetConsumer.accept(new SEntityVelocityPacket(this.trackedEntity.getEntityId(), this.velocity));
|
this.packetConsumer.accept(new SEntityVelocityPacket(this.trackedEntity.getEntityId(), this.velocity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packet2 != null) {
|
if (ipacket1 != null) {
|
||||||
this.packetConsumer.accept(packet2);
|
this.packetConsumer.accept(ipacket1);
|
||||||
}
|
}
|
||||||
this.sendMetadata();
|
this.sendMetadata();
|
||||||
this.riding = false;
|
this.riding = false;
|
||||||
}
|
}
|
||||||
int i = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
|
int j1 = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
|
||||||
if (Math.abs(i - this.encodedRotationYawHead) >= 1) {
|
if (Math.abs(j1 - this.encodedRotationYawHead) >= 1) {
|
||||||
this.packetConsumer.accept(new SEntityHeadLookPacket(this.trackedEntity, (byte) i));
|
this.packetConsumer.accept(new SEntityHeadLookPacket(this.trackedEntity, (byte) j1));
|
||||||
this.encodedRotationYawHead = i;
|
this.encodedRotationYawHead = j1;
|
||||||
}
|
}
|
||||||
this.trackedEntity.isAirBorne = false;
|
this.trackedEntity.isAirBorne = false;
|
||||||
}
|
}
|
||||||
@ -216,11 +224,12 @@ public abstract class TrackedEntityMixin {
|
|||||||
a(consumer, playerEntity);
|
a(consumer, playerEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(final Consumer<IPacket<?>> consumer, final ServerPlayerEntity entityplayer) {
|
public void a(Consumer<IPacket<?>> consumer, ServerPlayerEntity entityplayer) {
|
||||||
|
MobEntity entityinsentient;
|
||||||
if (this.trackedEntity.removed) {
|
if (this.trackedEntity.removed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final IPacket<?> packet = this.trackedEntity.createSpawnPacket();
|
IPacket<?> packet = this.trackedEntity.createSpawnPacket();
|
||||||
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
|
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
|
||||||
consumer.accept(packet);
|
consumer.accept(packet);
|
||||||
if (!this.trackedEntity.getDataManager().isEmpty()) {
|
if (!this.trackedEntity.getDataManager().isEmpty()) {
|
||||||
@ -228,8 +237,7 @@ public abstract class TrackedEntityMixin {
|
|||||||
}
|
}
|
||||||
boolean flag = this.sendVelocityUpdates;
|
boolean flag = this.sendVelocityUpdates;
|
||||||
if (this.trackedEntity instanceof LivingEntity) {
|
if (this.trackedEntity instanceof LivingEntity) {
|
||||||
final AttributeMap attributemapserver = (AttributeMap) ((LivingEntity) this.trackedEntity).getAttributes();
|
Collection<ModifiableAttributeInstance> collection = ((LivingEntity) this.trackedEntity).getAttributeManager().getWatchedInstances();
|
||||||
final Collection<IAttributeInstance> collection = attributemapserver.getWatchedAttributes();
|
|
||||||
if (this.trackedEntity.getEntityId() == entityplayer.getEntityId()) {
|
if (this.trackedEntity.getEntityId() == entityplayer.getEntityId()) {
|
||||||
((ServerPlayerEntityBridge) this.trackedEntity).bridge$getBukkitEntity().injectScaledMaxHealth(collection, false);
|
((ServerPlayerEntityBridge) this.trackedEntity).bridge$getBukkitEntity().injectScaledMaxHealth(collection, false);
|
||||||
}
|
}
|
||||||
@ -245,18 +253,21 @@ public abstract class TrackedEntityMixin {
|
|||||||
consumer.accept(new SEntityVelocityPacket(this.trackedEntity.getEntityId(), this.velocity));
|
consumer.accept(new SEntityVelocityPacket(this.trackedEntity.getEntityId(), this.velocity));
|
||||||
}
|
}
|
||||||
if (this.trackedEntity instanceof LivingEntity) {
|
if (this.trackedEntity instanceof LivingEntity) {
|
||||||
for (final EquipmentSlotType enumitemslot : EquipmentSlotType.values()) {
|
ArrayList<Pair<EquipmentSlotType, ItemStack>> list = Lists.newArrayList();
|
||||||
final ItemStack itemstack = ((LivingEntity) this.trackedEntity).getItemStackFromSlot(enumitemslot);
|
for (EquipmentSlotType enumitemslot : EquipmentSlotType.values()) {
|
||||||
if (!itemstack.isEmpty()) {
|
ItemStack itemstack = ((LivingEntity) this.trackedEntity).getItemStackFromSlot(enumitemslot);
|
||||||
consumer.accept(new SEntityEquipmentPacket(this.trackedEntity.getEntityId(), enumitemslot, itemstack));
|
if (itemstack.isEmpty()) continue;
|
||||||
|
list.add(Pair.of(enumitemslot, itemstack.copy()));
|
||||||
}
|
}
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
consumer.accept(new SEntityEquipmentPacket(this.trackedEntity.getEntityId(), list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
|
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
|
||||||
consumer.accept(new SEntityHeadLookPacket(this.trackedEntity, (byte) this.encodedRotationYawHead));
|
consumer.accept(new SEntityHeadLookPacket(this.trackedEntity, (byte) this.encodedRotationYawHead));
|
||||||
if (this.trackedEntity instanceof LivingEntity) {
|
if (this.trackedEntity instanceof LivingEntity) {
|
||||||
final LivingEntity entityliving = (LivingEntity) this.trackedEntity;
|
LivingEntity entityliving = (LivingEntity) this.trackedEntity;
|
||||||
for (final EffectInstance mobeffect : entityliving.getActivePotionEffects()) {
|
for (EffectInstance mobeffect : entityliving.getActivePotionEffects()) {
|
||||||
consumer.accept(new SPlayEntityEffectPacket(this.trackedEntity.getEntityId(), mobeffect));
|
consumer.accept(new SPlayEntityEffectPacket(this.trackedEntity.getEntityId(), mobeffect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,16 +277,13 @@ public abstract class TrackedEntityMixin {
|
|||||||
if (this.trackedEntity.isPassenger()) {
|
if (this.trackedEntity.isPassenger()) {
|
||||||
consumer.accept(new SSetPassengersPacket(this.trackedEntity.getRidingEntity()));
|
consumer.accept(new SSetPassengersPacket(this.trackedEntity.getRidingEntity()));
|
||||||
}
|
}
|
||||||
if (this.trackedEntity instanceof MobEntity) {
|
if (this.trackedEntity instanceof MobEntity && (entityinsentient = (MobEntity) this.trackedEntity).getLeashed()) {
|
||||||
MobEntity mobentity = (MobEntity) this.trackedEntity;
|
consumer.accept(new SMountEntityPacket(entityinsentient, entityinsentient.getLeashHolder()));
|
||||||
if (mobentity.getLeashed()) {
|
|
||||||
consumer.accept(new SMountEntityPacket(mobentity, mobentity.getLeashHolder()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "sendMetadata", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/TrackedEntity;sendPacket(Lnet/minecraft/network/IPacket;)V"))
|
@Inject(method = "sendMetadata", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/TrackedEntity;sendPacket(Lnet/minecraft/network/IPacket;)V"))
|
||||||
private void arclight$sendScaledHealth(CallbackInfo ci, EntityDataManager entitydatamanager, AttributeMap attributemap, Set<IAttributeInstance> set) {
|
private void arclight$sendScaledHealth(CallbackInfo ci, EntityDataManager entitydatamanager, Set<ModifiableAttributeInstance> set) {
|
||||||
if (this.trackedEntity instanceof ServerPlayerEntity) {
|
if (this.trackedEntity instanceof ServerPlayerEntity) {
|
||||||
((ServerPlayerEntityBridge) this.trackedEntity).bridge$getBukkitEntity().injectScaledMaxHealth(set, false);
|
((ServerPlayerEntityBridge) this.trackedEntity).bridge$getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user