Update upstream (#470)
This commit is contained in:
parent
ef628e4ecd
commit
42a0da8be8
|
@ -1,13 +1,13 @@
|
||||||
package io.izzel.arclight.common.bridge.core.entity;
|
package io.izzel.arclight.common.bridge.core.entity;
|
||||||
|
|
||||||
import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge;
|
import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import org.bukkit.craftbukkit.v.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v.entity.CraftEntity;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
|
|
||||||
public interface EntityBridge extends ICommandSourceBridge {
|
public interface EntityBridge extends ICommandSourceBridge {
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ public interface EntityBridge extends ICommandSourceBridge {
|
||||||
|
|
||||||
boolean bridge$isChunkLoaded();
|
boolean bridge$isChunkLoaded();
|
||||||
|
|
||||||
boolean bridge$isForceExplosionKnockback();
|
boolean bridge$isLastDamageCancelled();
|
||||||
|
|
||||||
void bridge$setForceExplosionKnockback(boolean forceExplosionKnockback);
|
void bridge$setLastDamageCancelled(boolean cancelled);
|
||||||
|
|
||||||
void bridge$postTick();
|
void bridge$postTick();
|
||||||
|
|
||||||
|
|
|
@ -401,9 +401,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "handleSelectTrade", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/MerchantMenu;setSelectionHint(I)V"))
|
@Inject(method = "handleSelectTrade", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/MerchantMenu;setSelectionHint(I)V"))
|
||||||
private void arclight$tradeSelect(ServerboundSelectTradePacket packetIn, CallbackInfo ci, int i, AbstractContainerMenu container) {
|
private void arclight$tradeSelect(ServerboundSelectTradePacket packetIn, CallbackInfo ci, int i, AbstractContainerMenu container) {
|
||||||
CraftEventFactory.callTradeSelectEvent(this.player, i, (MerchantMenu) container);
|
var event = CraftEventFactory.callTradeSelectEvent(this.player, i, (MerchantMenu) container);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity().updateInventory();
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "handleEditBook", at = @At("HEAD"))
|
@Inject(method = "handleEditBook", at = @At("HEAD"))
|
||||||
|
|
|
@ -158,7 +158,7 @@ public abstract class ServerPlayerGameModeMixin implements PlayerInteractionMana
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockPos.getX(), blockPos.getY(), blockPos.getZ(), this.player.getInventory().getSelected(), f >= 1.0f);
|
BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockPos, this.player.getInventory().getSelected(), f >= 1.0f);
|
||||||
if (blockEvent.isCancelled()) {
|
if (blockEvent.isCancelled()) {
|
||||||
this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, blockPos));
|
this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, blockPos));
|
||||||
return;
|
return;
|
||||||
|
@ -177,6 +177,7 @@ public abstract class ServerPlayerGameModeMixin implements PlayerInteractionMana
|
||||||
int j = (int) (f * 10.0f);
|
int j = (int) (f * 10.0f);
|
||||||
this.level.destroyBlockProgress(this.player.getId(), blockPos, j);
|
this.level.destroyBlockProgress(this.player.getId(), blockPos, j);
|
||||||
this.player.connection.send(new ClientboundBlockBreakAckPacket(blockPos, this.level.getBlockState(blockPos), action, true, "actual start of destroying"));
|
this.player.connection.send(new ClientboundBlockBreakAckPacket(blockPos, this.level.getBlockState(blockPos), action, true, "actual start of destroying"));
|
||||||
|
CraftEventFactory.callBlockDamageAbortEvent(this.player, blockPos, this.player.getInventory().getSelected());
|
||||||
this.lastSentState = j;
|
this.lastSentState = j;
|
||||||
}
|
}
|
||||||
} else if (action == ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK) {
|
} else if (action == ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK) {
|
||||||
|
|
|
@ -16,8 +16,6 @@ import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
|
||||||
import net.minecraft.world.entity.item.PrimedTnt;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
|
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
|
||||||
|
@ -34,6 +32,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.entity.PartEntity;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
|
||||||
|
@ -172,10 +171,31 @@ public abstract class ExplosionMixin implements ExplosionBridge {
|
||||||
double d10 = (1.0D - d12) * d14;
|
double d10 = (1.0D - d12) * d14;
|
||||||
|
|
||||||
CraftEventFactory.entityDamage = this.source;
|
CraftEventFactory.entityDamage = this.source;
|
||||||
((EntityBridge) entity).bridge$setForceExplosionKnockback(false);
|
((EntityBridge) entity).bridge$setLastDamageCancelled(false);
|
||||||
boolean wasDamaged = entity.hurt(this.getDamageSource(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
|
||||||
|
// Special case ender dragon only give knockback if no damage is cancelled
|
||||||
|
// Thinks to note:
|
||||||
|
// - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed)
|
||||||
|
// - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon
|
||||||
|
// - Damaging EntityEnderDragon does nothing
|
||||||
|
// - EntityEnderDragon hitbock always covers the other parts and is therefore always present
|
||||||
|
if (entity instanceof PartEntity<?>) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parts = entity.getParts();
|
||||||
|
if (parts != null) {
|
||||||
|
for (var part : parts) {
|
||||||
|
if (list.contains(part)) {
|
||||||
|
part.hurt(this.getDamageSource(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entity.hurt(this.getDamageSource(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||||
|
}
|
||||||
|
|
||||||
CraftEventFactory.entityDamage = null;
|
CraftEventFactory.entityDamage = null;
|
||||||
if (!wasDamaged && !(entity instanceof PrimedTnt || entity instanceof FallingBlockEntity) && !((EntityBridge) entity).bridge$isForceExplosionKnockback()) {
|
if (((EntityBridge) entity).bridge$isLastDamageCancelled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||||
public boolean generation;
|
public boolean generation;
|
||||||
public boolean valid;
|
public boolean valid;
|
||||||
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
||||||
public boolean forceExplosionKnockback; // SPIGOT-949
|
public boolean lastDamageCancelled; // SPIGOT-949
|
||||||
public boolean persistentInvisibility = false;
|
public boolean persistentInvisibility = false;
|
||||||
public BlockPos lastLavaContact;
|
public BlockPos lastLavaContact;
|
||||||
public int maxAirTicks = getDefaultMaxAirSupply();
|
public int maxAirTicks = getDefaultMaxAirSupply();
|
||||||
|
@ -362,13 +362,13 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean bridge$isForceExplosionKnockback() {
|
public boolean bridge$isLastDamageCancelled() {
|
||||||
return forceExplosionKnockback;
|
return lastDamageCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bridge$setForceExplosionKnockback(boolean forceExplosionKnockback) {
|
public void bridge$setLastDamageCancelled(boolean cancelled) {
|
||||||
this.forceExplosionKnockback = forceExplosionKnockback;
|
this.lastDamageCancelled = cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postTick() {
|
public void postTick() {
|
||||||
|
|
|
@ -534,7 +534,6 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
||||||
boolean flag1 = true;
|
boolean flag1 = true;
|
||||||
if ((float) this.invulnerableTime > 10.0F) {
|
if ((float) this.invulnerableTime > 10.0F) {
|
||||||
if (amount <= this.lastHurt) {
|
if (amount <= this.lastHurt) {
|
||||||
this.forceExplosionKnockback = true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,6 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt
|
||||||
if (this.isInvulnerableTo(source)) {
|
if (this.isInvulnerableTo(source)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (this.abilities.invulnerable && !source.isBypassInvul()) {
|
} else if (this.abilities.invulnerable && !source.isBypassInvul()) {
|
||||||
this.forceExplosionKnockback = true;
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.noActionTime = 0;
|
this.noActionTime = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user