Class WrappedBlockState
java.lang.Object
com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState
This class is designed to take advantage of modern minecraft versions
It has also been designed so that legacy versions can use this system
Write your code once, and use it everywhere. Platform and version agnostic.
The mappings for legacy versions (1.12) was generated by setting blocks in the world at the pos id * 2, 255, data * 2 and then the world was upgraded to 1.18 and the block was read, dumping it all into a text file.
Mappings from modern versions are from ViaVersion, who have a similar (but a bit slower) system.
-
Constructor Summary
ConstructorDescriptionWrappedBlockState
(StateType type, String[] data, int globalID, byte mappingsIndex) Deprecated.WrappedBlockState
(StateType type, Map<StateValue, Object> data, int globalID, byte mappingsIndex) -
Method Summary
Modifier and TypeMethodDescriptionclone()
static WrappedBlockState
decode
(NBT nbt, ClientVersion version) static NBT
encode
(WrappedBlockState state, ClientVersion version) static void
boolean
int
getAge()
getAxis()
int
getBites()
getBloom()
static @NotNull WrappedBlockState
getByGlobalId
(int globalID) static @NotNull WrappedBlockState
getByGlobalId
(int globalID, boolean clone) static @NotNull WrappedBlockState
getByGlobalId
(ClientVersion version, int globalID) static @NotNull WrappedBlockState
getByGlobalId
(ClientVersion version, int globalID, boolean clone) static @NotNull WrappedBlockState
getByString
(ClientVersion version, String string) static @NotNull WrappedBlockState
getByString
(ClientVersion version, String string, boolean clone) static @NotNull WrappedBlockState
getByString
(String string) int
int
Removed with 1.21.4static @NotNull WrappedBlockState
getDefaultState
(ClientVersion version, StateType type) static @NotNull WrappedBlockState
getDefaultState
(ClientVersion version, StateType type, boolean clone) static @NotNull WrappedBlockState
getDefaultState
(StateType type) int
getDelay()
int
getEast()
int
getEggs()
getFace()
int
int
Global ID For pre-1.13: 4 bits of block data, 4 bits empty, 8 bits block type For post-1.13: Global IDgetHalf()
int
getHatch()
getHinge()
int
Deprecated.int
int
getLevel()
getMode()
int
getNorth()
int
getNote()
getPart()
int
int
getPower()
int
getShape()
getSouth()
int
getStage()
getTilt()
getType()
getWest()
int
hashCode()
boolean
isActive()
Added with 1.21.4boolean
boolean
boolean
isBottom()
boolean
boolean
boolean
boolean
boolean
boolean
isDown()
boolean
isDrag()
boolean
isDusted()
boolean
boolean
boolean
isEye()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isInWall()
boolean
isLit()
boolean
isLocked()
boolean
Added with 1.21.4boolean
boolean
isOpen()
boolean
boolean
boolean
isShort()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isSnowy()
boolean
isTip()
boolean
boolean
boolean
isUp()
boolean
void
setActive
(boolean active) Added with 1.21.4void
setAge
(int age) void
setAttached
(boolean attached) void
setAttachment
(Attachment attachment) void
void
setBerries
(boolean berries) void
setBites
(int bites) void
void
setBottom
(boolean bottom) void
setCandles
(int candles) void
setCanSummon
(boolean canSummon) void
setCharges
(int charges) void
setConditional
(boolean conditional) void
setCracked
(boolean cracked) void
setCrafting
(boolean crafting) void
setCreaking
(CreakingHeartState creakingHeartState) Removed with 1.21.4void
setDelay
(int delay) void
setDisarmed
(boolean disarmed) void
setDistance
(int distance) void
setDown
(boolean down) void
setDrag
(boolean drag) void
setDusted
(boolean dusted) void
void
setEggs
(int eggs) void
setEnabled
(boolean enabled) void
setExtended
(boolean extended) void
setEye
(boolean eye) void
void
void
setFlowerAmount
(int flowerAmount) void
void
setHanging
(boolean hanging) void
setHasBook
(boolean hasBook) void
setHasBottle0
(boolean hasBottle0) void
setHasBottle1
(boolean hasBottle1) void
setHasBottle2
(boolean hasBottle2) void
setHasRecord
(boolean hasRecord) void
setHatch
(int hatch) void
void
setHoneyLevel
(int honeyLevel) void
setInstrument
(Instrument instrument) void
setInverted
(boolean inverted) void
setInWall
(boolean inWall) void
setLayers
(int layers) void
void
setLevel
(int level) void
setLit
(boolean lit) void
setLocked
(boolean locked) void
void
setMoisture
(int moisture) void
setNatural
(boolean natural) Added with 1.21.4void
void
setNote
(int note) void
setOccupied
(boolean occupied) void
setOpen
(boolean open) void
setOrientation
(Orientation orientation) void
void
setPersistent
(boolean persistent) void
setPickles
(int pickles) void
setPower
(int power) void
setPowered
(boolean powered) void
setRotation
(int rotation) void
setSculkSensorPhase
(SculkSensorPhase sculkSensorPhase) void
void
setShort
(boolean short_) void
setShrieking
(boolean shrieking) void
setSignalFire
(boolean signalFire) void
setSlotFiveOccupied
(boolean slotFiveOccupied) void
setSlotFourOccupied
(boolean slotFourOccupied) void
setSlotOneOccupied
(boolean slotOneOccupied) void
setSlotThreeOccupied
(boolean slotThreeOccupied) void
setSlotTwoOccupied
(boolean slotTwoOccupied) void
setSlotZeroOccupied
(boolean slotZeroOccupied) void
setSnowy
(boolean snowy) void
void
setStage
(int stage) void
setThickness
(Thickness thickness) void
void
setTip
(boolean tip) void
setTrialSpawnerState
(TrialSpawnerState trialSpawnerState) void
setTriggered
(boolean triggered) void
setTypeData
(Type type) void
setUnstable
(boolean unstable) void
setUp
(boolean up) void
setVerticalDirection
(VerticalDirection verticalDirection) void
setWaterlogged
(boolean waterlogged) void
toString()
-
Constructor Details
-
WrappedBlockState
@Deprecated public WrappedBlockState(StateType type, String[] data, int globalID, byte mappingsIndex) Deprecated. -
WrappedBlockState
public WrappedBlockState(StateType type, Map<StateValue, Object> data, int globalID, byte mappingsIndex)
-
-
Method Details
-
decode
-
encode
-
getByGlobalId
-
getByGlobalId
-
getByGlobalId
@NotNull public static @NotNull WrappedBlockState getByGlobalId(ClientVersion version, int globalID) -
getByGlobalId
@NotNull public static @NotNull WrappedBlockState getByGlobalId(ClientVersion version, int globalID, boolean clone) -
getByString
-
getByString
-
getByString
@NotNull public static @NotNull WrappedBlockState getByString(ClientVersion version, String string, boolean clone) -
getDefaultState
-
getDefaultState
@NotNull public static @NotNull WrappedBlockState getDefaultState(ClientVersion version, StateType type) -
getDefaultState
@NotNull public static @NotNull WrappedBlockState getDefaultState(ClientVersion version, StateType type, boolean clone) -
clone
-
equals
-
hashCode
public int hashCode() -
getType
-
getAge
public int getAge() -
setAge
public void setAge(int age) -
isAttached
public boolean isAttached() -
setAttached
public void setAttached(boolean attached) -
getAttachment
-
setAttachment
-
getAxis
-
setAxis
-
isBerries
public boolean isBerries() -
setBerries
public void setBerries(boolean berries) -
getBites
public int getBites() -
setBites
public void setBites(int bites) -
isBottom
public boolean isBottom() -
setBottom
public void setBottom(boolean bottom) -
getCandles
public int getCandles() -
setCandles
public void setCandles(int candles) -
getCharges
public int getCharges() -
setCharges
public void setCharges(int charges) -
isConditional
public boolean isConditional() -
setConditional
public void setConditional(boolean conditional) -
getDelay
public int getDelay() -
setDelay
public void setDelay(int delay) -
isDisarmed
public boolean isDisarmed() -
setDisarmed
public void setDisarmed(boolean disarmed) -
getDistance
public int getDistance() -
setDistance
public void setDistance(int distance) -
isDown
public boolean isDown() -
setDown
public void setDown(boolean down) -
isDrag
public boolean isDrag() -
setDrag
public void setDrag(boolean drag) -
isDusted
public boolean isDusted() -
setDusted
public void setDusted(boolean dusted) -
getEggs
public int getEggs() -
setEggs
public void setEggs(int eggs) -
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean enabled) -
isExtended
public boolean isExtended() -
setExtended
public void setExtended(boolean extended) -
isEye
public boolean isEye() -
setEye
public void setEye(boolean eye) -
getFace
-
setFace
-
getFacing
-
setFacing
-
getFlowerAmount
public int getFlowerAmount() -
setFlowerAmount
public void setFlowerAmount(int flowerAmount) -
getHalf
-
setHalf
-
isHanging
public boolean isHanging() -
setHanging
public void setHanging(boolean hanging) -
isHasBook
public boolean isHasBook() -
setHasBook
public void setHasBook(boolean hasBook) -
isHasBottle0
public boolean isHasBottle0() -
setHasBottle0
public void setHasBottle0(boolean hasBottle0) -
isHasBottle1
public boolean isHasBottle1() -
setHasBottle1
public void setHasBottle1(boolean hasBottle1) -
isHasBottle2
public boolean isHasBottle2() -
setHasBottle2
public void setHasBottle2(boolean hasBottle2) -
isHasRecord
public boolean isHasRecord() -
setHasRecord
public void setHasRecord(boolean hasRecord) -
getHatch
public int getHatch() -
setHatch
public void setHatch(int hatch) -
getHinge
-
setHinge
-
getHoneyLevel
public int getHoneyLevel() -
setHoneyLevel
public void setHoneyLevel(int honeyLevel) -
isInWall
public boolean isInWall() -
setInWall
public void setInWall(boolean inWall) -
getInstrument
-
setInstrument
-
isInverted
public boolean isInverted() -
setInverted
public void setInverted(boolean inverted) -
getLayers
public int getLayers() -
setLayers
public void setLayers(int layers) -
getLeaves
-
setLeaves
-
getLevel
public int getLevel() -
setLevel
public void setLevel(int level) -
isLit
public boolean isLit() -
setLit
public void setLit(boolean lit) -
isTip
public boolean isTip() -
setTip
public void setTip(boolean tip) -
isLocked
public boolean isLocked() -
setLocked
public void setLocked(boolean locked) -
getMode
-
setMode
-
getMoisture
public int getMoisture() -
setMoisture
public void setMoisture(int moisture) -
getNorth
-
setNorth
-
getNote
public int getNote() -
setNote
public void setNote(int note) -
isOccupied
public boolean isOccupied() -
setOccupied
public void setOccupied(boolean occupied) -
isShrieking
public boolean isShrieking() -
setShrieking
public void setShrieking(boolean shrieking) -
isCanSummon
public boolean isCanSummon() -
setCanSummon
public void setCanSummon(boolean canSummon) -
isOpen
public boolean isOpen() -
setOpen
public void setOpen(boolean open) -
getOrientation
-
setOrientation
-
getPart
-
setPart
-
isPersistent
public boolean isPersistent() -
setPersistent
public void setPersistent(boolean persistent) -
getPickles
public int getPickles() -
setPickles
public void setPickles(int pickles) -
getPower
public int getPower() -
setPower
public void setPower(int power) -
isPowered
public boolean isPowered() -
setPowered
public void setPowered(boolean powered) -
getRotation
public int getRotation() -
setRotation
public void setRotation(int rotation) -
getSculkSensorPhase
-
setSculkSensorPhase
-
getShape
-
setShape
-
isShort
public boolean isShort() -
setShort
public void setShort(boolean short_) -
isSignalFire
public boolean isSignalFire() -
setSignalFire
public void setSignalFire(boolean signalFire) -
isSlotZeroOccupied
public boolean isSlotZeroOccupied() -
setSlotZeroOccupied
public void setSlotZeroOccupied(boolean slotZeroOccupied) -
isSlotOneOccupied
public boolean isSlotOneOccupied() -
setSlotOneOccupied
public void setSlotOneOccupied(boolean slotOneOccupied) -
isSlotTwoOccupied
public boolean isSlotTwoOccupied() -
setSlotTwoOccupied
public void setSlotTwoOccupied(boolean slotTwoOccupied) -
isSlotThreeOccupied
public boolean isSlotThreeOccupied() -
setSlotThreeOccupied
public void setSlotThreeOccupied(boolean slotThreeOccupied) -
isSlotFourOccupied
public boolean isSlotFourOccupied() -
setSlotFourOccupied
public void setSlotFourOccupied(boolean slotFourOccupied) -
isSlotFiveOccupied
public boolean isSlotFiveOccupied() -
setSlotFiveOccupied
public void setSlotFiveOccupied(boolean slotFiveOccupied) -
isSnowy
public boolean isSnowy() -
setSnowy
public void setSnowy(boolean snowy) -
getStage
public int getStage() -
setStage
public void setStage(int stage) -
getSouth
-
setSouth
-
getThickness
-
setThickness
-
getTilt
-
setTilt
-
isTriggered
public boolean isTriggered() -
setTriggered
public void setTriggered(boolean triggered) -
getTypeData
-
setTypeData
-
isUnstable
public boolean isUnstable() -
setUnstable
public void setUnstable(boolean unstable) -
isUp
public boolean isUp() -
setUp
public void setUp(boolean up) -
getVerticalDirection
-
setVerticalDirection
-
isWaterlogged
public boolean isWaterlogged() -
setWaterlogged
public void setWaterlogged(boolean waterlogged) -
getEast
-
setEast
-
getWest
-
setWest
-
getBloom
-
setBloom
-
isCracked
public boolean isCracked() -
setCracked
public void setCracked(boolean cracked) -
isCrafting
public boolean isCrafting() -
setCrafting
public void setCrafting(boolean crafting) -
getTrialSpawnerState
-
setTrialSpawnerState
-
getCreaking
Removed with 1.21.4 -
setCreaking
Removed with 1.21.4 -
isActive
public boolean isActive()Added with 1.21.4 -
setActive
public void setActive(boolean active) Added with 1.21.4 -
isNatural
public boolean isNatural()Added with 1.21.4 -
setNatural
public void setNatural(boolean natural) Added with 1.21.4 -
getInternalData
Deprecated.This method is helpful if you want to check if a block can be waterlogged, or has other properties.Unless you know what you are doing exactly, don't touch this method! It can result in invalid block types when modified directly
-
getGlobalId
public int getGlobalId()Global ID For pre-1.13: 4 bits of block data, 4 bits empty, 8 bits block type For post-1.13: Global ID- Returns:
-
toString
-
ensureLoad
public static void ensureLoad()
-