mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
1.20.2-pre1
This commit is contained in:
368 files changed
+3555
-6356
No files matched your search
@@ -105,6 +105,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.FilteredText;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
@@ -127,9 +128,6 @@ import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||
import net.minecraftforge.common.loot.LootModifierManager;
|
||||
import net.minecraftforge.common.loot.LootTableIdCondition;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.BrainBuilder;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
@@ -400,29 +398,13 @@ public class ForgeHooks
|
||||
return !MinecraftForge.EVENT_BUS.post(new VanillaGameEvent(level, vanillaEvent, pos, context));
|
||||
}
|
||||
|
||||
private static String getRawText(Component message)
|
||||
{
|
||||
return message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Component onServerChatSubmittedEvent(ServerPlayer player, String plain, Component decorated)
|
||||
{
|
||||
ServerChatEvent event = new ServerChatEvent(player, plain, decorated);
|
||||
public static Component onServerChatSubmittedEvent(ServerPlayer player, Component message) {
|
||||
var plain = message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : "";
|
||||
ServerChatEvent event = new ServerChatEvent(player, plain, message);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ChatDecorator getServerChatSubmittedDecorator()
|
||||
{
|
||||
return (sender, message) -> CompletableFuture.supplyAsync(() -> {
|
||||
if (sender == null)
|
||||
return message; // Vanilla should never get here with the patches we use, but let's be safe with dumb mods
|
||||
|
||||
return onServerChatSubmittedEvent(sender, getRawText(message), message);
|
||||
});
|
||||
}
|
||||
|
||||
static final Pattern URL_PATTERN = Pattern.compile(
|
||||
// schema ipv4 OR namespace port path ends
|
||||
// |-----------------| |-------------------------| |-------------------------| |---------| |--| |---------------|
|
||||
@@ -738,13 +720,6 @@ public class ForgeHooks
|
||||
return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target);
|
||||
}
|
||||
|
||||
public static boolean onTravelToDimension(Entity entity, ResourceKey<Level> dimension)
|
||||
{
|
||||
EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
public static InteractionResult onInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand)
|
||||
{
|
||||
Vec3 vec3d = ray.getLocation().subtract(entity.position());
|
||||
@@ -812,21 +787,18 @@ public class ForgeHooks
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null if game type should not be changed, desired new GameType otherwise
|
||||
*/
|
||||
@Nullable
|
||||
public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType)
|
||||
{
|
||||
if (currentGameType != newGameType)
|
||||
{
|
||||
PlayerEvent.PlayerChangeGameModeEvent evt = new PlayerEvent.PlayerChangeGameModeEvent(player, currentGameType, newGameType);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.isCanceled() ? null : evt.getNewGameMode();
|
||||
}
|
||||
return newGameType;
|
||||
public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType) {
|
||||
if (currentGameType == newGameType)
|
||||
return currentGameType;
|
||||
|
||||
var evt = new PlayerEvent.PlayerChangeGameModeEvent(player, currentGameType, newGameType);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
return currentGameType;
|
||||
|
||||
return evt.getNewGameMode();
|
||||
}
|
||||
|
||||
/* TODO: GLM
|
||||
private static final ThreadLocal<Deque<LootTableContext>> lootContext = new ThreadLocal<>();
|
||||
private static LootTableContext getLootTableContext()
|
||||
{
|
||||
@@ -918,6 +890,7 @@ public class ForgeHooks
|
||||
|
||||
return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a vanilla fluid type for the given fluid.
|
||||
@@ -1147,6 +1120,7 @@ public class ForgeHooks
|
||||
FurnaceBlockEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(e.getKey()), e.getValue()));
|
||||
}
|
||||
|
||||
// TODO: GLM
|
||||
/**
|
||||
* All loot table drops should be passed to this function so that mod added effects
|
||||
* (e.g. smelting enchantments) can be processed.
|
||||
@@ -1159,7 +1133,7 @@ public class ForgeHooks
|
||||
*
|
||||
* @implNote This method will use the {@linkplain LootTableIdCondition#UNKNOWN_LOOT_TABLE
|
||||
* unknown loot table marker} when redirecting.
|
||||
*/
|
||||
* /
|
||||
@Deprecated
|
||||
public static List<ItemStack> modifyLoot(List<ItemStack> list, LootContext context) {
|
||||
return modifyLoot(LootTableIdCondition.UNKNOWN_LOOT_TABLE, ObjectArrayList.wrap((ItemStack[]) list.toArray()), context);
|
||||
@@ -1178,7 +1152,7 @@ public class ForgeHooks
|
||||
*
|
||||
* @apiNote The given context will be modified by this method to also store the ID of the
|
||||
* loot table being queried.
|
||||
*/
|
||||
* /
|
||||
public static ObjectArrayList<ItemStack> modifyLoot(ResourceLocation lootTableId, ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
context.setQueriedLootTableId(lootTableId); // In case the ID was set via copy constructor, this will be ignored: intended
|
||||
LootModifierManager man = ForgeInternalHandler.getLootModifierManager();
|
||||
@@ -1187,6 +1161,7 @@ public class ForgeHooks
|
||||
}
|
||||
return generatedLoot;
|
||||
}
|
||||
*/
|
||||
|
||||
public static List<String> getModPacks()
|
||||
{
|
||||
@@ -1417,33 +1392,6 @@ public class ForgeHooks
|
||||
throw new IllegalArgumentException("Unknown lifecycle.");
|
||||
}
|
||||
|
||||
public static void saveMobEffect(CompoundTag nbt, String key, MobEffect effect)
|
||||
{
|
||||
var registryName = ForgeRegistries.MOB_EFFECTS.getKey(effect);
|
||||
if (registryName != null)
|
||||
{
|
||||
nbt.putString(key, registryName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static MobEffect loadMobEffect(CompoundTag nbt, String key, @Nullable MobEffect fallback)
|
||||
{
|
||||
var registryName = nbt.getString(key);
|
||||
if (Strings.isNullOrEmpty(registryName))
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
try
|
||||
{
|
||||
return ForgeRegistries.MOB_EFFECTS.getValue(new ResourceLocation(registryName));
|
||||
}
|
||||
catch (ResourceLocationException e)
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask)
|
||||
{
|
||||
return mask.isEnderMask(player, enderMan) || MinecraftForge.EVENT_BUS.post(new EnderManAngerEvent(enderMan, player));
|
||||
@@ -1474,40 +1422,6 @@ public class ForgeHooks
|
||||
return biomeLocation != null && !biomeLocation.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE);
|
||||
}
|
||||
|
||||
public static Map<PackType, Integer> readTypedPackFormats(JsonObject json)
|
||||
{
|
||||
ImmutableMap.Builder<PackType, Integer> map = ImmutableMap.builder();
|
||||
|
||||
for (PackType packType : PackType.values())
|
||||
{
|
||||
String key = makePackFormatKey(packType);
|
||||
if (json.has(key))
|
||||
{
|
||||
map.put(packType, GsonHelper.getAsInt(json, key));
|
||||
}
|
||||
}
|
||||
|
||||
return map.buildOrThrow();
|
||||
}
|
||||
|
||||
public static void writeTypedPackFormats(JsonObject json, PackMetadataSection section)
|
||||
{
|
||||
int packFormat = section.getPackFormat();
|
||||
for (PackType packType : PackType.values())
|
||||
{
|
||||
int format = section.getPackFormat(packType);
|
||||
if (format != packFormat)
|
||||
{
|
||||
json.addProperty(makePackFormatKey(packType), format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String makePackFormatKey(PackType packType)
|
||||
{
|
||||
return "forge:" + packType.name().toLowerCase(Locale.ROOT) + "_pack_format";
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft
|
||||
@@ -1569,7 +1483,7 @@ public class ForgeHooks
|
||||
*/
|
||||
public static void onLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount)
|
||||
{
|
||||
// Check things that vanilla considers to be air - these will cause the air supply to be increased.
|
||||
// Check things that vanilla considers to be air - these will cause the air supply to be increased.
|
||||
boolean isAir = entity.getEyeInFluidType().isAir() || entity.level().getBlockState(BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ())).is(Blocks.BUBBLE_COLUMN);
|
||||
// The following effects cause the entity to not drown, but do not cause the air supply to be increased.
|
||||
boolean canBreathe = !entity.canDrownInFluidType(entity.getEyeInFluidType()) || MobEffectUtil.hasWaterBreathing(entity) || (entity instanceof Player && ((Player) entity).getAbilities().invulnerable);
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.server.TickTask;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.common.loot.LootModifierManager;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
@@ -114,6 +113,7 @@ public class ForgeInternalHandler
|
||||
ConfigCommand.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
/*
|
||||
private static LootModifierManager INSTANCE;
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -129,6 +129,7 @@ public class ForgeInternalHandler
|
||||
throw new IllegalStateException("Can not retrieve LootModifierManager until resources have loaded once.");
|
||||
return INSTANCE;
|
||||
}
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void resourceReloadListeners(AddReloadListenerEvent event)
|
||||
|
||||
@@ -43,9 +43,6 @@ import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.common.crafting.PartialNBTIngredient;
|
||||
import net.minecraftforge.common.crafting.DifferenceIngredient;
|
||||
import net.minecraftforge.common.crafting.IntersectionIngredient;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.common.data.ForgeBiomeTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeFluidTagsProvider;
|
||||
@@ -53,8 +50,6 @@ import net.minecraftforge.common.data.ForgeSpriteSourceProvider;
|
||||
import net.minecraftforge.common.data.VanillaSoundDefinitionsProvider;
|
||||
import net.minecraftforge.common.extensions.IForgeEntity;
|
||||
import net.minecraftforge.common.extensions.IForgePlayer;
|
||||
import net.minecraftforge.common.loot.CanToolPerformAction;
|
||||
import net.minecraftforge.common.loot.LootTableIdCondition;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.common.world.ForgeBiomeModifiers.AddFeaturesBiomeModifier;
|
||||
import net.minecraftforge.common.world.ForgeBiomeModifiers.AddSpawnsBiomeModifier;
|
||||
@@ -80,7 +75,6 @@ import net.minecraftforge.network.NetworkConstants;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.network.filters.VanillaPacketSplitter;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
import net.minecraftforge.server.command.ModIdArgument;
|
||||
import net.minecraftforge.server.permission.events.PermissionGatherEvent;
|
||||
@@ -94,11 +88,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CompoundIngredient;
|
||||
import net.minecraftforge.common.crafting.ConditionalRecipe;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.StrictNBTIngredient;
|
||||
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
|
||||
import net.minecraftforge.common.crafting.conditions.AndCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.FalseCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.ItemExistsCondition;
|
||||
@@ -110,7 +100,6 @@ import net.minecraftforge.common.crafting.conditions.TrueCondition;
|
||||
import net.minecraftforge.common.data.ForgeBlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeEntityTypeTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeItemTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeLootTableProvider;
|
||||
import net.minecraftforge.common.data.ForgeRecipeProvider;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -476,7 +465,7 @@ public class ForgeMod
|
||||
public void preInit(FMLCommonSetupEvent evt)
|
||||
{
|
||||
VersionChecker.startVersionCheck();
|
||||
VanillaPacketSplitter.register();
|
||||
//VanillaPacketSplitter.register();
|
||||
}
|
||||
|
||||
public void loadComplete(FMLLoadCompleteEvent event)
|
||||
@@ -501,11 +490,11 @@ public class ForgeMod
|
||||
|
||||
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||
gen.addProvider(true, new PackMetadataGenerator(packOutput)
|
||||
.add(PackMetadataSection.TYPE, new PackMetadataSection(
|
||||
Component.translatable("pack.forge.description"),
|
||||
DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES),
|
||||
Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion))
|
||||
))
|
||||
.add(PackMetadataSection.TYPE, new PackMetadataSection(
|
||||
Component.translatable("pack.forge.description"),
|
||||
DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES),
|
||||
Optional.empty() //Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion))
|
||||
))
|
||||
);
|
||||
ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(packOutput, lookupProvider, existingFileHelper);
|
||||
gen.addProvider(event.includeServer(), blockTags);
|
||||
@@ -513,7 +502,7 @@ public class ForgeMod
|
||||
gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput));
|
||||
gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput));
|
||||
//gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput));
|
||||
gen.addProvider(event.includeServer(), new ForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
|
||||
gen.addProvider(event.includeClient(), new ForgeSpriteSourceProvider(packOutput, existingFileHelper));
|
||||
@@ -621,14 +610,16 @@ public class ForgeMod
|
||||
CraftingHelper.register(TrueCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(TagEmptyCondition.Serializer.INSTANCE);
|
||||
|
||||
/*
|
||||
CraftingHelper.register(new ResourceLocation("forge", "compound"), CompoundIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("forge", "nbt"), StrictNBTIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("forge", "partial_nbt"), PartialNBTIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("forge", "difference"), DifferenceIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("forge", "intersection"), IntersectionIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("minecraft", "item"), VanillaIngredientSerializer.INSTANCE);
|
||||
*/
|
||||
|
||||
event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, new ResourceLocation("forge", "conditional"), ConditionalRecipe.Serializer::new);
|
||||
//event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, new ResourceLocation("forge", "conditional"), ConditionalRecipe.Serializer::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,8 +628,8 @@ public class ForgeMod
|
||||
if (!event.getRegistryKey().equals(Registries.LOOT_CONDITION_TYPE))
|
||||
return;
|
||||
|
||||
event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID);
|
||||
event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE);
|
||||
//event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID);
|
||||
//event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE);
|
||||
}
|
||||
|
||||
public static final PermissionNode<Boolean> USE_SELECTORS_PERMISSION = new PermissionNode<>("forge", "use_entity_selectors",
|
||||
|
||||
@@ -351,7 +351,7 @@ public class TierSortingRegistry
|
||||
|
||||
private static void syncToPlayer(ServerPlayer serverPlayer)
|
||||
{
|
||||
if (SYNC_CHANNEL.isRemotePresent(serverPlayer.connection.connection) && !serverPlayer.connection.connection.isMemoryConnection())
|
||||
if (SYNC_CHANNEL.isRemotePresent(serverPlayer.connection.getConnection()) && !serverPlayer.connection.getConnection().isMemoryConnection())
|
||||
{
|
||||
SYNC_CHANNEL.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new SyncPacket(sortedTiers.stream().map(TierSortingRegistry::getName).toList()));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.tags.TagKey;
|
||||
@@ -19,18 +19,15 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Extension of {@link Ingredient} which makes most methods custom ingredients need to implement abstract, and removes the static constructors
|
||||
* Mods are encouraged to extend this class for their custom ingredients
|
||||
*/
|
||||
public abstract class AbstractIngredient extends Ingredient
|
||||
{
|
||||
/** Empty constructor, for the sake of dynamic ingredients */
|
||||
protected AbstractIngredient()
|
||||
{
|
||||
* /
|
||||
public abstract class AbstractIngredient extends Ingredient {
|
||||
/** Empty constructor, for the sake of dynamic ingredients * /
|
||||
protected AbstractIngredient() {
|
||||
super(Stream.of());
|
||||
}
|
||||
|
||||
/** Value constructor, for ingredients that have some vanilla representation */
|
||||
protected AbstractIngredient(Stream<? extends Value> values)
|
||||
{
|
||||
/** Value constructor, for ingredients that have some vanilla representation * /
|
||||
protected AbstractIngredient(Stream<? extends Value> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
@@ -41,64 +38,57 @@ public abstract class AbstractIngredient extends Ingredient
|
||||
public abstract IIngredientSerializer<? extends Ingredient> getSerializer();
|
||||
|
||||
@Override
|
||||
public abstract JsonElement toJson();
|
||||
public abstract JsonElement toJson(boolean allowEmpty);
|
||||
|
||||
|
||||
/* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients */
|
||||
/* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients * /
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromValues(Stream)} */
|
||||
/** @deprecated use {@link Ingredient#fromValues(Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromValues(Stream<? extends Ingredient.Value> values)
|
||||
{
|
||||
public static Ingredient fromValues(Stream<? extends Ingredient.Value> values) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromValues()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of()} */
|
||||
/** @deprecated use {@link Ingredient#of()} * /
|
||||
@Deprecated
|
||||
public static Ingredient of()
|
||||
{
|
||||
public static Ingredient of() {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(ItemLike... items)
|
||||
{
|
||||
public static Ingredient of(ItemLike... items) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(ItemStack... stacks)
|
||||
{
|
||||
public static Ingredient of(ItemStack... stacks) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(Stream)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(Stream)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(Stream<ItemStack> stacks)
|
||||
{
|
||||
public static Ingredient of(Stream<ItemStack> stacks) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(TagKey<Item> tag)
|
||||
{
|
||||
public static Ingredient of(TagKey<Item> tag) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} */
|
||||
/** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromNetwork(FriendlyByteBuf buffer)
|
||||
{
|
||||
public static Ingredient fromNetwork(FriendlyByteBuf buffer) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromNetwork()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromJson(@Nullable JsonElement json)
|
||||
{
|
||||
public static Ingredient fromJson(@Nullable JsonElement json) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromJson()");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Ingredient that matches if any of the child ingredients match */
|
||||
/** Ingredient that matches if any of the child ingredients match * /
|
||||
public class CompoundIngredient extends AbstractIngredient
|
||||
{
|
||||
private List<Ingredient> children;
|
||||
@@ -41,7 +41,7 @@ public class CompoundIngredient extends AbstractIngredient
|
||||
this.isSimple = children.stream().allMatch(Ingredient::isSimple);
|
||||
}
|
||||
|
||||
/** Creates a compound ingredient from the given list of ingredients */
|
||||
/** Creates a compound ingredient from the given list of ingredients * /
|
||||
public static Ingredient of(Ingredient... children)
|
||||
{
|
||||
// if 0 or 1 ingredient, can save effort
|
||||
@@ -182,3 +182,4 @@ public class CompoundIngredient extends AbstractIngredient
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -32,7 +32,7 @@ public class ConditionalAdvancement
|
||||
* Processes the conditional advancement during loading.
|
||||
* @param json The incoming json from the advancement file.
|
||||
* @return The advancement that passed the conditions, or null if none did.
|
||||
*/
|
||||
* /
|
||||
@Nullable
|
||||
public static JsonObject processConditional(JsonObject json, ICondition.IContext context) {
|
||||
JsonArray entries = GsonHelper.getAsJsonArray(json, "advancements", null);
|
||||
@@ -128,3 +128,4 @@ public class ConditionalAdvancement
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/* TODO: Conditional Recipes
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -14,6 +14,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
@@ -153,6 +154,7 @@ public class ConditionalRecipe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Finished implements FinishedRecipe
|
||||
{
|
||||
private final ResourceLocation id;
|
||||
@@ -189,19 +191,21 @@ public class ConditionalRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
public ResourceLocation id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getType()
|
||||
public RecipeSerializer<?> type()
|
||||
{
|
||||
return SERIALZIER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject serializeAdvancement() {
|
||||
return adv == null ? null : adv.write();
|
||||
public AdvancementHolder advancement() {
|
||||
if (adv == null)
|
||||
return null;
|
||||
return new AdvancementHolder(advId, adv.)
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,3 +214,4 @@ public class ConditionalRecipe
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -6,13 +6,9 @@
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -24,12 +20,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -38,28 +32,18 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CraftingHelper
|
||||
{
|
||||
public class CraftingHelper {
|
||||
@SuppressWarnings("unused")
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@SuppressWarnings("unused")
|
||||
private static final Marker CRAFTHELPER = MarkerManager.getMarker("CRAFTHELPER");
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Map<ResourceLocation, IConditionSerializer<?>> conditions = new HashMap<>();
|
||||
/* TODO: Custom Ingredients
|
||||
private static final BiMap<ResourceLocation, IIngredientSerializer<?>> ingredients = HashBiMap.create();
|
||||
|
||||
public static IConditionSerializer<?> register(IConditionSerializer<?> serializer)
|
||||
{
|
||||
ResourceLocation key = serializer.getID();
|
||||
if (conditions.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe condition serializer: " + key);
|
||||
conditions.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
public static <T extends Ingredient> IIngredientSerializer<T> register(ResourceLocation key, IIngredientSerializer<T> serializer)
|
||||
{
|
||||
|
||||
public static <T extends Ingredient> IIngredientSerializer<T> register(ResourceLocation key, IIngredientSerializer<T> serializer) {
|
||||
if (ingredients.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe ingredient serializer: " + key);
|
||||
if (ingredients.containsValue(serializer))
|
||||
@@ -67,45 +51,40 @@ public class CraftingHelper
|
||||
ingredients.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation getID(IIngredientSerializer<?> serializer)
|
||||
{
|
||||
public static ResourceLocation getID(IIngredientSerializer<?> serializer) {
|
||||
return ingredients.inverse().get(serializer);
|
||||
}
|
||||
public static <T extends Ingredient> void write(FriendlyByteBuf buffer, T ingredient)
|
||||
{
|
||||
|
||||
public static <T extends Ingredient> void write(FriendlyByteBuf buffer, T ingredient) {
|
||||
@SuppressWarnings("unchecked") //I wonder if there is a better way generic wise...
|
||||
IIngredientSerializer<T> serializer = (IIngredientSerializer<T>)ingredient.getSerializer();
|
||||
ResourceLocation key = ingredients.inverse().get(serializer);
|
||||
if (key == null)
|
||||
throw new IllegalArgumentException("Tried to serialize unregistered Ingredient: " + ingredient + " " + serializer);
|
||||
if (serializer != VanillaIngredientSerializer.INSTANCE)
|
||||
{
|
||||
if (serializer != VanillaIngredientSerializer.INSTANCE) {
|
||||
buffer.writeVarInt(-1); //Marker to know there is a custom ingredient
|
||||
buffer.writeResourceLocation(key);
|
||||
}
|
||||
serializer.write(buffer, ingredient);
|
||||
}
|
||||
|
||||
public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer)
|
||||
{
|
||||
public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer) {
|
||||
IIngredientSerializer<?> serializer = ingredients.get(type);
|
||||
if (serializer == null)
|
||||
throw new IllegalArgumentException("Can not deserialize unknown Ingredient type: " + type);
|
||||
return serializer.parse(buffer);
|
||||
}
|
||||
|
||||
public static Ingredient getIngredient(JsonElement json, boolean allowEmpty)
|
||||
{
|
||||
public static Ingredient getIngredient(JsonElement json, boolean allowEmpty) {
|
||||
if (json == null || json.isJsonNull())
|
||||
throw new JsonSyntaxException("Json cannot be null");
|
||||
|
||||
if (json.isJsonArray())
|
||||
{
|
||||
if (json.isJsonArray()) {
|
||||
List<Ingredient> ingredients = Lists.newArrayList();
|
||||
List<Ingredient> vanilla = Lists.newArrayList();
|
||||
json.getAsJsonArray().forEach((ele) ->
|
||||
{
|
||||
json.getAsJsonArray().forEach((ele) -> {
|
||||
Ingredient ing = CraftingHelper.getIngredient(ele, allowEmpty);
|
||||
|
||||
if (ing.getClass() == Ingredient.class) //Vanilla, Due to how we read it splits each itemstack, so we pull out to re-merge later
|
||||
@@ -117,12 +96,9 @@ public class CraftingHelper
|
||||
if (!vanilla.isEmpty())
|
||||
ingredients.add(Ingredient.merge(vanilla));
|
||||
|
||||
if (ingredients.size() == 0)
|
||||
{
|
||||
if (ingredients.size() == 0) {
|
||||
if (allowEmpty)
|
||||
{
|
||||
return Ingredient.EMPTY;
|
||||
}
|
||||
throw new JsonSyntaxException("Item array cannot be empty, at least one item must be defined");
|
||||
}
|
||||
|
||||
@@ -147,14 +123,13 @@ public class CraftingHelper
|
||||
|
||||
return serializer.parse(obj);
|
||||
}
|
||||
*/
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT)
|
||||
{
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT) {
|
||||
return getItemStack(json, readNBT, false);
|
||||
}
|
||||
|
||||
public static Item getItem(String itemName, boolean disallowsAirInRecipe)
|
||||
{
|
||||
public static Item getItem(String itemName, boolean disallowsAirInRecipe) {
|
||||
ResourceLocation itemKey = new ResourceLocation(itemName);
|
||||
if (!ForgeRegistries.ITEMS.containsKey(itemKey))
|
||||
throw new JsonSyntaxException("Unknown item '" + itemName + "'");
|
||||
@@ -165,31 +140,24 @@ public class CraftingHelper
|
||||
return Objects.requireNonNull(item);
|
||||
}
|
||||
|
||||
public static CompoundTag getNBT(JsonElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static CompoundTag getNBT(JsonElement element) {
|
||||
try {
|
||||
if (element.isJsonObject())
|
||||
return TagParser.parseTag(GSON.toJson(element));
|
||||
else
|
||||
return TagParser.parseTag(GsonHelper.convertToString(element, "nbt"));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
} catch (CommandSyntaxException e) {
|
||||
throw new JsonSyntaxException("Invalid NBT Entry: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe)
|
||||
{
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe) {
|
||||
String itemName = GsonHelper.getAsString(json, "item");
|
||||
Item item = getItem(itemName, disallowsAirInRecipe);
|
||||
if (readNBT && json.has("nbt"))
|
||||
{
|
||||
if (readNBT && json.has("nbt")) {
|
||||
CompoundTag nbt = getNBT(json.get("nbt"));
|
||||
CompoundTag tmp = new CompoundTag();
|
||||
if (nbt.contains("ForgeCaps"))
|
||||
{
|
||||
if (nbt.contains("ForgeCaps")) {
|
||||
tmp.put("ForgeCaps", nbt.get("ForgeCaps"));
|
||||
nbt.remove("ForgeCaps");
|
||||
}
|
||||
@@ -204,13 +172,21 @@ public class CraftingHelper
|
||||
return new ItemStack(item, GsonHelper.getAsInt(json, "count", 1));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context)
|
||||
{
|
||||
// CONDITIONS
|
||||
private static final Map<ResourceLocation, IConditionSerializer<?>> conditions = new HashMap<>();
|
||||
public static IConditionSerializer<?> register(IConditionSerializer<?> serializer) {
|
||||
ResourceLocation key = serializer.getID();
|
||||
if (conditions.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe condition serializer: " + key);
|
||||
conditions.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context) {
|
||||
return !json.has(memberName) || processConditions(GsonHelper.getAsJsonArray(json, memberName), context);
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonArray conditions, ICondition.IContext context)
|
||||
{
|
||||
public static boolean processConditions(JsonArray conditions, ICondition.IContext context) {
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
{
|
||||
if (!conditions.get(x).isJsonObject())
|
||||
@@ -223,8 +199,7 @@ public class CraftingHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ICondition getCondition(JsonObject json)
|
||||
{
|
||||
public static ICondition getCondition(JsonObject json) {
|
||||
ResourceLocation type = new ResourceLocation(GsonHelper.getAsString(json, "type"));
|
||||
IConditionSerializer<?> serializer = conditions.get(type);
|
||||
if (serializer == null)
|
||||
@@ -232,8 +207,7 @@ public class CraftingHelper
|
||||
return serializer.read(json);
|
||||
}
|
||||
|
||||
public static <T extends ICondition> JsonObject serialize(T condition)
|
||||
{
|
||||
public static <T extends ICondition> JsonObject serialize(T condition) {
|
||||
@SuppressWarnings("unchecked")
|
||||
IConditionSerializer<T> serializer = (IConditionSerializer<T>)conditions.get(condition.getID());
|
||||
if (serializer == null)
|
||||
@@ -241,13 +215,10 @@ public class CraftingHelper
|
||||
return serializer.getJson(condition);
|
||||
}
|
||||
|
||||
public static JsonArray serialize(ICondition... conditions)
|
||||
{
|
||||
public static JsonArray serialize(ICondition... conditions) {
|
||||
JsonArray arr = new JsonArray();
|
||||
for(ICondition iCond : conditions)
|
||||
{
|
||||
arr.add(serialize(iCond));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient */
|
||||
/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient * /
|
||||
public class DifferenceIngredient extends AbstractIngredient
|
||||
{
|
||||
private final Ingredient base;
|
||||
@@ -37,7 +37,7 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
* @param base Ingredient the item must match
|
||||
* @param subtracted Ingredient the item must not match
|
||||
* @return Ingredient that {@code base} anything in base that is not in {@code subtracted}
|
||||
*/
|
||||
* /
|
||||
public static DifferenceIngredient of(Ingredient base, Ingredient subtracted)
|
||||
{
|
||||
return new DifferenceIngredient(base, subtracted);
|
||||
@@ -98,12 +98,12 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson()
|
||||
public JsonElement toJson(boolean allowEmpty)
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("type", CraftingHelper.getID(Serializer.INSTANCE).toString());
|
||||
json.add("base", base.toJson());
|
||||
json.add("subtracted", subtracted.toJson());
|
||||
json.add("base", base.toJson(allowEmpty));
|
||||
json.add("subtracted", subtracted.toJson(allowEmpty));
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -113,8 +113,7 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
public static class Serializer implements IIngredientSerializer<DifferenceIngredient>
|
||||
{
|
||||
public static class Serializer implements IIngredientSerializer<DifferenceIngredient> {
|
||||
public static final IIngredientSerializer<DifferenceIngredient> INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
@@ -141,3 +140,4 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -5,16 +5,18 @@
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
// TODO: Ingredient Serializers
|
||||
/*
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
public interface IIngredientSerializer<T extends Ingredient>
|
||||
{
|
||||
public interface IIngredientSerializer<T extends Ingredient> {
|
||||
T parse(FriendlyByteBuf buffer);
|
||||
|
||||
T parse(JsonObject json);
|
||||
|
||||
void write(FriendlyByteBuf buffer, T ingredient);
|
||||
}
|
||||
*/
|
||||
@@ -15,8 +15,7 @@ import net.minecraft.world.inventory.CraftingContainer;
|
||||
* For GUIs with recipe books, this allows their containers to have
|
||||
* recipe completion and ghost recipes in their craft matrices.
|
||||
*/
|
||||
public interface IRecipeContainer
|
||||
{
|
||||
public interface IRecipeContainer {
|
||||
/**
|
||||
* The crafting result slot of your container, where you take out the crafted item.
|
||||
* The equivalent for {@link CraftingMenu} is {@code CraftingMenu#resultSlots}.
|
||||
|
||||
@@ -13,8 +13,7 @@ import net.minecraft.world.item.crafting.Recipe;
|
||||
* book and auto crafting picks the correct shape.
|
||||
* Note: These methods can't be named 'getHeight' or 'getWidth' due to obfusication issues.
|
||||
*/
|
||||
public interface IShapedRecipe<T extends Container> extends Recipe<T>
|
||||
{
|
||||
public interface IShapedRecipe<T extends Container> extends Recipe<T> {
|
||||
int getRecipeWidth();
|
||||
int getRecipeHeight();
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** Ingredient that matches if all child ingredients match */
|
||||
/** Ingredient that matches if all child ingredients match * /
|
||||
public class IntersectionIngredient extends AbstractIngredient
|
||||
{
|
||||
private final List<Ingredient> children;
|
||||
@@ -44,7 +44,7 @@ public class IntersectionIngredient extends AbstractIngredient
|
||||
* Gets an intersection ingredient
|
||||
* @param ingredients List of ingredients to match
|
||||
* @return Ingredient that only matches if all the passed ingredients match
|
||||
*/
|
||||
* /
|
||||
public static Ingredient of(Ingredient... ingredients)
|
||||
{
|
||||
if (ingredients.length == 0)
|
||||
@@ -175,3 +175,4 @@ public class IntersectionIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -54,3 +54,4 @@ public class MultiItemValue implements Value
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -28,7 +28,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT */
|
||||
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT * /
|
||||
public class PartialNBTIngredient extends AbstractIngredient
|
||||
{
|
||||
private final Set<Item> items;
|
||||
@@ -52,13 +52,13 @@ public class PartialNBTIngredient extends AbstractIngredient
|
||||
this.predicate = new NbtPredicate(nbt);
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching any item from the list, containing the given NBT */
|
||||
/** Creates a new ingredient matching any item from the list, containing the given NBT * /
|
||||
public static PartialNBTIngredient of(CompoundTag nbt, ItemLike... items)
|
||||
{
|
||||
return new PartialNBTIngredient(Arrays.stream(items).map(ItemLike::asItem).collect(Collectors.toSet()), nbt);
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching the given item, containing the given NBT */
|
||||
/** Creates a new ingredient matching the given item, containing the given NBT * /
|
||||
public static PartialNBTIngredient of(ItemLike item, CompoundTag nbt)
|
||||
{
|
||||
return new PartialNBTIngredient(Set.of(item.asItem()), nbt);
|
||||
@@ -154,3 +154,4 @@ public class PartialNBTIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. */
|
||||
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. * /
|
||||
public class StrictNBTIngredient extends AbstractIngredient
|
||||
{
|
||||
private final ItemStack stack;
|
||||
@@ -26,7 +26,7 @@ public class StrictNBTIngredient extends AbstractIngredient
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching the given stack and tag */
|
||||
/** Creates a new ingredient matching the given stack and tag * /
|
||||
public static StrictNBTIngredient of(ItemStack stack)
|
||||
{
|
||||
return new StrictNBTIngredient(stack);
|
||||
@@ -85,3 +85,4 @@ public class StrictNBTIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -36,3 +36,4 @@ public class VanillaIngredientSerializer implements IIngredientSerializer<Ingred
|
||||
buffer.writeItem(stack);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -3,11 +3,10 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.client.resources.ClientPackSource;
|
||||
import net.minecraft.client.resources.IndexedAssetSource;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.server.packs.FilePackResources;
|
||||
import net.minecraft.server.packs.FilePackResources.FileResourcesSupplier;
|
||||
import net.minecraft.server.packs.PathPackResources;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
@@ -103,7 +104,7 @@ public class ExistingFileHelper {
|
||||
candidateServerResources.add(ServerPacksSource.createVanillaPackSource());
|
||||
for (Path existing : existingPacks) {
|
||||
File file = existing.toFile();
|
||||
PackResources pack = file.isDirectory() ? new PathPackResources(file.getName(), file.toPath(), false) : new FilePackResources(file.getName(), file, false);
|
||||
PackResources pack = file.isDirectory() ? new PathPackResources(file.getName(), file.toPath(), false) : new FileResourcesSupplier(file, false).openPrimary(file.getName()); // FilePackResources(file.getName(), file, false, "");
|
||||
candidateClientResources.add(pack);
|
||||
candidateServerResources.add(pack);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.advancements.AdvancementProvider;
|
||||
@@ -20,8 +20,8 @@ import java.util.function.Consumer;
|
||||
* An extension of the {@link AdvancementProvider} to provide a feature-complete
|
||||
* experience to generate modded advancements.
|
||||
*/
|
||||
public class ForgeAdvancementProvider extends AdvancementProvider
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ForgeAdvancementProvider extends AdvancementProvider {
|
||||
/**
|
||||
* Constructs an advancement provider using the generators to write the
|
||||
* advancements to a file.
|
||||
@@ -31,8 +31,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider
|
||||
* @param existingFileHelper a helper used to find whether a file exists
|
||||
* @param subProviders the generators used to create the advancements
|
||||
*/
|
||||
public ForgeAdvancementProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, ExistingFileHelper existingFileHelper, List<AdvancementGenerator> subProviders)
|
||||
{
|
||||
public ForgeAdvancementProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, ExistingFileHelper existingFileHelper, List<AdvancementGenerator> subProviders) {
|
||||
super(output, registries, subProviders.stream().map(generator -> generator.toSubProvider(existingFileHelper)).toList());
|
||||
}
|
||||
|
||||
@@ -42,8 +41,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider
|
||||
*
|
||||
* @see AdvancementSubProvider
|
||||
*/
|
||||
public interface AdvancementGenerator
|
||||
{
|
||||
public interface AdvancementGenerator {
|
||||
/**
|
||||
* A method used to generate advancements for a mod. Advancements should be
|
||||
* built via {@link net.minecraftforge.common.extensions.IForgeAdvancementBuilder#save(Consumer, ResourceLocation, ExistingFileHelper)}.
|
||||
@@ -52,7 +50,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider
|
||||
* @param saver a consumer used to write advancements to a file
|
||||
* @param existingFileHelper a helper used to find whether a file exists
|
||||
*/
|
||||
void generate(HolderLookup.Provider registries, Consumer<Advancement> saver, ExistingFileHelper existingFileHelper);
|
||||
void generate(HolderLookup.Provider registries, Consumer<AdvancementHolder> saver, ExistingFileHelper existingFileHelper);
|
||||
|
||||
/**
|
||||
* Creates an {@link AdvancementSubProvider} from this generator.
|
||||
@@ -60,8 +58,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider
|
||||
* @param existingFileHelper a helper used to find whether a file exists
|
||||
* @return a sub provider wrapping this generator
|
||||
*/
|
||||
default AdvancementSubProvider toSubProvider(ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
default AdvancementSubProvider toSubProvider(ExistingFileHelper existingFileHelper) {
|
||||
return (registries, saver) -> this.generate(registries, saver, existingFileHelper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
/*
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.loot.LootTableProvider;
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
|
||||
|
||||
/**
|
||||
* Currently used only for replacing shears item to shears_dig tool action
|
||||
*/
|
||||
* /
|
||||
public final class ForgeLootTableProvider extends LootTableProvider {
|
||||
public ForgeLootTableProvider(PackOutput packOutput) {
|
||||
super(packOutput, Set.of(), VanillaLootTableProvider.create(packOutput).getTables());
|
||||
@@ -184,3 +184,4 @@ public final class ForgeLootTableProvider extends LootTableProvider {
|
||||
return items != null && items.contains(expected);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -6,10 +6,12 @@
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.advancements.Advancement.Builder;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.ShapedRecipeBuilder;
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
||||
import net.minecraft.data.recipes.packs.VanillaRecipeProvider;
|
||||
@@ -36,7 +38,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
private final Map<Item, TagKey<Item>> replacements = new HashMap<>();
|
||||
@@ -59,7 +60,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipes(Consumer<FinishedRecipe> consumer) {
|
||||
protected void buildRecipes(RecipeOutput consumer) {
|
||||
replace(Items.STICK, Tags.Items.RODS_WOODEN);
|
||||
replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD);
|
||||
replace(Items.IRON_INGOT, Tags.Items.INGOTS_IRON);
|
||||
@@ -92,10 +93,18 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
exclude(Blocks.COBBLED_DEEPSLATE_SLAB);
|
||||
exclude(Blocks.COBBLED_DEEPSLATE_WALL);
|
||||
|
||||
super.buildRecipes(vanilla -> {
|
||||
FinishedRecipe modified = enhance(vanilla);
|
||||
if (modified != null)
|
||||
consumer.accept(modified);
|
||||
super.buildRecipes(new RecipeOutput() {
|
||||
@Override
|
||||
public void accept(FinishedRecipe vanilla) {
|
||||
var modified = enhance(vanilla);
|
||||
if (modified != null)
|
||||
consumer.accept(modified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder advancement() {
|
||||
return consumer.advancement();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,7 +122,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
List<Ingredient> ingredients = getField(ShapelessRecipeBuilder.Result.class, vanilla, 4);
|
||||
boolean modified = false;
|
||||
for (int x = 0; x < ingredients.size(); x++) {
|
||||
Ingredient ing = enhance(vanilla.getId(), ingredients.get(x));
|
||||
Ingredient ing = enhance(vanilla.id(), ingredients.get(x));
|
||||
if (ing != null) {
|
||||
ingredients.set(x, ing);
|
||||
modified = true;
|
||||
@@ -124,13 +133,13 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected CompletableFuture<?> saveAdvancement(CachedOutput output, FinishedRecipe recipe, JsonObject json) {
|
||||
protected CompletableFuture<?> saveAdvancement(CachedOutput output, JsonObject advancementJson, AdvancementHolder holder, FinishedRecipe finishedRecipe) {
|
||||
// NOOP - We don't replace any of the advancement things yet...
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<?> buildAdvancement(CachedOutput output, ResourceLocation name, Advancement.Builder builder) {
|
||||
protected CompletableFuture<?> buildAdvancement(CachedOutput p_253674_, AdvancementHolder p_297687_) {
|
||||
// NOOP - We don't replace any of the advancement things yet...
|
||||
return CompletableFuture.allOf();
|
||||
}
|
||||
@@ -140,7 +149,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider {
|
||||
Map<Character, Ingredient> ingredients = getField(ShapedRecipeBuilder.Result.class, vanilla, 5);
|
||||
boolean modified = false;
|
||||
for (Character x : ingredients.keySet()) {
|
||||
Ingredient ing = enhance(vanilla.getId(), ingredients.get(x));
|
||||
Ingredient ing = enhance(vanilla.id(), ingredients.get(x));
|
||||
if (ing != null) {
|
||||
ingredients.put(x, ing);
|
||||
modified = true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
/*
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
|
||||
* Provider for forge's GlobalLootModifier system. See {@link LootModifier}
|
||||
*
|
||||
* This provider only requires implementing {@link #start()} and calling {@link #add} from it.
|
||||
*/
|
||||
* /
|
||||
public abstract class GlobalLootModifierProvider implements DataProvider
|
||||
{
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
@@ -48,7 +48,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider
|
||||
|
||||
/**
|
||||
* Sets the "replace" key in global_loot_modifiers to true.
|
||||
*/
|
||||
* /
|
||||
protected void replacing()
|
||||
{
|
||||
this.replace = true;
|
||||
@@ -56,7 +56,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider
|
||||
|
||||
/**
|
||||
* Call {@link #add} here, which will pass in the necessary information to write the jsons.
|
||||
*/
|
||||
* /
|
||||
protected abstract void start();
|
||||
|
||||
@Override
|
||||
@@ -91,7 +91,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider
|
||||
*
|
||||
* @param modifier The name of the modifier, which will be the file name.
|
||||
* @param instance The instance to serialize
|
||||
*/
|
||||
* /
|
||||
public <T extends IGlobalLootModifier> void add(String modifier, T instance)
|
||||
{
|
||||
JsonElement json = IGlobalLootModifier.DIRECT_CODEC.encodeStart(JsonOps.INSTANCE, instance).getOrThrow(false, s -> {});
|
||||
@@ -104,3 +104,4 @@ public abstract class GlobalLootModifierProvider implements DataProvider
|
||||
return "Global Loot Modifiers : " + modid;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -7,7 +7,6 @@ package net.minecraftforge.common.data;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
@@ -18,21 +17,14 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper.ResourceType;
|
||||
import net.minecraftforge.registries.DataPackRegistriesHooks;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
@@ -96,6 +88,7 @@ public class JsonCodecProvider<T> implements DataProvider
|
||||
final Path path = outputFolder.resolve(id.getNamespace()).resolve(this.directory).resolve(id.getPath() + ".json");
|
||||
JsonElement encoded = this.codec.encodeStart(this.dynamicOps, value)
|
||||
.getOrThrow(false, msg -> LOGGER.error("Failed to encode {}: {}", path, msg));
|
||||
/* TODO: Conditional JSONS
|
||||
ICondition[] conditions = this.conditions.get(id);
|
||||
if (conditions != null && conditions.length > 0)
|
||||
{
|
||||
@@ -108,6 +101,7 @@ public class JsonCodecProvider<T> implements DataProvider
|
||||
LOGGER.error("Attempted to apply conditions to a type that is not a JsonObject! - Path: {}", path);
|
||||
}
|
||||
}
|
||||
*/
|
||||
futuresBuilder.add(DataProvider.saveStable(cache, encoded, path));
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementRewards;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IForgeAdvancementBuilder
|
||||
{
|
||||
|
||||
private Advancement.Builder self()
|
||||
{
|
||||
return (Advancement.Builder) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this builder with the given id using the {@link ExistingFileHelper} to check if the parent is already known.
|
||||
*
|
||||
* @param saver a {@link Consumer} which saves any advancements provided
|
||||
* @param id the {@link ResourceLocation} id for the new advancement
|
||||
* @param fileHelper the {@link ExistingFileHelper} where all known advancements are registered
|
||||
* @return the built advancement
|
||||
* @throws IllegalStateException if the parent of the advancement is not known
|
||||
*/
|
||||
default Advancement save(Consumer<Advancement> saver, ResourceLocation id, ExistingFileHelper fileHelper)
|
||||
{
|
||||
boolean canBuild = self().canBuild((advancementId) ->
|
||||
{
|
||||
if (fileHelper.exists(advancementId, PackType.SERVER_DATA, ".json", "advancements"))
|
||||
{
|
||||
return new Advancement(advancementId, null, null, AdvancementRewards.EMPTY, Maps.newHashMap(), new String[0][0], false);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (!canBuild)
|
||||
{
|
||||
throw new IllegalStateException("Tried to build Advancement without valid Parent!");
|
||||
}
|
||||
|
||||
Advancement advancement = self().build(id);
|
||||
saver.accept(advancement);
|
||||
return advancement;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
@@ -15,44 +15,36 @@ import net.minecraft.world.scores.Scoreboard;
|
||||
/**
|
||||
* Additional methods for {@link CommandSourceStack} so that commands and arguments can access various things without directly referencing using server specific classes
|
||||
*/
|
||||
public interface IForgeCommandSourceStack
|
||||
{
|
||||
|
||||
private CommandSourceStack self()
|
||||
{
|
||||
public interface IForgeCommandSourceStack {
|
||||
private CommandSourceStack self() {
|
||||
return (CommandSourceStack) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scoreboard
|
||||
*/
|
||||
default Scoreboard getScoreboard()
|
||||
{
|
||||
default Scoreboard getScoreboard() {
|
||||
return self().getServer().getScoreboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the advancement from the id
|
||||
*/
|
||||
default Advancement getAdvancement(ResourceLocation id)
|
||||
{
|
||||
return self().getServer().getAdvancements().getAdvancement(id);
|
||||
default AdvancementHolder getAdvancement(ResourceLocation id) {
|
||||
return self().getServer().getAdvancements().get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the recipe manager
|
||||
*/
|
||||
default RecipeManager getRecipeManager()
|
||||
{
|
||||
default RecipeManager getRecipeManager() {
|
||||
return self().getServer().getRecipeManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level but without being specifically the server side level
|
||||
*/
|
||||
default Level getUnsidedLevel()
|
||||
{
|
||||
default Level getUnsidedLevel() {
|
||||
return self().getLevel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
|
||||
public interface IForgeRecipeSerializer<T extends Recipe<?>>
|
||||
{
|
||||
private RecipeSerializer<T> self()
|
||||
{
|
||||
return (RecipeSerializer<T>) this;
|
||||
}
|
||||
|
||||
default T fromJson(ResourceLocation recipeLoc, JsonObject recipeJson, ICondition.IContext context)
|
||||
{
|
||||
return self().fromJson(recipeLoc, recipeJson);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
/*
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -22,7 +22,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* This LootItemCondition "forge:can_tool_perform_action" can be used to check if a tool can perform a given ToolAction.
|
||||
*/
|
||||
* /
|
||||
public class CanToolPerformAction implements LootItemCondition {
|
||||
|
||||
public static final LootItemConditionType LOOT_CONDITION_TYPE = new LootItemConditionType(new CanToolPerformAction.Serializer());
|
||||
@@ -64,3 +64,4 @@ public class CanToolPerformAction implements LootItemCondition {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.mojang.serialization.Codec;
|
||||
@@ -26,7 +26,7 @@ import java.util.function.Function;
|
||||
* {@link LootModifier} Supplies base functionality; most modders should only need to extend that.<br/>
|
||||
* Requires a {@link Codec} to be registered: {@link ForgeRegistries#GLOBAL_LOOT_MODIFIER_SERIALIZERS}, and returned in {@link #codec()}
|
||||
* Individual instances of modifiers must be registered via json, see forge:loot_modifiers/global_loot_modifiers
|
||||
*/
|
||||
* /
|
||||
public interface IGlobalLootModifier {
|
||||
Codec<IGlobalLootModifier> DIRECT_CODEC = ExtraCodecs.lazyInitializedCodec(() -> ForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS.get().getCodec())
|
||||
.dispatch(IGlobalLootModifier::codec, Function.identity());
|
||||
@@ -74,12 +74,13 @@ public interface IGlobalLootModifier {
|
||||
* @param generatedLoot the list of ItemStacks that will be dropped, generated by loot tables
|
||||
* @param context the LootContext, identical to what is passed to loot tables
|
||||
* @return modified loot drops
|
||||
*/
|
||||
* /
|
||||
@NotNull
|
||||
ObjectArrayList<ItemStack> apply(ObjectArrayList<ItemStack> generatedLoot, LootContext context);
|
||||
|
||||
/**
|
||||
* Returns the registered codec for this modifier
|
||||
*/
|
||||
* /
|
||||
Codec<? extends IGlobalLootModifier> codec();
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
/*
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.mojang.datafixers.Products;
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* A base implementation of a Global Loot Modifier for modders to extend.
|
||||
* Takes care of ILootCondition matching and comes with the base codec to extend.
|
||||
*/
|
||||
* /
|
||||
public abstract class LootModifier implements IGlobalLootModifier
|
||||
{
|
||||
protected final LootItemCondition[] conditions;
|
||||
@@ -35,7 +35,7 @@ public abstract class LootModifier implements IGlobalLootModifier
|
||||
* </p>
|
||||
* Otherwise can follow this with #and() to add more fields.
|
||||
* Examples: Forge Test Subclasses or {@link BendingTrunkPlacer#CODEC}
|
||||
*/
|
||||
* /
|
||||
protected static <T extends LootModifier> Products.P1<RecordCodecBuilder.Mu<T>, LootItemCondition[]> codecStart(RecordCodecBuilder.Instance<T> instance)
|
||||
{
|
||||
return instance.group(LOOT_CONDITIONS_CODEC.fieldOf("conditions").forGetter(lm -> lm.conditions));
|
||||
@@ -44,7 +44,7 @@ public abstract class LootModifier implements IGlobalLootModifier
|
||||
/**
|
||||
* Constructs a LootModifier.
|
||||
* @param conditionsIn the ILootConditions that need to be matched before the loot is modified.
|
||||
*/
|
||||
* /
|
||||
protected LootModifier(LootItemCondition[] conditionsIn)
|
||||
{
|
||||
this.conditions = conditionsIn;
|
||||
@@ -64,7 +64,8 @@ public abstract class LootModifier implements IGlobalLootModifier
|
||||
* @param generatedLoot the list of ItemStacks that will be dropped, generated by loot tables
|
||||
* @param context the LootContext, identical to what is passed to loot tables
|
||||
* @return modified loot drops
|
||||
*/
|
||||
* /
|
||||
@NotNull
|
||||
protected abstract ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context);
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
/*
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -16,7 +16,6 @@ import java.util.*;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.world.level.storage.loot.Deserializers;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -87,9 +86,10 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener {
|
||||
|
||||
/**
|
||||
* An immutable collection of the registered loot modifiers in layered order.
|
||||
*/
|
||||
* /
|
||||
public Collection<IGlobalLootModifier> getAllLootMods() {
|
||||
return registeredLootModifiers.values();
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
@@ -77,3 +77,4 @@ public class LootTableIdCondition implements LootItemCondition
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.common.ServerboundClientInformationPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQuery;
|
||||
@@ -24,17 +25,14 @@ import net.minecraft.network.protocol.game.ServerboundChatCommandPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundClientCommandPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundClientInformationPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerButtonClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundEditBookPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundEntityTagQuery;
|
||||
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundJigsawGeneratePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundKeepAlivePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundLockDifficultyPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket;
|
||||
@@ -48,7 +46,6 @@ import net.minecraft.network.protocol.game.ServerboundPlayerInputPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundRecipeBookChangeSettingsPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundRecipeBookSeenRecipePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundRenameItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundResourcePackPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSeenAdvancementsPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSelectTradePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetBeaconPacket;
|
||||
@@ -64,8 +61,10 @@ import net.minecraft.network.protocol.game.ServerboundTeleportToEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ClientInformation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
@@ -77,12 +76,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* A basic fake server player implementation that can be used to simulate player actions.
|
||||
*/
|
||||
public class FakePlayer extends ServerPlayer
|
||||
{
|
||||
public FakePlayer(ServerLevel level, GameProfile name)
|
||||
{
|
||||
super(level.getServer(), level, name);
|
||||
this.connection = new FakePlayerNetHandler(level.getServer(), this);
|
||||
@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
public class FakePlayer extends ServerPlayer {
|
||||
protected FakePlayer(ServerLevel level, GameProfile name, ClientInformation info) {
|
||||
super(level.getServer(), level, name, info);
|
||||
}
|
||||
|
||||
@Override public void displayClientMessage(Component chatComponent, boolean actionBar) { }
|
||||
@@ -91,15 +88,14 @@ public class FakePlayer extends ServerPlayer
|
||||
@Override public boolean canHarmPlayer(Player player) { return false; }
|
||||
@Override public void die(DamageSource source) { }
|
||||
@Override public void tick() { }
|
||||
@Override public void updateOptions(ServerboundClientInformationPacket packet) { }
|
||||
@Override @Nullable public MinecraftServer getServer() { return ServerLifecycleHooks.getCurrentServer(); }
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private static class FakePlayerNetHandler extends ServerGamePacketListenerImpl {
|
||||
static class NetHandler extends ServerGamePacketListenerImpl {
|
||||
private static final Connection DUMMY_CONNECTION = new Connection(PacketFlow.CLIENTBOUND);
|
||||
|
||||
public FakePlayerNetHandler(MinecraftServer server, ServerPlayer player) {
|
||||
super(server, DUMMY_CONNECTION, player);
|
||||
NetHandler(MinecraftServer server, ServerPlayer player, CommonListenerCookie cookie) {
|
||||
super(server, DUMMY_CONNECTION, player, cookie);
|
||||
}
|
||||
|
||||
@Override public void tick() { }
|
||||
@@ -130,7 +126,6 @@ public class FakePlayer extends ServerPlayer
|
||||
@Override public void handleUseItemOn(ServerboundUseItemOnPacket packet) { }
|
||||
@Override public void handleUseItem(ServerboundUseItemPacket packet) { }
|
||||
@Override public void handleTeleportToEntityPacket(ServerboundTeleportToEntityPacket packet) { }
|
||||
@Override public void handleResourcePackResponse(ServerboundResourcePackPacket packet) { }
|
||||
@Override public void handlePaddleBoat(ServerboundPaddleBoatPacket packet) { }
|
||||
@Override public void onDisconnect(Component message) { }
|
||||
@Override public void send(Packet<?> packet) { }
|
||||
@@ -147,10 +142,7 @@ public class FakePlayer extends ServerPlayer
|
||||
@Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { }
|
||||
@Override public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket packet) { }
|
||||
@Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { }
|
||||
@Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { }
|
||||
@Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { }
|
||||
@Override public void handleClientInformation(ServerboundClientInformationPacket packet) { }
|
||||
@Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { }
|
||||
@Override public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { }
|
||||
@Override public void handleLockDifficulty(ServerboundLockDifficultyPacket packet) { }
|
||||
@Override public void teleport(double x, double y, double z, float yaw, float pitch, Set<RelativeMovement> relativeSet) { }
|
||||
|
||||
@@ -12,8 +12,10 @@ import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
|
||||
//To be expanded for generic Mod fake players?
|
||||
|
||||
@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
public class FakePlayerFactory
|
||||
{
|
||||
private static final GameProfile MINECRAFT = new GameProfile(UUID.fromString("41C82C87-7AfB-4024-BA57-13D2C99CAE77"), "[Minecraft]");
|
||||
@@ -35,11 +37,18 @@ public class FakePlayerFactory
|
||||
public static FakePlayer get(ServerLevel level, GameProfile username)
|
||||
{
|
||||
FakePlayerKey key = new FakePlayerKey(level, username);
|
||||
return fakePlayers.computeIfAbsent(key, k -> new FakePlayer(k.level(), k.username()));
|
||||
return fakePlayers.computeIfAbsent(key, FakePlayerFactory::create);
|
||||
}
|
||||
|
||||
public static void unloadLevel(ServerLevel level)
|
||||
{
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().level() == level);
|
||||
}
|
||||
|
||||
private static FakePlayer create(FakePlayerKey key) {
|
||||
var cookie = CommonListenerCookie.createInitial(key.username());
|
||||
var ret = new FakePlayer(key.level(), cookie.gameProfile(), cookie.clientInformation());
|
||||
new FakePlayer.NetHandler(key.level().getServer(), ret, cookie);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -6,58 +6,63 @@
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LevelCapabilityData extends SavedData
|
||||
{
|
||||
public class LevelCapabilityData extends SavedData {
|
||||
public static final String ID = "capabilities";
|
||||
|
||||
private INBTSerializable<CompoundTag> serializable;
|
||||
private CompoundTag capNBT = null;
|
||||
|
||||
public LevelCapabilityData(@Nullable INBTSerializable<CompoundTag> serializable)
|
||||
{
|
||||
public LevelCapabilityData(@Nullable INBTSerializable<CompoundTag> serializable) {
|
||||
this.serializable = serializable;
|
||||
}
|
||||
|
||||
public static LevelCapabilityData load(CompoundTag tag, @Nullable INBTSerializable<CompoundTag> serializable) {
|
||||
LevelCapabilityData data = new LevelCapabilityData(serializable);
|
||||
data.read(tag);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void read(CompoundTag nbt)
|
||||
{
|
||||
public void read(CompoundTag nbt) {
|
||||
this.capNBT = nbt;
|
||||
if (serializable != null)
|
||||
{
|
||||
if (serializable != null) {
|
||||
serializable.deserializeNBT(this.capNBT);
|
||||
this.capNBT = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt)
|
||||
{
|
||||
public CompoundTag save(CompoundTag nbt) {
|
||||
if (serializable != null)
|
||||
nbt = serializable.serializeNBT();
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty()
|
||||
{
|
||||
public boolean isDirty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCapabilities(INBTSerializable<CompoundTag> capabilities)
|
||||
{
|
||||
public void setCapabilities(INBTSerializable<CompoundTag> capabilities) {
|
||||
this.serializable = capabilities;
|
||||
if (this.capNBT != null && serializable != null)
|
||||
{
|
||||
if (this.capNBT != null && serializable != null) {
|
||||
serializable.deserializeNBT(this.capNBT);
|
||||
this.capNBT = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static LevelCapabilityData compute(DimensionDataStorage data, @Nullable INBTSerializable<CompoundTag> caps) {
|
||||
var factory = new Factory<>(
|
||||
() -> new LevelCapabilityData(caps),
|
||||
(tag) -> {
|
||||
var ret = new LevelCapabilityData(caps);
|
||||
ret.read(tag);
|
||||
return ret;
|
||||
},
|
||||
DataFixTypes.SAVED_DATA_COMMAND_STORAGE //TODO: Hook this for our own types?
|
||||
);
|
||||
|
||||
var ret = data.computeIfAbsent(factory, ID);
|
||||
ret.setCapabilities(caps);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class ForgeChunkManager
|
||||
*/
|
||||
public static boolean hasForcedChunks(ServerLevel level)
|
||||
{
|
||||
ForcedChunksSavedData data = level.getDataStorage().get(ForcedChunksSavedData::load, "chunks");
|
||||
ForcedChunksSavedData data = level.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||
if (data == null) return false;
|
||||
return !data.getChunks().isEmpty() || !data.getBlockForcedChunks().isEmpty() || !data.getEntityForcedChunks().isEmpty();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class ForgeChunkManager
|
||||
LOGGER.warn("A mod attempted to force a chunk for an unloaded mod of id: {}", modId);
|
||||
return false;
|
||||
}
|
||||
ForcedChunksSavedData saveData = level.getDataStorage().computeIfAbsent(ForcedChunksSavedData::load, ForcedChunksSavedData::new, "chunks");
|
||||
ForcedChunksSavedData saveData = level.getDataStorage().computeIfAbsent(ForcedChunksSavedData.factory(), "chunks");
|
||||
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
long chunk = pos.toLong();
|
||||
TicketTracker<T> tickets = ticketGetter.apply(saveData);
|
||||
|
||||
Reference in new issue
Block a user