Skip to content

Commit

Permalink
Fix: cannot hit solidified blocks and running blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Oct 14, 2024
1 parent f22054e commit a6c3f82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/main/java/dev/tylerm/khs/game/listener/DisguiseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedEnumEntityUseAction;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.util.Disguise;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute;
Expand All @@ -21,6 +23,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;

import java.util.ArrayList;
Expand Down Expand Up @@ -54,10 +57,11 @@ public void onPacketReceiving(PacketEvent event) {
PacketContainer packet = event.getPacket();

// only left click attacks
EnumWrappers.EntityUseAction action = packet.getEntityUseActions().getValues().stream().findFirst().orElse(null);
if (action == null) return;
//EnumWrappers.EntityUseAction action = packet.getEntityUseActions().getValues().stream().findFirst().orElse(null);
var action = packet.getEnumEntityUseActions().getValues().stream().findFirst().orElse(null);
if (action == null || action.getAction() != EnumWrappers.EntityUseAction.ATTACK) return;
//noinspection ComparatorResultComparison
if (action.compareTo(EnumWrappers.EntityUseAction.INTERACT) == 2) {
if (action.getAction().compareTo(EnumWrappers.EntityUseAction.INTERACT) == 2) {
return;
}

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/dev/tylerm/khs/game/util/Disguise.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.messages.ActionBar;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.util.packet.BlockChangePacket;
import dev.tylerm.khs.util.packet.EntityTeleportPacket;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.loot.LootTable;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import java.util.HashMap;

@SuppressWarnings("deprecation")
public class Disguise {

final Player hider;
final Material material;
FallingBlock block;
AbstractHorse hitBox;
PolarBear hitBox;
Location blockLocation;
boolean solid, solidify, solidifying;
static Team hidden;
Expand Down Expand Up @@ -150,7 +154,7 @@ private void respawnFallingBlock() {
}

private void respawnHitbox() {
hitBox = (AbstractHorse) hider.getLocation().getWorld().spawnEntity(hider.getLocation().add(0, 1000, 0), EntityType.SKELETON_HORSE);
hitBox = (PolarBear) hider.getLocation().getWorld().spawnEntity(hider.getLocation().add(0, 1000, 0), EntityType.POLAR_BEAR);
hitBox.setGravity(false);
hitBox.setAI(false);
hitBox.setInvulnerable(true);
Expand Down

0 comments on commit a6c3f82

Please sign in to comment.