mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 00:17:43 +01:00
Configurable block blast resistance
This commit is contained in:
@@ -7,3 +7,4 @@ public net.minecraft.world.entity.monster.Shulker MAX_SCALE
|
||||
public net.minecraft.world.entity.player.Player canGlide()Z
|
||||
public net.minecraft.world.level.block.entity.FuelValues values
|
||||
public-f net.minecraft.world.entity.EntityType dimensions
|
||||
public-f net.minecraft.world.level.block.state.BlockBehaviour explosionResistance
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MelnCat <melncatuwu@gmail.com>
|
||||
Date: Sat, 1 Oct 2022 13:29:17 -0700
|
||||
Subject: [PATCH] Configurable block blast resistance
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index 6376b8b3ff444f4cab93e2bb5d2becc77c33c118..c8ae6e4cd74549f753ec04def5d882de1ab72308 100644
|
||||
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -91,7 +91,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
|
||||
protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP};
|
||||
public final boolean hasCollision;
|
||||
- protected final float explosionResistance;
|
||||
+ public float explosionResistance; // Purpur - protected final -> public
|
||||
protected final boolean isRandomlyTicking;
|
||||
protected final SoundType soundType;
|
||||
protected final float friction;
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index dca02d697dd0982b006d4d975e7df745ab62dac5..87ae04dff2645ba058325077cae4bcb20c7eab40 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -498,4 +498,19 @@ public class PurpurConfig {
|
||||
String setPattern = getString("settings.username-valid-characters", defaultPattern);
|
||||
usernameValidCharactersPattern = java.util.regex.Pattern.compile(setPattern == null || setPattern.isBlank() ? defaultPattern : setPattern);
|
||||
}
|
||||
+
|
||||
+ private static void blastResistanceSettings() {
|
||||
+ getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
||||
+ Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
||||
+ if (block == Blocks.AIR) {
|
||||
+ log(Level.SEVERE, "Invalid block for `settings.blast-resistance-overrides`: " + blockId);
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!(value instanceof Number blastResistance)) {
|
||||
+ log(Level.SEVERE, "Invalid blast resistance for `settings.blast-resistance-overrides." + blockId + "`: " + value);
|
||||
+ return;
|
||||
+ }
|
||||
+ block.explosionResistance = blastResistance.floatValue();
|
||||
+ });
|
||||
+ }
|
||||
}
|
||||
@@ -3,12 +3,14 @@ package org.purpurmc.purpur;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -16,6 +18,7 @@ import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -491,4 +494,19 @@ public class PurpurConfig {
|
||||
String setPattern = getString("settings.username-valid-characters", defaultPattern);
|
||||
usernameValidCharactersPattern = Pattern.compile(setPattern == null || setPattern.isBlank() ? defaultPattern : setPattern);
|
||||
}
|
||||
|
||||
private static void blastResistanceSettings() {
|
||||
getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
||||
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
||||
if (block == Blocks.AIR) {
|
||||
log(Level.SEVERE, "Invalid block for `settings.blast-resistance-overrides`: " + blockId);
|
||||
return;
|
||||
}
|
||||
if (!(value instanceof Number blastResistance)) {
|
||||
log(Level.SEVERE, "Invalid blast resistance for `settings.blast-resistance-overrides." + blockId + "`: " + value);
|
||||
return;
|
||||
}
|
||||
block.explosionResistance = blastResistance.floatValue();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user