Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7f98d25
initial work towards custom items
MrHell228 Mar 14, 2025
582802d
continue custom items
MrHell228 Mar 15, 2025
686ea21
DataManipulatorProxy
MrHell228 Mar 23, 2025
30f1b66
rename: ValueContainerProxy getAsDataHolder() -> getAsData()
MrHell228 Mar 23, 2025
2da9102
continue custom items
MrHell228 Mar 24, 2025
2a430d4
move enums to specific package
MrHell228 Mar 24, 2025
ea070e2
continue custom items
MrHell228 Mar 25, 2025
0ec4861
continue custom items
MrHell228 Mar 26, 2025
ee2b212
continue custom stuff
MrHell228 Apr 20, 2025
c0574f7
continue custom stuff
MrHell228 Apr 27, 2025
dcb1794
continue custom stuff
MrHell228 Apr 27, 2025
18c80ee
try split behavioir into action & product
MrHell228 Apr 27, 2025
b43ae58
Revert "try split behavioir into action & product"
MrHell228 Apr 27, 2025
6b95dea
continue custom stuff
MrHell228 Apr 29, 2025
3813999
continue custom stuff
MrHell228 May 4, 2025
16ec045
continue custom stuff
MrHell228 May 11, 2025
d38bba4
continue custom stuff
MrHell228 May 14, 2025
1838e31
continue custom stuff
MrHell228 May 17, 2025
3a49748
math
MrHell228 May 22, 2025
a9d14fa
continue custom stuff
MrHell228 Oct 5, 2025
1c99680
continue custom stuff
MrHell228 Oct 8, 2025
ccb8160
update to api 14.1.0
MrHell228 Oct 9, 2025
a365310
Update ViewerProxy.java
MrHell228 Oct 9, 2025
31eff50
refactor into single project with subprojects
MrHell228 Oct 9, 2025
f9f599a
Update README.md
MrHell228 Oct 9, 2025
17dd735
continue custom stuff
MrHell228 Oct 10, 2025
2135ef9
continue custom stuff
MrHell228 Oct 13, 2025
d0b2f2f
Merge branch 'api-14-custom-items' of https://github.com/MrHell228/Sp…
MrHell228 Oct 13, 2025
b59b7f5
try approach with actual custom ItemType
MrHell228 Oct 25, 2025
0388215
do proper networking with custom types
MrHell228 Nov 2, 2025
94c7f4b
add actual custom blocks
MrHell228 Nov 4, 2025
b6a9021
add more block keys, implement custom mining
MrHell228 Nov 5, 2025
5b80fff
properly sanitize network Components
MrHell228 Nov 6, 2025
04c4162
TODO fix. Temporarily disable connection check
MrHell228 Nov 6, 2025
de98fc6
remove per-archetype network item
MrHell228 Nov 6, 2025
4b87281
fix PotionEffect modifier templates
MrHell228 Nov 6, 2025
284e773
fix displaying ingredients with custom items
MrHell228 Nov 6, 2025
41a9975
properly register display states and state variants
MrHell228 Nov 13, 2025
92da616
support multiple Variants per block state
MrHell228 Nov 13, 2025
d338cfe
add custom ItemActions
MrHell228 Nov 14, 2025
dac9b2b
move things around
MrHell228 Nov 21, 2025
9cf8a90
add scaffolding-like item and block
MrHell228 Nov 24, 2025
98dd72f
make custom scaffoldings work
MrHell228 Nov 25, 2025
f2c5592
make custom item actions work
MrHell228 Nov 25, 2025
818daa9
some network changes
MrHell228 Nov 25, 2025
9931d00
rename: Archetype -> TypeArchetype
MrHell228 Nov 26, 2025
31a168e
split custom types to TypeBased and InstanceBased
MrHell228 Nov 27, 2025
43b6e5c
initial work towards custom entity types
MrHell228 Nov 28, 2025
deeb3d1
some behaviour changes
MrHell228 Nov 28, 2025
7f69a17
more changes to Behaviour API
MrHell228 Dec 2, 2025
392fc7b
more behaviour API & custom entity changes
MrHell228 Dec 7, 2025
defd8bc
more custom entity changes
MrHell228 Apr 10, 2026
905897a
support equipment itemstack component
MrHell228 Apr 11, 2026
ef44749
support custom attributes
MrHell228 Apr 12, 2026
2ef37b6
fix custom attributes syncing
MrHell228 Apr 13, 2026
4dcfcf2
custom attributes changes
MrHell228 Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# SpongeToolsAPI
# SpongeTools
Various useful utilities for SpongeAPI
152 changes: 152 additions & 0 deletions api/src/main/java/net/hellheim/spongetools/SpongeTools.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package net.hellheim.spongetools;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockSoundGroup;
import org.spongepowered.api.data.Key;
import org.spongepowered.api.data.value.ListValue;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.effect.sound.SoundType;
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
import org.spongepowered.api.map.color.MapColorType;
import org.spongepowered.api.registry.DefaultedRegistryType;
import org.spongepowered.api.registry.RegistryRoots;
import org.spongepowered.api.registry.RegistryType;

