mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-22 16:29:25 +00:00
Initial happy ghast implementation
This commit is contained in:
@@ -81,6 +81,7 @@ import org.geysermc.geyser.entity.type.living.TadpoleEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.ArmadilloEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.AxolotlEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.BeeEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.HappyGhastEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.farm.ChickenEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.farm.CowEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.FoxEntity;
|
||||
@@ -215,6 +216,7 @@ public final class EntityDefinitions {
|
||||
public static final EntityDefinition<GlowSquidEntity> GLOW_SQUID;
|
||||
public static final EntityDefinition<GoatEntity> GOAT;
|
||||
public static final EntityDefinition<GuardianEntity> GUARDIAN;
|
||||
public static final EntityDefinition<HappyGhastEntity> HAPPY_GHAST;
|
||||
public static final EntityDefinition<HoglinEntity> HOGLIN;
|
||||
public static final EntityDefinition<MinecartEntity> HOPPER_MINECART;
|
||||
public static final EntityDefinition<HorseEntity> HORSE;
|
||||
@@ -989,6 +991,13 @@ public final class EntityDefinitions {
|
||||
.addTranslator(MetadataTypes.FROG_VARIANT, FrogEntity::setVariant)
|
||||
.addTranslator(MetadataTypes.OPTIONAL_UNSIGNED_INT, FrogEntity::setTongueTarget)
|
||||
.build();
|
||||
HAPPY_GHAST = EntityDefinition.inherited(HappyGhastEntity::new, ageableEntityBase)
|
||||
.type(EntityType.HAPPY_GHAST)
|
||||
.heightAndWidth(4f)
|
||||
.properties(VanillaEntityProperties.HAPPY_GHAST)
|
||||
.addTranslator(null) // Is leash holder
|
||||
.addTranslator(MetadataTypes.BOOLEAN, HappyGhastEntity::setStaysStill)
|
||||
.build();
|
||||
HOGLIN = EntityDefinition.inherited(HoglinEntity::new, ageableEntityBase)
|
||||
.type(EntityType.HOGLIN)
|
||||
.height(1.4f).width(1.3965f)
|
||||
|
||||
@@ -61,6 +61,10 @@ public class VanillaEntityProperties {
|
||||
.addInt(CreakingEntity.CREAKING_SWAYING_TICKS, 0, 6)
|
||||
.build();
|
||||
|
||||
public static final GeyserEntityProperties HAPPY_GHAST = new GeyserEntityProperties.Builder()
|
||||
.addBoolean("minecraft:can_move")
|
||||
.build();
|
||||
|
||||
public static final GeyserEntityProperties WOLF_SOUND_VARIANT = new GeyserEntityProperties.Builder()
|
||||
.addEnum("minecraft:sound_variant",
|
||||
"default",
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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.entity.type.living.animal;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||
import org.geysermc.geyser.session.cache.tags.Tag;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class HappyGhastEntity extends AnimalEntity {
|
||||
public HappyGhastEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
|
||||
setFlag(EntityFlag.CAN_FLY, true);
|
||||
setFlag(EntityFlag.TAMED, true);
|
||||
setFlag(EntityFlag.CAN_WALK, true);
|
||||
|
||||
setFlag(EntityFlag.WASD_AIR_CONTROLLED, true);
|
||||
setFlag(EntityFlag.DOES_SERVER_AUTH_ONLY_DISMOUNT, true);
|
||||
|
||||
// TODO: verify which flags are necessary
|
||||
|
||||
setAirSupply(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Tag<Item> getFoodTag() {
|
||||
return ItemTag.HAPPY_GHAST_FOOD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getBabySize() {
|
||||
return 0.2375f;
|
||||
}
|
||||
|
||||
public void setStaysStill(BooleanEntityMetadata entityMetadata) {
|
||||
propertyManager.add("minecraft:can_move", !entityMetadata.getPrimitiveValue());
|
||||
updateBedrockEntityProperties();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
|
||||
if (this.isBaby()) {
|
||||
return super.testMobInteraction(hand, itemInHand);
|
||||
} else {
|
||||
if (!itemInHand.isEmpty()) {
|
||||
if (session.getTagCache().is(ItemTag.HARNESSES, itemInHand)) {
|
||||
if (!this.body.isValid()) {
|
||||
// Harnesses the ghast
|
||||
return InteractiveTag.HARNESS_HAPPY_GHAST;
|
||||
}
|
||||
}
|
||||
// TODO: Handle shearing the harness off
|
||||
}
|
||||
|
||||
if (this.body.isValid() && !session.isSneaking()) {
|
||||
// Rides happy ghast
|
||||
return InteractiveTag.RIDE_HORSE;
|
||||
} else {
|
||||
return super.testMobInteraction(hand, itemInHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
|
||||
if (this.isBaby()) {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
} else {
|
||||
if (!itemInHand.isEmpty()) {
|
||||
if (session.getTagCache().is(ItemTag.HARNESSES, itemInHand)) {
|
||||
if (!this.body.isValid()) {
|
||||
// Harnesses the ghast
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
// TODO: Handle shearing the harness off
|
||||
}
|
||||
|
||||
if (this.body.isValid() && !session.isSneaking()) {
|
||||
// Rides happy ghast
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,6 +242,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
stackPacket.getResourcePacks().addAll(this.resourcePackLoadEvent.orderedPacks());
|
||||
// Allows Vibrant Visuals to be toggled in the settings
|
||||
stackPacket.getExperiments().add(new ExperimentData("experimental_graphics", true));
|
||||
// Enables 2025 Content Drop 2 features
|
||||
stackPacket.getExperiments().add(new ExperimentData("y_2025_drop_2", true));
|
||||
|
||||
session.sendUpstreamPacket(stackPacket);
|
||||
}
|
||||
|
||||
@@ -1691,6 +1691,8 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
startGamePacket.getExperiments().add(new ExperimentData("experimental_molang_features", true));
|
||||
// Allows Vibrant Visuals to appear in the settings menu
|
||||
startGamePacket.getExperiments().add(new ExperimentData("experimental_graphics", true));
|
||||
// Enables 2025 Content Drop 2 features
|
||||
startGamePacket.getExperiments().add(new ExperimentData("y_2025_drop_2", true));
|
||||
|
||||
startGamePacket.setVanillaVersion("*");
|
||||
startGamePacket.setInventoriesServerAuthoritative(true);
|
||||
|
||||
@@ -73,7 +73,8 @@ public enum InteractiveTag {
|
||||
GIVE_ITEM_TO_ALLAY("allay"),
|
||||
EQUIP_WOLF_ARMOR("equipwolfarmor"),
|
||||
REMOVE_WOLF_ARMOR("removewolfarmor"),
|
||||
REPAIR_WOLF_ARMOR("repairwolfarmor");
|
||||
REPAIR_WOLF_ARMOR("repairwolfarmor"),
|
||||
HARNESS_HAPPY_GHAST("equipharness");
|
||||
|
||||
/**
|
||||
* The full string that should be passed on to the client.
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user