From d11a0bade5c7b300df807fdd538883b42e65ef74 Mon Sep 17 00:00:00 2001 From: booky10 Date: Mon, 21 Oct 2024 01:36:03 +0200 Subject: [PATCH] Add tip and creaking block state properties for 1.21.2 --- .../world/states/WrappedBlockState.java | 21 +++++++++++++++ .../states/enums/CreakingHeartState.java | 26 +++++++++++++++++++ .../world/states/type/StateValue.java | 5 +++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/enums/CreakingHeartState.java diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/WrappedBlockState.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/WrappedBlockState.java index e85714f7ac..bb33ba2a5c 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/WrappedBlockState.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/WrappedBlockState.java @@ -15,6 +15,7 @@ import com.github.retrooper.packetevents.protocol.world.states.enums.Attachment; import com.github.retrooper.packetevents.protocol.world.states.enums.Axis; import com.github.retrooper.packetevents.protocol.world.states.enums.Bloom; +import com.github.retrooper.packetevents.protocol.world.states.enums.CreakingHeartState; import com.github.retrooper.packetevents.protocol.world.states.enums.East; import com.github.retrooper.packetevents.protocol.world.states.enums.Face; import com.github.retrooper.packetevents.protocol.world.states.enums.Half; @@ -941,6 +942,16 @@ public void setLit(boolean lit) { checkIsStillValid(); } + public boolean isTip() { + return (boolean) data.get(StateValue.TIP); + } + + public void setTip(boolean tip) { + checkIfCloneNeeded(); + data.put(StateValue.TIP, tip); + checkIsStillValid(); + } + public boolean isLocked() { return (boolean) data.get(StateValue.LOCKED); } @@ -1371,6 +1382,16 @@ public void setTrialSpawnerState(TrialSpawnerState trialSpawnerState) { checkIsStillValid(); } + public CreakingHeartState getCreaking() { + return (CreakingHeartState) data.get(StateValue.CREAKING); + } + + public void setCreaking(CreakingHeartState creakingHeartState) { + checkIfCloneNeeded(); + data.put(StateValue.CREAKING, creakingHeartState); + checkIsStillValid(); + } + // End all block data types /** diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/enums/CreakingHeartState.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/enums/CreakingHeartState.java new file mode 100644 index 0000000000..44ac3a38a6 --- /dev/null +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/enums/CreakingHeartState.java @@ -0,0 +1,26 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2024 retrooper and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.github.retrooper.packetevents.protocol.world.states.enums; + +public enum CreakingHeartState { + + DISABLED, + DORMANT, + ACTIVE, +} diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/type/StateValue.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/type/StateValue.java index da0dfa65a6..8b7702a2b2 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/type/StateValue.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/world/states/type/StateValue.java @@ -21,6 +21,7 @@ import com.github.retrooper.packetevents.protocol.world.BlockFace; import com.github.retrooper.packetevents.protocol.world.states.enums.Attachment; import com.github.retrooper.packetevents.protocol.world.states.enums.Axis; +import com.github.retrooper.packetevents.protocol.world.states.enums.CreakingHeartState; import com.github.retrooper.packetevents.protocol.world.states.enums.East; import com.github.retrooper.packetevents.protocol.world.states.enums.Face; import com.github.retrooper.packetevents.protocol.world.states.enums.Half; @@ -93,6 +94,7 @@ public enum StateValue { LEAVES("leaves", Leaves.class, Leaves::valueOf), LEVEL("level", int.class, Integer::parseInt), LIT("lit", boolean.class, Boolean::parseBoolean), + TIP("tip", boolean.class, Boolean::parseBoolean), LOCKED("locked", boolean.class, Boolean::parseBoolean), MODE("mode", Mode.class, Mode::valueOf), MOISTURE("moisture", int.class, Integer::parseInt), @@ -132,7 +134,8 @@ public enum StateValue { VAULT_STATE("vault_state", VaultState.class, VaultState::valueOf), VERTICAL_DIRECTION("vertical_direction", VerticalDirection.class, VerticalDirection::valueOf), WATERLOGGED("waterlogged", boolean.class, Boolean::parseBoolean), - WEST("west", West.class, West::valueOf); + WEST("west", West.class, West::valueOf), + CREAKING("creaking", CreakingHeartState.class, CreakingHeartState::valueOf); public static final Index NAME_INDEX = Index.create( StateValue.class, StateValue::getName);