-
-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into gamemode-switch
- Loading branch information
Showing
88 changed files
with
6,241 additions
and
334 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
api/src/main/java/org/geysermc/geyser/api/block/custom/CustomBlockData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org | ||
* | ||
* 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. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.block.custom; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.geysermc.geyser.api.GeyserApi; | ||
import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; | ||
import org.geysermc.geyser.api.block.custom.property.CustomBlockProperty; | ||
import org.geysermc.geyser.api.util.CreativeCategory; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class is used to store data for a custom block. | ||
*/ | ||
public interface CustomBlockData { | ||
/** | ||
* Gets the name of the custom block | ||
* | ||
* @return The name of the custom block. | ||
*/ | ||
@NonNull String name(); | ||
|
||
/** | ||
* Gets the identifier of the custom block | ||
* | ||
* @return The identifier of the custom block. | ||
*/ | ||
@NonNull String identifier(); | ||
|
||
/** | ||
* Gets if the custom block is included in the creative inventory | ||
* | ||
* @return If the custom block is included in the creative inventory. | ||
*/ | ||
boolean includedInCreativeInventory(); | ||
|
||
/** | ||
* Gets the item's creative category, or tab id. | ||
* | ||
* @return the item's creative category | ||
*/ | ||
@Nullable CreativeCategory creativeCategory(); | ||
|
||
/** | ||
* Gets the item's creative group. | ||
* | ||
* @return the item's creative group | ||
*/ | ||
@Nullable String creativeGroup(); | ||
|
||
/** | ||
* Gets the components of the custom block | ||
* | ||
* @return The components of the custom block. | ||
*/ | ||
@Nullable CustomBlockComponents components(); | ||
|
||
/** | ||
* Gets the custom block's map of block property names to CustomBlockProperty | ||
* objects | ||
* | ||
* @return The custom block's map of block property names to CustomBlockProperty objects. | ||
*/ | ||
@NonNull Map<String, CustomBlockProperty<?>> properties(); | ||
|
||
/** | ||
* Gets the list of the custom block's permutations | ||
* | ||
* @return The permutations of the custom block. | ||
*/ | ||
@NonNull List<CustomBlockPermutation> permutations(); | ||
|
||
/** | ||
* Gets the custom block's default block state | ||
* | ||
* @return The default block state of the custom block. | ||
*/ | ||
@NonNull CustomBlockState defaultBlockState(); | ||
|
||
/** | ||
* Gets a builder for a custom block state | ||
* | ||
* @return The builder for a custom block state. | ||
*/ | ||
CustomBlockState.@NonNull Builder blockStateBuilder(); | ||
|
||
/** | ||
* Create a Builder for CustomBlockData | ||
* | ||
* @return A CustomBlockData Builder | ||
*/ | ||
static CustomBlockData.Builder builder() { | ||
return GeyserApi.api().provider(CustomBlockData.Builder.class); | ||
} | ||
|
||
interface Builder { | ||
Builder name(@NonNull String name); | ||
|
||
Builder includedInCreativeInventory(boolean includedInCreativeInventory); | ||
|
||
Builder creativeCategory(@Nullable CreativeCategory creativeCategory); | ||
|
||
Builder creativeGroup(@Nullable String creativeGroup); | ||
|
||
Builder components(@NonNull CustomBlockComponents components); | ||
|
||
Builder booleanProperty(@NonNull String propertyName); | ||
|
||
Builder intProperty(@NonNull String propertyName, List<Integer> values); | ||
|
||
Builder stringProperty(@NonNull String propertyName, List<String> values); | ||
|
||
Builder permutations(@NonNull List<CustomBlockPermutation> permutations); | ||
|
||
CustomBlockData build(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
api/src/main/java/org/geysermc/geyser/api/block/custom/CustomBlockPermutation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org | ||
* | ||
* 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. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.block.custom; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; | ||
|
||
/** | ||
* This class is used to store a custom block permutations, which contain custom | ||
* block components mapped to a Molang query that should return true or false | ||
* | ||
* @param components The components of the block | ||
* @param condition The Molang query that should return true or false | ||
*/ | ||
public record CustomBlockPermutation(@NonNull CustomBlockComponents components, @NonNull String condition) { | ||
} |
75 changes: 75 additions & 0 deletions
75
api/src/main/java/org/geysermc/geyser/api/block/custom/CustomBlockState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org | ||
* | ||
* 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. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.block.custom; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* This class is used to store a custom block state, which contains CustomBlockData | ||
* tied to defined properties and values | ||
*/ | ||
public interface CustomBlockState { | ||
/** | ||
* Gets the custom block data associated with the state | ||
* | ||
* @return The custom block data for the state. | ||
*/ | ||
@NonNull CustomBlockData block(); | ||
|
||
/** | ||
* Gets the name of the state | ||
* | ||
* @return The name of the state. | ||
*/ | ||
@NonNull String name(); | ||
|
||
/** | ||
* Gets the given property for the state | ||
* | ||
* @param propertyName the property name | ||
* @return the boolean, int, or string property. | ||
*/ | ||
@NonNull <T> T property(@NonNull String propertyName); | ||
|
||
/** | ||
* Gets a map of the properties for the state | ||
* | ||
* @return The properties for the state. | ||
*/ | ||
@NonNull Map<String, Object> properties(); | ||
|
||
interface Builder { | ||
Builder booleanProperty(@NonNull String propertyName, boolean value); | ||
|
||
Builder intProperty(@NonNull String propertyName, int value); | ||
|
||
Builder stringProperty(@NonNull String propertyName, @NonNull String value); | ||
|
||
CustomBlockState build(); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
api/src/main/java/org/geysermc/geyser/api/block/custom/NonVanillaCustomBlockData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org | ||
* | ||
* 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. | ||
* | ||
* @author GeyserMC | ||
* @link https://github.com/GeyserMC/Geyser | ||
*/ | ||
|
||
package org.geysermc.geyser.api.block.custom; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.geysermc.geyser.api.GeyserApi; | ||
import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; | ||
import org.geysermc.geyser.api.util.CreativeCategory; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represents a completely custom block that is not based on an existing vanilla Minecraft block. | ||
*/ | ||
public interface NonVanillaCustomBlockData extends CustomBlockData { | ||
/** | ||
* Gets the namespace of the custom block | ||
* | ||
* @return The namespace of the custom block. | ||
*/ | ||
@NonNull String namespace(); | ||
|
||
|
||
/** | ||
* Create a Builder for NonVanillaCustomBlockData | ||
* | ||
* @return A NonVanillaCustomBlockData Builder | ||
*/ | ||
static NonVanillaCustomBlockData.Builder builder() { | ||
return GeyserApi.api().provider(NonVanillaCustomBlockData.Builder.class); | ||
} | ||
|
||
interface Builder extends CustomBlockData.Builder { | ||
|
||
Builder namespace(@NonNull String namespace); | ||
|
||
@Override | ||
Builder name(@NonNull String name); | ||
|
||
@Override | ||
Builder includedInCreativeInventory(boolean includedInCreativeInventory); | ||
|
||
@Override | ||
Builder creativeCategory(@Nullable CreativeCategory creativeCategory); | ||
|
||
@Override | ||
Builder creativeGroup(@Nullable String creativeGroup); | ||
|
||
@Override | ||
Builder components(@NonNull CustomBlockComponents components); | ||
|
||
@Override | ||
Builder booleanProperty(@NonNull String propertyName); | ||
|
||
@Override | ||
Builder intProperty(@NonNull String propertyName, List<Integer> values); | ||
|
||
@Override | ||
Builder stringProperty(@NonNull String propertyName, List<String> values); | ||
|
||
@Override | ||
Builder permutations(@NonNull List<CustomBlockPermutation> permutations); | ||
|
||
@Override | ||
NonVanillaCustomBlockData build(); | ||
} | ||
} |
Oops, something went wrong.