• Recently Browsing

    No registered users viewing this page.

  • Posts

    • I'm currently working on data generation and I followed a tutorial from mcJty. I keep getting joptsimple.MultipleArgumentsForOptionException whenever I run runData. I tried copy pasting the whole file from mcJty's source but it still doesn't work. code: BaseLootTableProvider: package com.jun2040.sourcemod.datagen; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.minecraft.block.Block; import net.minecraft.data.DataGenerator; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; import net.minecraft.data.LootTableProvider; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.*; import net.minecraft.world.storage.loot.functions.CopyName; import net.minecraft.world.storage.loot.functions.CopyNbt; import net.minecraft.world.storage.loot.functions.SetContents; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.Path; import java.util.HashMap; import java.util.Map; public abstract class BaseLootTableProvider extends LootTableProvider { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); protected final Map<Block, LootTable.Builder> lootTables = new HashMap<>(); private final DataGenerator generator; public BaseLootTableProvider(DataGenerator dataGeneratorIn) { super(dataGeneratorIn); this.generator = dataGeneratorIn; } protected abstract void addTables(); protected LootTable.Builder createStandardTable(String name, Block block) { LootPool.Builder builder = LootPool.builder() .name(name) .rolls(ConstantRange.of(1)) .addEntry(ItemLootEntry.builder(block) .acceptFunction(CopyName.func_215893_a(CopyName.Source.BLOCK_ENTITY)) .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) .func_216055_a("inv", "BlockEntityTag.inv", CopyNbt.Action.REPLACE) .func_216055_a("energy", "BlockEntityTag.energy", CopyNbt.Action.REPLACE)) .acceptFunction(SetContents.func_215920_b() .func_216075_a(DynamicLootEntry.func_216162_a(new ResourceLocation("minecraft", "contents")))) ); return LootTable.builder().addLootPool(builder); } @Override public void act(DirectoryCache cache) { addTables(); Map<ResourceLocation, LootTable> tables = new HashMap<>(); for (Map.Entry<Block, LootTable.Builder> entry : lootTables.entrySet()) { tables.put(entry.getKey().getLootTable(), entry.getValue().setParameterSet(LootParameterSets.BLOCK).build()); } writeTables(cache, tables); } private void writeTables(DirectoryCache cache, Map<ResourceLocation, LootTable> tables) { Path outputFolder = this.generator.getOutputFolder(); tables.forEach((key, lootTable) -> { Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json"); try { IDataProvider.save(GSON, cache, LootTableManager.toJson(lootTable), path); } catch (IOException e) { LOGGER.error("Couldn't write loot table {}", path, e); } }); } @Override public String getName() { return "Sourcemod LootTables"; } } DataGenerators: package com.jun2040.sourcemod.datagen; import net.minecraft.data.DataGenerator; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class DataGenerators { @SubscribeEvent public static void gatherData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); generator.addProvider(new Recipes(generator)); generator.addProvider(new LootTables(generator)); } } LootTables: package com.jun2040.sourcemod.datagen; import com.jun2040.sourcemod.blocks.ModBlocks; import net.minecraft.data.DataGenerator; public class LootTables extends BaseLootTableProvider { public LootTables(DataGenerator dataGeneratorIn) { super(dataGeneratorIn); } @Override protected void addTables() { lootTables.put(ModBlocks.EXAMPLE_BLOCK, createStandardTable("example_block", ModBlocks.EXAMPLE_BLOCK)); } } Recipes: package com.jun2040.sourcemod.datagen; import com.jun2040.sourcemod.blocks.ModBlocks; import net.minecraft.advancements.criterion.InventoryChangeTrigger; import net.minecraft.block.Blocks; import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; import net.minecraft.data.ShapedRecipeBuilder; import java.util.function.Consumer; public class Recipes extends RecipeProvider { public Recipes(DataGenerator generatorIn) { super(generatorIn); } @Override protected void registerRecipes(Consumer<IFinishedRecipe> consumer) { ShapedRecipeBuilder.shapedRecipe(ModBlocks.EXAMPLE_BLOCK) .patternLine("###") .patternLine("#x#") .patternLine("###") .key('#', Blocks.COBBLESTONE) .key('x', Blocks.OAK_PLANKS) .setGroup("exampletab") .addCriterion("cobblestone", InventoryChangeTrigger.Instance.forItems(Blocks.COBBLESTONE)) .build(consumer); } }
    • I'm new to mod development and I'm having a hard time here. Is this the correct document for 'how to send custom packets with Forge'? https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/   Or do you have other documents that I don't know about?
    • If you follow the documentation on how to send custom packets with Forge, those packets will be sent using "custom payload" packets. Bukkit calls these "plugin channels".
  • Topics

  • Who's Online (See full list)