Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom blocks and skulls #3505

Merged
merged 190 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
0eb7218
Super cursed custom skulls custom block
davchoo Jun 19, 2022
c2a6e8c
Rename some stuff
davchoo Jul 6, 2022
f553dee
Attempt to clean up some code
davchoo Jul 7, 2022
49f7f6d
Remove skull translation events and define custom blocks for custom s…
davchoo Jul 7, 2022
9e0af6e
Auto generate skull resource pack
davchoo Jul 8, 2022
774b300
Add config options for custom blocks and custom skull blocks
davchoo Jul 9, 2022
d07a06c
Fix formatting and names for player skulls
davchoo Jul 9, 2022
08c24cb
Use block states more efficiently for custom skulls
davchoo Jul 10, 2022
86c8226
Clean up custom block api a bit
davchoo Jul 10, 2022
a577512
Apply some suggestions from Camotoy
davchoo Jul 10, 2022
49550a5
Move custom skull config stuff to its own file
davchoo Jul 11, 2022
8247e73
Merge branch 'feature/extensions' into feature/blockstuff-updated
davchoo Jul 25, 2022
e9e89b4
Update custom block nbt for v534
davchoo Jul 25, 2022
cb0b52b
Disable collision box & selection box when box is empty
davchoo Jul 25, 2022
88725f8
Merge branch 'feature/extensions' into feature/blockstuff-updated
davchoo Jul 26, 2022
f5d23a6
Add custom block stuff to provider registry loader
davchoo Jul 27, 2022
5676870
More API changes
davchoo Jul 27, 2022
8244afa
Convert skull floor geometries into a template
davchoo Jul 27, 2022
15fd535
Crop and reorder skull textures to eliminate unused space
davchoo Jul 28, 2022
9f4f2ac
Revert "Crop and reorder skull textures to eliminate unused space"
davchoo Jul 28, 2022
2ca3680
Use identifier from CustomBlockData in SkullResourcePackManager
davchoo Jul 28, 2022
36f540f
Fix isIncorrectHeldItem check for custom skull blocks
davchoo Jul 29, 2022
d00886e
Fix adding duplicate block states for custom blocks with 0 properties
davchoo Jul 29, 2022
42fdbeb
Add basis for overriding Bedrock block states
davchoo Jul 29, 2022
f2d4176
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Dec 21, 2022
3257f3c
Fix custom blocks in 1.19.50
Kas-tle Dec 21, 2022
b5eeaff
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Dec 21, 2022
a176fdf
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Dec 28, 2022
928b252
Decouple mappings from items
Kas-tle Dec 28, 2022
e3dcb6d
Decouple mappings from items
Kas-tle Dec 28, 2022
7988882
Null check
Kas-tle Dec 28, 2022
e696972
Move to CustomBlockRegistryPopulator
Kas-tle Dec 30, 2022
4b1ffa3
Remove name_hash from blocksTag/vanillaBlockStates
davchoo Dec 21, 2022
88ad6ce
Limit Bedrock versions to 1.19.40+
davchoo Dec 23, 2022
bc7564f
Un-revert Crop and reorder skull textures to eliminate unused space
davchoo Dec 23, 2022
f495c85
Add validation custom block components and s/lightFilter/lightDampening/
davchoo Dec 23, 2022
8f7d67b
Add display name component and add toggle for client block placing
davchoo Dec 23, 2022
2029ba8
Begin parsing block mappings (still much to do!)
Kas-tle Dec 30, 2022
d9cdacc
CustomBlockMapping stores block w/ all states
Kas-tle Dec 31, 2022
c71f2c5
Mappings almost :/
Kas-tle Jan 1, 2023
461bff6
Ok now they work at least
Kas-tle Jan 1, 2023
f4071f4
Read most mapping components
Kas-tle Jan 2, 2023
fb15b94
Block mappings mostly done
Kas-tle Jan 2, 2023
41947f3
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 2, 2023
6409d79
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 5, 2023
96967da
Translate block item
Kas-tle Jan 5, 2023
a51ff57
Add docs for custom blocks
Kas-tle Jan 5, 2023
010e99d
Add tags
Kas-tle Jan 6, 2023
9bc4244
Merge branch 'feature/blocky' of https://github.com/Kas-tle/Geyser in…
Kas-tle Jan 6, 2023
00837d9
More docs
Kas-tle Jan 6, 2023
a8e60b6
Accidentally added name comp.
Kas-tle Jan 6, 2023
880d8e5
Fix collide box and warn for >16 props
Kas-tle Jan 6, 2023
d019160
add registerBlockItemOverride event + refactor
Kas-tle Jan 6, 2023
df710cb
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 8, 2023
3d1d51d
Inventory overrides for multistate bedrock blocks
Kas-tle Jan 15, 2023
bfdebad
Implement all remaining block components
Kas-tle Jan 15, 2023
cc2e409
Minor cleanup and javadocs
Kas-tle Jan 16, 2023
2efdce4
Update custom skull config example
Kas-tle Jan 16, 2023
b2d9095
Address @Camotoy's review
Kas-tle Jan 18, 2023
77d9919
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 18, 2023
4ab26e0
Fix light_emission and light_dampening components
davchoo Jan 16, 2023
4d78503
Remove redundant populate method and remove BLOCKS_JSON after last use
davchoo Jan 16, 2023
0f0308b
Fix inventories with block state overrides not opening
davchoo Jan 16, 2023
1e75b88
Merge pull request #1 from davchoo/feature/blocky
Kas-tle Jan 19, 2023
9007ee4
API event for skull blocks & let register via URL
Kas-tle Jan 22, 2023
04565f9
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 22, 2023
a25ee6c
Use skin hash instead of URL
Kas-tle Jan 24, 2023
d71d9c1
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 24, 2023
57c90da
Address @davchoo's review
Kas-tle Jan 29, 2023
1efe734
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jan 29, 2023
d99cb46
Rework MappingsReader_v1 to avoid passing maps around
davchoo Jan 30, 2023
00a453f
Treat all properties as string properties
davchoo Jan 30, 2023
d1790cc
Merge pull request #2 from davchoo/feature/blocky
Kas-tle Jan 31, 2023
a91b531
Fix block registry scan in MappingsReader
davchoo Feb 1, 2023
cbe7256
Skin hashes can have less than 64 characters?
davchoo Feb 1, 2023
7bc0bde
Include entry when logging exceptions from block mappings
davchoo Feb 1, 2023
d14ca99
Merge pull request #3 from davchoo/feature/blocky
Kas-tle Feb 1, 2023
9e74e90
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Feb 4, 2023
c1412c5
Merge and exit API removal hellscape
Kas-tle Feb 12, 2023
5f2c8b0
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Feb 20, 2023
48c6f94
Submodule
Kas-tle Feb 20, 2023
29835a1
Fix block break speeds thanks to @Camotoy
Kas-tle Feb 21, 2023
7a8796a
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Feb 25, 2023
f59d728
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 6, 2023
e077407
Temporarily fix build on eclipse so I may work...
Kas-tle Mar 6, 2023
0d110ca
Custom tool breakspeed by server; Closes #3348
Kas-tle Mar 6, 2023
f1bd04a
Account for if custom skulls are added on 1st run
Kas-tle Mar 6, 2023
4002c1d
Initial framework for extended collision boxes
Kas-tle Mar 7, 2023
7c3cead
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 8, 2023
06db476
Add some notes for the extended collision box impl
Kas-tle Mar 8, 2023
45d5034
We have our extended collision registry
Kas-tle Mar 9, 2023
0bd1489
Notes for me
Kas-tle Mar 9, 2023
5f5159d
Extended collision boxes almost work
Kas-tle Mar 11, 2023
550a472
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 11, 2023
7f85e90
Extended collision boxes actually work
Kas-tle Mar 13, 2023
b36ccbe
Consider all hitboxes in calculation
Kas-tle Mar 14, 2023
553ea3e
X is mirrored...
Kas-tle Mar 14, 2023
9be2ec9
Merge upstream (1.19.4/1.19.70)
Kas-tle Mar 15, 2023
eb5e281
Extended collision boxes are much improved
Kas-tle Mar 19, 2023
ac9ea6f
Merge 'upstream/master' into feature/blocky
Kas-tle Mar 19, 2023
7327e27
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 24, 2023
7770a8b
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 26, 2023
024feed
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Mar 31, 2023
c748523
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Apr 6, 2023
d7a3430
Merge branch 'feature/protocol-3.0' of https://github.com/GeyserMC/Ge…
Unoqwy Apr 27, 2023
40a7466
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Unoqwy Apr 27, 2023
67ae0e8
Merge pull request #5 from blockgamecode/feature/blocky-protocol-3.0
Kas-tle Apr 27, 2023
bb6e2e4
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 12, 2023
d6ed896
Upstream fallout
Kas-tle May 12, 2023
410712c
Address @Redned235's review
Kas-tle May 12, 2023
8b8cc5b
Oops my bad that makes no sense :)
Kas-tle May 12, 2023
bbd297c
Ext collision box chunk translation optimization
Kas-tle May 13, 2023
cd62048
Trunc skinhash to 32 chars due to 80 char limit
Kas-tle May 13, 2023
5ab360b
Use new transformation cmpnt vs legacy rotation
Kas-tle May 13, 2023
0e534f5
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 13, 2023
31bb382
keep arr null on get extcolstor
Kas-tle May 13, 2023
fe49003
Properly handle if extended collision box is below
Kas-tle May 13, 2023
a886fd2
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 13, 2023
c27bfaf
Less ugly (realized it can go here)
Kas-tle May 13, 2023
4e88a7f
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 13, 2023
41d7d8e
Prevent 2x placement due to extended collision box
Kas-tle May 14, 2023
e266ee9
Properly build on eclipse via indra
Kas-tle May 14, 2023
e4b1257
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 14, 2023
764a652
Ensure enough bits in bedrockData for paletteIDs
Kas-tle May 14, 2023
45c1a9d
Fix not needed whitespace
Kas-tle May 15, 2023
f750059
Update license headers to 2023
Kas-tle May 15, 2023
899b1e2
Use release indra over snapshot
Kas-tle May 17, 2023
70193e9
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 17, 2023
211f55a
Revert "Update license headers to 2023"
Kas-tle May 18, 2023
58d9a9f
Account for collisions in chunk section y0 layer
Kas-tle May 19, 2023
4d12d0f
Fix extended collision @ air section bottom
Kas-tle May 20, 2023
f19e16f
Address @davchoo's review
Kas-tle May 20, 2023
a7f0177
Address @rtm516's review
Kas-tle May 20, 2023
1c0ac39
More @rtm516's review
Kas-tle May 20, 2023
350efec
Address @Camotoy's review
Kas-tle May 20, 2023
2a11186
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 20, 2023
7e08b6f
Update javadocs
Kas-tle May 20, 2023
86cb4fe
Address @davchoo's review
Kas-tle May 21, 2023
294da78
Lock extended collision to section
Kas-tle May 21, 2023
41015ed
Clear ext col even when air
Kas-tle May 21, 2023
023bd50
Let override vanilla items in creative inventory
Kas-tle May 23, 2023
cced65a
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 25, 2023
7c5fa3c
Avoid creating 12 HashSets for every overrided block state
davchoo May 24, 2023
b95b49a
Super minor nitpicks + Custom Skull NBT fix
davchoo May 24, 2023
c602edd
Check custom skull is within Bedrock bounds
davchoo May 27, 2023
7f5a038
Add static builder methods to match CustomItemData API
davchoo May 27, 2023
6509819
Merge pull request #6 from davchoo/feature/blocky-ec2
Kas-tle May 27, 2023
b7dc172
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle May 27, 2023
878208f
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jun 5, 2023
41ebcfa
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jun 5, 2023
64a356e
1.20; figure out the mess later
Kas-tle Jun 7, 2023
a04a8f2
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jun 8, 2023
e8cd6c7
Upstream
Kas-tle Jun 8, 2023
33b89eb
Initial API setup for modded blocks (no impl yet)
Kas-tle Jun 8, 2023
6d2cceb
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jun 10, 2023
9ce1df1
More work on nonvanilla blocks (nonfunctional)
Kas-tle Jun 10, 2023
a39ab13
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jun 11, 2023
a1bb484
Fix compile
Kas-tle Jun 11, 2023
9e34c16
Update submodules
Kas-tle Jun 11, 2023
6b4b0e1
Modded reg so far (not done)
Kas-tle Jun 11, 2023
32dda8f
Add non-vanilla registration and fix a few bugs
Redned235 Jun 25, 2023
bc92b4f
Fixes for non-vanilla blocks
Redned235 Jun 25, 2023
e111808
Remove import
Redned235 Jun 25, 2023
0e505fd
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jul 3, 2023
25b5906
CustomRegPop. go1st for now; must split for modded
Kas-tle Jul 3, 2023
58ab104
Merge 1.20.10
Kas-tle Jul 15, 2023
1d86961
Address silent change to geo component for blocks
Kas-tle Jul 15, 2023
32da8a1
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jul 22, 2023
5f089fc
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jul 29, 2023
50b8262
Seperate bedrock, vanilla, & nonvanilla block reg
Kas-tle Jul 30, 2023
6ba0bf1
Single event
Kas-tle Jul 30, 2023
df1aa27
Impl MaterialInstance as builder per @Redned235
Kas-tle Jul 30, 2023
ce51916
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Jul 30, 2023
4ff4c05
Added creative category enum & added some missing overrides (#7)
ImDaBigBoss Aug 4, 2023
dc42d97
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Aug 4, 2023
5db3101
Add material instance to provider registry
Kas-tle Aug 5, 2023
265a657
oops
Kas-tle Aug 5, 2023
e40cab2
Fix case of correctBedrockIdentifier not found
Kas-tle Aug 5, 2023
5d530ab
Fix docs
Kas-tle Aug 5, 2023
0362d27
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Aug 9, 2023
ac249b0
Address @Camotoy's review
Kas-tle Aug 9, 2023
ba7708f
Address review from @davchoo
Kas-tle Aug 10, 2023
7051977
Set namespace of custom blocks vs ident direct
Kas-tle Aug 12, 2023
aca66be
Address review from @rtm516
Kas-tle Aug 15, 2023
bd74e36
One more
Kas-tle Aug 15, 2023
7dd77d2
Remove rogue space
rtm516 Aug 19, 2023
6488fef
Merge remote-tracking branch 'upstream/master' into feature/blocky
Kas-tle Aug 20, 2023
0c90a82
Geo component as builder
Kas-tle Aug 20, 2023
ea42fdc
use super name
Kas-tle Aug 21, 2023
1be0be7
Bump version
Kas-tle Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Kas-tle marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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();
}
}
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) {
Kas-tle marked this conversation as resolved.
Show resolved Hide resolved
}
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();
Kas-tle marked this conversation as resolved.
Show resolved Hide resolved

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();
}
}
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 {
Kas-tle marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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();
}
}
Loading