Skip to content

Commit

Permalink
Update block state properties to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
booky10 committed Nov 29, 2024
1 parent b6ce588 commit 4ec975f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.github.retrooper.packetevents.protocol.world.states.type.StateValue;
import com.github.retrooper.packetevents.util.BinaryNBTCompound;
import com.github.retrooper.packetevents.util.mappings.MappingHelper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -1377,16 +1378,56 @@ public void setTrialSpawnerState(TrialSpawnerState trialSpawnerState) {
checkIsStillValid();
}

/**
* Removed with 1.21.4
*/
@ApiStatus.Obsolete
public CreakingHeartState getCreaking() {
return (CreakingHeartState) data.get(StateValue.CREAKING);
}

/**
* Removed with 1.21.4
*/
@ApiStatus.Obsolete
public void setCreaking(CreakingHeartState creakingHeartState) {
checkIfCloneNeeded();
data.put(StateValue.CREAKING, creakingHeartState);
checkIsStillValid();
}

/**
* Added with 1.21.4
*/
public boolean isActive() {
return (boolean) this.data.get(StateValue.ACTIVE);
}

/**
* Added with 1.21.4
*/
public void setActive(boolean active) {
this.checkIfCloneNeeded();
this.data.put(StateValue.ACTIVE, active);
this.checkIsStillValid();
}

/**
* Added with 1.21.4
*/
public boolean isNatural() {
return (boolean) this.data.get(StateValue.NATURAL);
}

/**
* Added with 1.21.4
*/
public void setNatural(boolean natural) {
this.checkIfCloneNeeded();
this.data.put(StateValue.NATURAL, natural);
this.checkIsStillValid();
}

// End all block data types

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

package com.github.retrooper.packetevents.protocol.world.states.enums;

import org.jetbrains.annotations.ApiStatus;

/**
* Removed with 1.21.4
*/
@ApiStatus.Obsolete
public enum CreakingHeartState {

DISABLED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.github.retrooper.packetevents.protocol.world.states.enums.VerticalDirection;
import com.github.retrooper.packetevents.protocol.world.states.enums.West;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.function.Function;
Expand Down Expand Up @@ -135,7 +136,20 @@ public enum StateValue {
VERTICAL_DIRECTION("vertical_direction", VerticalDirection.class, VerticalDirection::valueOf),
WATERLOGGED("waterlogged", boolean.class, Boolean::parseBoolean),
WEST("west", West.class, West::valueOf),
CREAKING("creaking", CreakingHeartState.class, CreakingHeartState::valueOf);
/**
* Removed with 1.21.4
*/
@ApiStatus.Obsolete
CREAKING("creaking", CreakingHeartState.class, CreakingHeartState::valueOf),
/**
* Added with 1.21.4
*/
ACTIVE("active", boolean.class, Boolean::parseBoolean),
/**
* Added with 1.21.4
*/
NATURAL("natural", boolean.class, Boolean::parseBoolean),
;

public static final Index<String, StateValue> NAME_INDEX = Index.create(
StateValue.class, StateValue::getName);
Expand Down

0 comments on commit 4ec975f

Please sign in to comment.