aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch276
1 files changed, 276 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch
new file mode 100644
index 0000000000..8332b045b6
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/Interaction.java.patch
@@ -0,0 +1,276 @@
+--- a/net/minecraft/world/entity/Interaction.java
++++ b/net/minecraft/world/entity/Interaction.java
+@@ -16,14 +16,20 @@
+ import net.minecraft.network.syncher.EntityDataSerializers;
+ import net.minecraft.network.syncher.SynchedEntityData;
+ import net.minecraft.server.level.ServerPlayer;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+-import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.level.Level;
+-import net.minecraft.world.level.material.PushReaction;
++import net.minecraft.world.level.material.EnumPistonReaction;
+ import net.minecraft.world.phys.AABB;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import net.minecraft.world.damagesource.DamageSource;
++import net.minecraft.world.entity.player.Player;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.EntityDamageEvent;
++// CraftBukkit end
++
+ public class Interaction extends Entity implements Attackable, Targeting {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+@@ -36,17 +42,16 @@
+ private static final String TAG_INTERACTION = "interaction";
+ private static final String TAG_RESPONSE = "response";
+ @Nullable
+- private Interaction.PlayerAction attack;
++ public Interaction.PlayerAction attack;
+ @Nullable
+- private Interaction.PlayerAction interaction;
++ public Interaction.PlayerAction interaction;
+
+- public Interaction(EntityType<?> entitytype, Level level) {
+- super(entitytype, level);
++ public Interaction(EntityType<?> entityType, Level level) {
++ super(entityType, level);
+ this.noPhysics = true;
+ }
+
+ @Override
+- @Override
+ protected void defineSynchedData() {
+ this.entityData.define(Interaction.DATA_WIDTH_ID, 1.0F);
+ this.entityData.define(Interaction.DATA_HEIGHT_ID, 1.0F);
+@@ -54,21 +59,20 @@
+ }
+
+ @Override
+- @Override
+- protected void readAdditionalSaveData(CompoundTag compoundtag) {
+- if (compoundtag.contains("width", 99)) {
+- this.setWidth(compoundtag.getFloat("width"));
++ protected void readAdditionalSaveData(CompoundTag compound) {
++ if (compound.contains("width", 99)) {
++ this.setWidth(compound.getFloat("width"));
+ }
+
+- if (compoundtag.contains("height", 99)) {
+- this.setHeight(compoundtag.getFloat("height"));
++ if (compound.contains("height", 99)) {
++ this.setHeight(compound.getFloat("height"));
+ }
+
+- DataResult dataresult;
++ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.Tag>> dataresult; // CraftBukkit - decompile error
+ Logger logger;
+
+- if (compoundtag.contains("attack")) {
+- dataresult = Interaction.PlayerAction.CODEC.decode(NbtOps.INSTANCE, compoundtag.get("attack"));
++ if (compound.contains("attack")) {
++ dataresult = Interaction.PlayerAction.CODEC.decode(NbtOps.INSTANCE, compound.get("attack"));
+ logger = Interaction.LOGGER;
+ Objects.requireNonNull(logger);
+ dataresult.resultOrPartial(Util.prefix("Interaction entity", logger::error)).ifPresent((pair) -> {
+@@ -78,8 +82,8 @@
+ this.attack = null;
+ }
+
+- if (compoundtag.contains("interaction")) {
+- dataresult = Interaction.PlayerAction.CODEC.decode(NbtOps.INSTANCE, compoundtag.get("interaction"));
++ if (compound.contains("interaction")) {
++ dataresult = Interaction.PlayerAction.CODEC.decode(NbtOps.INSTANCE, compound.get("interaction"));
+ logger = Interaction.LOGGER;
+ Objects.requireNonNull(logger);
+ dataresult.resultOrPartial(Util.prefix("Interaction entity", logger::error)).ifPresent((pair) -> {
+@@ -89,75 +93,75 @@
+ this.interaction = null;
+ }
+
+- this.setResponse(compoundtag.getBoolean("response"));
++ this.setResponse(compound.getBoolean("response"));
+ this.setBoundingBox(this.makeBoundingBox());
+ }
+
+ @Override
+- @Override
+- protected void addAdditionalSaveData(CompoundTag compoundtag) {
+- compoundtag.putFloat("width", this.getWidth());
+- compoundtag.putFloat("height", this.getHeight());
++ protected void addAdditionalSaveData(CompoundTag compound) {
++ compound.putFloat("width", this.getWidth());
++ compound.putFloat("height", this.getHeight());
+ if (this.attack != null) {
+- Interaction.PlayerAction.CODEC.encodeStart(NbtOps.INSTANCE, this.attack).result().ifPresent((tag) -> {
+- compoundtag.put("attack", tag);
++ Interaction.PlayerAction.CODEC.encodeStart(NbtOps.INSTANCE, this.attack).result().ifPresent((nbtbase) -> {
++ compound.put("attack", nbtbase);
+ });
+ }
+
+ if (this.interaction != null) {
+- Interaction.PlayerAction.CODEC.encodeStart(NbtOps.INSTANCE, this.interaction).result().ifPresent((tag) -> {
+- compoundtag.put("interaction", tag);
++ Interaction.PlayerAction.CODEC.encodeStart(NbtOps.INSTANCE, this.interaction).result().ifPresent((nbtbase) -> {
++ compound.put("interaction", nbtbase);
+ });
+ }
+
+- compoundtag.putBoolean("response", this.getResponse());
++ compound.putBoolean("response", this.getResponse());
+ }
+
+ @Override
+- @Override
+- public void onSyncedDataUpdated(EntityDataAccessor<?> entitydataaccessor) {
+- super.onSyncedDataUpdated(entitydataaccessor);
+- if (Interaction.DATA_HEIGHT_ID.equals(entitydataaccessor) || Interaction.DATA_WIDTH_ID.equals(entitydataaccessor)) {
++ public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
++ super.onSyncedDataUpdated(key);
++ if (Interaction.DATA_HEIGHT_ID.equals(key) || Interaction.DATA_WIDTH_ID.equals(key)) {
+ this.setBoundingBox(this.makeBoundingBox());
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean canBeHitByProjectile() {
+ return false;
+ }
+
+ @Override
+- @Override
+ public boolean isPickable() {
+ return true;
+ }
+
+ @Override
+- @Override
+- public PushReaction getPistonPushReaction() {
+- return PushReaction.IGNORE;
++ public EnumPistonReaction getPistonPushReaction() {
++ return EnumPistonReaction.IGNORE;
+ }
+
+ @Override
+- @Override
+ public boolean isIgnoringBlockTriggers() {
+ return true;
+ }
+
+ @Override
+- @Override
+ public boolean skipAttackInteraction(Entity entity) {
+ if (entity instanceof Player) {
+- Player player = (Player) entity;
++ Player entityhuman = (Player) entity;
++ // CraftBukkit start
++ DamageSource source = entityhuman.damageSources().playerAttack(entityhuman);
++ EntityDamageEvent event = CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
++ if (event.isCancelled()) {
++ return true;
++ }
++ // CraftBukkit end
+
+- this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime());
+- if (player instanceof ServerPlayer) {
+- ServerPlayer serverplayer = (ServerPlayer) player;
++ this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level().getGameTime());
++ if (entityhuman instanceof ServerPlayer) {
++ ServerPlayer entityplayer = (ServerPlayer) entityhuman;
+
+- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverplayer, this, player.damageSources().generic(), 1.0F, 1.0F, false);
++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, source, (float) event.getFinalDamage(), 1.0F, false); // CraftBukkit
+ }
+
+ return !this.getResponse();
+@@ -167,8 +171,7 @@
+ }
+
+ @Override
+- @Override
+- public InteractionResult interact(Player player, InteractionHand interactionhand) {
++ public InteractionResult interact(Player player, EnumHand hand) {
+ if (this.level().isClientSide) {
+ return this.getResponse() ? InteractionResult.SUCCESS : InteractionResult.CONSUME;
+ } else {
+@@ -178,44 +181,41 @@
+ }
+
+ @Override
+- @Override
+ public void tick() {}
+
+ @Nullable
+ @Override
+- @Override
+ public LivingEntity getLastAttacker() {
+ return this.attack != null ? this.level().getPlayerByUUID(this.attack.player()) : null;
+ }
+
+ @Nullable
+ @Override
+- @Override
+ public LivingEntity getTarget() {
+ return this.interaction != null ? this.level().getPlayerByUUID(this.interaction.player()) : null;
+ }
+
+- private void setWidth(float f) {
+- this.entityData.set(Interaction.DATA_WIDTH_ID, f);
++ public void setWidth(float width) {
++ this.entityData.set(Interaction.DATA_WIDTH_ID, width);
+ }
+
+- private float getWidth() {
++ public float getWidth() {
+ return (Float) this.entityData.get(Interaction.DATA_WIDTH_ID);
+ }
+
+- private void setHeight(float f) {
+- this.entityData.set(Interaction.DATA_HEIGHT_ID, f);
++ public void setHeight(float height) {
++ this.entityData.set(Interaction.DATA_HEIGHT_ID, height);
+ }
+
+- private float getHeight() {
++ public float getHeight() {
+ return (Float) this.entityData.get(Interaction.DATA_HEIGHT_ID);
+ }
+
+- private void setResponse(boolean flag) {
+- this.entityData.set(Interaction.DATA_RESPONSE_ID, flag);
++ public void setResponse(boolean response) {
++ this.entityData.set(Interaction.DATA_RESPONSE_ID, response);
+ }
+
+- private boolean getResponse() {
++ public boolean getResponse() {
+ return (Boolean) this.entityData.get(Interaction.DATA_RESPONSE_ID);
+ }
+
+@@ -224,18 +224,16 @@
+ }
+
+ @Override
+- @Override
+- public EntityDimensions getDimensions(Pose pose) {
++ public EntityDimensions getDimensions(EntityPose pose) {
+ return this.getDimensions();
+ }
+
+ @Override
+- @Override
+ protected AABB makeBoundingBox() {
+ return this.getDimensions().makeBoundingBox(this.position());
+ }
+
+- private static record PlayerAction(UUID player, long timestamp) {
++ public static record PlayerAction(UUID player, long timestamp) {
+
+ public static final Codec<Interaction.PlayerAction> CODEC = RecordCodecBuilder.create((instance) -> {
+ return instance.group(UUIDUtil.CODEC.fieldOf("player").forGetter(Interaction.PlayerAction::player), Codec.LONG.fieldOf("timestamp").forGetter(Interaction.PlayerAction::timestamp)).apply(instance, Interaction.PlayerAction::new);