Merge remote-tracking branch 'upstream/feature/1.20.5' into feature/1.20.5

This commit is contained in:
onebeastchris 2024-04-26 15:36:41 +02:00
commit 68534f386c
4 changed files with 30 additions and 5 deletions

View File

@ -50,7 +50,7 @@ public class EnumProperty implements PropertyType {
public NbtMap nbtMap() { public NbtMap nbtMap() {
return NbtMap.builder() return NbtMap.builder()
.putString("name", name) .putString("name", name)
.putList("values", NbtType.STRING, values) .putList("enum", NbtType.STRING, values)
.putInt("type", 3) .putInt("type", 3)
.build(); .build();
} }

View File

@ -32,23 +32,42 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ArmadilloSt
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata; import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
public class ArmadilloEntity extends AnimalEntity { public class ArmadilloEntity extends AnimalEntity {
private ArmadilloState armadilloState = ArmadilloState.IDLE;
public ArmadilloEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, public ArmadilloEntity(GeyserSession session, int entityId, long geyserId, UUID uuid,
EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) { EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
// TODO: This is completely wrong; probably need to store the previous IDLE/ROLLING/SCARED state and check for transitions (pain)
public void setArmadilloState(ObjectEntityMetadata<ArmadilloState> entityMetadata) { public void setArmadilloState(ObjectEntityMetadata<ArmadilloState> entityMetadata) {
ArmadilloState armadilloState = entityMetadata.getValue(); armadilloState = entityMetadata.getValue();
switch (armadilloState) { switch (armadilloState) {
case IDLE -> propertyManager.add("minecraft:armadillo_state", "unrolled"); case IDLE -> propertyManager.add("minecraft:armadillo_state", "unrolled");
case ROLLING -> propertyManager.add("minecraft:armadillo_state", "rolled_up"); case ROLLING -> propertyManager.add("minecraft:armadillo_state", "rolled_up");
case SCARED -> propertyManager.add("minecraft:armadillo_state", "rolled_up_peeking"); case SCARED -> propertyManager.add("minecraft:armadillo_state", "rolled_up_relaxing");
case UNROLLING -> propertyManager.add("minecraft:armadillo_state", "rolled_up_unrolling");
} }
updateBedrockEntityProperties(); updateBedrockEntityProperties();
} }
public void onPeeking() {
// Technically we should wait if not currently scared
if (armadilloState == ArmadilloState.SCARED) {
propertyManager.add("minecraft:armadillo_state", "rolled_up_peeking");
updateBedrockEntityProperties();
// Needed for consecutive peeks
session.scheduleInEventLoop(() -> {
if (armadilloState == ArmadilloState.SCARED) {
propertyManager.add("minecraft:armadillo_state", "rolled_up_relaxing");
updateBedrockEntityProperties();
}
}, 250, TimeUnit.MILLISECONDS);
}
}
} }

View File

@ -40,6 +40,7 @@ import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.EvokerFangsEntity; import org.geysermc.geyser.entity.type.EvokerFangsEntity;
import org.geysermc.geyser.entity.type.FishingHookEntity; import org.geysermc.geyser.entity.type.FishingHookEntity;
import org.geysermc.geyser.entity.type.LivingEntity; import org.geysermc.geyser.entity.type.LivingEntity;
import org.geysermc.geyser.entity.type.living.animal.ArmadilloEntity;
import org.geysermc.geyser.entity.type.living.monster.WardenEntity; import org.geysermc.geyser.entity.type.living.monster.WardenEntity;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
@ -257,6 +258,11 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
wardenEntity.onSonicBoom(); wardenEntity.onSonicBoom();
} }
break; break;
case ARMADILLO_PEEKING:
if (entity instanceof ArmadilloEntity armadilloEntity) {
armadilloEntity.onPeeking();
}
break;
} }
if (entityEventPacket.getType() != null) { if (entityEventPacket.getType() != null) {

View File

@ -15,7 +15,7 @@ protocol-connection = "3.0.0.Beta1-20240411.165033-128"
raknet = "1.0.0.CR3-20240416.144209-1" raknet = "1.0.0.CR3-20240416.144209-1"
blockstateupdater="1.20.80-20240411.142413-1" blockstateupdater="1.20.80-20240411.142413-1"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "1ca8808" # Revert from jitpack after release mcprotocollib = "1e053f0" # Revert from jitpack after release
adventure = "4.14.0" adventure = "4.14.0"
adventure-platform = "4.3.0" adventure-platform = "4.3.0"
junit = "5.9.2" junit = "5.9.2"