Skip to content

Commit

Permalink
Merge block enhancements. Merges #2514
Browse files Browse the repository at this point in the history
  • Loading branch information
gabizou committed Jun 4, 2024
2 parents 73fd67d + e4bae21 commit 1fb6e5b
Show file tree
Hide file tree
Showing 32 changed files with 354 additions and 26 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/spongepowered/api/data/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.spongepowered.api.data.type.PistonType;
import org.spongepowered.api.data.type.PortionType;
import org.spongepowered.api.data.type.ProfessionType;
import org.spongepowered.api.data.type.PushReaction;
import org.spongepowered.api.data.type.RabbitType;
import org.spongepowered.api.data.type.RailDirection;
import org.spongepowered.api.data.type.SculkSensorState;
Expand Down Expand Up @@ -562,6 +563,12 @@ public final class Keys {
*/
public static final Key<Value<Ticks>> BREEDING_COOLDOWN = Keys.key(ResourceKey.sponge("breeding_cooldown"), Ticks.class);

/**
* Whether a {@link BlockState} can be lit on fire by things like spreading lava,
* or sometimes a {@link ServerLocation} to be directionally specific.
*/
public static final Key<Value<Boolean>> BURNABLE = Keys.key(ResourceKey.sponge("burnable"), Boolean.class);

/**
* The burntime of an {@link ItemStack} fuel in a furnace.
* See {@link #FUEL} for the time
Expand Down Expand Up @@ -2608,6 +2615,12 @@ public final class Keys {
*/
public static final Key<Value<Integer>> PROFESSION_LEVEL = Keys.key(ResourceKey.sponge("profession_level"), Integer.class);

/**
* The {@link Entity} or {@link BlockState} push reaction when a {@link Piston} pushes it.
* Readonly
*/
public static final Key<Value<PushReaction>> PUSH_REACTION = Keys.key(ResourceKey.sponge("push_reaction"), PushReaction.class);

/**
* Whether pvp combat is enabled in a world of a {@link WorldTemplate} or {@link ServerWorldProperties}
* Readonly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
* Represents a block surface.
*/
@CatalogedBy(AttachmentSurfaces.class)
public interface AttachmentSurface extends DefaultedRegistryValue, Comparable<AttachmentSurface> {
public interface AttachmentSurface extends DefaultedRegistryValue, Comparable<AttachmentSurface>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* Represents the type of leaves of a {@link BlockTypes#BAMBOO} block.
*/
@CatalogedBy(BambooLeavesTypes.class)
public interface BambooLeavesType extends DefaultedRegistryValue, Comparable<BambooLeavesType> {
public interface BambooLeavesType extends DefaultedRegistryValue, Comparable<BambooLeavesType>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* Represents the attachment-type of a {@link BlockTypes#BELL} block.
*/
@CatalogedBy(BellAttachmentTypes.class)
public interface BellAttachmentType extends DefaultedRegistryValue, Comparable<BellAttachmentType> {
public interface BellAttachmentType extends DefaultedRegistryValue, Comparable<BellAttachmentType>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
* chests into a double chests.
*/
@CatalogedBy(ChestAttachmentTypes.class)
public interface ChestAttachmentType extends DefaultedRegistryValue, Comparable<ChestAttachmentType> {
public interface ChestAttachmentType extends DefaultedRegistryValue, Comparable<ChestAttachmentType>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(ComparatorModes.class)
public interface ComparatorMode extends DefaultedRegistryValue, Comparable<ComparatorMode> {
public interface ComparatorMode extends DefaultedRegistryValue, Comparable<ComparatorMode>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* Represents a side of a hinge.
*/
@CatalogedBy(DoorHinges.class)
public interface DoorHinge extends DefaultedRegistryValue, Cycleable<DoorHinge>, Comparable<DoorHinge> {
public interface DoorHinge extends DefaultedRegistryValue, Cycleable<DoorHinge>, Comparable<DoorHinge>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(DripstoneSegments.class)
public interface DripstoneSegment extends DefaultedRegistryValue, Comparable<DripstoneSegment> {
public interface DripstoneSegment extends DefaultedRegistryValue, Comparable<DripstoneSegment>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Represents a type of instrument.
*/
@CatalogedBy(InstrumentTypes.class)
public interface InstrumentType extends DefaultedRegistryValue, Comparable<InstrumentType> {
public interface InstrumentType extends DefaultedRegistryValue, Comparable<InstrumentType>, StringRepresentable {

/**
* Gets the {@link SoundType} that is used by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Represents the front and top orientation of {@link BlockTypes#JIGSAW} blocks.
*/
@CatalogedBy(JigsawBlockOrientations.class)
public interface JigsawBlockOrientation extends DefaultedRegistryValue, Comparable<JigsawBlockOrientation> {
public interface JigsawBlockOrientation extends DefaultedRegistryValue, Comparable<JigsawBlockOrientation>, StringRepresentable {

/**
* The front facing direction of a jigsaw block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
* Represents a "type" of piston.
*/
@CatalogedBy(PistonTypes.class)
public interface PistonType extends DefaultedRegistryValue, Comparable<PistonType> {
public interface PistonType extends DefaultedRegistryValue, Comparable<PistonType>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(PortionTypes.class)
public interface PortionType extends DefaultedRegistryValue, Comparable<PortionType> {
public interface PortionType extends DefaultedRegistryValue, Comparable<PortionType>, StringRepresentable {

}
32 changes: 32 additions & 0 deletions src/main/java/org/spongepowered/api/data/type/PushReaction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.data.type;

import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(PushReactions.class)
public interface PushReaction {

}
52 changes: 52 additions & 0 deletions src/main/java/org/spongepowered/api/data/type/PushReactions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.data.type;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
import org.spongepowered.api.registry.RegistryTypes;

@RegistryScopes(scopes = RegistryScope.GAME)
public final class PushReactions {

public static final DefaultedRegistryReference<PushReaction> NORMAL = key(ResourceKey.minecraft("NORMAL"));
public static final DefaultedRegistryReference<PushReaction> DESTROY = key(ResourceKey.minecraft("DESTROY"));
public static final DefaultedRegistryReference<PushReaction> BLOCK = key(ResourceKey.minecraft("BLOCK"));
public static final DefaultedRegistryReference<PushReaction> IGNORE = key(ResourceKey.minecraft("IGNORE"));
public static final DefaultedRegistryReference<PushReaction> PUSH_ONLY = key(ResourceKey.minecraft("PUSH_ONLY"));

public static Registry<PushReaction> registry() {
return Sponge.game().registry(RegistryTypes.PUSH_REACTION);
}

private static DefaultedRegistryReference<PushReaction> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.PUSH_REACTION, location).asDefaultedReference(Sponge::game);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(RailDirections.class)
public interface RailDirection extends DefaultedRegistryValue, Cycleable<RailDirection>, Comparable<RailDirection> {
public interface RailDirection extends DefaultedRegistryValue, Cycleable<RailDirection>, Comparable<RailDirection>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(SculkSensorStates.class)
public interface SculkSensorState extends DefaultedRegistryValue, Comparable<SculkSensorState> {
public interface SculkSensorState extends DefaultedRegistryValue, Comparable<SculkSensorState>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
* example {@link BlockTypes#STONE_SLAB}.
*/
@CatalogedBy(SlabPortions.class)
public interface SlabPortion extends DefaultedRegistryValue, Comparable<SlabPortion> {
public interface SlabPortion extends DefaultedRegistryValue, Comparable<SlabPortion>, StringRepresentable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
* Represents a stair shape.
*/
@CatalogedBy(StairShapes.class)
public interface StairShape extends DefaultedRegistryValue, Comparable<StairShape> {
public interface StairShape extends DefaultedRegistryValue, Comparable<StairShape>, StringRepresentable {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.data.type;

/**
* Represents a type that has a stable string representation, usually an enumerated
* set of values, like most catalog types:
* {@link org.spongepowered.api.data.type.ArtType},
* {@link RabbitType}, {@link RailDirection}, etc.
*/
public interface StringRepresentable {

String serializationString();

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* Represents a mode that a {@link StructureBlock} may be in.
*/
@CatalogedBy(StructureModes.class)
public interface StructureMode extends DefaultedRegistryValue, Comparable<StructureMode> {
public interface StructureMode extends DefaultedRegistryValue, Comparable<StructureMode>, StringRepresentable {

}
2 changes: 1 addition & 1 deletion src/main/java/org/spongepowered/api/data/type/Tilt.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(Tilts.class)
public interface Tilt extends DefaultedRegistryValue, Comparable<Tilt> {
public interface Tilt extends DefaultedRegistryValue, Comparable<Tilt>, StringRepresentable {

/**
* {@return Whether a block entering this tilt state will trigger any
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.data.type;

import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(TrialSpawnerStates.class)
public interface TrialSpawnerState extends Comparable<TrialSpawnerState>, StringRepresentable {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.data.type;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryTypes;

public final class TrialSpawnerStates {

public static final DefaultedRegistryReference<TrialSpawnerState> INACTIVE = TrialSpawnerStates.key(ResourceKey.sponge("INACTIVE"));

public static final DefaultedRegistryReference<TrialSpawnerState> WAITING_FOR_PLAYERS = TrialSpawnerStates.key(ResourceKey.sponge("WAITING_FOR_PLAYERS"));

public static final DefaultedRegistryReference<TrialSpawnerState> ACTIVE = TrialSpawnerStates.key(ResourceKey.sponge("ACTIVE"));

public static final DefaultedRegistryReference<TrialSpawnerState> WAITING_FOR_REWARD_EJECTION = TrialSpawnerStates.key(ResourceKey.sponge("WAITING_FOR_REWARD_EJECTION"));

public static final DefaultedRegistryReference<TrialSpawnerState> EJECTING_REWARD = TrialSpawnerStates.key(ResourceKey.sponge("EJECTING_REWARD"));

public static final DefaultedRegistryReference<TrialSpawnerState> COOLDOWN = TrialSpawnerStates.key(ResourceKey.sponge("COOLDOWN"));


public static Registry<TrialSpawnerState> registry() {
return Sponge.game().registry(RegistryTypes.TRIAL_SPAWNER_STATE);
}

private static DefaultedRegistryReference<TrialSpawnerState> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.TRIAL_SPAWNER_STATE, location).asDefaultedReference(Sponge::game);
}
}
Loading

0 comments on commit 1fb6e5b

Please sign in to comment.