Revive custom ingredient types.

This commit is contained in:
LexManos committed 2023-10-06 21:14:04 -07:00
1 parent 587b684035
commit 5b0abf97c8
47 files changed
+1891 -1353

No files matched your search

@@ -0,0 +1,106 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.util;
import java.util.List;
import java.util.UUID;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
public interface INBTBuilder {
default Builder nbt() {
return new Builder();
}
public static class Builder implements INBTBuilder {
private final CompoundTag tag = new CompoundTag();
public CompoundTag build() {
return tag;
}
public Builder tag(String key, Tag value) {
tag.put(key, value);
return this;
}
public Builder putByte(String key, byte value) {
tag.putByte(key, value);
return this;
}
public Builder putShort(String key, short value) {
tag.putShort(key, value);
return this;
}
public Builder putInt(String key, int value) {
tag.putInt(key, value);
return this;
}
public Builder putLong(String key, long value) {
tag.putLong(key, value);
return this;
}
public Builder putFloat(String key, float value) {
tag.putFloat(key, value);
return this;
}
public Builder putDouble(String key, double value) {
tag.putDouble(key, value);
return this;
}
public Builder putByteArray(String key, byte... value) {
tag.putByteArray(key, value);
return this;
}
public Builder putByteArray(String key, List<Byte> value) {
tag.putByteArray(key, value);
return this;
}
public Builder putIntArray(String key, int... value) {
tag.putIntArray(key, value);
return this;
}
public Builder putIntArray(String key, List<Integer> value) {
tag.putIntArray(key, value);
return this;
}
public Builder putLongArray(String key, long... value) {
tag.putLongArray(key, value);
return this;
}
public Builder putLongArray(String key, List<Long> value) {
tag.putLongArray(key, value);
return this;
}
public Builder put(String key, boolean value) {
tag.putBoolean(key, value);
return this;
}
public Builder put(String key, String value) {
tag.putString(key, value);
return this;
}
public Builder put(String key, UUID value) {
tag.putUUID(key, value);
return this;
}
}
}
@@ -6,7 +6,6 @@
package net.minecraftforge.common.util;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Collections;
import java.util.Enumeration;
@@ -21,32 +20,27 @@ import java.util.TreeSet;
* This is implemented very basically, and thus is not a speedy system.
* This is not recommended for used in high traffic areas, and is mainly intended for writing to disc.
*/
public class SortedProperties extends Properties
{
public class SortedProperties extends Properties {
private static final long serialVersionUID = -8913480931455982442L;
@Override
public Set<Map.Entry<Object, Object>> entrySet()
{
public Set<Map.Entry<Object, Object>> entrySet() {
Set<Map.Entry<Object, Object>> ret = new TreeSet<>((left, right) -> left.getKey().toString().compareTo(right.getKey().toString()));
ret.addAll(super.entrySet());
return ret;
}
@Override
public Set<Object> keySet()
{
public Set<Object> keySet() {
return new TreeSet<>(super.keySet());
}
@Override
public synchronized Enumeration<Object> keys()
{
public synchronized Enumeration<Object> keys() {
return Collections.enumeration(new TreeSet<>(super.keySet()));
}
public static void store(Properties props, Writer stream, String comment) throws IOException
{
public static void store(Properties props, Writer stream, String comment) throws IOException {
SortedProperties sorted = new SortedProperties();
sorted.putAll(props);
sorted.store(stream, comment);