aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-22 11:35:45 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-22 11:35:45 +0100
commit547ec0214b9d6c259109471064f62d2064a7a6d8 (patch)
tree220fe4260506c09d4a91d6066886988a45da69ee /src/main
parent189b1d5f1f41326becc614e32d78fbb2f5228530 (diff)
downloadygasi-547ec0214b9d6c259109471064f62d2064a7a6d8.tar.gz
ygasi-547ec0214b9d6c259109471064f62d2064a7a6d8.tar.bz2
ygasi-547ec0214b9d6c259109471064f62d2064a7a6d8.zip
Some ItemMixin stuff
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/mixin/ItemMixin.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/mixin/ItemMixin.java b/src/main/java/dev/mayaqq/ygasi/mixin/ItemMixin.java
index 8cfbe8b..26c6401 100644
--- a/src/main/java/dev/mayaqq/ygasi/mixin/ItemMixin.java
+++ b/src/main/java/dev/mayaqq/ygasi/mixin/ItemMixin.java
@@ -19,6 +19,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.EulerAngle;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
+import net.minecraft.world.explosion.Explosion;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -65,14 +66,14 @@ public class ItemMixin {
for (BlockPos relativeBlockPos : relativeBlockPositions) {
BlockPos blockPos = pos.add(relativeBlockPos);
Block block = sword.world.getBlockState(blockPos).getBlock();
- if(block != Blocks.AIR) {
+ if(block != Blocks.AIR && hitTarget) {
LOGGER.info("Sword hit a block!");
hitTarget = onHit(serverWorld, player, sword, hitTarget);
isAir = false;
}
double entityCheckRadius = 1;
for (PlayerEntity pl : world.getPlayers()) {
- if (pl.distanceTo(sword) <= entityCheckRadius && pl != player && pl.getScoreboardTeam() != player.getScoreboardTeam()) {
+ if (pl.distanceTo(sword) <= entityCheckRadius && pl != player && pl.getScoreboardTeam() != player.getScoreboardTeam() && hitTarget) {
LOGGER.info("Sword hit a player!");
//create an explosion at the position of the sword
hitTarget = onHit(serverWorld, player, sword, hitTarget);
@@ -98,7 +99,8 @@ public class ItemMixin {
}
public boolean onHit(ServerWorld world, ServerPlayerEntity player, ArmorStandEntity sword, Boolean hitTraget) {
if (hitTraget) {
- world.createExplosion(player, DamageSource.player(player), null, sword.getX(), sword.getY(), sword.getZ(), 10, false, World.ExplosionSourceType.MOB, false);
+ LOGGER.info("Sword hit a target!");
+ world.createExplosion(sword, sword.getX(), sword.getY(), sword.getZ(), 1, World.ExplosionSourceType.NONE);
sword.remove(Entity.RemovalReason.DISCARDED);
return false;
}