Skip to content

Commit 64ab4f5

Browse files
committed
more fixes to the vanilla support for 1.20.5+
1 parent c677d09 commit 64ab4f5

File tree

4 files changed

+510
-239
lines changed

4 files changed

+510
-239
lines changed

Item Creator/src/main/java/org/broken/arrow/library/itemcreator/utility/compound/CompoundTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* and no changes will be applied to the compound.</p>
2626
*
2727
*/
28-
public final class CompoundTag {
28+
public class CompoundTag {
2929
private final CompoundEditor compoundSession;
3030

3131
/**
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.broken.arrow.library.itemcreator.utility.compound;
2+
3+
import org.broken.arrow.library.itemcreator.utility.nms.ComponentItemDataSession;
4+
5+
import javax.annotation.Nonnull;
6+
7+
public final class VanillaCompoundTag extends CompoundTag {
8+
9+
private final ComponentItemDataSession.VanillaComponentSession vanillaSession;
10+
11+
/**
12+
* Create the base Component to set Minecraft data like minecraft:damage.
13+
*
14+
* @param base the component object (not used).
15+
* @param vanillaSession the section of the vanilla wrapper for the data set.
16+
*/
17+
public VanillaCompoundTag(@Nonnull final Object base,@Nonnull final ComponentItemDataSession.VanillaComponentSession vanillaSession) {
18+
super(base);
19+
this.vanillaSession = vanillaSession;
20+
}
21+
22+
@Override
23+
public void setInt(String key, int value) {
24+
vanillaSession.setInt(key, value);
25+
}
26+
27+
@Override
28+
public void setString(String key, String value) {
29+
vanillaSession.setValue(key, value);
30+
}
31+
32+
@Override
33+
public void remove(String key) {
34+
vanillaSession.remove(key);
35+
}
36+
37+
@Override
38+
public boolean hasKey(String key) {
39+
return vanillaSession.hasKey(key);
40+
}
41+
42+
@Override
43+
public int getInt(String key) {
44+
Object o = vanillaSession.getRaw(key);
45+
return (o instanceof Integer) ? (int) o : -1;
46+
}
47+
48+
@Override
49+
public String getString(String key) {
50+
Object o = vanillaSession.getRaw(key);
51+
return (o instanceof String) ? o.toString() : "";
52+
}
53+
}

0 commit comments

Comments
 (0)