Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/feature/1.20.5' into feature/1…
Browse files Browse the repository at this point in the history
….20.5
  • Loading branch information
onebeastchris committed Apr 26, 2024
2 parents f67c131 + 3656395 commit 68534f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public EnumProperty(String name, List<String> values) {
public NbtMap nbtMap() {
return NbtMap.builder()
.putString("name", name)
.putList("values", NbtType.STRING, values)
.putList("enum", NbtType.STRING, values)
.putInt("type", 3)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,42 @@
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

public class ArmadilloEntity extends AnimalEntity {
private ArmadilloState armadilloState = ArmadilloState.IDLE;

public ArmadilloEntity(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);
}

// 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) {
ArmadilloState armadilloState = entityMetadata.getValue();
armadilloState = entityMetadata.getValue();

switch (armadilloState) {
case IDLE -> propertyManager.add("minecraft:armadillo_state", "unrolled");
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();
}

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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.geysermc.geyser.entity.type.EvokerFangsEntity;
import org.geysermc.geyser.entity.type.FishingHookEntity;
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.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
Expand Down Expand Up @@ -257,6 +258,11 @@ public void translate(GeyserSession session, ClientboundEntityEventPacket packet
wardenEntity.onSonicBoom();
}
break;
case ARMADILLO_PEEKING:
if (entity instanceof ArmadilloEntity armadilloEntity) {
armadilloEntity.onPeeking();
}
break;
}

if (entityEventPacket.getType() != null) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol-connection = "3.0.0.Beta1-20240411.165033-128"
raknet = "1.0.0.CR3-20240416.144209-1"
blockstateupdater="1.20.80-20240411.142413-1"
mcauthlib = "d9d773e"
mcprotocollib = "1ca8808" # Revert from jitpack after release
mcprotocollib = "1e053f0" # Revert from jitpack after release
adventure = "4.14.0"
adventure-platform = "4.3.0"
junit = "5.9.2"
Expand Down

0 comments on commit 68534f3

Please sign in to comment.