mirror of
https://github.com/GeyserMC/Geyser.git
synced 2026-01-04 15:31:36 +00:00
More work on events, closer to working
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
|
||||
package org.geysermc.geyser.api.entity;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.util.Identifier;
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,16 @@ public interface JavaEntityType {
|
||||
*/
|
||||
boolean vanilla();
|
||||
|
||||
/**
|
||||
* @return the width of the Java entity
|
||||
*/
|
||||
float width();
|
||||
|
||||
/**
|
||||
* @return the height of the Java entity
|
||||
*/
|
||||
float height();
|
||||
|
||||
/**
|
||||
* Compares two entity identifiers.
|
||||
*
|
||||
@@ -56,4 +68,10 @@ public interface JavaEntityType {
|
||||
default boolean is(Identifier javaIdentifier) {
|
||||
return identifier().equals(javaIdentifier);
|
||||
}
|
||||
|
||||
@Nullable GeyserEntityDefinition defaultBedrockDefinition();
|
||||
|
||||
static JavaEntityType ofVanilla(Identifier identifier) {
|
||||
return GeyserApi.api().provider(JavaEntityType.class, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2025 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.entity.custom;
|
||||
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.entity.GeyserEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.JavaEntityType;
|
||||
import org.geysermc.geyser.api.util.Identifier;
|
||||
|
||||
public interface CustomJavaEntityType extends JavaEntityType {
|
||||
|
||||
@Override
|
||||
default boolean vanilla() {
|
||||
return false;
|
||||
};
|
||||
|
||||
interface Builder {
|
||||
|
||||
Builder type(Identifier entityType);
|
||||
|
||||
Builder javaId(int javaId);
|
||||
|
||||
Builder width(@NonNegative float width);
|
||||
|
||||
Builder height(@NonNegative float height);
|
||||
|
||||
Builder defaultBedrockDefinition(@Nullable GeyserEntityDefinition defaultBedrockDefinition);
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.geyser.api.entity.GeyserEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.util.Identifier;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomJavaEntityType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Called when entities are defined within Geyser.
|
||||
@@ -64,8 +65,7 @@ public interface GeyserDefineEntitiesEvent extends Event {
|
||||
/**
|
||||
* Registers a non-vanilla Java entity type.
|
||||
*
|
||||
* @param javaEntityType the identifier of the Java entity type
|
||||
* @param javaId the network id of this entity type
|
||||
* @param builderConsumer the builder for the non-vanilla type
|
||||
*/
|
||||
void registerEntityType(@NonNull Identifier javaEntityType, int javaId, CustomEntityDefinition defaultDefinition);
|
||||
void registerEntityType(Consumer<CustomJavaEntityType.Builder> builderConsumer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user