aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch264
1 files changed, 264 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch
new file mode 100644
index 0000000000..0d0972b193
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/Interaction.java.patch
@@ -0,0 +1,264 @@
+--- a/net/minecraft/world/entity/Interaction.java
++++ b/net/minecraft/world/entity/Interaction.java
+@@ -1,10 +1,10 @@
+ package net.minecraft.world.entity;
+
+-import com.mojang.datafixers.util.Pair;
+ import com.mojang.logging.LogUtils;
+ import com.mojang.serialization.Codec;
++import com.mojang.serialization.DataResult;
+ import com.mojang.serialization.codecs.RecordCodecBuilder;
+-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance;
++import java.util.Objects;
+ import java.util.UUID;
+ import javax.annotation.Nullable;
+ import net.minecraft.Util;
+@@ -12,20 +12,26 @@
+ import net.minecraft.core.UUIDUtil;
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.nbt.NbtOps;
+-import net.minecraft.nbt.Tag;
+ import net.minecraft.network.syncher.EntityDataAccessor;
+ 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();
+ private static final EntityDataAccessor<Float> DATA_WIDTH_ID = SynchedEntityData.defineId(Interaction.class, EntityDataSerializers.FLOAT);
+ private static final EntityDataAccessor<Float> DATA_HEIGHT_ID = SynchedEntityData.defineId(Interaction.class, EntityDataSerializers.FLOAT);
+@@ -36,9 +42,9 @@
+ 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);
+@@ -47,9 +53,9 @@
+
+ @Override
+ protected void defineSynchedData() {
+- this.entityData.define(DATA_WIDTH_ID, 1.0F);
+- this.entityData.define(DATA_HEIGHT_ID, 1.0F);
+- this.entityData.define(DATA_RESPONSE_ID, false);
++ this.entityData.define(Interaction.DATA_WIDTH_ID, 1.0F);
++ this.entityData.define(Interaction.DATA_HEIGHT_ID, 1.0F);
++ this.entityData.define(Interaction.DATA_RESPONSE_ID, false);
+ }
+
+ @Override
+@@ -62,20 +68,27 @@
+ this.setHeight(compound.getFloat("height"));
+ }
+
++ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.Tag>> dataresult; // CraftBukkit - decompile error
++ Logger logger;
++
+ if (compound.contains("attack")) {
+- Interaction.PlayerAction.CODEC
+- .decode(NbtOps.INSTANCE, compound.get("attack"))
+- .resultOrPartial(Util.prefix("Interaction entity", LOGGER::error))
+- .ifPresent(pair -> this.attack = pair.getFirst());
++ 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) -> {
++ this.attack = (Interaction.PlayerAction) pair.getFirst();
++ });
+ } else {
+ this.attack = null;
+ }
+
+ if (compound.contains("interaction")) {
+- Interaction.PlayerAction.CODEC
+- .decode(NbtOps.INSTANCE, compound.get("interaction"))
+- .resultOrPartial(Util.prefix("Interaction entity", LOGGER::error))
+- .ifPresent(pair -> this.interaction = pair.getFirst());
++ 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) -> {
++ this.interaction = (Interaction.PlayerAction) pair.getFirst();
++ });
+ } else {
+ this.interaction = null;
+ }
+@@ -89,11 +102,15 @@
+ 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 -> compound.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 -> compound.put("interaction", tag));
++ Interaction.PlayerAction.CODEC.encodeStart(NbtOps.INSTANCE, this.interaction).result().ifPresent((nbtbase) -> {
++ compound.put("interaction", nbtbase);
++ });
+ }
+
+ compound.putBoolean("response", this.getResponse());
+@@ -102,9 +119,10 @@
+ @Override
+ public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
+ super.onSyncedDataUpdated(key);
+- if (DATA_HEIGHT_ID.equals(key) || DATA_WIDTH_ID.equals(key)) {
++ if (Interaction.DATA_HEIGHT_ID.equals(key) || Interaction.DATA_WIDTH_ID.equals(key)) {
+ this.setBoundingBox(this.makeBoundingBox());
+ }
++
+ }
+
+ @Override
+@@ -118,8 +136,8 @@
+ }
+
+ @Override
+- public PushReaction getPistonPushReaction() {
+- return PushReaction.IGNORE;
++ public EnumPistonReaction getPistonPushReaction() {
++ return EnumPistonReaction.IGNORE;
+ }
+
+ @Override
+@@ -129,12 +147,23 @@
+
+ @Override
+ public boolean skipAttackInteraction(Entity entity) {
+- if (entity instanceof Player player) {
+- this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime());
+- if (player instanceof ServerPlayer serverPlayer) {
+- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, 1.0F, false);
++ if (entity instanceof Player) {
++ 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(entityhuman.getUUID(), this.level().getGameTime());
++ if (entityhuman instanceof ServerPlayer) {
++ ServerPlayer entityplayer = (ServerPlayer) entityhuman;
++
++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, source, (float) event.getFinalDamage(), 1.0F, false); // CraftBukkit
++ }
++
+ return !this.getResponse();
+ } else {
+ return false;
+@@ -142,7 +171,7 @@
+ }
+
+ @Override
+- public InteractionResult interact(Player player, InteractionHand hand) {
++ public InteractionResult interact(Player player, EnumHand hand) {
+ if (this.level().isClientSide) {
+ return this.getResponse() ? InteractionResult.SUCCESS : InteractionResult.CONSUME;
+ } else {
+@@ -152,8 +181,7 @@
+ }
+
+ @Override
+- public void tick() {
+- }
++ public void tick() {}
+
+ @Nullable
+ @Override
+@@ -167,28 +195,28 @@
+ return this.interaction != null ? this.level().getPlayerByUUID(this.interaction.player()) : null;
+ }
+
+- private void setWidth(float width) {
+- this.entityData.set(DATA_WIDTH_ID, width);
++ public void setWidth(float width) {
++ this.entityData.set(Interaction.DATA_WIDTH_ID, width);
+ }
+
+- private float getWidth() {
+- return this.entityData.get(DATA_WIDTH_ID);
++ public float getWidth() {
++ return (Float) this.entityData.get(Interaction.DATA_WIDTH_ID);
+ }
+
+- private void setHeight(float height) {
+- this.entityData.set(DATA_HEIGHT_ID, height);
++ public void setHeight(float height) {
++ this.entityData.set(Interaction.DATA_HEIGHT_ID, height);
+ }
+
+- private float getHeight() {
+- return this.entityData.get(DATA_HEIGHT_ID);
++ public float getHeight() {
++ return (Float) this.entityData.get(Interaction.DATA_HEIGHT_ID);
+ }
+
+- private void setResponse(boolean response) {
+- this.entityData.set(DATA_RESPONSE_ID, response);
++ public void setResponse(boolean response) {
++ this.entityData.set(Interaction.DATA_RESPONSE_ID, response);
+ }
+
+- private boolean getResponse() {
+- return this.entityData.get(DATA_RESPONSE_ID);
++ public boolean getResponse() {
++ return (Boolean) this.entityData.get(Interaction.DATA_RESPONSE_ID);
+ }
+
+ private EntityDimensions getDimensions() {
+@@ -196,7 +224,7 @@
+ }
+
+ @Override
+- public EntityDimensions getDimensions(Pose pose) {
++ public EntityDimensions getDimensions(EntityPose pose) {
+ return this.getDimensions();
+ }
+
+@@ -205,13 +233,10 @@
+ return this.getDimensions().makeBoundingBox(this.position());
+ }
+
+- static record PlayerAction(UUID player, long timestamp) {
+- public static final Codec<Interaction.PlayerAction> CODEC = RecordCodecBuilder.create(
+- instance -> instance.group(
+- UUIDUtil.CODEC.fieldOf("player").forGetter(Interaction.PlayerAction::player),
+- Codec.LONG.fieldOf("timestamp").forGetter(Interaction.PlayerAction::timestamp)
+- )
+- .apply(instance, Interaction.PlayerAction::new)
+- );
++ 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);
++ });
+ }
+ }