3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-02 08:00:07 +02:00

add registerBlockItemOverride event + refactor

Dieser Commit ist enthalten in:
Joshua Castle 2023-01-05 22:28:32 -08:00
Ursprung 880d8e528e
Commit d019160939
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: F674F38216C35D5D
6 geänderte Dateien mit 24 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -54,4 +54,13 @@ public abstract class GeyserDefineCustomBlocksEvent implements Event {
* @param customBlockState the custom block state with which to override java state identifier
*/
public abstract void registerBlockStateOverride(@NonNull String javaIdentifier, @NonNull CustomBlockState customBlockState);
/**
* Registers the given {@link CustomBlockData} as an override for the
* given java item identifier
*
* @param javaIdentifier the java item identifier to override
* @param customBlockData the custom block data with which to override java item identifier
*/
public abstract void registerBlockItemOverride(@NonNull String javaIdentifier, @NonNull CustomBlockData customBlockData);
}

Datei anzeigen

@ -29,8 +29,8 @@ import com.fasterxml.jackson.databind.JsonNode;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.block.custom.CustomBlockMapping;
import org.geysermc.geyser.api.item.custom.CustomItemData;
import org.geysermc.geyser.registry.mappings.util.CustomBlockMapping;
import org.geysermc.geyser.registry.mappings.versions.MappingsReader;
import org.geysermc.geyser.registry.mappings.versions.MappingsReader_v1;

Datei anzeigen

@ -23,11 +23,13 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.api.block.custom;
package org.geysermc.geyser.registry.mappings.util;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
/**
* This class is used to store a custom block mappings, which contain all of the

Datei anzeigen

@ -27,10 +27,10 @@ package org.geysermc.geyser.registry.mappings.versions;
import com.fasterxml.jackson.databind.JsonNode;
import org.geysermc.geyser.api.block.custom.CustomBlockMapping;
import org.geysermc.geyser.api.item.custom.CustomItemData;
import org.geysermc.geyser.api.item.custom.CustomRenderOffsets;
import org.geysermc.geyser.item.exception.InvalidCustomMappingsFileException;
import org.geysermc.geyser.registry.mappings.util.CustomBlockMapping;
import java.nio.file.Path;
import java.util.function.BiConsumer;

Datei anzeigen

@ -31,7 +31,6 @@ import com.google.common.base.CharMatcher;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockMapping;
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
import org.geysermc.geyser.api.block.custom.component.BoxComponent;
@ -47,6 +46,7 @@ import org.geysermc.geyser.level.block.GeyserCustomBlockData.CustomBlockDataBuil
import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.mappings.util.BlockPropertyTypeMaps;
import org.geysermc.geyser.registry.mappings.util.CustomBlockMapping;
import org.geysermc.geyser.registry.type.BlockMapping;
import org.geysermc.geyser.util.BlockUtils;
@ -480,7 +480,7 @@ public class MappingsReader_v1 extends MappingsReader {
return pairs;
}
public float clamp(float value, float min, float max) {
private float clamp(float value, float min, float max) {
return Math.max(min, Math.min(max, value));
}

Datei anzeigen

@ -72,6 +72,14 @@ public class CustomBlockRegistryPopulator {
javaIdentifier + " Old override: " + oldBlockState.name() + " New override: " + customBlockState.name());
}
}
@Override
public void registerBlockItemOverride(@NonNull String javaIdentifier, @NonNull CustomBlockData customBlockData) {
if (!customBlocks.contains(customBlockData)) {
throw new IllegalArgumentException("Custom block is unregistered. Name: " + customBlockData.name());
}
customBlockItemOverrides.put(javaIdentifier, customBlockData);
}
});
for (CustomSkull customSkull : BlockRegistries.CUSTOM_SKULLS.get().values()) {