1.16: entities part 3

This commit is contained in:
IzzelAliz 2020-08-24 22:16:28 +08:00
parent 1263cf11ea
commit 90bf29ed3d
36 changed files with 623 additions and 763 deletions

View File

@ -2,6 +2,7 @@ package io.izzel.arclight.common.bridge.block;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftPortalEvent;
import org.jetbrains.annotations.Nullable;
public interface PortalInfoBridge {
@ -11,5 +12,5 @@ public interface PortalInfoBridge {
void bridge$setWorld(ServerWorld world);
ServerWorld bridge$getWorld();
@Nullable ServerWorld bridge$getWorld();
}

View File

@ -11,10 +11,6 @@ public interface PlayerEntityBridge extends LivingEntityBridge {
boolean bridge$isFauxSleeping();
String bridge$getSpawnWorld();
void bridge$setSpawnWorld(String world);
@Override
CraftHumanEntity bridge$getBukkitEntity();

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.TeleportationRepositioner;
import net.minecraft.util.math.BlockPos;
@ -11,4 +12,6 @@ public interface TeleporterBridge {
boolean bridge$makePortal(Entity entityIn, BlockPos pos, int createRadius);
Optional<TeleportationRepositioner.Result> bridge$findPortal(BlockPos pos, int searchRadius);
Optional<TeleportationRepositioner.Result> bridge$createPortal(BlockPos pos, Direction.Axis axis, Entity entity, int createRadius);
}

View File

@ -191,6 +191,10 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
@Shadow protected BlockPos field_242271_ac;
@Shadow protected abstract Vector3d func_241839_a(Direction.Axis p_241839_1_, TeleportationRepositioner.Result p_241839_2_);
@Shadow public abstract EntitySize getSize(Pose poseIn);
@Shadow protected abstract boolean func_233566_aG_();
@Shadow public abstract boolean isInLava();
@Shadow protected abstract void setOnFireFromLava();
@Shadow protected boolean firstUpdate;
// @formatter:on
private static final int CURRENT_LEVEL = 2;
@ -862,7 +866,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
ServerWorld worldFinal = world = ((CraftWorld) event.getTo().getWorld()).getHandle();
blockpos1 = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
return this.a(world, blockpos1, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((p_242275_2_) -> {
return this.findOrCreatePortal(world, blockpos1, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((p_242275_2_) -> {
BlockState blockstate = this.world.getBlockState(this.field_242271_ac);
Direction.Axis direction$axis;
Vector3d vector3d;
@ -911,6 +915,10 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
}
protected Optional<TeleportationRepositioner.Result> a(ServerWorld serverWorld, BlockPos pos, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) {
return findOrCreatePortal(serverWorld, pos, flag, searchRadius, canCreatePortal, createRadius);
}
protected Optional<TeleportationRepositioner.Result> findOrCreatePortal(ServerWorld serverWorld, BlockPos pos, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) {
return ((TeleporterBridge) serverWorld.getDefaultTeleporter()).bridge$findPortal(pos, searchRadius);
}
}

View File

@ -170,6 +170,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
@Shadow public abstract void applyKnockback(float strength, double ratioX, double ratioZ);
@Shadow protected abstract void damageArmor(DamageSource damageSource, float damage);
@Shadow protected abstract void playEquipSound(ItemStack stack);
@Shadow public abstract boolean getShouldBeDead();
// @formatter:on
public int expToDrop;

View File

@ -9,7 +9,6 @@ import net.minecraft.util.math.BlockPos;
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;
@ -18,37 +17,21 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightningBoltEntity.class)
public abstract class LightningBoltEntityMixin extends EntityMixin {
// @formatter:off
@Shadow private int lightningState;
// @formatter:on
public boolean isSilent = false;
public boolean isEffect;
public boolean isSilent;
@Inject(method = "<init>", at = @At("RETURN"))
private void arclight$init(World worldIn, double x, double y, double z, boolean effectOnlyIn, CallbackInfo ci) {
this.isEffect = effectOnlyIn;
this.isSilent = false;
}
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onStruckByLightning(Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;func_241841_a(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
private void arclight$captureEntity(CallbackInfo ci) {
ArclightCaptures.captureDamageEventEntity((Entity) (Object) this);
}
@Inject(method = "tick", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/Entity;onStruckByLightning(Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
@Inject(method = "tick", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/Entity;func_241841_a(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
private void arclight$resetEntity(CallbackInfo ci) {
ArclightCaptures.captureDamageEventEntity(null);
}
@Redirect(method = "tick", at = @At(value = "FIELD", ordinal = 6, target = "Lnet/minecraft/entity/effect/LightningBoltEntity;lightningState:I"))
private int arclight$effectOnlyCheck(LightningBoltEntity entity) {
return (this.lightningState >= 0 && !this.isEffect) ? this.lightningState : -1;
}
@Redirect(method = "igniteBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
private boolean arclight$blockIgnite(World world, BlockPos pos, BlockState state) {
if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, pos, (LightningBoltEntity) (Object) this).isCancelled()) {
if (!CraftEventFactory.callBlockIgniteEvent(world, pos, (LightningBoltEntity) (Object) this).isCancelled()) {
return world.setBlockState(pos, state);
} else {
return false;

View File

@ -1,11 +1,10 @@
package io.izzel.arclight.common.mixin.core.entity.item;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import io.izzel.arclight.common.mixin.core.entity.projectile.ProjectileItemEntityMixin;
import net.minecraft.entity.item.ExperienceBottleEntity;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.ExpBottleEvent;
@ -13,7 +12,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(ExperienceBottleEntity.class)
public abstract class ExperienceBottleEntityMixin extends EntityMixin {
public abstract class ExperienceBottleEntityMixin extends ProjectileItemEntityMixin {
/**
* @author IzzelAliz
@ -21,17 +20,18 @@ public abstract class ExperienceBottleEntityMixin extends EntityMixin {
*/
@Overwrite
protected void onImpact(RayTraceResult result) {
super.onImpact(result);
if (!this.world.isRemote) {
int i = 3 + this.world.rand.nextInt(5) + this.world.rand.nextInt(5);
ExpBottleEvent event = CraftEventFactory.callExpBottleEvent((ExperienceBottleEntity) (Object) this, i);
i = event.getExperience();
if (event.getShowEffect()) {
this.world.playEvent(2002, new BlockPos((ExperienceBottleEntity) (Object) this), PotionUtils.getPotionColor(Potions.WATER));
this.world.playEvent(2002, this.getPosition(), PotionUtils.getPotionColor(Potions.WATER));
}
while (i > 0) {
int j = ExperienceOrbEntity.getXPSplit(i);
i -= j;
this.world.addEntity(new ExperienceOrbEntity(this.world, this.posX, this.posY, this.posZ, j));
this.world.addEntity(new ExperienceOrbEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), j));
}
this.remove();
}

View File

@ -34,7 +34,7 @@ public abstract class ItemFrameEntityMixin extends HangingEntityMixin {
if (!itemstack.isEmpty()) {
itemstack = itemstack.copy();
itemstack.setCount(1);
itemstack.setItemFrame((ItemFrameEntity) (Object) this);
itemstack.setAttachedEntity((ItemFrameEntity) (Object) this);
}
this.getDataManager().set(ITEM, itemstack);
if (!itemstack.isEmpty() && playSound) {
@ -51,9 +51,7 @@ public abstract class ItemFrameEntityMixin extends HangingEntityMixin {
double locY = blockPosition.getY() + 0.5 - direction.getYOffset() * 0.46875;
double locZ = blockPosition.getZ() + 0.5 - direction.getZOffset() * 0.46875;
if (entity != null) {
entity.posX = locX;
entity.posY = locY;
entity.posZ = locZ;
entity.setRawPosition(locX, locY, locZ);
}
double d2 = width;
double d3 = height;

View File

@ -5,6 +5,7 @@ import net.minecraft.entity.item.LeashKnotEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.server.SMountEntityPacket;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
@ -30,13 +31,13 @@ public abstract class LeashKnotEntityMixin extends HangingEntityMixin {
*/
@SuppressWarnings("ConstantConditions")
@Overwrite
public boolean processInitialInteract(final PlayerEntity entityhuman, final Hand enumhand) {
public ActionResultType processInitialInteract(final PlayerEntity entityhuman, final Hand enumhand) {
if (this.world.isRemote) {
return true;
return ActionResultType.SUCCESS;
}
boolean flag = false;
final double d0 = 7.0;
final List<MobEntity> list = this.world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(this.posX - 7.0, this.posY - 7.0, this.posZ - 7.0, this.posX + 7.0, this.posY + 7.0, this.posZ + 7.0));
final List<MobEntity> list = this.world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(this.getPosX() - 7.0, this.getPosY() - 7.0, this.getPosZ() - 7.0, this.getPosX() + 7.0, this.getPosY() + 7.0, this.getPosZ() + 7.0));
for (final MobEntity entityinsentient : list) {
if (entityinsentient.getLeashHolder() == entityhuman) {
if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, (LeashKnotEntity) (Object) this, entityhuman).isCancelled()) {
@ -62,6 +63,6 @@ public abstract class LeashKnotEntityMixin extends HangingEntityMixin {
this.remove();
}
}
return true;
return ActionResultType.CONSUME;
}
}

View File

@ -3,8 +3,8 @@ package io.izzel.arclight.common.mixin.core.entity.item.minecart;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PoweredRailBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
@ -17,7 +17,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityPredicates;
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.World;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -59,6 +59,7 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
@Shadow public abstract void onActivatorRailPass(int x, int y, int z, boolean receivingPower);
@Shadow private boolean isInReverse;
@Shadow public abstract AbstractMinecartEntity.Type getMinecartType();
@Shadow public abstract boolean canUseRail();
// @formatter:on
public boolean slowWhenEmpty = true;
@ -130,9 +131,9 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
*/
@Overwrite
public void tick() {
double prevX = this.posX;
double prevY = this.posY;
double prevZ = this.posZ;
double prevX = this.getPosX();
double prevY = this.getPosY();
double prevZ = this.getPosZ();
float prevYaw = this.rotationYaw;
float prevPitch = this.rotationPitch;
if (this.getRollingAmplitude() > 0) {
@ -141,14 +142,14 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
if (this.getDamage() > 0.0f) {
this.setDamage(this.getDamage() - 1.0f);
}
if (this.posY < -64.0) {
if (this.getPosY() < -64.0) {
this.outOfWorld();
}
if (this.world.isRemote) {
if (this.turnProgress > 0) {
double d0 = this.posX + (this.minecartX - this.posX) / this.turnProgress;
double d2 = this.posY + (this.minecartY - this.posY) / this.turnProgress;
double d3 = this.posZ + (this.minecartZ - this.posZ) / this.turnProgress;
double d0 = this.getPosX() + (this.minecartX - this.getPosX()) / this.turnProgress;
double d2 = this.getPosY() + (this.minecartY - this.getPosY()) / this.turnProgress;
double d3 = this.getPosZ() + (this.minecartZ - this.getPosZ()) / this.turnProgress;
double d4 = MathHelper.wrapDegrees(this.minecartYaw - this.rotationYaw);
this.rotationYaw += (float) (d4 / this.turnProgress);
this.rotationPitch += (float) ((this.minecartPitch - this.rotationPitch) / this.turnProgress);
@ -156,38 +157,38 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
this.setPosition(d0, d2, d3);
this.setRotation(this.rotationYaw, this.rotationPitch);
} else {
this.setPosition(this.posX, this.posY, this.posZ);
this.setPosition(this.getPosX(), this.getPosY(), this.getPosZ());
this.setRotation(this.rotationYaw, this.rotationPitch);
}
} else {
/*
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.prevPosX = this.getPosX();
this.prevPosY = this.getPosY();
this.prevPosZ = this.getPosZ();
*/
if (!this.hasNoGravity()) {
this.setMotion(this.getMotion().add(0.0, -0.04, 0.0));
}
int i = MathHelper.floor(this.posX);
int j = MathHelper.floor(this.posY);
int k = MathHelper.floor(this.posZ);
int i = MathHelper.floor(this.getPosX());
int j = MathHelper.floor(this.getPosY());
int k = MathHelper.floor(this.getPosZ());
if (this.world.getBlockState(new BlockPos(i, j - 1, k)).isIn(BlockTags.RAILS)) {
--j;
}
BlockPos blockposition = new BlockPos(i, j, k);
BlockState iblockdata = this.world.getBlockState(blockposition);
if (iblockdata.isIn(BlockTags.RAILS)) {
this.moveAlongTrack(blockposition, iblockdata);
if (iblockdata.getBlock() == Blocks.ACTIVATOR_RAIL) {
this.onActivatorRailPass(i, j, k, iblockdata.get(PoweredRailBlock.POWERED));
BlockState blockstate = this.world.getBlockState(blockposition);
if (this.canUseRail() && AbstractRailBlock.isRail(blockstate)) {
this.moveAlongTrack(blockposition, blockstate);
if (blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()).isActivatorRail()) {
this.onActivatorRailPass(i, j, k, blockstate.get(PoweredRailBlock.POWERED));
}
} else {
this.moveDerailedMinecart();
}
this.doBlockCollisions();
this.rotationPitch = 0.0f;
double d5 = this.prevPosX - this.posX;
double d6 = this.prevPosZ - this.posZ;
double d5 = this.prevPosX - this.getPosX();
double d6 = this.prevPosZ - this.getPosZ();
if (d5 * d5 + d6 * d6 > 0.001) {
this.rotationYaw = (float) (MathHelper.atan2(d6, d5) * 180.0 / 3.141592653589793);
if (this.isInReverse) {
@ -202,7 +203,7 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
this.setRotation(this.rotationYaw, this.rotationPitch);
org.bukkit.World bworld = ((WorldBridge) this.world).bridge$getWorld();
Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
Location to = new Location(bworld, this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
Location to = new Location(bworld, this.getPosX(), this.getPosY(), this.getPosZ(), this.rotationYaw, this.rotationPitch);
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
Bukkit.getPluginManager().callEvent(new VehicleUpdateEvent(vehicle));
if (!from.equals(to)) {
@ -242,7 +243,12 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
}
}
}
this.handleWaterMovement();
this.func_233566_aG_();
if (this.isInLava()) {
this.setOnFireFromLava();
this.fallDistance *= 0.5F;
}
this.firstUpdate = false;
}
}
@ -262,14 +268,14 @@ public abstract class AbstractMinecartEntityMixin extends EntityMixin {
@Overwrite
protected void moveDerailedMinecart() {
final double d0 = this.getMaximumSpeed();
final Vec3d vec3d = this.getMotion();
final Vector3d vec3d = this.getMotion();
this.setMotion(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0));
if (this.onGround) {
this.setMotion(new Vec3d(this.getMotion().x * this.derailedX, this.getMotion().y * this.derailedY, this.getMotion().z * this.derailedZ));
this.setMotion(new Vector3d(this.getMotion().x * this.derailedX, this.getMotion().y * this.derailedY, this.getMotion().z * this.derailedZ));
}
this.move(MoverType.SELF, this.getMotion());
if (!this.onGround) {
this.setMotion(new Vec3d(this.getMotion().x * this.flyingX, this.getMotion().y * this.flyingY, this.getMotion().z * this.flyingZ));
this.setMotion(new Vector3d(this.getMotion().x * this.flyingX, this.getMotion().y * this.flyingY, this.getMotion().z * this.flyingZ));
}
}

View File

@ -3,15 +3,15 @@ package io.izzel.arclight.common.mixin.core.entity.item.minecart;
import io.izzel.arclight.common.bridge.command.ICommandSourceBridge;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.item.minecart.MinecartCommandBlockEntity;
import net.minecraft.entity.item.minecart.CommandBlockMinecartEntity;
import org.bukkit.command.CommandSender;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(MinecartCommandBlockEntity.MinecartCommandLogic.class)
public abstract class MinecartCommandBlockEntity_MinecartCommandLogicMixin implements ICommandSourceBridge {
@Mixin(CommandBlockMinecartEntity.MinecartCommandLogic.class)
public abstract class CommandBlockMinecartEntity_MinecartCommandLogicMixin implements ICommandSourceBridge {
@Shadow(aliases = {"this$0", "field_210168_a"}, remap = false) private MinecartCommandBlockEntity outerThis;
@Shadow(aliases = {"this$0", "field_210168_a"}, remap = false) private CommandBlockMinecartEntity outerThis;
public CommandSender getBukkitSender(CommandSource wrapper) {
return ((EntityBridge) outerThis).bridge$getBukkitEntity();

View File

@ -25,6 +25,7 @@ public abstract class AbstractSkeletonEntityMixin extends CreatureEntityMixin {
if (event.isCancelled()) {
event.getProjectile().remove();
ci.cancel();
return;
}
if (event.getProjectile() != ((EntityBridge) arrowEntity).bridge$getBukkitEntity()) {
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

View File

@ -34,7 +34,7 @@ public abstract class SilverfishEntity_SummonSilverfishGoalMixin extends Goal {
if (this.lookForFriends <= 0) {
World world = this.silverfish.world;
Random random = this.silverfish.getRNG();
BlockPos blockpos = new BlockPos(this.silverfish);
BlockPos blockpos = this.silverfish.getPosition();
for (int i = 0; i <= 5 && i >= -5; i = (i <= 0 ? 1 : 0) - i) {
for (int j = 0; j <= 10 && j >= -10; j = (j <= 0 ? 1 : 0) - j) {

View File

@ -5,6 +5,7 @@ import io.izzel.arclight.common.mixin.core.entity.MobEntityMixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.SlimeEntity;
import net.minecraft.util.text.ITextComponent;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.Slime;
@ -35,30 +36,36 @@ public abstract class SlimeEntityMixin extends MobEntityMixin {
@Override
public void remove(boolean keepData) {
int i = this.getSlimeSize();
if (!this.world.isRemote && i > 1 && this.getHealth() <= 0.0f) {
int j = 2 + this.rand.nextInt(3);
SlimeSplitEvent event = new SlimeSplitEvent((Slime) this.getBukkitEntity(), j);
if (!this.world.isRemote && i > 1 && this.getShouldBeDead() && !this.removed) {
ITextComponent itextcomponent = this.getCustomName();
boolean flag = this.isAIDisabled();
float f = (float) i / 4.0F;
int j = i / 2;
int k = 2 + this.rand.nextInt(3);
SlimeSplitEvent event = new SlimeSplitEvent((Slime) this.getBukkitEntity(), k);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled() || event.getCount() <= 0) {
super.remove(keepData);
return;
}
j = event.getCount();
List<LivingEntity> slimes = new ArrayList<>(j);
for (int k = 0; k < j; ++k) {
float f = (k % 2 - 0.5f) * i / 4.0f;
float f2 = (k / 2 - 0.5f) * i / 4.0f;
SlimeEntity entityslime = this.getType().create(this.world);
if (this.hasCustomName()) {
entityslime.setCustomName(this.getCustomName());
}
k = event.getCount();
List<LivingEntity> slimes = new ArrayList<>(k);
for (int l = 0; l < k; ++l) {
float f1 = ((float) (l % 2) - 0.5F) * f;
float f2 = ((float) (l / 2) - 0.5F) * f;
SlimeEntity slimeentity = this.getType().create(this.world);
if (this.isNoDespawnRequired()) {
entityslime.enablePersistence();
slimeentity.enablePersistence();
}
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSlimeSize(i / 2, true);
entityslime.setLocationAndAngles(this.posX + f, this.posY + 0.5, this.posZ + f2, this.rand.nextFloat() * 360.0f, 0.0f);
slimes.add(entityslime);
slimeentity.setCustomName(itextcomponent);
slimeentity.setNoAI(flag);
slimeentity.setInvulnerable(this.isInvulnerable());
slimeentity.setSlimeSize(j, true);
slimeentity.setLocationAndAngles(this.getPosX() + (double) f1, this.getPosY() + 0.5D, this.getPosZ() + (double) f2, this.rand.nextFloat() * 360.0F, 0.0F);
slimes.add(slimeentity);
}
if (CraftEventFactory.callEntityTransformEvent((SlimeEntity) (Object) this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
return;

View File

@ -0,0 +1,25 @@
package io.izzel.arclight.common.mixin.core.entity.monster;
import net.minecraft.entity.monster.SpellcastingIllagerEntity;
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;
@Mixin(SpellcastingIllagerEntity.UseSpellGoal.class)
public abstract class SpellcastingIllagerEntity_UseSpellGoalMixin {
// @formatter:off
@Shadow(aliases = {"this$0", "field_193323_e"}, remap = false) private SpellcastingIllagerEntity outerThis;
@Shadow protected abstract SpellcastingIllagerEntity.SpellType getSpellType();
// @formatter:on
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/SpellcastingIllagerEntity$UseSpellGoal;castSpell()V"))
private void arclight$castSpell(CallbackInfo ci) {
if (!CraftEventFactory.handleEntitySpellCastEvent(outerThis, this.getSpellType())) {
ci.cancel();
}
}
}

View File

@ -1,30 +1,23 @@
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import net.minecraft.entity.ILivingEntityData;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.monster.SpiderEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.IWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
import net.minecraft.world.IServerWorld;
import org.bukkit.event.entity.EntityPotionEffectEvent;
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.CallbackInfoReturnable;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
@Mixin(SpiderEntity.class)
public abstract class SpiderEntityMixin extends CreatureEntityMixin {
@Inject(method = "onInitialSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$spawnReason(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag, CallbackInfoReturnable<ILivingEntityData> cir) {
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.JOCKEY);
}
@Inject(method = "onInitialSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/SpiderEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$potionReason(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag, CallbackInfoReturnable<ILivingEntityData> cir) {
private void arclight$potionReason(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag, CallbackInfoReturnable<ILivingEntityData> cir) {
bridge$pushEffectCause(EntityPotionEffectEvent.Cause.SPIDER_SPAWN);
}
}

View File

@ -1,56 +0,0 @@
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.ZombiePigmanEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DamageSource;
import org.bukkit.Bukkit;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.entity.PigZombieAngerEvent;
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.CallbackInfoReturnable;
@Mixin(ZombiePigmanEntity.class)
public abstract class ZombiePigmanEntityMixin extends ZombieEntityMixin {
// @formatter:off
@Shadow protected abstract boolean func_226547_i_(LivingEntity p_70835_1_);
@Shadow protected abstract int func_223336_ef();
// @formatter:on
public boolean attackEntityFrom(DamageSource damagesource, float f) {
if (this.isInvulnerableTo(damagesource)) {
return false;
}
Entity entity = damagesource.getTrueSource();
boolean result = super.attackEntityFrom(damagesource, f);
if (result && entity instanceof PlayerEntity && !((PlayerEntity) entity).isCreative() && this.canEntityBeSeen(entity)) {
this.func_226547_i_((LivingEntity) entity);
}
return result;
}
@Inject(method = "func_226547_i_", cancellable = true, at = @At("HEAD"))
private void arclight$anger(LivingEntity entity, CallbackInfoReturnable<Boolean> cir) {
PigZombieAngerEvent event = new PigZombieAngerEvent((PigZombie) this.getBukkitEntity(), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), this.func_223336_ef());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(false);
} else {
arclight$capture = event.getNewAnger();
}
}
private transient int arclight$capture;
@Redirect(method = "func_226547_i_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombiePigmanEntity;func_223336_ef()I"))
private int arclight$useAnger(ZombiePigmanEntity pigmanEntity) {
return arclight$capture;
}
}

View File

@ -0,0 +1,64 @@
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.monster.ZombifiedPiglinEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PigZombieAngerEvent;
import org.jetbrains.annotations.Nullable;
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.callback.CallbackInfo;
import java.util.UUID;
@Mixin(ZombifiedPiglinEntity.class)
public abstract class ZombifiedPiglinEntityMixin extends ZombieEntityMixin {
// @formatter:off
@Shadow public abstract UUID getAngerTarget();
@Shadow public abstract void setAngerTarget(@Nullable UUID target);
@Shadow public abstract void setAngerTime(int time);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private void func_241411_fa_() {
double d0 = this.getAttributeValue(Attributes.FOLLOW_RANGE);
AxisAlignedBB axisalignedbb = AxisAlignedBB.fromVector(this.getPositionVec()).grow(d0, 10.0D, d0);
for (ZombifiedPiglinEntity piglinEntity : this.world.getLoadedEntitiesWithinAABB(ZombifiedPiglinEntity.class, axisalignedbb)) {
if (piglinEntity != (Object) this) {
if (piglinEntity.getAttackTarget() == null) {
if (!piglinEntity.isOnSameTeam(this.getAttackTarget())) {
((MobEntityBridge) piglinEntity).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true);
piglinEntity.setAttackTarget(this.getAttackTarget());
}
}
}
}
}
@Eject(method = "func_230258_H__", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombifiedPiglinEntity;setAngerTime(I)V"))
private void arclight$pigAngry(ZombifiedPiglinEntity piglinEntity, int time, CallbackInfo ci) {
Entity entity = ((ServerWorld) this.world).getEntityByUuid(this.getAngerTarget());
PigZombieAngerEvent event = new PigZombieAngerEvent((PigZombie) this.getBukkitEntity(), entity == null ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), time);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.setAngerTarget(null);
ci.cancel();
}
this.setAngerTime(event.getNewAnger());
}
}

View File

@ -3,9 +3,10 @@ package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.passive.CowEntity;
import net.minecraft.entity.passive.MooshroomEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityTransformEvent;
@ -16,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Collections;
import java.util.List;
@Mixin(MooshroomEntity.class)
@ -26,9 +28,9 @@ public abstract class MooshroomEntityMixin extends AnimalEntityMixin {
}
@Inject(method = "onSheared", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$animalTransform(ItemStack item, IWorld world, BlockPos pos, int fortune, CallbackInfoReturnable<List<ItemStack>> cir, List<ItemStack> stackList, CowEntity cowEntity) {
private void arclight$animalTransform(PlayerEntity player, ItemStack item, World world, BlockPos pos, int fortune, CallbackInfoReturnable<List<ItemStack>> cir, CowEntity cowEntity) {
if (CraftEventFactory.callEntityTransformEvent((MooshroomEntity) (Object) this, cowEntity, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
cir.setReturnValue(stackList);
cir.setReturnValue(Collections.emptyList());
} else {
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SHEARED);
this.remove();

View File

@ -24,7 +24,7 @@ public abstract class PandaEntityMixin extends AnimalEntityMixin {
@Overwrite
protected void updateEquipmentIfNeeded(ItemEntity itemEntity) {
boolean cancel = this.getItemStackFromSlot(EquipmentSlotType.MAINHAND).isEmpty() && PANDA_ITEMS.test(itemEntity);
if (CraftEventFactory.callEntityPickupItemEvent((PandaEntity) (Object) this, itemEntity, 0, cancel).isCancelled()) {
if (!CraftEventFactory.callEntityPickupItemEvent((PandaEntity) (Object) this, itemEntity, 0, cancel).isCancelled()) {
ItemStack itemstack = itemEntity.getItem();
this.setItemStackToSlot(EquipmentSlotType.MAINHAND, itemstack);
this.inventoryHandsDropChances[EquipmentSlotType.MAINHAND.getIndex()] = 2.0F;

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.mixin.core.entity.passive;
import net.minecraft.entity.ai.goal.SitGoal;
import net.minecraft.entity.passive.ParrotEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.spongepowered.asm.mixin.Mixin;
@ -14,12 +14,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ParrotEntity.class)
public abstract class ParrotEntityMixin extends AnimalEntityMixin {
@Inject(method = "processInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/ParrotEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$feed(PlayerEntity player, Hand hand, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "func_230254_b_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/ParrotEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$feed(PlayerEntity p_230254_1_, Hand p_230254_2_, CallbackInfoReturnable<ActionResultType> cir) {
bridge$pushEffectCause(EntityPotionEffectEvent.Cause.FOOD);
}
@Redirect(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/goal/SitGoal;setSitting(Z)V"))
private void arclight$handledInSuper(SitGoal sitGoal, boolean sitting) {
@Redirect(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/ParrotEntity;func_233687_w_(Z)V"))
private void arclight$handledInSuper(ParrotEntity parrotEntity, boolean p_233687_1_) {
}
}

View File

@ -2,8 +2,9 @@ package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.monster.ZombiePigmanEntity;
import net.minecraft.entity.monster.ZombifiedPiglinEntity;
import net.minecraft.entity.passive.PigEntity;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.spongepowered.asm.mixin.Mixin;
@ -15,10 +16,10 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(PigEntity.class)
public abstract class PigEntityMixin extends AnimalEntityMixin {
@Inject(method = "onStruckByLightning", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$pigZap(LightningBoltEntity lightningBolt, CallbackInfo ci, ZombiePigmanEntity pigmanEntity) {
if (CraftEventFactory.callPigZapEvent((PigEntity) (Object) this, lightningBolt, pigmanEntity).isCancelled()) {
@Inject(method = "func_241841_a", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$pigZap(ServerWorld p_241841_1_, LightningBoltEntity lightningBolt, CallbackInfo ci, ZombifiedPiglinEntity piglin) {
if (CraftEventFactory.callPigZapEvent((PigEntity) (Object) this, lightningBolt, piglin).isCancelled()) {
ci.cancel();
} else {
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.LIGHTNING);

View File

@ -18,12 +18,12 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(SheepEntity.class)
public abstract class SheepEntityMixin extends AnimalEntityMixin {
@Inject(method = "func_213612_dV", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;entityDropItem(Lnet/minecraft/util/IItemProvider;I)Lnet/minecraft/entity/item/ItemEntity;"))
@Inject(method = "shear", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;entityDropItem(Lnet/minecraft/util/IItemProvider;I)Lnet/minecraft/entity/item/ItemEntity;"))
private void arclight$forceDrop(CallbackInfo ci) {
forceDrops = true;
}
@Inject(method = "func_213612_dV", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/passive/SheepEntity;entityDropItem(Lnet/minecraft/util/IItemProvider;I)Lnet/minecraft/entity/item/ItemEntity;"))
@Inject(method = "shear", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/passive/SheepEntity;entityDropItem(Lnet/minecraft/util/IItemProvider;I)Lnet/minecraft/entity/item/ItemEntity;"))
private void arclight$forceDropReset(CallbackInfo ci) {
forceDrops = false;
}

View File

@ -17,6 +17,7 @@ import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.boss.dragon.EnderDragonPartEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.item.ItemEntity;
@ -38,7 +39,6 @@ import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.FoodStats;
import net.minecraft.util.Hand;
import net.minecraft.util.HandSide;
@ -48,6 +48,7 @@ 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.vector.Vector3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
@ -132,103 +133,6 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
((IInventoryBridge) this.enterChestInventory).setOwner(this.getBukkitEntity());
}
private boolean arclight$forceSleep = false;
private Object arclight$processSleep = null;
private Either<PlayerEntity.SleepResult, Unit> getBedResult(BlockPos at, Direction direction) {
arclight$processSleep = true;
Either<PlayerEntity.SleepResult, Unit> either = this.trySleep(at);
arclight$processSleep = null;
return either;
}
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
arclight$forceSleep = force;
try {
return this.trySleep(at);
} finally {
arclight$forceSleep = false;
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "HEAD"))
public void arclight$onSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep == null) {
Either<PlayerEntity.SleepResult, Unit> result = getBedResult(at, null);
if (result.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) {
cir.setReturnValue(result);
return;
}
if (arclight$forceSleep) {
result = Either.right(Unit.INSTANCE);
}
if (this.bridge$getBukkitEntity() instanceof Player) {
result = CraftEventFactory.callPlayerBedEnterEvent((PlayerEntity) (Object) this, at, result);
if (result.left().isPresent()) {
cir.setReturnValue(result);
return;
}
}
this.startSleeping(at);
this.sleepTimer = 0;
if (this.world instanceof ServerWorld) {
((ServerWorld) this.world).updateAllPlayersSleepingFlag();
}
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;startSleeping(Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$preSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep != null) {
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I"))
private void arclight$wakeup(boolean flag, boolean flag1, CallbackInfo ci) {
BlockPos blockPos = this.getBedPosition().orElse(null);
if (this.bridge$getBukkitEntity() instanceof Player) {
Player player = (Player) this.bridge$getBukkitEntity();
Block bed;
if (blockPos != null) {
bed = CraftBlock.at(this.world, blockPos);
} else {
bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation());
}
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
Bukkit.getPluginManager().callEvent(event);
}
}
@Inject(method = "setSpawnPoint", remap = false, at = @At("RETURN"))
private void arclight$updateSpawnpoint(BlockPos pos, boolean p_226560_2_, boolean p_226560_3_, DimensionType dim, CallbackInfo ci) {
bridge$setSpawnWorld(pos == null ? "" : this.world.worldInfo.getWorldName());
}
@Inject(method = "startFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$startGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, true).isCancelled()) {
this.setFlag(7, true);
this.setFlag(7, false);
ci.cancel();
}
}
@Inject(method = "stopFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$stopGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, false).isCancelled()) {
ci.cancel();
}
}
@Override
public Either<PlayerEntity.SleepResult, Unit> bridge$trySleep(BlockPos at, boolean force) {
return sleep(at, force);
}
@Override
public boolean bridge$isFauxSleeping() {
return fauxSleeping;
@ -270,19 +174,6 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
}
@Inject(method = "readAdditional", at = @At("RETURN"))
private void arclight$readSpawnWorld(CompoundNBT compound, CallbackInfo ci) {
this.spawnWorld = compound.getString("SpawnWorld");
if ("".equals(spawnWorld)) {
this.spawnWorld = Bukkit.getWorlds().get(0).getName();
}
}
@Inject(method = "writeAdditional", at = @At("RETURN"))
private void arclight$writeSpawnWorld(CompoundNBT compound, CallbackInfo ci) {
compound.putString("SpawnWorld", this.spawnWorld);
}
/**
* @author IzzelAliz
* @reason
@ -365,7 +256,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
public void attackTargetEntityWithCurrentItem(final Entity entity) {
if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget((PlayerEntity) (Object) this, entity)) return;
if (entity.canBeAttackedWithItem() && !entity.hitByEntity((PlayerEntity) (Object) this)) {
float f = (float) this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getValue();
float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
float f2;
if (entity instanceof LivingEntity) {
f2 = EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((LivingEntity) entity).getCreatureAttribute());
@ -382,7 +273,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
final byte b0 = 0;
int i = b0 + EnchantmentHelper.getKnockbackModifier((PlayerEntity) (Object) this);
if (this.isSprinting() && flag) {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0f, 1.0f);
++i;
flag2 = true;
}
@ -415,12 +306,12 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
}
}
final Vec3d vec3d = entity.getMotion();
final Vector3d vec3d = entity.getMotion();
final boolean flag6 = entity.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) (Object) this), f);
if (flag6) {
if (i > 0) {
if (entity instanceof LivingEntity) {
((LivingEntity) entity).knockBack((PlayerEntity) (Object) this, i * 0.5f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
((LivingEntity) entity).applyKnockback(i * 0.5f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
} else {
entity.addVelocity(-MathHelper.sin(this.rotationYaw * 0.017453292f) * i * 0.5f, 0.1, MathHelper.cos(this.rotationYaw * 0.017453292f) * i * 0.5f);
}
@ -432,10 +323,10 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
final List<LivingEntity> list = this.world.getEntitiesWithinAABB(LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0));
for (final LivingEntity entityliving : list) {
if (entityliving != (Object) this && entityliving != entity && !this.isOnSameTeam(entityliving) && (!(entityliving instanceof ArmorStandEntity) || !((ArmorStandEntity) entityliving).hasMarker()) && this.getDistanceSq(entityliving) < 9.0 && entityliving.attackEntityFrom(((DamageSourceBridge) DamageSource.causePlayerDamage((PlayerEntity) (Object) this)).bridge$sweep(), f5)) {
entityliving.knockBack((PlayerEntity) (Object) this, 0.4f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
entityliving.applyKnockback(0.4f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
}
}
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0f, 1.0f);
this.spawnSweepParticles();
}
if (entity instanceof ServerPlayerEntity && entity.velocityChanged) {
@ -456,14 +347,14 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
}
if (flag3) {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0f, 1.0f);
this.onCriticalHit(entity);
}
if (!flag3 && !flag4) {
if (flag) {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0f, 1.0f);
} else {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0f, 1.0f);
}
}
if (f2 > 0.0f) {
@ -499,12 +390,12 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
if (this.world instanceof ServerWorld && f6 > 2.0f) {
final int k = (int) (f6 * 0.5);
((ServerWorld) this.world).spawnParticle(ParticleTypes.DAMAGE_INDICATOR, entity.posX, entity.posY + entity.getHeight() * 0.5f, entity.posZ, k, 0.1, 0.0, 0.1, 0.2);
((ServerWorld) this.world).spawnParticle(ParticleTypes.DAMAGE_INDICATOR, entity.getPosX(), entity.getPosY() + entity.getHeight() * 0.5f, entity.getPosZ(), k, 0.1, 0.0, 0.1, 0.2);
}
}
this.addExhaustion(0.1f);
} else {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0f, 1.0f);
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0f, 1.0f);
if (flag5) {
entity.extinguish();
}
@ -516,9 +407,32 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
}
protected transient boolean arclight$forceSleep;
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
this.arclight$forceSleep = force;
return this.trySleep(at);
}
@Override
public void bridge$setSpawnWorld(String world) {
this.spawnWorld = world;
public Either<PlayerEntity.SleepResult, Unit> bridge$trySleep(BlockPos at, boolean force) {
return sleep(at, force);
}
@Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I"))
private void arclight$wakeup(boolean flag, boolean flag1, CallbackInfo ci) {
BlockPos blockPos = this.getBedPosition().orElse(null);
if (this.bridge$getBukkitEntity() instanceof Player) {
Player player = (Player) this.bridge$getBukkitEntity();
Block bed;
if (blockPos != null) {
bed = CraftBlock.at(this.world, blockPos);
} else {
bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation());
}
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
Bukkit.getPluginManager().callEvent(event);
}
}
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setFlag(IZ)V"))
@ -528,6 +442,22 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
}
@Inject(method = "startFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$startGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, true).isCancelled()) {
this.setFlag(7, true);
this.setFlag(7, false);
ci.cancel();
}
}
@Inject(method = "stopFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$stopGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, false).isCancelled()) {
ci.cancel();
}
}
/**
* @author IzzelAliz
* @reason
@ -549,7 +479,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
if (entity instanceof TameableEntity) {
((TameableEntity) entity).setOwnerId(this.entityUniqueID);
}
entity.setPosition(this.posX, this.posY + 0.699999988079071, this.posZ);
entity.setPosition(this.getPosX(), this.getPosY() + 0.699999988079071, this.getPosZ());
return ((ServerWorldBridge) this.world).bridge$addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY);
}).orElse(true);
}
@ -562,9 +492,4 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
public CraftHumanEntity bridge$getBukkitEntity() {
return (CraftHumanEntity) ((InternalEntityBridge) this).internal$getBukkitEntity();
}
@Override
public String bridge$getSpawnWorld() {
return spawnWorld;
}
}

View File

@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.entity.player;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.block.PortalInfoBridge;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
@ -10,26 +11,23 @@ import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
import io.izzel.arclight.common.bridge.util.FoodStatsBridge;
import io.izzel.arclight.common.bridge.world.TeleporterBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Blocks;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.block.NetherPortalBlock;
import net.minecraft.block.PortalInfo;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.SpawnLocationHelper;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.HorseInventoryContainer;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.RecipeBook;
import net.minecraft.item.crafting.ServerRecipeBook;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.network.play.client.CClientSettingsPacket;
@ -55,41 +53,48 @@ import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.CombatTracker;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.FoodStats;
import net.minecraft.util.HandSide;
import net.minecraft.util.NonNullList;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.TeleportationRepositioner;
import net.minecraft.util.Unit;
import net.minecraft.util.Util;
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.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraft.world.DimensionType;
import net.minecraft.world.GameRules;
import net.minecraft.world.GameType;
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.biome.BiomeManager;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.storage.IWorldInfo;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.fml.hooks.BasicEventHooks;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.WeatherType;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.craftbukkit.v.entity.CraftPlayer;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.event.CraftPortalEvent;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.scoreboard.CraftScoreboardManager;
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator;
import org.bukkit.craftbukkit.v.util.CraftChatMessage;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -100,7 +105,6 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerLocaleChangeEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.inventory.MainHand;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -120,6 +124,7 @@ import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.UUID;
import java.util.function.Consumer;
@Mixin(ServerPlayerEntity.class)
@ -138,17 +143,27 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
@Shadow public abstract ServerWorld getServerWorld();
@Shadow public boolean queuedEndExit;
@Shadow private boolean seenCredits;
@Shadow @Nullable private Vec3d enteredNetherPosition;
@Shadow @Nullable private Vector3d enteredNetherPosition;
@Shadow public abstract void func_213846_b(ServerWorld p_213846_1_);
@Shadow public int lastExperience;
@Shadow private float lastHealth;
@Shadow private int lastFoodLevel;
@Shadow public int currentWindowId;
@Shadow public abstract void getNextWindowId();
@Shadow public abstract void sendMessage(ITextComponent component);
@Shadow public String language;
@Shadow private String language;
@Shadow public abstract void teleport(ServerWorld p_200619_1_, double x, double y, double z, float yaw, float pitch);
@Shadow public abstract void giveExperiencePoints(int p_195068_1_);
@Shadow private RegistryKey<World> field_241137_cq_;
@Shadow @Nullable public abstract BlockPos func_241140_K_();
@Shadow public abstract float func_242109_L();
@Shadow protected abstract void func_241157_eT_();
@Shadow protected abstract void func_242110_a(ServerWorld p_242110_1_, BlockPos p_242110_2_);
@Shadow @Final private static Logger LOGGER;
@Shadow public abstract boolean isCreative();
@Shadow public abstract void func_242111_a(RegistryKey<World> p_242111_1_, @org.jetbrains.annotations.Nullable BlockPos p_242111_2_, float p_242111_3_, boolean p_242111_4_, boolean p_242111_5_);
@Shadow protected abstract boolean func_241156_b_(BlockPos p_241156_1_, Direction p_241156_2_);
@Shadow protected abstract boolean func_241147_a_(BlockPos p_241147_1_, Direction p_241147_2_);
@Shadow public abstract void sendMessage(ITextComponent component, UUID senderUUID);
// @formatter:on
public String displayName;
@ -167,6 +182,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
public WeatherType weather = null;
private float pluginRainPosition;
private float pluginRainPositionPrevious;
public String locale = "en_us";
@Inject(method = "<init>", at = @At("RETURN"))
public void arclight$init(CallbackInfo ci) {
@ -175,254 +191,11 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
this.maxHealthCache = this.getMaxHealth();
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite(remap = false)
@Nullable
public Entity changeDimension(DimensionType dim, ITeleporter teleporter) {
DimensionType[] destination = {dim};
if (this.isSleeping()) return (ServerPlayerEntity) (Object) this;
if (!ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, destination[0])) return null;
PlayerTeleportEvent.TeleportCause cause = bridge$getTeleportCause().orElse(PlayerTeleportEvent.TeleportCause.UNKNOWN);
// this.invulnerableDimensionChange = true;
DimensionType dimensiontype = this.dimension;
if (((DimensionTypeBridge) dimensiontype).bridge$getType() == DimensionType.THE_END && ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
this.invulnerableDimensionChange = true;
this.detach();
this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
if (!this.queuedEndExit) {
this.queuedEndExit = true;
this.connection.sendPacket(new SChangeGameStatePacket(4, this.seenCredits ? 0.0F : 1.0F));
this.seenCredits = true;
}
return (ServerPlayerEntity) (Object) this;
} else {
ServerWorld serverworld = this.server.getWorld(dimensiontype);
// this.dimension = destination;
ServerWorld[] serverworld1 = {this.server.getWorld(destination[0])};
/*
WorldInfo worldinfo = serverworld1.getWorldInfo();
NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this);
this.connection.sendPacket(new SRespawnPacket(destination, WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType()));
this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList();
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
*/
PlayerList[] playerlist = new PlayerList[1];
Entity e = teleporter.placeEntity((ServerPlayerEntity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> {//Forge: Start vanilla logic
double d0 = this.getPosX();
double d1 = this.getPosY();
double d2 = this.getPosZ();
float f = this.rotationPitch;
float f1 = this.rotationYaw;
double d3 = 8.0D;
float f2 = f1;
serverworld.getProfiler().startSection("moving");
if (serverworld1[0] != null) {
double moveFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor();
d0 *= moveFactor;
d2 *= moveFactor;
if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_NETHER) {
this.enteredNetherPosition = this.getPositionVec();
} else if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_END) {
BlockPos blockpos = serverworld1[0].getSpawnCoordinate();
d0 = blockpos.getX();
d1 = blockpos.getY();
d2 = blockpos.getZ();
f1 = 90.0F;
f = 0.0F;
}
}
Location enter = this.bridge$getBukkitEntity().getLocation();
Location exit = (serverworld1[0] == null) ? null : new Location(((ServerWorldBridge) serverworld1[0]).bridge$getWorld(), d0, d1, d2, f1, f);
PlayerPortalEvent event = new PlayerPortalEvent(this.bridge$getBukkitEntity(), enter, exit, cause, 128, true, ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END ? 0 : 16);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null) {
return null;
}
exit = event.getTo();
if (exit == null) {
return null;
}
serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle();
d0 = exit.getX();
d1 = exit.getY();
d2 = exit.getZ();
// this.setLocationAndAngles(d0, d1, d2, f1, f);
serverworld.getProfiler().endSection();
serverworld.getProfiler().startSection("placing");
double d7 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D);
double d4 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D);
double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D);
double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D);
d0 = MathHelper.clamp(d0, d7, d5);
d2 = MathHelper.clamp(d2, d4, d6);
// this.setLocationAndAngles(d0, d1, d2, f1, f);
Vec3d exitVelocity = Vec3d.ZERO;
BlockPos exitPosition = new BlockPos(d0, d1, d2);
if (((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END) {
int i = exitPosition.getX();
int j = exitPosition.getY() - 1;
int k = exitPosition.getZ();
if (event.getCanCreatePortal()) {
BlockStateListPopulator blockList = new BlockStateListPopulator(serverworld1[0]);
for (int j1 = -2; j1 <= 2; ++j1) {
for (int k1 = -2; k1 <= 2; ++k1) {
for (int l1 = -1; l1 < 3; ++l1) {
int i2 = i + k1 * 1 + j1 * 0;
int j2 = j + l1;
int k2 = k + k1 * 0 - j1 * 1;
boolean flag = l1 < 0;
blockList.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState(), 3);
}
}
}
org.bukkit.World bworld = ((ServerWorldBridge) serverworld1[0]).bridge$getWorld();
PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, this.bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.END_PLATFORM);
Bukkit.getPluginManager().callEvent(portalEvent);
if (!portalEvent.isCancelled()) {
blockList.updateList();
}
}
// this.setLocationAndAngles(i, j, k, f1, 0.0F);
exit.setX(i);
exit.setY(j);
exit.setZ(k);
// this.setMotion(Vec3d.ZERO);
exitVelocity = Vec3d.ZERO;
} else {
BlockPattern.PortalInfo portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true);
if (spawnPortal && portalInfo == null && event.getCanCreatePortal()) {
if (((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$makePortal((ServerPlayerEntity) (Object) this, exitPosition, event.getCreationRadius())) {
// serverworld1.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f2);
portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true);
}
}
if (portalInfo == null) {
return null;
}
exitVelocity = portalInfo.motion;
exit.setX(portalInfo.pos.getX());
exit.setY(portalInfo.pos.getY());
exit.setZ(portalInfo.pos.getZ());
exit.setYaw(f2 + (float) portalInfo.rotation);
}
serverworld.getProfiler().endSection();
PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.bridge$getBukkitEntity(), enter, exit, cause);
Bukkit.getServer().getPluginManager().callEvent(tpEvent);
if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
return null;
}
exit = tpEvent.getTo();
if (exit == null) {
return null;
}
serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle();
this.invulnerableDimensionChange = true;
destination[0] = serverworld1[0].getDimension().getType();
this.dimension = destination[0];
WorldInfo worldinfo = serverworld1[0].getWorldInfo();
NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this);
this.connection.sendPacket(new SRespawnPacket(destination[0], WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType()));
this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
playerlist[0] = this.server.getPlayerList();
playerlist[0].updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
this.setMotion(exitVelocity);
this.setWorld(serverworld1[0]);
serverworld1[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
this.func_213846_b(serverworld);
// this.connection.setPlayerLocation(this.getPosX(), this.getPosY(), this.getPosZ(), f1, f);
((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit);
this.connection.captureCurrentPosition();
return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch
});//Forge: End vanilla logic
if (e == null) {
return (ServerPlayerEntity) (Object) this;
} else if (e != (Object) this) {
throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this));
}
this.interactionManager.setWorld(serverworld1[0]);
this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities));
playerlist[0].sendWorldInfo((ServerPlayerEntity) (Object) this, serverworld1[0]);
playerlist[0].sendInventory((ServerPlayerEntity) (Object) this);
for (EffectInstance effectinstance : this.getActivePotionEffects()) {
this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), effectinstance));
}
this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, dimensiontype, destination[0]);
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.bridge$getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld());
Bukkit.getPluginManager().callEvent(changeEvent);
return (ServerPlayerEntity) (Object) this;
}
}
public Entity a(DimensionType dimensionmanager, final PlayerTeleportEvent.TeleportCause cause) {
bridge$pushChangeDimensionCause(cause);
return this.changeDimension(dimensionmanager);
}
@Override
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
return super.sleep(at, force).ifRight((p_213849_1_) -> {
this.addStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger((ServerPlayerEntity) (Object) this);
});
}
@Inject(method = "stopSleepInBed", cancellable = true, at = @At("HEAD"))
private void arclight$notWake(boolean flag, boolean flag1, CallbackInfo ci) {
if (!isSleeping()) ci.cancel();
}
// todo
@Override
public Entity bridge$changeDimension(DimensionType dimensionType, PlayerTeleportEvent.TeleportCause cause) {
return a(dimensionType, cause);
}
public BlockPos getSpawnPoint(ServerWorld worldserver) {
public final BlockPos getSpawnPoint(ServerWorld worldserver) {
BlockPos blockposition = worldserver.getSpawnPoint();
if (worldserver.dimension.hasSkyLight() && worldserver.getWorldInfo().getGameType() != GameType.ADVENTURE) {
if (worldserver.func_230315_m_().hasSkyLight() && worldserver.field_241103_E_.getGameType() != GameType.ADVENTURE) {
long k;
long l;
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getClosestDistance(blockposition.getX(), blockposition.getZ()));
if (j < i) {
@ -431,17 +204,16 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
if (j <= 1) {
i = 1;
}
int k = (i * 2 + 1) * (i * 2 + 1);
int l = this.func_205735_q(k);
int i2 = new Random().nextInt(k);
for (int j2 = 0; j2 < k; ++j2) {
int k2 = (i2 + l * j2) % k;
int l2 = k2 % (i * 2 + 1);
int i3 = k2 / (i * 2 + 1);
BlockPos blockposition2 = worldserver.getDimension().findSpawn(blockposition.getX() + l2 - i, blockposition.getZ() + i3 - i, false);
if (blockposition2 != null) {
return blockposition2;
}
int i1 = (l = (k = (long) (i * 2 + 1)) * k) > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) l;
int j1 = this.func_205735_q(i1);
int k1 = new Random().nextInt(i1);
for (int l1 = 0; l1 < i1; ++l1) {
int i2 = (k1 + j1 * l1) % i1;
int j2 = i2 % (i * 2 + 1);
int k2 = i2 / (i * 2 + 1);
BlockPos blockposition1 = SpawnLocationHelper.func_241092_a_(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i, false);
if (blockposition1 == null) continue;
return blockposition1;
}
}
return blockposition;
@ -455,6 +227,11 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
@Inject(method = "readAdditional", at = @At("RETURN"))
private void arclight$readExtra(CompoundNBT compound, CallbackInfo ci) {
this.getBukkitEntity().readExtraData(compound);
String spawnWorld = compound.getString("SpawnWorld");
CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld);
if (oldWorld != null) {
this.field_241137_cq_ = oldWorld.getHandle().getDimensionKey();
}
}
@Redirect(method = "writeAdditional", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isOnePlayerRiding()Z"))
@ -483,22 +260,17 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
super.setWorld(world);
if (world == null) {
this.removed = false;
Vec3d position = null;
if (this.spawnWorld != null && !this.spawnWorld.equals("")) {
CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld);
if (cworld != null && this.getBedLocation() != null) {
world = cworld.getHandle();
position = PlayerEntity.checkBedValidRespawnPosition(cworld.getHandle(), this.getBedLocation(), false).orElse(null);
}
Vector3d position = null;
if (this.field_241137_cq_ != null && (world = ServerLifecycleHooks.getCurrentServer().getWorld(this.field_241137_cq_)) != null && this.func_241140_K_() != null) {
position = PlayerEntity.func_242374_a((ServerWorld) world, this.func_241140_K_(), this.func_242109_L(), false, false).orElse(null);
}
if (world == null || position == null) {
world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
position = new Vec3d(world.getSpawnPoint());
position = Vector3d.copyCentered(((ServerWorld) world).getSpawnPoint());
}
this.world = world;
this.setPosition(position.getX(), position.getY(), position.getZ());
}
this.dimension = this.world.getDimension().getType();
this.interactionManager.setWorld((ServerWorld) world);
}
@ -563,9 +335,9 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
if (!p_212356_2_.isSuccess()) {
int i = 256;
String s = itextcomponent.getStringTruncated(256);
ITextComponent itextcomponent1 = new TranslationTextComponent("death.attack.message_too_long", (new StringTextComponent(s)).applyTextStyle(TextFormatting.YELLOW));
ITextComponent itextcomponent2 = (new TranslationTextComponent("death.attack.even_more_magic", this.getDisplayName())).applyTextStyle((p_212357_1_) -> {
p_212357_1_.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, itextcomponent1));
ITextComponent itextcomponent1 = new TranslationTextComponent("death.attack.message_too_long", (new StringTextComponent(s)).mergeStyle(TextFormatting.YELLOW));
ITextComponent itextcomponent2 = (new TranslationTextComponent("death.attack.even_more_magic", this.getDisplayName())).modifyStyle((p_212357_1_) -> {
return p_212357_1_.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, itextcomponent1));
});
this.connection.sendPacket(new SCombatPacket(this.getCombatTracker(), SCombatPacket.Event.ENTITY_DIED, itextcomponent2));
}
@ -579,13 +351,17 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
this.server.getPlayerList().sendMessageToTeamOrAllPlayers((ServerPlayerEntity) (Object) this, itextcomponent);
}
} else {
this.server.getPlayerList().sendMessage(itextcomponent);
this.server.getPlayerList().func_232641_a_(itextcomponent, ChatType.SYSTEM, Util.DUMMY_UUID);
}
} else {
this.connection.sendPacket(new SCombatPacket(this.getCombatTracker(), SCombatPacket.Event.ENTITY_DIED));
}
this.spawnShoulderEntities();
if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) {
this.func_241157_eT_();
}
this.dropExperience();
if (!event.getKeepInventory()) {
@ -625,6 +401,232 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
cir.setReturnValue(((WorldBridge) this.world).bridge$isPvpMode());
}
/**
* @author IzzelAliz
* @reason
*/
@Nullable
@Overwrite
protected PortalInfo func_241829_a(ServerWorld p_241829_1_) {
PortalInfo portalinfo = super.func_241829_a(p_241829_1_);
if (portalinfo != null && ((WorldBridge) this.world).bridge$getTypeKey() == DimensionType.OVERWORLD && ((WorldBridge) p_241829_1_).bridge$getTypeKey() == DimensionType.THE_END) {
Vector3d vector3d = portalinfo.pos.add(0.0D, -1.0D, 0.0D);
PortalInfo newInfo = new PortalInfo(vector3d, Vector3d.ZERO, 90.0F, 0.0F);
((PortalInfoBridge) newInfo).bridge$setWorld(p_241829_1_);
((PortalInfoBridge) newInfo).bridge$setPortalEventInfo(((PortalInfoBridge) portalinfo).bridge$getPortalEventInfo());
return newInfo;
} else {
return portalinfo;
}
}
@Override
public Entity bridge$changeDimension(ServerWorld world, PlayerTeleportEvent.TeleportCause cause) {
this.arclight$cause = cause;
return changeDimension(world);
}
private transient PlayerTeleportEvent.TeleportCause arclight$cause;
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
@Nullable
public Entity changeDimension(ServerWorld server, ITeleporter teleporter) {
if (this.isSleeping()) {
return (ServerPlayerEntity) (Object) this;
}
if (!ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, server.getDimensionKey())) return null;
PlayerTeleportEvent.TeleportCause cause = arclight$cause == null ? PlayerTeleportEvent.TeleportCause.UNKNOWN : arclight$cause;
arclight$cause = null;
// this.invulnerableDimensionChange = true;
ServerWorld serverworld = this.getServerWorld();
RegistryKey<DimensionType> registrykey = ((WorldBridge) serverworld).bridge$getTypeKey();
if (registrykey == DimensionType.THE_END && ((WorldBridge) server).bridge$getTypeKey() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
this.detach();
this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
if (!this.queuedEndExit) {
this.queuedEndExit = true;
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241768_e_, this.seenCredits ? 0.0F : 1.0F));
this.seenCredits = true;
}
return (ServerPlayerEntity) (Object) this;
} else {
PlayerList playerlist = this.server.getPlayerList();
/*
IWorldInfo iworldinfo = server.getWorldInfo();
this.connection.sendPacket(new SRespawnPacket(server.func_230315_m_(), server.getDimensionKey(), BiomeManager.func_235200_a_(server.getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), server.isDebug(), server.func_241109_A_(), true));
this.connection.sendPacket(new SServerDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList();
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
*/
PortalInfo portalinfo = this.func_241829_a(server);
ServerWorld[] exitWorld = new ServerWorld[]{server};
if (portalinfo != null) {
Entity e = teleporter.placeEntity((ServerPlayerEntity) (Object) this, serverworld, exitWorld[0], this.rotationYaw, spawnPortal -> {//Forge: Start vanilla logic
serverworld.getProfiler().startSection("moving");
exitWorld[0] = ((PortalInfoBridge) portalinfo).bridge$getWorld();
if (exitWorld[0] != null) {
if (registrykey == DimensionType.OVERWORLD && ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == DimensionType.THE_NETHER) {
this.enteredNetherPosition = this.getPositionVec();
} else if (spawnPortal && ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == DimensionType.THE_END && ((PortalInfoBridge) portalinfo).bridge$getPortalEventInfo().getCanCreatePortal()) {
this.func_242110_a(exitWorld[0], new BlockPos(portalinfo.pos));
}
}
Location enter = this.getBukkitEntity().getLocation();
Location exit = (exitWorld[0] == null) ? null : new Location(((WorldBridge) exitWorld[0]).bridge$getWorld(), portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.field_242960_c, portalinfo.field_242961_d);
PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause);
Bukkit.getServer().getPluginManager().callEvent(tpEvent);
if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
return null;
}
exit = tpEvent.getTo();
exitWorld[0] = ((CraftWorld) exit.getWorld()).getHandle();
serverworld.getProfiler().endSection();
serverworld.getProfiler().startSection("placing");
this.invulnerableDimensionChange = true;
IWorldInfo iworldinfo = exitWorld[0].getWorldInfo();
this.connection.sendPacket(new SRespawnPacket(exitWorld[0].func_230315_m_(), exitWorld[0].getDimensionKey(), BiomeManager.func_235200_a_(exitWorld[0].getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), exitWorld[0].isDebug(), exitWorld[0].func_241109_A_(), true));
this.connection.sendPacket(new SServerDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked()));
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
this.setWorld(exitWorld[0]);
exitWorld[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit);
this.connection.captureCurrentPosition();
serverworld.getProfiler().endSection();
this.func_213846_b(exitWorld[0]);
return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch
});//Forge: End vanilla logic
if (e == null) {
return null;
} else if (e != (Object) this) {
throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this));
}
this.interactionManager.setWorld(exitWorld[0]);
this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities));
playerlist.sendWorldInfo((ServerPlayerEntity) (Object) this, exitWorld[0]);
playerlist.sendInventory((ServerPlayerEntity) (Object) this);
for (EffectInstance effectinstance : this.getActivePotionEffects()) {
this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), effectinstance));
}
this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, serverworld.getDimensionKey(), exitWorld[0].getDimensionKey());
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld());
Bukkit.getPluginManager().callEvent(changeEvent);
} else {
return null;
}
return (ServerPlayerEntity) (Object) this;
}
}
@Override
protected CraftPortalEvent callPortalEvent(Entity entity, ServerWorld exitWorldServer, BlockPos exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
Location enter = this.getBukkitEntity().getLocation();
Location exit = new Location(((WorldBridge) exitWorldServer).bridge$getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ(), this.rotationYaw, this.rotationPitch);
PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, creationRadius);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
return null;
}
return new CraftPortalEvent(event);
}
@Override
protected Optional<TeleportationRepositioner.Result> findOrCreatePortal(ServerWorld worldserver, BlockPos blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) {
Optional<TeleportationRepositioner.Result> optional = super.a(worldserver, blockposition, flag, searchRadius, canCreatePortal, createRadius);
if (optional.isPresent() || !canCreatePortal) {
return optional;
}
Direction.Axis enumdirection_enumaxis = this.world.getBlockState(this.field_242271_ac).func_235903_d_(NetherPortalBlock.AXIS).orElse(Direction.Axis.X);
Optional<TeleportationRepositioner.Result> optional1 = ((TeleporterBridge) worldserver.getDefaultTeleporter()).bridge$createPortal(blockposition, enumdirection_enumaxis, (ServerPlayerEntity) (Object) this, createRadius);
if (!optional1.isPresent()) {
LOGGER.error("Unable to create a portal, likely target out of worldborder");
}
return optional1;
}
private Either<PlayerEntity.SleepResult, Unit> getBedResult(BlockPos blockposition, Direction enumdirection) {
if (!this.isSleeping() && this.isAlive()) {
if (!this.world.func_230315_m_().func_236043_f_()) {
return Either.left(PlayerEntity.SleepResult.NOT_POSSIBLE_HERE);
}
if (!this.func_241147_a_(blockposition, enumdirection)) {
return Either.left(PlayerEntity.SleepResult.TOO_FAR_AWAY);
}
if (this.func_241156_b_(blockposition, enumdirection)) {
return Either.left(PlayerEntity.SleepResult.OBSTRUCTED);
}
this.func_242111_a(this.world.getDimensionKey(), blockposition, this.rotationYaw, false, true);
if (this.world.isDaytime()) {
return Either.left(PlayerEntity.SleepResult.NOT_POSSIBLE_NOW);
}
if (!this.isCreative()) {
double d0 = 8.0;
double d1 = 5.0;
Vector3d vec3d = Vector3d.copyCenteredHorizontally(blockposition);
List<MonsterEntity> list = this.world.getEntitiesWithinAABB(MonsterEntity.class, new AxisAlignedBB(vec3d.getX() - 8.0, vec3d.getY() - 5.0, vec3d.getZ() - 8.0, vec3d.getX() + 8.0, vec3d.getY() + 5.0, vec3d.getZ() + 8.0), entitymonster -> entitymonster.func_230292_f_((ServerPlayerEntity) (Object) this));
if (!list.isEmpty()) {
return Either.left(PlayerEntity.SleepResult.NOT_SAFE);
}
}
return Either.right(Unit.INSTANCE);
}
return Either.left(PlayerEntity.SleepResult.OTHER_PROBLEM);
}
@Redirect(method = "trySleep", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/util/Either;left(Ljava/lang/Object;)Lcom/mojang/datafixers/util/Either;"))
private <L, R> Either<L, R> arclight$failSleep(L value, BlockPos pos) {
Either<L, R> either = Either.left(value);
return arclight$fireBedEvent(either, pos);
}
@Redirect(method = "trySleep", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/util/Either;ifRight(Ljava/util/function/Consumer;)Lcom/mojang/datafixers/util/Either;"))
private <L, R> Either<L, R> arclight$successSleep(Either<L, R> either, Consumer<? super R> consumer, BlockPos pos) {
return arclight$fireBedEvent(either, pos).ifRight(consumer);
}
@SuppressWarnings("unchecked")
private <L, R> Either<L, R> arclight$fireBedEvent(Either<L, R> e, BlockPos pos) {
Either<PlayerEntity.SleepResult, Unit> either = (Either<PlayerEntity.SleepResult, Unit>) e;
if (either.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) {
return (Either<L, R>) either;
} else {
if (arclight$forceSleep) {
either = Either.right(Unit.INSTANCE);
}
return (Either<L, R>) CraftEventFactory.callPlayerBedEnterEvent((ServerPlayerEntity) (Object) this, pos, either);
}
}
@Inject(method = "stopSleepInBed", cancellable = true, at = @At(value = "HEAD"))
private void arclight$wakeupOutBed(boolean p_225652_1_, boolean p_225652_2_, CallbackInfo ci) {
if (!this.isSleeping()) ci.cancel();
}
public int nextContainerCounter() {
this.getNextWindowId();
return this.currentWindowId;
@ -698,24 +700,20 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
this.lastExperience = -1;
}
public void sendMessage(ITextComponent[] ichatbasecomponent) {
for (final ITextComponent component : ichatbasecomponent) {
this.sendMessage(component);
public void sendMessage(ITextComponent[] components) {
for (final ITextComponent component : components) {
this.sendMessage(component, Util.DUMMY_UUID);
}
}
@Override
public void bridge$sendMessage(ITextComponent[] ichatbasecomponent) {
sendMessage(ichatbasecomponent);
public void bridge$sendMessage(ITextComponent[] components) {
sendMessage(components);
}
@Override
public void bridge$sendMessage(ITextComponent component) {
this.sendMessage(component);
}
@Redirect(method = "copyFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/crafting/ServerRecipeBook;copyFrom(Lnet/minecraft/item/crafting/RecipeBook;)V"))
private void arclight$noRecipeBookCopy(ServerRecipeBook serverRecipeBook, RecipeBook that) {
this.sendMessage(component, Util.DUMMY_UUID);
}
@Inject(method = "setGameType", cancellable = true, at = @At("HEAD"))
@ -735,13 +733,14 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
@Inject(method = "handleClientSettings", at = @At("HEAD"))
private void arclight$settingChange(CClientSettingsPacket packetIn, CallbackInfo ci) {
if (this.getPrimaryHand() != packetIn.getMainHand()) {
final PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), (this.getPrimaryHand() == HandSide.LEFT) ? MainHand.LEFT : MainHand.RIGHT);
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), (this.getPrimaryHand() == HandSide.LEFT) ? MainHand.LEFT : MainHand.RIGHT);
Bukkit.getPluginManager().callEvent(event);
}
if (!this.language.equals(packetIn.getLang())) {
final PlayerLocaleChangeEvent event2 = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packetIn.getLang());
if (!this.language.equals(packetIn.getLanguage())) {
PlayerLocaleChangeEvent event2 = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packetIn.getLanguage());
Bukkit.getPluginManager().callEvent(event2);
}
this.locale = packetIn.getLanguage();
this.clientViewDistance = packetIn.view;
}
@ -782,8 +781,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
return (CraftPlayer) ((InternalEntityBridge) this).internal$getBukkitEntity();
}
private transient PlayerTeleportEvent.TeleportCause arclight$cause;
@Override
public void bridge$pushChangeDimensionCause(PlayerTeleportEvent.TeleportCause cause) {
arclight$cause = cause;
@ -809,7 +806,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
return this.weather;
}
public void setPlayerWeather(final WeatherType type, final boolean plugin) {
public void setPlayerWeather(WeatherType type, boolean plugin) {
if (!plugin && this.weather != null) {
return;
}
@ -817,25 +814,25 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
this.weather = type;
}
if (type == WeatherType.DOWNFALL) {
this.connection.sendPacket(new SChangeGameStatePacket(2, 0.0f));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241766_c_, 0.0f));
} else {
this.connection.sendPacket(new SChangeGameStatePacket(1, 0.0f));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241765_b_, 0.0f));
}
}
public void updateWeather(final float oldRain, final float newRain, final float oldThunder, final float newThunder) {
public void updateWeather(float oldRain, float newRain, float oldThunder, float newThunder) {
if (this.weather == null) {
if (oldRain != newRain) {
this.connection.sendPacket(new SChangeGameStatePacket(7, newRain));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241771_h_, newRain));
}
} else if (this.pluginRainPositionPrevious != this.pluginRainPosition) {
this.connection.sendPacket(new SChangeGameStatePacket(7, this.pluginRainPosition));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241771_h_, this.pluginRainPosition));
}
if (oldThunder != newThunder) {
if (this.weather == WeatherType.DOWNFALL || this.weather == null) {
this.connection.sendPacket(new SChangeGameStatePacket(8, newThunder));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241772_i_, newThunder));
} else {
this.connection.sendPacket(new SChangeGameStatePacket(8, 0.0f));
this.connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241772_i_, 0.0f));
}
}
}
@ -860,7 +857,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
@Override
public String toString() {
return super.toString() + "(" + this.getScoreboardName() + " at " + this.posX + "," + this.posY + "," + this.posZ + ")";
return super.toString() + "(" + this.getScoreboardName() + " at " + this.getPosX() + "," + this.getPosY() + "," + this.getPosZ() + ")";
}
public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) {

View File

@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(AbstractFireballEntity.class)
public class AbstractFireballEntityMixin {
public abstract class AbstractFireballEntityMixin extends DamagingProjectileEntityMixin {
@Inject(method = "readAdditional", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/projectile/AbstractFireballEntity;setStack(Lnet/minecraft/item/ItemStack;)V"))
private void arclight$nonNullItem(CompoundNBT compound, CallbackInfo ci, ItemStack stack) {

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.entity.projectile.LlamaSpitEntity;
import net.minecraft.util.math.RayTraceResult;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LlamaSpitEntity.class)
public abstract class LlamaSpitEntityMixin extends EntityMixin {
@Inject(method = "onHit", at = @At("HEAD"))
private void arclight$projectileHit(RayTraceResult result, CallbackInfo ci) {
CraftEventFactory.callProjectileHitEvent((LlamaSpitEntity)(Object)this, result);
}
}

View File

@ -36,7 +36,7 @@ import java.util.List;
import java.util.Map;
@Mixin(PotionEntity.class)
public abstract class PotionEntityMixin extends ThrowableEntityMixin {
public abstract class PotionEntityMixin extends ProjectileItemEntityMixin {
@Redirect(method = "onImpact", at = @At(value = "INVOKE", remap = false, ordinal = 1, target = "Ljava/util/List;isEmpty()Z"))
private boolean arclight$callEvent(List list) {
@ -77,7 +77,7 @@ public abstract class PotionEntityMixin extends ThrowableEntityMixin {
double d2 = event.getIntensity(victim);
for (EffectInstance mobeffect : list) {
Effect mobeffectlist = mobeffect.getPotion();
if (!((WorldBridge) this.world).bridge$isPvpMode() && this.getThrower() instanceof ServerPlayerEntity && entityliving2 instanceof ServerPlayerEntity && entityliving2 != this.getThrower()) {
if (!((WorldBridge) this.world).bridge$isPvpMode() && this.func_234616_v_() instanceof ServerPlayerEntity && entityliving2 instanceof ServerPlayerEntity && entityliving2 != this.func_234616_v_()) {
int i = Effect.getId(mobeffectlist);
if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18) {
continue;
@ -87,7 +87,7 @@ public abstract class PotionEntityMixin extends ThrowableEntityMixin {
}
}
if (mobeffectlist.isInstant()) {
mobeffectlist.affectEntity((PotionEntity) (Object) this, this.getThrower(), entityliving2, mobeffect.getAmplifier(), d2);
mobeffectlist.affectEntity((PotionEntity) (Object) this, this.func_234616_v_(), entityliving2, mobeffect.getAmplifier(), d2);
} else {
int i = (int) (d2 * mobeffect.getDuration() + 0.5);
if (i <= 20) {
@ -110,7 +110,7 @@ public abstract class PotionEntityMixin extends ThrowableEntityMixin {
}
}
@Inject(method = "extinguishFires", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;extinguishFire(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z"))
@Inject(method = "extinguishFires", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
private void arclight$entityChangeBlock(BlockPos pos, Direction direction, CallbackInfo ci) {
if (CraftEventFactory.callEntityChangeBlockEvent((PotionEntity) (Object) this, pos.offset(direction), Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();

View File

@ -7,9 +7,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ShulkerBulletEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -23,7 +21,6 @@ import javax.annotation.Nullable;
public abstract class ShulkerBulletEntityMixin extends EntityMixin {
// @formatter:off
@Shadow private LivingEntity owner;
@Shadow private Entity target;
@Shadow @Nullable private Direction direction;
@Shadow protected abstract void selectNextMoveDirection(@Nullable Direction.Axis p_184569_1_);
@ -34,22 +31,9 @@ public abstract class ShulkerBulletEntityMixin extends EntityMixin {
this.projectileSource = ((LivingEntityBridge) ownerIn).bridge$getBukkitEntity();
}
@Inject(method = "bulletHit", at = @At("HEAD"))
private void arclight$projectileHit(RayTraceResult result, CallbackInfo ci) {
CraftEventFactory.callProjectileHitEvent((ShulkerBulletEntity) (Object) this, result);
}
@Inject(method = "bulletHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$reason(RayTraceResult result, CallbackInfo ci) {
((LivingEntityBridge) ((EntityRayTraceResult) result).getEntity()).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
}
public LivingEntity getShooter() {
return this.owner;
}
public void setShooter(final LivingEntity e) {
this.owner = e;
@Inject(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$reason(EntityRayTraceResult result, CallbackInfo ci) {
((LivingEntityBridge) result.getEntity()).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
}
public Entity getTarget() {

View File

@ -1,78 +1,51 @@
package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.api.ArclightVersion;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.projectile.SmallFireballEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
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;
@Mixin(SmallFireballEntity.class)
public abstract class SmallFireballEntityMixin extends DamagingProjectileEntityMixin {
public abstract class SmallFireballEntityMixin extends AbstractFireballEntityMixin {
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;DDD)V", at = @At("RETURN"))
private void arclight$init(World worldIn, LivingEntity shooter, double accelX, double accelY, double accelZ, CallbackInfo ci) {
if (this.shootingEntity != null && this.shootingEntity instanceof MobEntity) {
if (this.func_234616_v_() != null && this.func_234616_v_() instanceof MobEntity) {
this.isIncendiary = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING);
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void onImpact(RayTraceResult result) {
if (ArclightVersion.atLeast(ArclightVersion.v1_15)) {
super.onImpact(result);
}
if (!this.world.isRemote) {
if (result.getType() == RayTraceResult.Type.ENTITY) {
Entity entity = ((EntityRayTraceResult) result).getEntity();
if (!entity.isImmuneToFire()) {
int i = entity.getFireTimer();
if (isIncendiary) {
EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), 5);
Bukkit.getPluginManager().callEvent(event);
@Redirect(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setFire(I)V"))
private void arclight$entityCombust(Entity entity, int seconds) {
if (this.isIncendiary) {
EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), seconds);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
((EntityBridge) entity).bridge$setOnFire(event.getDuration(), false);
}
}
boolean flag = entity.attackEntityFrom(DamageSource.causeFireballDamage((SmallFireballEntity) (Object) this, this.shootingEntity), 5.0F);
if (flag) {
this.applyEnchantments(this.shootingEntity, entity);
} else {
entity.setFireTimer(i);
}
}
} else if (isIncendiary && this.shootingEntity == null || !(this.shootingEntity instanceof MobEntity) || ForgeEventFactory.getMobGriefingEvent(this.world, this.shootingEntity)) {
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) result;
BlockPos blockpos = blockraytraceresult.getPos().offset(blockraytraceresult.getFace());
if (this.world.isAirBlock(blockpos) && !CraftEventFactory.callBlockIgniteEvent(this.world, blockpos, (SmallFireballEntity) (Object) this).isCancelled()) {
this.world.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
}
if (!event.isCancelled()) {
((EntityBridge) entity).bridge$setOnFire(event.getDuration(), false);
}
this.remove();
}
}
@Inject(method = "func_230299_a_", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
private void arclight$burnBlock(BlockRayTraceResult result, CallbackInfo ci, Entity entity, BlockPos pos) {
if (!this.isIncendiary || CraftEventFactory.callBlockIgniteEvent(this.world, pos, (SmallFireballEntity) (Object) this).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -2,24 +2,26 @@ package io.izzel.arclight.common.mixin.core.entity.projectile;
import io.izzel.arclight.common.bridge.entity.projectile.TridentEntityBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.world.World;
import org.bukkit.event.weather.LightningStrikeEvent;
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 org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(TridentEntity.class)
public abstract class TridentEntityMixin extends AbstractArrowEntityMixin implements TridentEntityBridge {
@Shadow public ItemStack thrownStack;
@Inject(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addLightningBolt(Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
private void arclight$lightning(EntityRayTraceResult p_213868_1_, CallbackInfo ci) {
((ServerWorldBridge) this.world).bridge$pushStrikeLightningCause(LightningStrikeEvent.Cause.TRIDENT);
@Redirect(method = "onEntityHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$lightning(World world, Entity entityIn) {
((ServerWorldBridge) this.world).bridge$strikeLightning((LightningBoltEntity) entityIn, LightningStrikeEvent.Cause.TRIDENT);
return true;
}
@Override

View File

@ -1,14 +1,12 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShearsItem;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import org.bukkit.Bukkit;
import org.bukkit.event.player.PlayerShearEntityEvent;
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.Inject;
@ -17,14 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ShearsItem.class)
public class ShearsItemMixin {
@Inject(method = "itemInteractionForEntity", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/common/IShearable;isShearable(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/IWorldReader;Lnet/minecraft/util/math/BlockPos;)Z"))
private void arclight$onShear(ItemStack stack, PlayerEntity playerIn, LivingEntity entity, Hand hand, CallbackInfoReturnable<Boolean> cir) {
if (playerIn instanceof ServerPlayerEntityBridge) {
PlayerShearEntityEvent event = new PlayerShearEntityEvent(((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(false);
}
@Inject(method = "itemInteractionForEntity", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/common/IForgeShearable;isShearable(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z"))
private void arclight$onShear(ItemStack stack, PlayerEntity playerIn, LivingEntity entity, Hand hand, CallbackInfoReturnable<ActionResultType> cir) {
if (!CraftEventFactory.handlePlayerShearEntityEvent(playerIn, entity, stack, hand)) {
cir.setReturnValue(ActionResultType.PASS);
}
}
}

View File

@ -165,36 +165,6 @@ public class ArclightMixinPlugin implements IMixinConfigPlugin {
}
}
modifyConstructor(targetClassName, targetClass);
if (targetClassName.equals("net.minecraft.entity.projectile.LlamaSpitEntity")) {
for (FieldNode node : targetClass.fields) {
if (node.name.equals("field_190539_a")) {
node.desc = "Lnet/minecraft/entity/LivingEntity;";
}
}
for (MethodNode node : targetClass.methods) {
ListIterator<AbstractInsnNode> iterator = node.instructions.iterator();
while (iterator.hasNext()) {
AbstractInsnNode insnNode = iterator.next();
if (insnNode instanceof FieldInsnNode) {
FieldInsnNode fieldInsnNode = (FieldInsnNode) insnNode;
if (fieldInsnNode.getOpcode() == Opcodes.GETFIELD || fieldInsnNode.getOpcode() == Opcodes.PUTFIELD) {
if (fieldInsnNode.name.equals("field_190539_a")) {
fieldInsnNode.desc = "Lnet/minecraft/entity/LivingEntity;";
if (iterator.hasNext()) {
AbstractInsnNode next = iterator.next();
if (next.getOpcode() == Opcodes.INVOKEVIRTUAL && ((MethodInsnNode) next).name.equals("func_110124_au")
&& ((MethodInsnNode) next).desc.equals("()Ljava/util/UUID;")) {
((MethodInsnNode) next).owner = "net/minecraft/entity/LivingEntity";
}
}
}
}
}
}
}
FieldNode node = new FieldNode(Opcodes.ACC_PUBLIC, "field_190539_a", "Lnet/minecraft/entity/passive/horse/LlamaEntity;", null, null);
targetClass.fields.add(node);
}
if (targetClassName.equals("net.minecraft.world.chunk.Chunk")) {
for (FieldNode field : targetClass.fields) {
if (field.name.equals("$$world")) {

View File

@ -2,7 +2,6 @@ package io.izzel.arclight.common.mod.server.event;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.entity.monster.EndermanEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -17,16 +16,14 @@ public class EntityTeleportEventDispatcher {
@SubscribeEvent(receiveCanceled = true)
public void onTeleport(EnderTeleportEvent event) {
if (!(event.getEntity() instanceof EndermanEntity)) {
if (event.getEntity() instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
}
if (event.getEntity() instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
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()));

View File

@ -42,6 +42,7 @@ public net.minecraft.entity.passive.BeeEntity$PollinateGoal func_226504_l_()V #c
# Arclight 1.16
public net.minecraft.block.ComposterBlock func_235490_d_(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState; #resetFillState
public net.minecraft.util.text.Style <init>(Lnet/minecraft/util/text/Color;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lnet/minecraft/util/text/event/ClickEvent;Lnet/minecraft/util/text/event/HoverEvent;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;)V
public net.minecraft.entity.player.SpawnLocationHelper func_241092_a_(Lnet/minecraft/world/server/ServerWorld;IIZ)Lnet/minecraft/util/math/BlockPos; #func_241092_a_
# Bukkit
public net.minecraft.entity.player.PlayerEntity func_190531_bD()I
public net.minecraft.entity.item.ItemFrameEntity func_174859_a(Lnet/minecraft/util/Direction;)V

View File

@ -163,7 +163,7 @@
"entity.item.TNTEntityMixin",
"entity.item.minecart.AbstractMinecartEntityMixin",
"entity.item.minecart.ContainerMinecartEntityMixin",
"entity.item.minecart.MinecartCommandBlockEntity_MinecartCommandLogicMixin",
"entity.item.minecart.CommandBlockMinecartEntity_MinecartCommandLogicMixin",
"entity.merchant.IMerchantMixin",
"entity.merchant.villager.AbstractVillagerEntityMixin",
"entity.merchant.villager.VillagerEntityMixin",
@ -187,13 +187,15 @@
"entity.monster.SilverfishEntity_HideInStoneGoalMixin",
"entity.monster.SilverfishEntity_SummonSilverfishGoalMixin",
"entity.monster.SlimeEntityMixin",
"entity.monster.SpellcastingIllagerEntity_UseSpellGoalMixin",
"entity.monster.SpellcastingIllagerEntityMixin",
"entity.monster.SpiderEntityMixin",
"entity.monster.VexEntity_CopyOwnerTargetGoalMixin",
"entity.monster.WitchEntityMixin",
"entity.monster.WitherSkeletonEntityMixin",
"entity.monster.ZombieEntityMixin",
"entity.monster.ZombiePigmanEntity_HurtByAggressorGoalMixin",
"entity.monster.ZombiePigmanEntityMixin",
"entity.monster.ZombifiedPiglinEntityMixin",
"entity.monster.ZombieVillagerEntityMixin",
"entity.passive.AnimalEntityMixin",
"entity.passive.BatEntityMixin",