Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Warden time
Dieser Commit ist enthalten in:
Ursprung
a70f1bc003
Commit
e2ce553d3a
@ -156,6 +156,7 @@ public final class EntityDefinitions {
|
|||||||
public static final EntityDefinition<VillagerEntity> VILLAGER;
|
public static final EntityDefinition<VillagerEntity> VILLAGER;
|
||||||
public static final EntityDefinition<VindicatorEntity> VINDICATOR;
|
public static final EntityDefinition<VindicatorEntity> VINDICATOR;
|
||||||
public static final EntityDefinition<AbstractMerchantEntity> WANDERING_TRADER;
|
public static final EntityDefinition<AbstractMerchantEntity> WANDERING_TRADER;
|
||||||
|
public static final EntityDefinition<WardenEntity> WARDEN;
|
||||||
public static final EntityDefinition<RaidParticipantEntity> WITCH;
|
public static final EntityDefinition<RaidParticipantEntity> WITCH;
|
||||||
public static final EntityDefinition<WitherEntity> WITHER;
|
public static final EntityDefinition<WitherEntity> WITHER;
|
||||||
public static final EntityDefinition<AbstractSkeletonEntity> WITHER_SKELETON;
|
public static final EntityDefinition<AbstractSkeletonEntity> WITHER_SKELETON;
|
||||||
@ -561,6 +562,11 @@ public final class EntityDefinitions {
|
|||||||
.height(0.8f).width(0.4f)
|
.height(0.8f).width(0.4f)
|
||||||
.addTranslator(MetadataType.BYTE, VexEntity::setVexFlags)
|
.addTranslator(MetadataType.BYTE, VexEntity::setVexFlags)
|
||||||
.build();
|
.build();
|
||||||
|
WARDEN = EntityDefinition.inherited(WardenEntity::new, mobEntityBase)
|
||||||
|
.type(EntityType.WARDEN)
|
||||||
|
.height(2.9f).width(0.9f)
|
||||||
|
.addTranslator(MetadataType.INT, WardenEntity::setAngerLevel)
|
||||||
|
.build();
|
||||||
WITHER = EntityDefinition.inherited(WitherEntity::new, mobEntityBase)
|
WITHER = EntityDefinition.inherited(WitherEntity::new, mobEntityBase)
|
||||||
.type(EntityType.WITHER)
|
.type(EntityType.WITHER)
|
||||||
.height(3.5f).width(0.9f)
|
.height(3.5f).width(0.9f)
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.entity.type.living.monster;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
|
import com.nukkitx.math.GenericMath;
|
||||||
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.util.MathUtils;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class WardenEntity extends MonsterEntity {
|
||||||
|
public WardenEntity(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPose(Pose pose) {
|
||||||
|
setFlag(EntityFlag.DIGGING, pose == Pose.DIGGING);
|
||||||
|
setFlag(EntityFlag.EMERGING, pose == Pose.EMERGING);
|
||||||
|
setFlag(EntityFlag.ROARING, pose == Pose.ROARING);
|
||||||
|
setFlag(EntityFlag.SNIFFING, pose == Pose.SNIFFING);
|
||||||
|
super.setPose(pose);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAngerLevel(IntEntityMetadata entityMetadata) {
|
||||||
|
float anger = (float) entityMetadata.getPrimitiveValue() / 80f;
|
||||||
|
dirtyMetadata.put(EntityData.HEARTBEAT_INTERVAL_TICKS, 40 - GenericMath.floor(MathUtils.clamp(anger, 0.0F, 1.0F) * 30F));
|
||||||
|
}
|
||||||
|
}
|
@ -101,6 +101,25 @@ public class MathUtils {
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamps the value between the low and high boundaries
|
||||||
|
* Copied from {@link com.nukkitx.math.GenericMath} with floats instead.
|
||||||
|
*
|
||||||
|
* @param value The value to clamp
|
||||||
|
* @param low The low bound of the clamp
|
||||||
|
* @param high The high bound of the clamp
|
||||||
|
* @return the clamped value
|
||||||
|
*/
|
||||||
|
public static double clamp(float value, float low, float high) {
|
||||||
|
if (value < low) {
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
if (value > high) {
|
||||||
|
return high;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures the resulting object is a byte. Java Edition does not care whether a byte is encoded as an integer or not;
|
* Ensures the resulting object is a byte. Java Edition does not care whether a byte is encoded as an integer or not;
|
||||||
* it converts it into a byte anyway.
|
* it converts it into a byte anyway.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren