Skip to content

Commit bd1f635

Browse files
Fix #111
1 parent b62647a commit bd1f635

54 files changed

Lines changed: 516 additions & 13 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

inventoryaccess/inventory-access-r1/src/main/java/xyz/xenondevs/inventoryaccess/r1/ItemUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.xenondevs.inventoryaccess.r1;
22

3+
import com.mojang.authlib.GameProfile;
34
import net.minecraft.server.v1_14_R1.ItemStack;
45
import net.minecraft.server.v1_14_R1.NBTCompressedStreamTools;
56
import net.minecraft.server.v1_14_R1.NBTTagCompound;
@@ -88,4 +89,13 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
8889
);
8990
}
9091

92+
@Override
93+
public void setSkullProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile profile) {
94+
if (ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD != null) {
95+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, profile);
96+
} else {
97+
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, itemMeta, profile);
98+
}
99+
}
100+
91101
}

inventoryaccess/inventory-access-r1/src/main/java/xyz/xenondevs/inventoryaccess/r1/PlayerUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.xenondevs.inventoryaccess.r1;
22

3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.properties.Property;
35
import net.minecraft.server.v1_14_R1.AdvancementDataPlayer;
46
import net.minecraft.server.v1_14_R1.EntityPlayer;
57
import net.minecraft.server.v1_14_R1.MapIcon;
@@ -15,6 +17,7 @@
1517
import java.lang.reflect.Method;
1618
import java.util.ArrayList;
1719
import java.util.List;
20+
import java.util.UUID;
1821
import java.util.stream.Collectors;
1922

2023
class PlayerUtilsImpl implements PlayerUtils {
@@ -75,4 +78,11 @@ private MapIcon toMapDecoration(xyz.xenondevs.inventoryaccess.map.MapIcon icon)
7578
);
7679
}
7780

81+
@Override
82+
public GameProfile crateGameProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String texture) {
83+
GameProfile gameProfile = new GameProfile(uuid, name);
84+
gameProfile.getProperties().put("textures", new Property("textures", texture));
85+
return gameProfile;
86+
}
87+
7888
}

inventoryaccess/inventory-access-r10/src/main/java/xyz/xenondevs/inventoryaccess/r10/ItemUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.xenondevs.inventoryaccess.r10;
22

3+
import com.mojang.authlib.GameProfile;
34
import net.minecraft.nbt.CompoundTag;
45
import net.minecraft.nbt.NbtIo;
56
import net.minecraft.world.item.ItemStack;
@@ -88,4 +89,13 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
8889
);
8990
}
9091

92+
@Override
93+
public void setSkullProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile profile) {
94+
if (ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD != null) {
95+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, profile);
96+
} else {
97+
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, itemMeta, profile);
98+
}
99+
}
100+
91101
}

inventoryaccess/inventory-access-r10/src/main/java/xyz/xenondevs/inventoryaccess/r10/PlayerUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.xenondevs.inventoryaccess.r10;
22

3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.properties.Property;
35
import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
46
import net.minecraft.server.PlayerAdvancements;
57
import net.minecraft.server.ServerAdvancementManager;
@@ -20,6 +22,7 @@
2022
import java.lang.reflect.Method;
2123
import java.util.ArrayList;
2224
import java.util.List;
25+
import java.util.UUID;
2326
import java.util.stream.Collectors;
2427

2528
class PlayerUtilsImpl implements PlayerUtils {
@@ -80,4 +83,11 @@ private MapItemSavedData.MapPatch toMapPatch(MapPatch patch) {
8083
);
8184
}
8285

86+
@Override
87+
public GameProfile crateGameProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String texture) {
88+
GameProfile gameProfile = new GameProfile(uuid, name);
89+
gameProfile.getProperties().put("textures", new Property("textures", texture));
90+
return gameProfile;
91+
}
92+
8393
}

inventoryaccess/inventory-access-r11/src/main/java/xyz/xenondevs/inventoryaccess/r11/ItemUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.xenondevs.inventoryaccess.r11;
22

3+
import com.mojang.authlib.GameProfile;
34
import net.minecraft.nbt.CompoundTag;
45
import net.minecraft.nbt.NbtIo;
56
import net.minecraft.world.item.ItemStack;
@@ -88,4 +89,13 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
8889
);
8990
}
9091

92+
@Override
93+
public void setSkullProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile profile) {
94+
if (ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD != null) {
95+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, profile);
96+
} else {
97+
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, itemMeta, profile);
98+
}
99+
}
100+
91101
}

inventoryaccess/inventory-access-r11/src/main/java/xyz/xenondevs/inventoryaccess/r11/PlayerUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.xenondevs.inventoryaccess.r11;
22

3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.properties.Property;
35
import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
46
import net.minecraft.server.PlayerAdvancements;
57
import net.minecraft.server.ServerAdvancementManager;
@@ -20,6 +22,7 @@
2022
import java.lang.reflect.Method;
2123
import java.util.ArrayList;
2224
import java.util.List;
25+
import java.util.UUID;
2326
import java.util.stream.Collectors;
2427

2528
class PlayerUtilsImpl implements PlayerUtils {
@@ -80,4 +83,11 @@ private MapItemSavedData.MapPatch toMapPatch(MapPatch patch) {
8083
);
8184
}
8285

86+
@Override
87+
public GameProfile crateGameProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String texture) {
88+
GameProfile gameProfile = new GameProfile(uuid, name);
89+
gameProfile.getProperties().put("textures", new Property("textures", texture));
90+
return gameProfile;
91+
}
92+
8393
}

inventoryaccess/inventory-access-r12/src/main/java/xyz/xenondevs/inventoryaccess/r12/ItemUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.xenondevs.inventoryaccess.r12;
22

3+
import com.mojang.authlib.GameProfile;
34
import net.minecraft.nbt.CompoundTag;
45
import net.minecraft.nbt.NbtIo;
56
import net.minecraft.world.item.ItemStack;
@@ -88,4 +89,13 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
8889
);
8990
}
9091

92+
@Override
93+
public void setSkullProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile profile) {
94+
if (ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD != null) {
95+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, profile);
96+
} else {
97+
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, itemMeta, profile);
98+
}
99+
}
100+
91101
}

inventoryaccess/inventory-access-r12/src/main/java/xyz/xenondevs/inventoryaccess/r12/PlayerUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.xenondevs.inventoryaccess.r12;
22

3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.properties.Property;
35
import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
46
import net.minecraft.server.PlayerAdvancements;
57
import net.minecraft.server.ServerAdvancementManager;
@@ -20,6 +22,7 @@
2022
import java.lang.reflect.Method;
2123
import java.util.ArrayList;
2224
import java.util.List;
25+
import java.util.UUID;
2326
import java.util.stream.Collectors;
2427

2528
class PlayerUtilsImpl implements PlayerUtils {
@@ -80,4 +83,11 @@ private MapItemSavedData.MapPatch toMapPatch(MapPatch patch) {
8083
);
8184
}
8285

86+
@Override
87+
public GameProfile crateGameProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String texture) {
88+
GameProfile gameProfile = new GameProfile(uuid, name);
89+
gameProfile.getProperties().put("textures", new Property("textures", texture));
90+
return gameProfile;
91+
}
92+
8393
}

inventoryaccess/inventory-access-r13/src/main/java/xyz/xenondevs/inventoryaccess/r13/ItemUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.xenondevs.inventoryaccess.r13;
22

3+
import com.mojang.authlib.GameProfile;
34
import net.minecraft.nbt.CompoundTag;
45
import net.minecraft.nbt.NbtIo;
56
import net.minecraft.world.item.ItemStack;
@@ -88,4 +89,13 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
8889
);
8990
}
9091

92+
@Override
93+
public void setSkullProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile profile) {
94+
if (ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD != null) {
95+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, profile);
96+
} else {
97+
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, itemMeta, profile);
98+
}
99+
}
100+
91101
}

inventoryaccess/inventory-access-r13/src/main/java/xyz/xenondevs/inventoryaccess/r13/PlayerUtilsImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.xenondevs.inventoryaccess.r13;
22

3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.properties.Property;
35
import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
46
import net.minecraft.server.PlayerAdvancements;
57
import net.minecraft.server.ServerAdvancementManager;
@@ -20,6 +22,7 @@
2022
import java.lang.reflect.Method;
2123
import java.util.ArrayList;
2224
import java.util.List;
25+
import java.util.UUID;
2326
import java.util.stream.Collectors;
2427

2528
class PlayerUtilsImpl implements PlayerUtils {
@@ -80,4 +83,11 @@ private MapItemSavedData.MapPatch toMapPatch(MapPatch patch) {
8083
);
8184
}
8285

86+
@Override
87+
public GameProfile crateGameProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String texture) {
88+
GameProfile gameProfile = new GameProfile(uuid, name);
89+
gameProfile.getProperties().put("textures", new Property("textures", texture));
90+
return gameProfile;
91+
}
92+
8393
}

0 commit comments

Comments
 (0)