From c2a6e8ce70174d0883dc78d6b0f203de4a4933db Mon Sep 17 00:00:00 2001 From: davchoo Date: Wed, 6 Jul 2022 09:12:52 -0400 Subject: [PATCH] Rename some stuff --- .../{RenderMethod.java => BoxComponent.java} | 6 +-- .../custom/component/CollisionComponent.java | 30 --------------- .../component/CustomBlockComponents.java | 14 +++---- .../custom/component/MaterialInstance.java | 2 +- .../java/org/geysermc/geyser/GeyserImpl.java | 2 +- .../block/GeyserCustomBlockComponents.java | 38 +++++++++---------- .../level/block/GeyserCustomBlockData.java | 4 +- .../block/GeyserCustomBlockPermutation.java | 2 +- .../level/block/GeyserCustomBlockState.java | 2 +- .../populator/BlockRegistryPopulator.java | 26 ++++++------- .../provider/GeyserBuilderProvider.java | 6 +-- 11 files changed, 50 insertions(+), 82 deletions(-) rename api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/{RenderMethod.java => BoxComponent.java} (90%) delete mode 100644 api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CollisionComponent.java diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/RenderMethod.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/BoxComponent.java similarity index 90% rename from api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/RenderMethod.java rename to api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/BoxComponent.java index 907d38031..b114a361c 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/RenderMethod.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/BoxComponent.java @@ -25,8 +25,6 @@ package org.geysermc.geyser.api.block.custom.component; -public enum RenderMethod { - BLEND, - OPAQUE, - ALPHA_TEST +public record BoxComponent(float originX, float originY, float originZ, + float sizeX, float sizeY, float sizeZ) { } diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CollisionComponent.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CollisionComponent.java deleted file mode 100644 index 6f975921a..000000000 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CollisionComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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; - -public record CollisionComponent(float originX, float originY, float originZ, - float sizeX, float sizeY, float sizeZ) { -} diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java index 6d60ba49c..92da81db8 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java @@ -28,9 +28,9 @@ package org.geysermc.geyser.api.block.custom.component; import java.util.Map; public interface CustomBlockComponents { - CollisionComponent aimCollision(); + BoxComponent selectionBox(); - CollisionComponent entityCollision(); + BoxComponent collisionBox(); String geometry(); @@ -40,16 +40,16 @@ public interface CustomBlockComponents { Float friction(); - Float lightEmission(); + Integer lightEmission(); - Integer lightFilter(); + Integer lightDampening(); RotationComponent rotation(); interface Builder { - Builder aimCollision(CollisionComponent aimCollision); + Builder aimCollision(BoxComponent aimCollision); - Builder entityCollision(CollisionComponent entityCollision); + Builder entityCollision(BoxComponent entityCollision); Builder geometry(String geometry); @@ -59,7 +59,7 @@ public interface CustomBlockComponents { Builder friction(Float friction); - Builder lightEmission(Float lightEmission); + Builder lightEmission(Integer lightEmission); Builder lightFilter(Integer lightFilter); diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java index 8331919e8..19ba0906d 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java @@ -27,6 +27,6 @@ package org.geysermc.geyser.api.block.custom.component; import org.checkerframework.checker.nullness.qual.NonNull; -public record MaterialInstance(@NonNull String texture, @NonNull RenderMethod renderMethod, boolean faceDimming, boolean ambientOcclusion) { +public record MaterialInstance(@NonNull String texture, @NonNull String renderMethod, boolean faceDimming, boolean ambientOcclusion) { } diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 4c3cf6fca..76a8f95f2 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -595,7 +595,7 @@ public class GeyserImpl implements GeyserApi { @Override public boolean isProductionEnvironment() { // noinspection ConstantConditions - changes in production - return !"git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION); + return !"${gitVersion}".equals(GeyserImpl.GIT_VERSION); } @Override diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java index 1f20c9b55..61e43b63f 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java @@ -25,7 +25,7 @@ package org.geysermc.geyser.level.block; -import org.geysermc.geyser.api.block.custom.component.CollisionComponent; +import org.geysermc.geyser.api.block.custom.component.BoxComponent; import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; import org.geysermc.geyser.api.block.custom.component.MaterialInstance; import org.geysermc.geyser.api.block.custom.component.RotationComponent; @@ -33,17 +33,17 @@ import org.geysermc.geyser.api.block.custom.component.RotationComponent; import java.util.Map; public class GeyserCustomBlockComponents implements CustomBlockComponents { - private final CollisionComponent aimCollision; - private final CollisionComponent entityCollision; + private final BoxComponent aimCollision; + private final BoxComponent entityCollision; private final String geometry; private final Map materialInstances; private final Float destroyTime; private final Float friction; - private final Float lightEmission; - private final Integer lightFilter; + private final Integer lightEmission; + private final Integer lightDampening; private final RotationComponent rotation; - public GeyserCustomBlockComponents(BuilderImpl builder) { + private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) { this.aimCollision = builder.aimCollision; this.entityCollision = builder.entityCollision; this.geometry = builder.geometry; @@ -51,17 +51,17 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { this.destroyTime = builder.destroyTime; this.friction = builder.friction; this.lightEmission = builder.lightEmission; - this.lightFilter = builder.lightFilter; + this.lightDampening = builder.lightFilter; this.rotation = builder.rotation; } @Override - public CollisionComponent aimCollision() { + public BoxComponent selectionBox() { return aimCollision; } @Override - public CollisionComponent entityCollision() { + public BoxComponent collisionBox() { return entityCollision; } @@ -86,13 +86,13 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { } @Override - public Float lightEmission() { + public Integer lightEmission() { return lightEmission; } @Override - public Integer lightFilter() { - return lightFilter; + public Integer lightDampening() { + return lightDampening; } @Override @@ -100,25 +100,25 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { return rotation; } - public static class BuilderImpl implements Builder { - protected CollisionComponent aimCollision; - protected CollisionComponent entityCollision; + public static class CustomBlockComponentsBuilder implements Builder { + protected BoxComponent aimCollision; + protected BoxComponent entityCollision; protected String geometry; protected Map materialInstances; protected Float destroyTime; protected Float friction; - protected Float lightEmission; + protected Integer lightEmission; protected Integer lightFilter; protected RotationComponent rotation; @Override - public Builder aimCollision(CollisionComponent aimCollision) { + public Builder aimCollision(BoxComponent aimCollision) { this.aimCollision = aimCollision; return this; } @Override - public Builder entityCollision(CollisionComponent entityCollision) { + public Builder entityCollision(BoxComponent entityCollision) { this.entityCollision = entityCollision; return this; } @@ -148,7 +148,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { } @Override - public Builder lightEmission(Float lightEmission) { + public Builder lightEmission(Integer lightEmission) { this.lightEmission = lightEmission; return this; } diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java index 1d2351a37..47d129a8d 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java @@ -69,10 +69,10 @@ public class GeyserCustomBlockData implements CustomBlockData { @Override public CustomBlockState.Builder blockStateBuilder() { - return new GeyserCustomBlockState.BuilderImpl(this); + return new GeyserCustomBlockState.CustomBlockStateBuilder(this); } - public static class BuilderImpl implements Builder { + public static class CustomBlockDataBuilder implements Builder { private String name; private CustomBlockComponents components; private Map> properties = new Object2ObjectOpenHashMap<>(); diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockPermutation.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockPermutation.java index c2bfc8b6c..22e03c99a 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockPermutation.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockPermutation.java @@ -49,7 +49,7 @@ public class GeyserCustomBlockPermutation implements CustomBlockPermutation { return components; } - public static class BuilderImpl implements Builder { + public static class CustomBlockPermutationBuilder implements Builder { private String condition; private CustomBlockComponents components; diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockState.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockState.java index b2b0e2148..506a72a93 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockState.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockState.java @@ -59,7 +59,7 @@ public class GeyserCustomBlockState implements CustomBlockState { } @RequiredArgsConstructor - public static class BuilderImpl implements CustomBlockState.Builder { + public static class CustomBlockStateBuilder implements CustomBlockState.Builder { private final CustomBlockData blockData; private final Object2ObjectMap properties = new Object2ObjectOpenHashMap<>(); diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java index a3bee28d1..b61d0e389 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java @@ -38,7 +38,7 @@ import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.api.block.custom.CustomBlockPermutation; import org.geysermc.geyser.api.block.custom.CustomBlockState; -import org.geysermc.geyser.api.block.custom.component.CollisionComponent; +import org.geysermc.geyser.api.block.custom.component.BoxComponent; import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; import org.geysermc.geyser.api.block.custom.component.MaterialInstance; import org.geysermc.geyser.api.block.custom.property.CustomBlockProperty; @@ -347,20 +347,20 @@ public class BlockRegistryPopulator { return NbtMap.EMPTY; } NbtMapBuilder builder = NbtMap.builder(); - if (components.aimCollision() != null) { - CollisionComponent collisionComponent = components.aimCollision(); + if (components.selectionBox() != null) { + BoxComponent selectionBox = components.selectionBox(); builder.putCompound("minecraft:aim_collision", NbtMap.builder() .putBoolean("enabled", true) - .putList("origin", NbtType.FLOAT, collisionComponent.originX(), collisionComponent.originY(), collisionComponent.originZ()) - .putList("size", NbtType.FLOAT, collisionComponent.sizeX(), collisionComponent.sizeY(), collisionComponent.sizeZ()) + .putList("origin", NbtType.FLOAT, selectionBox.originX(), selectionBox.originY(), selectionBox.originZ()) + .putList("size", NbtType.FLOAT, selectionBox.sizeX(), selectionBox.sizeY(), selectionBox.sizeZ()) .build()); } - if (components.entityCollision() != null) { - CollisionComponent collisionComponent = components.entityCollision(); + if (components.collisionBox() != null) { + BoxComponent collisionBox = components.collisionBox(); builder.putCompound("minecraft:block_collision", NbtMap.builder() .putBoolean("enabled", true) - .putList("origin", NbtType.FLOAT, collisionComponent.originX(), collisionComponent.originY(), collisionComponent.originZ()) - .putList("size", NbtType.FLOAT, collisionComponent.sizeX(), collisionComponent.sizeY(), collisionComponent.sizeZ()) + .putList("origin", NbtType.FLOAT, collisionBox.originX(), collisionBox.originY(), collisionBox.originZ()) + .putList("size", NbtType.FLOAT, collisionBox.sizeX(), collisionBox.sizeY(), collisionBox.sizeZ()) .build()); } if (components.geometry() != null) { @@ -374,7 +374,7 @@ public class BlockRegistryPopulator { MaterialInstance materialInstance = entry.getValue(); materialsBuilder.putCompound(entry.getKey(), NbtMap.builder() .putString("texture", materialInstance.texture()) - .putString("render_method", materialInstance.renderMethod().toString().toLowerCase(Locale.ROOT)) + .putString("render_method", materialInstance.renderMethod()) .putBoolean("face_dimming", materialInstance.faceDimming()) .putBoolean("ambient_occlusion", materialInstance.faceDimming()) .build()); @@ -396,12 +396,12 @@ public class BlockRegistryPopulator { } if (components.lightEmission() != null) { builder.putCompound("minecraft:block_light_emission", NbtMap.builder() - .putFloat("value", components.lightEmission()) + .putFloat("value", ((float) components.lightEmission()) / 15f) .build()); } - if (components.lightFilter() != null) { + if (components.lightDampening() != null) { builder.putCompound("minecraft:block_light_filter", NbtMap.builder() - .putByte("value", components.lightFilter().byteValue()) + .putByte("value", components.lightDampening().byteValue()) .build()); } if (components.rotation() != null) { diff --git a/core/src/main/java/org/geysermc/geyser/registry/provider/GeyserBuilderProvider.java b/core/src/main/java/org/geysermc/geyser/registry/provider/GeyserBuilderProvider.java index b40846b2c..88b37e456 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/provider/GeyserBuilderProvider.java +++ b/core/src/main/java/org/geysermc/geyser/registry/provider/GeyserBuilderProvider.java @@ -59,9 +59,9 @@ public class GeyserBuilderProvider extends AbstractProvider implements BuilderPr public void registerProviders(Map, ProviderSupplier> providers) { providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Class) args[0])); - providers.put(CustomBlockComponents.Builder.class, args -> new GeyserCustomBlockComponents.BuilderImpl()); - providers.put(CustomBlockData.Builder.class, args -> new GeyserCustomBlockData.BuilderImpl()); - providers.put(CustomBlockPermutation.Builder.class, args -> new GeyserCustomBlockPermutation.BuilderImpl()); + providers.put(CustomBlockComponents.Builder.class, args -> new GeyserCustomBlockComponents.CustomBlockComponentsBuilder()); + providers.put(CustomBlockData.Builder.class, args -> new GeyserCustomBlockData.CustomBlockDataBuilder()); + providers.put(CustomBlockPermutation.Builder.class, args -> new GeyserCustomBlockPermutation.CustomBlockPermutationBuilder()); providers.put(CustomItemData.Builder.class, args -> new GeyserCustomItemData.CustomItemDataBuilder()); providers.put(CustomItemOptions.Builder.class, args -> new GeyserCustomItemOptions.CustomItemOptionsBuilder());