import com.mojang.serialization.MapCodec;

import net.hellheim.spongetools.custom.type.block.BlockTypeArchetype;
import net.hellheim.spongetools.custom.type.block.ModeledBlock;
import net.hellheim.spongetools.custom.type.entity.EntityTypeArchetype;
import net.hellheim.spongetools.custom.type.entity.ModeledEntity;
import net.hellheim.spongetools.custom.type.item.CustomItemAction;
import net.hellheim.spongetools.custom.type.item.ItemTypeArchetype;
import net.hellheim.spongetools.custom.type.item.LoreProcessor;
import net.hellheim.spongetools.custom.type.item.LoreProvider;
import net.hellheim.spongetools.custom.type.item.ModeledItem;
import net.hellheim.spongetools.resourcepack.Model;
import net.hellheim.spongetools.resourcepack.block.BlockDefinition;
import net.hellheim.spongetools.resourcepack.item.ItemDefinition;

public final class SpongeTools {

public static final String NAMESPACE = "spongetools";

public static ResourceKey key(final String value) {
return ResourceKey.of(SpongeTools.NAMESPACE, value);
}

public static final class Registries {

// Archetypes

public static final DefaultedRegistryType<BlockTypeArchetype> BLOCK_TYPE_ARCHETYPE = Registries.key("block_type_archetype");

public static final DefaultedRegistryType<EntityTypeArchetype> ENTITY_TYPE_ARCHETYPE = Registries.key("entity_type_archetype");

public static final DefaultedRegistryType<ItemTypeArchetype> ITEM_TYPE_ARCHETYPE = Registries.key("item_type_archetype");

// Modeled types

public static final DefaultedRegistryType<ModeledBlock> MODELED_BLOCK = Registries.key("modeled_block");

public static final DefaultedRegistryType<ModeledEntity> MODELED_ENTITY = Registries.key("modeled_entity");

public static final DefaultedRegistryType<ModeledItem> MODELED_ITEM = Registries.key("modeled_item");

/**
* Definitions from this registry will be included in built ResourcePack.
*/
public static final DefaultedRegistryType<BlockDefinition> BLOCK_DEFINITION = Registries.key("blockstates");

/**
* Definitions from this registry will be included in built ResourcePack.
*/
public static final DefaultedRegistryType<ItemDefinition> ITEM_DEFINITION = Registries.key("items");

/**
* Models from this registry will be included in built ResourcePack.
*/
public static final DefaultedRegistryType<Model> MODEL = Registries.key("models");

public static final DefaultedRegistryType<MapCodec<? extends LoreProcessor>> LORE_PROCESSOR_TYPE = Registries.key("lore_processor_type");

public static final DefaultedRegistryType<MapCodec<? extends LoreProvider>> LORE_PROVIDER_TYPE = Registries.key("lore_provider_type");

public static final DefaultedRegistryType<MapCodec<? extends CustomItemAction.Config>> ITEM_ACTION_CONFIG_TYPE = Registries.key("item_action_config_type");

private static <V> DefaultedRegistryType<V> key(final String key) {
return RegistryType.of(RegistryRoots.SPONGE, SpongeTools.key(key)).asDefaultedType(Sponge::game);
}

private Registries() {
}
}

public static final class Keys {

public static final Key<Value<BlockSoundGroup>> BLOCK_SOUND_GROUP = Keys.key("block_sound_group", BlockSoundGroup.class);

public static final Key<Value<ResourceKey>> EQUIPMENT_ASSET = Keys.key("equipment_asset", ResourceKey.class);

public static final Key<Value<ResourceKey>> EQUIPMENT_CAMERA_OVERLAY = Keys.key("equipment_camera_overlay", ResourceKey.class);

public static final Key<Value<Boolean>> EQUIPMENT_DAMAGEABLE = Keys.key("equipment_damageable", Boolean.class);

public static final Key<Value<Boolean>> EQUIPMENT_DISPENSABLE = Keys.key("equipment_dispensable", Boolean.class);

public static final Key<Value<SoundType>> EQUIPMENT_SOUND = Keys.key("equipment_sound", SoundType.class);

public static final Key<Value<Boolean>> EQUIPMENT_SWAPPABLE = Keys.key("equipment_swappable", Boolean.class);

public static final Key<Value<EquipmentType>> EQUIPMENT_TYPE = Keys.key("equipment_type", EquipmentType.class);

public static final Key<Value<Double>> FRICTION_FACTOR = Keys.key("friction_factor", Double.class);

public static final Key<Value<Boolean>> HAS_COLLISION = Keys.key("collision", Boolean.class);

public static final Key<Value<Boolean>> HAS_DYNAMIC_SHAPE = Keys.key("dynamic_shape", Boolean.class);

public static final Key<Value<Boolean>> HAS_OCCLUSION = Keys.key("occlusion", Boolean.class);

public static final Key<Value<Double>> JUMP_FACTOR = Keys.key("jump_factor", Double.class);

public static final Key<Value<ResourceKey>> LOOT_TABLE_KEY = Keys.key("loot_table_key", ResourceKey.class);

public static final Key<Value<LoreProcessor>> LORE_PROCESSOR = Keys.key("lore_processor", LoreProcessor.class);

public static final Key<ListValue<LoreProvider>> LORE_PROVIDERS = Keys.listKey("lore_providers", LoreProvider.class);

public static final Key<Value<MapColorType>> MAP_COLOR_TYPE = Keys.key("map_color_type", MapColorType.class);

public static final Key<Value<Boolean>> REQUIRE_TOOL = Keys.key("require_tool", Boolean.class);

public static final Key<Value<Double>> SPEED_FACTOR = Keys.key("speed_factor", Double.class);

private static <E> Key<Value<E>> key(final String key, final Class<E> type) {
return Key.from(SpongeTools.key(key), type);
}

private static <E> Key<ListValue<E>> listKey(final String key, final Class<E> type) {
return Key.fromList(SpongeTools.key(key), type);
}

private Keys() {
}
}

public static final class Queries {

private Queries() {
}
}

public static final class Versions {

private Versions() {
}
}

private SpongeTools() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import com.mojang.serialization.Codec;

import net.hellheim.spongetools.codec.list.TypeCodecs;

public interface CodecMapper<R> {

interface M1<R> extends CodecMapper<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import com.mojang.serialization.Codec;

import net.hellheim.spongetools.codec.list.ExtraCodecs;

public final class CodecMapperDispatcher<I, V> {

private final LateBoundIdMapper<I, MapCodecMapper.M1<? extends V>> idMapper = new LateBoundIdMapper<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.google.common.collect.HashBiMap;
import com.mojang.serialization.Codec;

import net.hellheim.spongetools.codec.list.ExtraCodecs;

public class LateBoundIdMapper<I, V> {

protected final BiMap<I, V> idToValue = HashBiMap.create();

public Codec<V> codec(final Codec<I> idCodec) {
BiMap<V, I> bimap = this.idToValue.inverse();
final BiMap<V, I> bimap = this.idToValue.inverse();
return ExtraCodecs.idResolver(idCodec, this.idToValue::get, bimap::get);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;

import net.hellheim.spongetools.codec.list.TypeCodecs;

public interface MapCodecMapper<R> {

interface M1<R> extends MapCodecMapper<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.mojang.serialization.DataResult;
import com.mojang.serialization.DynamicOps;

import net.hellheim.spongetools.codec.list.ExtraCodecs;

public class StringRepresentableCodec<S extends StringRepresentable> implements Codec<S> {

private final Supplier<S[]> memoized;
Expand All @@ -30,7 +32,11 @@ public StringRepresentableCodec(
);
}

static <S extends StringRepresentable> StringRepresentableCodec<S> fromValues(final Supplier<S[]> values) {
public static <S extends StringRepresentable> StringRepresentableCodec<S> fromValues(final S[] values) {
return StringRepresentableCodec.fromValues(() -> values);
}

public static <S extends StringRepresentable> StringRepresentableCodec<S> fromValues(final Supplier<S[]> values) {
final Supplier<S[]> memoized = Suppliers.memoize(values::get);
final Supplier<List<S>> memoizedList = Suppliers.memoize(() -> List.of(memoized.get()));

Expand All @@ -40,7 +46,7 @@ static <S extends StringRepresentable> StringRepresentableCodec<S> fromValues(fi
return new StringRepresentableCodec<>(memoized, nameLookup, indexLookup);
}

static <S extends StringRepresentable> Function<String, S> nameLookup(
public static <S extends StringRepresentable> Function<String, S> nameLookup(
final Supplier<S[]> values, final Function<String, String> keyFunction
) {
final Supplier<S[]> memoized = Suppliers.memoize(values::get);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import net.hellheim.spongetools.codec.CodecMapperDispatcher;
import net.hellheim.spongetools.codec.MapCodecMapper;
import net.hellheim.spongetools.codec.SpongeCodecs;
import net.hellheim.spongetools.codec.list.SpongeCodecs;

public final class TableEntryCodecs {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;

import net.hellheim.spongetools.codec.CodecDispatcher;
import net.hellheim.spongetools.codec.SpongeCodecs;
import net.hellheim.spongetools.codec.list.SpongeCodecs;

public class VariableAmountCodecs {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.hellheim.spongetools.codec;
package net.hellheim.spongetools.codec.list;

import org.spongepowered.api.Sponge;

Expand Down Expand Up @@ -63,7 +63,7 @@ public final class AdventureCodecs {
public static final Codec<ChatType> CHAT_TYPE = AdventureCodecs.factory().chatType();

public static Codec<Key> key(final String defaultNamespace) {
if (Key.parseableNamespace(defaultNamespace)) {
if (!Key.parseableNamespace(defaultNamespace)) {
throw new IllegalArgumentException("Invalid namespace: " + defaultNamespace);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.hellheim.spongetools.codec;
package net.hellheim.spongetools.codec.list;

import java.util.Optional;
import java.util.function.Function;
Expand Down
Loading