Skip to content

Commit

Permalink
Make player death animation hitbox tiny
Browse files Browse the repository at this point in the history
Signed-off-by: Pablete1234 <[email protected]>
  • Loading branch information
Pablete1234 authored and Electroid committed Dec 14, 2020
1 parent 954bbc6 commit 0e540a3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 30 deletions.
8 changes: 0 additions & 8 deletions core/src/main/java/tc/oc/pgm/PGMConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public final class PGMConfig implements Config {
// gameplay.*
private final boolean woolRefill;
private final int griefScore;
private final int deathTicks;

// join.*
private final long minPlayers;
Expand Down Expand Up @@ -165,8 +164,6 @@ public final class PGMConfig implements Config {
this.verboseStats = parseBoolean(config.getString("ui.verbose-stats", "false"));
this.griefScore =
parseInteger(config.getString("gameplay.grief-score", "-10"), Range.atMost(0));
this.deathTicks =
parseInteger(config.getString("gameplay.death-ticks", "15"), Range.closed(0, 20));

this.minPlayers = parseInteger(config.getString("join.min-players", "1"));
this.limitJoin = parseBoolean(config.getString("join.limit", "true"));
Expand Down Expand Up @@ -521,11 +518,6 @@ public int getGriefScore() {
return griefScore;
}

@Override
public int getDeathTicks() {
return deathTicks;
}

@Override
public boolean showSideBar() {
return showSideBar;
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/tc/oc/pgm/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,6 @@ public interface Config {
*/
int getGriefScore();

/**
* Gets the length in ticks for how long the death animation is shown
*
* @return length of death animation
*/
int getDeathTicks();

/**
* Gets a group of players, used for prefixes and player sorting.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/tc/oc/pgm/spawns/SpawnModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class SpawnModule implements MapModule {

public static final Duration MINIMUM_RESPAWN_DELAY = Duration.ofSeconds(2);
public static final Duration MINIMUM_RESPAWN_DELAY = Duration.ofMillis(1500);
public static final Duration IGNORE_CLICKS_DELAY = Duration.ofMillis(500);

protected final Spawn defaultSpawn;
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/tc/oc/pgm/spawns/states/Dead.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import tc.oc.pgm.api.PGM;
import tc.oc.pgm.api.match.MatchScope;
import tc.oc.pgm.api.party.Competitor;
import tc.oc.pgm.api.player.MatchPlayer;
Expand All @@ -25,7 +24,7 @@

/** Player is waiting to respawn after dying in-game */
public class Dead extends Spawning {
private static final long CORPSE_ROT_TICKS = PGM.get().getConfiguration().getDeathTicks();
private static final long CORPSE_ROT_TICKS = 20;

private static final PotionEffect CONFUSION =
new PotionEffect(PotionEffectType.CONFUSION, 100, 0, true, false);
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ join:
gameplay:
refill-wool: true # Should wool in wool rooms be automatically refilled?
grief-score: -10 # Score under which players should be kept out of the match
death-ticks: 15 # Number of ticks the death animation should last

# Toggles various user interfaces.
ui:
Expand Down
29 changes: 18 additions & 11 deletions util/src/main/java/tc/oc/pgm/util/nms/NMSHacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,33 +475,40 @@ static void showBorderWarning(Player player, boolean show) {

static void playDeathAnimation(Player player) {
EntityPlayer handle = ((CraftPlayer) player).getHandle();
PacketPlayOutEntityMetadata packet =
PacketPlayOutEntityMetadata metadata =
new PacketPlayOutEntityMetadata(handle.getId(), handle.getDataWatcher(), false);

// Add/replace health to zero
boolean replaced = false;
DataWatcher.WatchableObject zeroHealth =
new DataWatcher.WatchableObject(3, 6, 0f); // type 3 (float), index 6 (health)

if (packet.b != null) {
for (int i = 0; i < packet.b.size(); i++) {
DataWatcher.WatchableObject wo = packet.b.get(i);
if (metadata.b != null) {
for (int i = 0; i < metadata.b.size(); i++) {
DataWatcher.WatchableObject wo = metadata.b.get(i);
if (wo.a() == 6) {
packet.b.set(i, zeroHealth);
metadata.b.set(i, zeroHealth);
replaced = true;
}
}
}

if (!replaced) {
if (packet.b == null) {
packet.b = Collections.singletonList(zeroHealth);
} else {
packet.b.add(zeroHealth);
}
if (metadata.b != null) metadata.b.add(zeroHealth);
else metadata.b = Collections.singletonList(zeroHealth);
}

sendPacketToViewers(player, packet);
Location location = player.getLocation();
PacketPlayOutBed useBed =
new PacketPlayOutBed(
((CraftPlayer) player).getHandle(),
new BlockPosition(location.getX(), location.getY(), location.getZ()));

Packet<?> teleport = teleportEntityPacket(player.getEntityId(), location);

sendPacketToViewers(player, metadata);
sendPacketToViewers(player, useBed);
sendPacketToViewers(player, teleport);
}

static org.bukkit.enchantments.Enchantment getEnchantment(String key) {
Expand Down

0 comments on commit 0e540a3

Please sign in to comment.