2020-11-26 09:30:08 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
|
|
Date: Wed, 25 Nov 2020 23:20:44 -0800
|
|
|
|
Subject: [PATCH] Implement TargetHitEvent
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockTarget.java b/src/main/java/net/minecraft/world/level/block/BlockTarget.java
|
2020-11-26 09:30:08 +01:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockTarget.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockTarget.java
|
2020-11-26 09:30:08 +01:00
|
|
|
@@ -0,0 +0,0 @@
|
2021-03-16 08:19:45 +01:00
|
|
|
package net.minecraft.world.level.block;
|
2020-11-26 09:30:08 +01:00
|
|
|
|
|
|
|
+import io.papermc.paper.event.block.TargetHitEvent; // Paper - Need to import because 'io' class exists in nms
|
|
|
|
import java.util.Random;
|
2021-03-16 08:19:45 +01:00
|
|
|
import net.minecraft.advancements.CriterionTriggers;
|
|
|
|
import net.minecraft.core.BlockPosition;
|
2020-11-26 09:30:08 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class BlockTarget extends Block {
|
|
|
|
@Override
|
|
|
|
public void a(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) {
|
|
|
|
int i = a((GeneratorAccess) world, iblockdata, movingobjectpositionblock, (Entity) iprojectile);
|
|
|
|
+ // Paper start
|
|
|
|
+ }
|
|
|
|
+ private static void awardTargetHitCriteria(IProjectile iprojectile, MovingObjectPositionBlock movingobjectpositionblock, int i) {
|
|
|
|
+ // Paper end
|
|
|
|
Entity entity = iprojectile.getShooter();
|
|
|
|
|
|
|
|
if (entity instanceof EntityPlayer) {
|
|
|
|
@@ -0,0 +0,0 @@ public class BlockTarget extends Block {
|
|
|
|
int i = a(movingobjectpositionblock, movingobjectpositionblock.getPos());
|
|
|
|
int j = entity instanceof EntityArrow ? 20 : 8;
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ if (entity instanceof IProjectile) {
|
|
|
|
+ final IProjectile projectile = (IProjectile) entity;
|
|
|
|
+ final org.bukkit.craftbukkit.block.CraftBlock craftBlock = org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, movingobjectpositionblock.getBlockPosition());
|
|
|
|
+ final org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(movingobjectpositionblock.getDirection());
|
|
|
|
+ final TargetHitEvent targetHitEvent = new TargetHitEvent((org.bukkit.entity.Projectile) projectile.getBukkitEntity(), craftBlock, blockFace, i);
|
|
|
|
+ if (targetHitEvent.callEvent()) {
|
|
|
|
+ i = targetHitEvent.getSignalStrength();
|
|
|
|
+ awardTargetHitCriteria(projectile, movingobjectpositionblock, i);
|
|
|
|
+ } else {
|
|
|
|
+ return i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
if (!generatoraccess.getBlockTickList().a(movingobjectpositionblock.getBlockPosition(), iblockdata.getBlock())) {
|
|
|
|
a(generatoraccess, iblockdata, i, movingobjectpositionblock.getBlockPosition(), j);
|
|
|
|
}
|