-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into conditional-rework
- Loading branch information
Showing
11 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...rm/platform-modern/src/main/java/tc/oc/pgm/platform/modern/material/ModernEncodeUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tc.oc.pgm.platform.modern.material; | ||
|
||
import net.minecraft.world.level.block.Block; | ||
import org.bukkit.block.data.BlockData; | ||
import org.bukkit.craftbukkit.block.data.CraftBlockData; | ||
|
||
class ModernEncodeUtil { | ||
private static final int ENCODED_NULL_MATERIAL = -1; | ||
|
||
static int encode(BlockData blockData) { | ||
return Block.BLOCK_STATE_REGISTRY.getId(((CraftBlockData) blockData).getState()); | ||
} | ||
|
||
static ModernBlockData decode(int encoded) { | ||
if (encoded == ENCODED_NULL_MATERIAL) return null; | ||
var vanillaBlockstate = Block.BLOCK_STATE_REGISTRY.byId(encoded); | ||
if (vanillaBlockstate == null) return null; | ||
return new ModernBlockData(vanillaBlockstate.createCraftBlockData()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...latform-sportpaper/src/main/java/tc/oc/pgm/platform/sportpaper/material/SpEncodeUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tc.oc.pgm.platform.sportpaper.material; | ||
|
||
import org.bukkit.Material; | ||
|
||
@SuppressWarnings("deprecation") | ||
class SpEncodeUtil { | ||
private static final int ENCODED_NULL_MATERIAL = -1; | ||
|
||
static int encode(Material mat, int data) { | ||
return encode(mat.getId(), data); | ||
} | ||
|
||
static int encode(int typeId, int data) { | ||
return typeId + (data << 12); | ||
} | ||
|
||
static SpMaterialData decode(int encoded) { | ||
if (encoded == ENCODED_NULL_MATERIAL) return null; | ||
return new SpMaterialData(decodeMaterial(encoded), decodeData(encoded)); | ||
} | ||
|
||
static Material decodeMaterial(int encoded) { | ||
return Material.getMaterial(encoded & 0xfff); | ||
} | ||
|
||
static byte decodeData(int encoded) { | ||
return (byte) (encoded >> 12); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters