mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add support for custom blocks and skulls (#3505)
* Super cursed custom skulls custom block * Rename some stuff * Attempt to clean up some code * Remove skull translation events and define custom blocks for custom skulls Clean up skull block translation a bit * Auto generate skull resource pack Change `davchoo` to `geyser` in geometry * Add config options for custom blocks and custom skull blocks * Fix formatting and names for player skulls * Use block states more efficiently for custom skulls 21 block states vs 48 block states * Clean up custom block api a bit * Apply some suggestions from Camotoy * Move custom skull config stuff to its own file Custom skulls can now be added by username, uuid, and textures Move skull nbt stuff from requestTexturesFromUsername to SkullBlockEntityTranslator Add requestTexturesFromUUID * Update custom block nbt for v534 * Disable collision box & selection box when box is empty Fix incorrect collision names used in CustomBlockComponentsBuilder * Add custom block stuff to provider registry loader * More API changes Convert CustomBlockPermutation into a record Change materialInstances in CustomBlockComponents Builder to materialInstance Reuse box components in CustomSkull * Convert skull floor geometries into a template Should be easier to modify in needed in the future. * Crop and reorder skull textures to eliminate unused space Should reduce memory & storage usage for Bedrock clients * Revert "Crop and reorder skull textures to eliminate unused space" This reverts commit15fd5353e1
. * Use identifier from CustomBlockData in SkullResourcePackManager * Fix isIncorrectHeldItem check for custom skull blocks Add defaultBlockState to CustomBlockData * Fix adding duplicate block states for custom blocks with 0 properties Remove defaultBlockState CustomBlockState field from GeyserCustomBlockData since it creates a circular reference * Add basis for overriding Bedrock block states Fix missing providers when used in GeyserDefineCustomBlocksEvent * Fix custom blocks in 1.19.50 * Decouple mappings from items * Decouple mappings from items * Null check * Move to CustomBlockRegistryPopulator * Remove name_hash from blocksTag/vanillaBlockStates Fixes creative inventory contents with custom blocks registered * Limit Bedrock versions to 1.19.40+ Custom blocks were released in 1.19.40 * Un-revert Crop and reorder skull textures to eliminate unused space Should reduce memory & storage usage for Bedrock clients Bug with top face flipping + per-face uv's was fixed in 1.19.40+ https://bugs.mojang.com/browse/MCPE-160073 Geometry is still offset by 0.5 to prevent lighting bugs * Add validation custom block components and s/lightFilter/lightDampening/ Also validate custom block names * Add display name component and add toggle for client block placing The display name component allows blocks to use other locale keys. placeAir will prevent the client from placing the default block state. * Begin parsing block mappings (still much to do!) * CustomBlockMapping stores block w/ all states * Mappings almost :/ * Ok now they work at least * Read most mapping components * Block mappings mostly done * Translate block item * Add docs for custom blocks * Add tags * More docs * Accidentally added name comp. * Fix collide box and warn for >16 props * add registerBlockItemOverride event + refactor * Inventory overrides for multistate bedrock blocks * Implement all remaining block components * Minor cleanup and javadocs * Update custom skull config example * Address @Camotoy's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix light_emission and light_dampening components * Remove redundant populate method and remove BLOCKS_JSON after last use * Fix inventories with block state overrides not opening * API event for skull blocks & let register via URL Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Use skin hash instead of URL Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @davchoo's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Rework MappingsReader_v1 to avoid passing maps around * Treat all properties as string properties There isn't a real need to check for boolean and int properties * Fix block registry scan in MappingsReader * Skin hashes can have less than 64 characters? * Include entry when logging exceptions from block mappings * Submodule Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix block break speeds thanks to @Camotoy Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Temporarily fix build on eclipse so I may work... Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Custom tool breakspeed by server; Closes #3348 Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Account for if custom skulls are added on 1st run Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Initial framework for extended collision boxes Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Add some notes for the extended collision box impl Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * We have our extended collision registry Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Notes for me Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Extended collision boxes almost work Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Extended collision boxes actually work Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Consider all hitboxes in calculation Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * X is mirrored... Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Extended collision boxes are much improved Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Upstream fallout Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @Redned235's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Oops my bad that makes no sense :) Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Ext collision box chunk translation optimization Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Trunc skinhash to 32 chars due to 80 char limit Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Use new transformation cmpnt vs legacy rotation Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * keep arr null on get extcolstor Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Properly handle if extended collision box is below Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Less ugly (realized it can go here) Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Prevent 2x placement due to extended collision box Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Properly build on eclipse via indra Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Ensure enough bits in bedrockData for paletteIDs Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix not needed whitespace Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Update license headers to 2023 Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Use release indra over snapshot Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Revert "Update license headers to 2023" This reverts commitf750059e8e
. * Account for collisions in chunk section y0 layer Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix extended collision @ air section bottom Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @davchoo's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @rtm516's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * More @rtm516's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @Camotoy's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Update javadocs Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @davchoo's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Lock extended collision to section Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Clear ext col even when air Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Let override vanilla items in creative inventory Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Avoid creating 12 HashSets for every overrided block state * Super minor nitpicks + Custom Skull NBT fix * Check custom skull is within Bedrock bounds Fixes NPE with custom skulls above y=320 or below y=-64 * Add static builder methods to match CustomItemData API * Upstream Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Initial API setup for modded blocks (no impl yet) Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * More work on nonvanilla blocks (nonfunctional) Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix compile Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Update submodules Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Modded reg so far (not done) Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Add non-vanilla registration and fix a few bugs * Fixes for non-vanilla blocks * Remove import * CustomRegPop. go1st for now; must split for modded Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address silent change to geo component for blocks Co-Authored-By: Unoqwy <pm@unoqwy.dev> Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Seperate bedrock, vanilla, & nonvanilla block reg Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Single event Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Impl MaterialInstance as builder per @Redned235 Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Added creative category enum & added some missing overrides (#7) * Add material instance to provider registry Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * oops Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix case of correctBedrockIdentifier not found Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Fix docs Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address @Camotoy's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address review from @davchoo Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Set namespace of custom blocks vs ident direct Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Address review from @rtm516 Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * One more Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Remove rogue space * Geo component as builder Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * use super name Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> * Bump version Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --------- Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: davchoo <davchoo@users.noreply.github.com> Co-authored-by: davchoo <4722249+davchoo@users.noreply.github.com> Co-authored-by: Unoqwy <pm@unoqwy.dev> Co-authored-by: RednedEpic <redned235@gmail.com> Co-authored-by: ImDaBigBoss <67973871+ImDaBigBoss@users.noreply.github.com> Co-authored-by: rtm516 <rtm516@users.noreply.github.com>
This commit is contained in:
parent
661a9b4741
commit
9ddfdf9374
88 changed files with 6235 additions and 328 deletions
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
/**
|
||||
* This class is used to store a box component for the selection and
|
||||
* collision boxes of a custom block.
|
||||
*
|
||||
* @param originX The origin X of the box
|
||||
* @param originY The origin Y of the box
|
||||
* @param originZ The origin Z of the box
|
||||
* @param sizeX The size X of the box
|
||||
* @param sizeY The size Y of the box
|
||||
* @param sizeZ The size Z of the box
|
||||
*/
|
||||
public record BoxComponent(float originX, float originY, float originZ, float sizeX, float sizeY, float sizeZ) {
|
||||
private static final BoxComponent FULL_BOX = new BoxComponent(-8, 0, -8, 16, 16, 16);
|
||||
private static final BoxComponent EMPTY_BOX = new BoxComponent(0, 0, 0, 0, 0, 0);
|
||||
|
||||
/**
|
||||
* Gets a full box component
|
||||
*
|
||||
* @return A full box component
|
||||
*/
|
||||
public static BoxComponent fullBox() {
|
||||
return FULL_BOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an empty box component
|
||||
*
|
||||
* @return An empty box component
|
||||
*/
|
||||
public static BoxComponent emptyBox() {
|
||||
return EMPTY_BOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the box component is empty
|
||||
*
|
||||
* @return If the box component is empty.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return sizeX == 0 && sizeY == 0 && sizeZ == 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class is used to store components for a custom block or custom block permutation.
|
||||
*/
|
||||
public interface CustomBlockComponents {
|
||||
|
||||
/**
|
||||
* Gets the selection box component
|
||||
* Equivalent to "minecraft:selection_box"
|
||||
*
|
||||
* @return The selection box.
|
||||
*/
|
||||
@Nullable BoxComponent selectionBox();
|
||||
|
||||
/**
|
||||
* Gets the collision box component
|
||||
* Equivalent to "minecraft:collision_box"
|
||||
* @return The collision box.
|
||||
*/
|
||||
@Nullable BoxComponent collisionBox();
|
||||
|
||||
/**
|
||||
* Gets the display name component
|
||||
* Equivalent to "minecraft:display_name"
|
||||
*
|
||||
* @return The display name.
|
||||
*/
|
||||
@Nullable String displayName();
|
||||
|
||||
/**
|
||||
* Gets the geometry component
|
||||
* Equivalent to "minecraft:geometry"
|
||||
*
|
||||
* @return The geometry.
|
||||
*/
|
||||
@Nullable GeometryComponent geometry();
|
||||
|
||||
/**
|
||||
* Gets the material instances component
|
||||
* Equivalent to "minecraft:material_instances"
|
||||
*
|
||||
* @return The material instances.
|
||||
*/
|
||||
@NonNull Map<String, MaterialInstance> materialInstances();
|
||||
|
||||
/**
|
||||
* Gets the placement filter component
|
||||
* Equivalent to "minecraft:placement_filter"
|
||||
*
|
||||
* @return The placement filter.
|
||||
*/
|
||||
@Nullable List<PlacementConditions> placementFilter();
|
||||
|
||||
/**
|
||||
* Gets the destructible by mining component
|
||||
* Equivalent to "minecraft:destructible_by_mining"
|
||||
*
|
||||
* @return The destructible by mining value.
|
||||
*/
|
||||
@Nullable Float destructibleByMining();
|
||||
|
||||
/**
|
||||
* Gets the friction component
|
||||
* Equivalent to "minecraft:friction"
|
||||
*
|
||||
* @return The friction value.
|
||||
*/
|
||||
@Nullable Float friction();
|
||||
|
||||
/**
|
||||
* Gets the light emission component
|
||||
* Equivalent to "minecraft:light_emission"
|
||||
*
|
||||
* @return The light emission value.
|
||||
*/
|
||||
@Nullable Integer lightEmission();
|
||||
|
||||
/**
|
||||
* Gets the light dampening component
|
||||
* Equivalent to "minecraft:light_dampening"
|
||||
*
|
||||
* @return The light dampening value.
|
||||
*/
|
||||
@Nullable Integer lightDampening();
|
||||
|
||||
/**
|
||||
* Gets the transformation component
|
||||
* Equivalent to "minecraft:transformation"
|
||||
*
|
||||
* @return The transformation.
|
||||
*/
|
||||
@Nullable TransformationComponent transformation();
|
||||
|
||||
/**
|
||||
* Gets the unit cube component
|
||||
* Equivalent to "minecraft:unit_cube"
|
||||
*
|
||||
* @return The rotation.
|
||||
*/
|
||||
boolean unitCube();
|
||||
|
||||
/**
|
||||
* Gets if the block should place only air
|
||||
* Equivalent to setting a dummy event to run on "minecraft:on_player_placing"
|
||||
*
|
||||
* @return If the block should place only air.
|
||||
*/
|
||||
boolean placeAir();
|
||||
|
||||
/**
|
||||
* Gets the set of tags
|
||||
* Equivalent to "tag:some_tag"
|
||||
*
|
||||
* @return The set of tags.
|
||||
*/
|
||||
@NonNull Set<String> tags();
|
||||
|
||||
/**
|
||||
* Create a Builder for CustomBlockComponents
|
||||
*
|
||||
* @return A CustomBlockComponents Builder
|
||||
*/
|
||||
static CustomBlockComponents.Builder builder() {
|
||||
return GeyserApi.api().provider(CustomBlockComponents.Builder.class);
|
||||
}
|
||||
|
||||
interface Builder {
|
||||
Builder selectionBox(BoxComponent selectionBox);
|
||||
|
||||
Builder collisionBox(BoxComponent collisionBox);
|
||||
|
||||
Builder displayName(String displayName);
|
||||
|
||||
Builder geometry(GeometryComponent geometry);
|
||||
|
||||
Builder materialInstance(@NonNull String name, @NonNull MaterialInstance materialInstance);
|
||||
|
||||
Builder placementFilter(List<PlacementConditions> placementConditions);
|
||||
|
||||
Builder destructibleByMining(Float destructibleByMining);
|
||||
|
||||
Builder friction(Float friction);
|
||||
|
||||
Builder lightEmission(Integer lightEmission);
|
||||
|
||||
Builder lightDampening(Integer lightDampening);
|
||||
|
||||
Builder transformation(TransformationComponent transformation);
|
||||
|
||||
Builder unitCube(boolean unitCube);
|
||||
|
||||
Builder placeAir(boolean placeAir);
|
||||
|
||||
Builder tags(Set<String> tags);
|
||||
|
||||
CustomBlockComponents build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class is used to store data for a geometry component.
|
||||
*/
|
||||
public interface GeometryComponent {
|
||||
|
||||
/**
|
||||
* Gets the identifier of the geometry
|
||||
*
|
||||
* @return The identifier of the geometry.
|
||||
*/
|
||||
@NonNull String identifier();
|
||||
|
||||
/**
|
||||
* Gets the bone visibility of the geometry
|
||||
*
|
||||
* @return The bone visibility of the geometry.
|
||||
*/
|
||||
@Nullable Map<String, String> boneVisibility();
|
||||
|
||||
/**
|
||||
* Creates a builder for GeometryComponent
|
||||
*
|
||||
* @return a builder for GeometryComponent.
|
||||
*/
|
||||
static GeometryComponent.Builder builder() {
|
||||
return GeyserApi.api().provider(GeometryComponent.Builder.class);
|
||||
}
|
||||
|
||||
interface Builder {
|
||||
Builder identifier(@NonNull String identifier);
|
||||
|
||||
Builder boneVisibility(@Nullable Map<String, String> boneVisibility);
|
||||
|
||||
GeometryComponent build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
|
||||
/**
|
||||
* This class is used to store data for a material instance.
|
||||
*/
|
||||
public interface MaterialInstance {
|
||||
/**
|
||||
* Gets the texture of the block
|
||||
*
|
||||
* @return The texture of the block.
|
||||
*/
|
||||
@NonNull String texture();
|
||||
|
||||
/**
|
||||
* Gets the render method of the block
|
||||
*
|
||||
* @return The render method of the block.
|
||||
*/
|
||||
@Nullable String renderMethod();
|
||||
|
||||
/**
|
||||
* Gets if the block should be dimmed on certain faces
|
||||
*
|
||||
* @return If the block should be dimmed on certain faces.
|
||||
*/
|
||||
@Nullable boolean faceDimming();
|
||||
|
||||
/**
|
||||
* Gets if the block should have ambient occlusion
|
||||
*
|
||||
* @return If the block should have ambient occlusion.
|
||||
*/
|
||||
@Nullable boolean ambientOcclusion();
|
||||
|
||||
/**
|
||||
* Creates a builder for MaterialInstance.
|
||||
*
|
||||
* @return a builder for MaterialInstance
|
||||
*/
|
||||
static MaterialInstance.Builder builder() {
|
||||
return GeyserApi.api().provider(MaterialInstance.Builder.class);
|
||||
}
|
||||
|
||||
interface Builder {
|
||||
Builder texture(@NonNull String texture);
|
||||
|
||||
Builder renderMethod(@Nullable String renderMethod);
|
||||
|
||||
Builder faceDimming(@Nullable boolean faceDimming);
|
||||
|
||||
Builder ambientOcclusion(@Nullable boolean ambientOcclusion);
|
||||
|
||||
MaterialInstance build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* This class is used to store conditions for a placement filter for a custom block.
|
||||
*
|
||||
* @param allowedFaces The faces that the block can be placed on
|
||||
* @param blockFilters The block filters that control what blocks the block can be placed on
|
||||
*/
|
||||
public record PlacementConditions(@NonNull Set<Face> allowedFaces, @NonNull LinkedHashMap<String, BlockFilterType> blockFilters) {
|
||||
public enum Face {
|
||||
DOWN,
|
||||
UP,
|
||||
NORTH,
|
||||
SOUTH,
|
||||
WEST,
|
||||
EAST;
|
||||
}
|
||||
|
||||
public enum BlockFilterType {
|
||||
BLOCK,
|
||||
TAG
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.component;
|
||||
|
||||
/**
|
||||
* This class is used to store the transformation component of a block
|
||||
*
|
||||
* @param rx The rotation on the x axis
|
||||
* @param ry The rotation on the y axis
|
||||
* @param rz The rotation on the z axis
|
||||
* @param sx The scale on the x axis
|
||||
* @param sy The scale on the y axis
|
||||
* @param sz The scale on the z axis
|
||||
* @param tx The translation on the x axis
|
||||
* @param ty The translation on the y axis
|
||||
* @param tz The translation on the z axis
|
||||
*/
|
||||
public record TransformationComponent(int rx, int ry, int rz, float sx, float sy, float sz, float tx, float ty, float tz) {
|
||||
|
||||
/**
|
||||
* Constructs a new TransformationComponent with the rotation values and assumes default scale and translation
|
||||
*
|
||||
* @param rx The rotation on the x axis
|
||||
* @param ry The rotation on the y axis
|
||||
* @param rz The rotation on the z axis
|
||||
*/
|
||||
public TransformationComponent(int rx, int ry, int rz) {
|
||||
this(rx, ry, rz, 1, 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new TransformationComponent with the rotation and scale values and assumes default translation
|
||||
*
|
||||
* @param rx The rotation on the x axis
|
||||
* @param ry The rotation on the y axis
|
||||
* @param rz The rotation on the z axis
|
||||
* @param sx The scale on the x axis
|
||||
* @param sy The scale on the y axis
|
||||
* @param sz The scale on the z axis
|
||||
*/
|
||||
public TransformationComponent(int rx, int ry, int rz, float sx, float sy, float sz) {
|
||||
this(rx, ry, rz, sx, sy, sz, 0, 0, 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.geysermc.geyser.api.block.custom.nonvanilla;
|
||||
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public record JavaBlockItem(@NonNull String identifier, @NonNegative int javaId, @NonNegative int stackSize) {
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package org.geysermc.geyser.api.block.custom.nonvanilla;
|
||||
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
|
||||
public interface JavaBlockState {
|
||||
/**
|
||||
* Gets the identifier of the block state
|
||||
*
|
||||
* @return the identifier of the block state
|
||||
*/
|
||||
@NonNull String identifier();
|
||||
|
||||
/**
|
||||
* Gets the Java ID of the block state
|
||||
*
|
||||
* @return the Java ID of the block state
|
||||
*/
|
||||
@NonNegative int javaId();
|
||||
|
||||
/**
|
||||
* Gets the state group ID of the block state
|
||||
*
|
||||
* @return the state group ID of the block state
|
||||
*/
|
||||
@NonNegative int stateGroupId();
|
||||
|
||||
/**
|
||||
* Gets the block hardness of the block state
|
||||
*
|
||||
* @return the block hardness of the block state
|
||||
*/
|
||||
@NonNegative float blockHardness();
|
||||
|
||||
/**
|
||||
* Gets whether the block state is waterlogged
|
||||
*
|
||||
* @return whether the block state is waterlogged
|
||||
*/
|
||||
@NonNull boolean waterlogged();
|
||||
|
||||
/**
|
||||
* Gets the collision of the block state
|
||||
*
|
||||
* @return the collision of the block state
|
||||
*/
|
||||
@NonNull JavaBoundingBox[] collision();
|
||||
|
||||
/**
|
||||
* Gets whether the block state can be broken with hand
|
||||
*
|
||||
* @return whether the block state can be broken with hand
|
||||
*/
|
||||
@NonNull boolean canBreakWithHand();
|
||||
|
||||
/**
|
||||
* Gets the pick item of the block state
|
||||
*
|
||||
* @return the pick item of the block state
|
||||
*/
|
||||
@Nullable String pickItem();
|
||||
|
||||
/**
|
||||
* Gets the piston behavior of the block state
|
||||
*
|
||||
* @return the piston behavior of the block state
|
||||
*/
|
||||
@Nullable String pistonBehavior();
|
||||
|
||||
/**
|
||||
* Gets whether the block state has block entity
|
||||
*
|
||||
* @return whether the block state has block entity
|
||||
*/
|
||||
@Nullable boolean hasBlockEntity();
|
||||
|
||||
/**
|
||||
* Creates a new {@link JavaBlockState.Builder} instance
|
||||
*
|
||||
* @return a new {@link JavaBlockState.Builder} instance
|
||||
*/
|
||||
static JavaBlockState.Builder builder() {
|
||||
return GeyserApi.api().provider(JavaBlockState.Builder.class);
|
||||
}
|
||||
|
||||
interface Builder {
|
||||
Builder identifier(@NonNull String identifier);
|
||||
|
||||
Builder javaId(@NonNegative int javaId);
|
||||
|
||||
Builder stateGroupId(@NonNegative int stateGroupId);
|
||||
|
||||
Builder blockHardness(@NonNegative float blockHardness);
|
||||
|
||||
Builder waterlogged(@NonNull boolean waterlogged);
|
||||
|
||||
Builder collision(@NonNull JavaBoundingBox[] collision);
|
||||
|
||||
Builder canBreakWithHand(@NonNull boolean canBreakWithHand);
|
||||
|
||||
Builder pickItem(@Nullable String pickItem);
|
||||
|
||||
Builder pistonBehavior(@Nullable String pistonBehavior);
|
||||
|
||||
Builder hasBlockEntity(@Nullable boolean hasBlockEntity);
|
||||
|
||||
JavaBlockState build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package org.geysermc.geyser.api.block.custom.nonvanilla;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public record JavaBoundingBox(@NonNull double middleX, @NonNull double middleY, @NonNull double middleZ, @NonNull double sizeX, @NonNull double sizeY, @NonNull double sizeZ) {
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.property;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to store a property of a custom block of a generic type.
|
||||
*/
|
||||
public interface CustomBlockProperty<T> {
|
||||
/**
|
||||
* Gets the name of the property
|
||||
*
|
||||
* @return The name of the property.
|
||||
*/
|
||||
@NonNull String name();
|
||||
|
||||
/**
|
||||
* Gets the values of the property
|
||||
*
|
||||
* @return The values of the property.
|
||||
*/
|
||||
@NonNull List<T> values();
|
||||
|
||||
/**
|
||||
* Gets the type of the property
|
||||
*
|
||||
* @return The type of the property.
|
||||
*/
|
||||
@NonNull PropertyType type();
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.property;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* This class is used to define a custom block property's type.
|
||||
*/
|
||||
public class PropertyType {
|
||||
private static final PropertyType BOOLEAN = new PropertyType(Boolean.class);
|
||||
private static final PropertyType INTEGER = new PropertyType(Integer.class);
|
||||
private static final PropertyType STRING = new PropertyType(String.class);
|
||||
|
||||
/**
|
||||
* Gets the property type for a boolean.
|
||||
*
|
||||
* @return The property type for a boolean.
|
||||
*/
|
||||
@NonNull public static PropertyType booleanProp() {
|
||||
return BOOLEAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property type for an integer.
|
||||
*
|
||||
* @return The property type for an integer.
|
||||
*/
|
||||
@NonNull public static PropertyType integerProp() {
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property type for a string.
|
||||
*
|
||||
* @return The property type for a string.
|
||||
*/
|
||||
@NonNull public static PropertyType stringProp() {
|
||||
return STRING;
|
||||
}
|
||||
|
||||
private final Class<?> typeClass;
|
||||
|
||||
/**
|
||||
* Gets the class of the property type
|
||||
*
|
||||
* @return The class of the property type.
|
||||
*/
|
||||
@NonNull public Class<?> typeClass() {
|
||||
return typeClass;
|
||||
}
|
||||
|
||||
private PropertyType(Class<?> typeClass) {
|
||||
this.typeClass = typeClass;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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.event.lifecycle;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.block.custom.CustomBlockData;
|
||||
import org.geysermc.geyser.api.block.custom.CustomBlockState;
|
||||
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockItem;
|
||||
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockState;
|
||||
import org.geysermc.event.Event;
|
||||
|
||||
/**
|
||||
* Called on Geyser's startup when looking for custom blocks. Custom blocks must be registered through this event.
|
||||
*
|
||||
* This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config.
|
||||
*/
|
||||
public abstract class GeyserDefineCustomBlocksEvent implements Event {
|
||||
/**
|
||||
* Registers the given {@link CustomBlockData} as a custom block
|
||||
*
|
||||
* @param customBlockData the custom block to register
|
||||
*/
|
||||
public abstract void register(@NonNull CustomBlockData customBlockData);
|
||||
|
||||
/**
|
||||
* Registers the given {@link CustomBlockState} as an override for the
|
||||
* given java state identifier
|
||||
* Java state identifiers are listed in
|
||||
* https://raw.githubusercontent.com/GeyserMC/mappings/master/blocks.json
|
||||
*
|
||||
* @param javaIdentifier the java state identifier to override
|
||||
* @param customBlockState the custom block state with which to override java state identifier
|
||||
*/
|
||||
public abstract void registerOverride(@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 registerItemOverride(@NonNull String javaIdentifier, @NonNull CustomBlockData customBlockData);
|
||||
|
||||
/**
|
||||
* Registers the given {@link CustomBlockState} as an override for the
|
||||
* given {@link JavaBlockState}
|
||||
*
|
||||
* @param javaBlockState the java block state for the non-vanilla block
|
||||
* @param customBlockState the custom block state with which to override java state identifier
|
||||
*/
|
||||
public abstract void registerOverride(@NonNull JavaBlockState javaBlockState, @NonNull CustomBlockState customBlockState);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.geysermc.geyser.api.event.lifecycle;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.event.Event;
|
||||
|
||||
/**
|
||||
* Called on Geyser's startup when looking for custom skulls. Custom skulls must be registered through this event.
|
||||
*
|
||||
* This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config.
|
||||
*/
|
||||
public abstract class GeyserDefineCustomSkullsEvent implements Event {
|
||||
/**
|
||||
* The type of texture provided
|
||||
*/
|
||||
public enum SkullTextureType {
|
||||
USERNAME,
|
||||
UUID,
|
||||
PROFILE,
|
||||
SKIN_HASH
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given username, UUID, base64 encoded profile, or skin hash as a custom skull blocks
|
||||
* @param texture the username, UUID, base64 encoded profile, or skin hash
|
||||
* @param type the type of texture provided
|
||||
*/
|
||||
public abstract void register(@NonNull String texture, @NonNull SkullTextureType type);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.util;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents the creative menu categories or tabs.
|
||||
*/
|
||||
public enum CreativeCategory {
|
||||
COMMANDS("commands", 1),
|
||||
CONSTRUCTION("construction", 2),
|
||||
EQUIPMENT("equipment", 3),
|
||||
ITEMS("items", 4),
|
||||
NATURE("nature", 5),
|
||||
NONE("none", 6);
|
||||
|
||||
private final String internalName;
|
||||
private final int id;
|
||||
|
||||
CreativeCategory(String internalName, int id) {
|
||||
this.internalName = internalName;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the internal name of the category.
|
||||
*
|
||||
* @return the name of the category
|
||||
*/
|
||||
@NonNull public String internalName() {
|
||||
return internalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the internal ID of the category.
|
||||
*
|
||||
* @return the ID of the category
|
||||
*/
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue