mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-07 07:51:38 +01:00
Fixed HideFlags
This commit is contained in:
parent
d416efad5b
commit
14408e9d15
@ -137,10 +137,10 @@ public class PlayerInit {
|
||||
return;
|
||||
|
||||
if (event.getBlockId() == Block.STONE.getBlockId()) {
|
||||
event.setCustomBlockId((short) 2); // custom stone block
|
||||
event.setCustomBlock((short) 2); // custom stone block
|
||||
}
|
||||
if (event.getBlockId() == Block.TORCH.getBlockId()) {
|
||||
event.setCustomBlockId((short) 3); // custom torch block
|
||||
event.setCustomBlock((short) 3); // custom torch block
|
||||
}
|
||||
|
||||
/*for (Player p : player.getInstance().getPlayers()) {
|
||||
@ -212,21 +212,21 @@ public class PlayerInit {
|
||||
});
|
||||
|
||||
player.addEventCallback(PlayerSpawnEvent.class, event -> {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.teleport(new Position(0, 45, 0));
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.teleport(new Position(0, 41f, 0));
|
||||
|
||||
player.setGlowing(true);
|
||||
|
||||
ItemStack item = new ItemStack(Material.STONE_SWORD, (byte) 1);
|
||||
item.setDisplayName("Item name");
|
||||
item.getLore().add("a lore line");
|
||||
item.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
item.setEnchantment(Enchantment.SHARPNESS, (short) 2);
|
||||
item.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
item.setEnchantment(Enchantment.SHARPNESS, (short) 50);
|
||||
player.getInventory().addItemStack(item);
|
||||
|
||||
player.openInventory(inventory);
|
||||
|
||||
player.getInventory().addItemStack(new ItemStack(Material.STONE, (byte) 100));
|
||||
//player.getInventory().addItemStack(new ItemStack(Material.STONE, (byte) 100));
|
||||
|
||||
Instance instance = player.getInstance();
|
||||
WorldBorder worldBorder = instance.getWorldBorder();
|
||||
@ -256,7 +256,7 @@ public class PlayerInit {
|
||||
});
|
||||
|
||||
player.addEventCallback(PlayerRespawnEvent.class, event -> {
|
||||
event.setRespawnPosition(new Position(0f, 45f, 0f));
|
||||
event.setRespawnPosition(new Position(0f, 41f, 0f));
|
||||
});
|
||||
|
||||
player.addEventCallback(PlayerUseItemEvent.class, useEvent -> {
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.minestom.server.item;
|
||||
|
||||
public enum ItemFlag {
|
||||
|
||||
HIDE_ATTRIBUTES,
|
||||
HIDE_DESTROYS,
|
||||
HIDE_ENCHANTS,
|
||||
HIDE_ATTRIBUTES,
|
||||
HIDE_UNBREAKABLE,
|
||||
HIDE_DESTROYS,
|
||||
HIDE_PLACED_ON,
|
||||
HIDE_POTION_EFFECTS,
|
||||
HIDE_UNBREAKABLE
|
||||
}
|
||||
|
@ -201,6 +201,10 @@ public class ItemStack implements DataContainer {
|
||||
return hideFlag;
|
||||
}
|
||||
|
||||
public void setHideFlag(int hideFlag) {
|
||||
this.hideFlag = hideFlag;
|
||||
}
|
||||
|
||||
public void addItemFlags(ItemFlag... hideFlags) {
|
||||
for (ItemFlag f : hideFlags) {
|
||||
this.hideFlag |= getBitModifier(f);
|
||||
|
@ -153,7 +153,6 @@ public class Utils {
|
||||
// End display
|
||||
|
||||
// Start enchantment
|
||||
// FIXME: something is broken, enchants are basically ignored...
|
||||
{
|
||||
Map<Enchantment, Short> enchantmentMap = itemStack.getEnchantmentMap();
|
||||
if (!enchantmentMap.isEmpty()) {
|
||||
@ -244,14 +243,14 @@ public class Utils {
|
||||
// End potion
|
||||
|
||||
// Start hide flags
|
||||
/*{
|
||||
{
|
||||
int hideFlag = itemStack.getHideFlag();
|
||||
if (hideFlag != 0) {
|
||||
packet.writeByte((byte) 3); // Type id (int)
|
||||
packet.writeShortSizedString("HideFlags");
|
||||
packet.writeInt(hideFlag);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
packet.writeByte((byte) 0); // End nbt
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class NbtReaderUtils {
|
||||
|
||||
byte typeId = reader.readByte();
|
||||
|
||||
System.out.println("DEBUG TYPE: " + typeId);
|
||||
//System.out.println("DEBUG TYPE: " + typeId);
|
||||
switch (typeId) {
|
||||
case 0x00: // TAG_End
|
||||
// End of item NBT
|
||||
@ -55,6 +55,13 @@ public class NbtReaderUtils {
|
||||
item.setUnbreakable(value == 1);
|
||||
readItemStackNBT(reader, item);
|
||||
}
|
||||
|
||||
if (intName.equals("HideFlags")) {
|
||||
int flag = reader.readInteger();
|
||||
item.setHideFlag(flag);
|
||||
readItemStackNBT(reader, item);
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x04: // TAG_Long
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user