Jump to content

acadus

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by acadus

  1. Ah, of course, I can't believe I overlooked it. Should I create an instance for my client and server proxy in the mod file and then remove the common proxy?
  2. Common Proxy: @Mod.EventBusSubscriber public class CommonProxy { public void registerItemRenderer(Item item, int meta, String id) { } public String localize(String unlocalized, Object... args) { return I18n.translateToLocalFormatted(unlocalized, args); } public void registerRenderers() { } public void preInit(FMLPreInitializationEvent e) { PacketHandler.registerMessages("packettests"); } public void init(FMLInitializationEvent e) { } public void postInit(FMLPostInitializationEvent e) { } public void openGui() { } } Client Proxy: @Mod.EventBusSubscriber(Side.CLIENT) public class ClientProxy extends CommonProxy { @Override public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(ModTest.MODID + ":" + id, "inventory")); } @Override public String localize(String unlocalized, Object... args) { return I18n.format(unlocalized, args); } @Override public void registerRenderers() { } @Override public void preInit(FMLPreInitializationEvent e) { } @Override public void init(FMLInitializationEvent e) { } @Override public void postInit(FMLPostInitializationEvent e) { } @Override public void openGui() { Minecraft.getMinecraft().displayGuiScreen(new GuiExample(new V3(1,1,1), "-x", null, (EntityPlayer)Minecraft.getMinecraft().player)); } } Mod File: @Mod(modid = ModTest.MODID, name = ModTest.MODNAME, version = ModTest.VERISON, useMetadata = true) public class ModTest { public static final String MODID = "modtest"; public static final String MODNAME = "Mod Test"; public static final String VERISON = "1.0.0"; @SidedProxy(clientSide = "acadus.modtest.proxy.ClientProxy", serverSide = "acadus.modtest.proxy.ServerProxy") public static CommonProxy proxy; @Mod.Instance public static ModTest instance; public static Logger log; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { log = event.getModLog(); proxy.preInit(event); } @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); } @Mod.EventBusSubscriber public static class RegsitrationHandler { @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { //ModItems.register(event.getRegistry()); ModBlocks.registerItemBlocks(event.getRegistry()); } @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { ModBlocks.register(event.getRegistry()); } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { //ModItems.registerModels(); ModBlocks.registerModels(); } } }
  3. Okay, I've removed the constructor arguments and moved the creation of the GuiScreen instance into the client proxy. I have actually registered the instance in the preInit of my common proxy which is then called in the mod file proxy, but I forgot to include this in the original post. However, the same NullPointerException keeps occuring at the same line in the Block Activation. Here are the updated classes: Packet and Handler public class PacketOpenGui implements IMessage { public PacketOpenGui() {} private BlockPos blockPos; @Override public void fromBytes(ByteBuf buf) { blockPos = BlockPos.fromLong(buf.readLong()); } @Override public void toBytes(ByteBuf buf) { buf.writeLong(blockPos.toLong()); } public static class Handler implements IMessageHandler<PacketOpenGui, IMessage> { @Override public IMessage onMessage(PacketOpenGui message, MessageContext ctx) { try{ FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx)); } catch(Exception e) { e.printStackTrace(); } return null; } private void handle(PacketOpenGui message, MessageContext ctx) { ModTest.proxy.openGui(); } } } Packet Registry public class PacketHandler { private static int packetId = 0; public static SimpleNetworkWrapper INSTANCE = null; public PacketHandler() { } public static int nextID() { return packetId++; } public static void registerMessages(String channelName) { INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); //Called in common proxy registerMessages(); } public static void registerMessages() { INSTANCE.registerMessage(PacketOpenGui.Handler.class, PacketOpenGui.class, nextID(), Side.CLIENT); } } Client Proxy Exert @Override public void openGui() { Minecraft.getMinecraft().displayGuiScreen(new GuiExample(new V3(1,1,1), "-x", null, (EntityPlayer)Minecraft.getMinecraft().player)); } Block Activation @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { PacketHandler.INSTANCE.sendTo(new PacketOpenGui(), (EntityPlayerMP)playerIn); } return true; } Edit: I just removed the use of blockPos for the time being to make things simpler.
  4. Ah sorry, my bad. I corrected it but the error still persists. Is there any way I can get more information on the error so that you can better help me?
  5. I'm trying to make it so that when a player right clicks on a block, it opens a GUI (no inventory) for them, but the packet I am using gives a NullPointerException when I try and send the packet. The error only highlights the line in the block activation code and does not say what variable is null, presumably due to the threading process. Here is my code: Packet & Handler public class PacketOpenGui implements IMessage { public PacketOpenGui(int guiid, BlockPos pos) { this.guiID = guiid; this.blockPos = pos; } private int guiID; private BlockPos blockPos; @Override public void fromBytes(ByteBuf buf) { guiID = buf.readInt(); blockPos = BlockPos.fromLong(buf.readLong()); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(guiID); buf.writeLong(blockPos.toLong()); } public static class Handler implements IMessageHandler<PacketOpenGui, IMessage> { @Override public IMessage onMessage(PacketOpenGui message, MessageContext ctx) { FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx)); return null; } private void handle(PacketOpenGui message, MessageContext ctx) { if(message.guiID == 0) { ModTest.proxy.openGui(new GuiExample(new V3(message.blockPos.getX(), message.blockPos.getY(), message.blockPos.getZ()), "-x", null, (EntityPlayer)ctx.getServerHandler().player)); } } } } Packet Registry public class PacketHandler { private static int packetId = 0; public static SimpleNetworkWrapper INSTANCE = null; public PacketHandler() { } public static int nextID() { return packetId++; } public static void registerMessages(String channelName) { INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); registerMessages(); } public static void registerMessages() { INSTANCE.registerMessage(PacketOpenGui.Handler.class, PacketOpenGui.class, nextID(), Side.SERVER); } } Client Proxy Exert public class ClientProxy extends CommonProxy { @Override //Override from empty function in CommonProxy public void openGui(@Nullable GuiScreen gui) { Minecraft.getMinecraft().displayGuiScreen(gui); } } Block Activation @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { PacketHandler.INSTANCE.sendTo(new PacketOpenGui(0, pos), (EntityPlayerMP)playerIn); //Error occurs on this line without any explanation } return true; }
  6. Okay, I have worked out what is causing the error, but I have no idea why it's a problem or how to fix it. After running setupDecompWorkspace --info, I learned that it's looking for the following dependencies: fastutil log4j api java objc bridge It is first looking for cached versions, but they are not accepted, and then tries to download them from files.minecraftforge.net/maven, but they do not exist in this location. Cached resource https://repo1.maven.org/maven2/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.pom is up-to-date (lastModified: Wed Feb 15 01:27:20 GMT 2017). [Fatal Error] fastutil-7.1.0.pom:2:1: Content is not allowed in prolog. Cached resource https://libraries.minecraft.net/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.pom is up-to-date (lastModified: Fri Mar 31 11:01:48 BST 2017). [Fatal Error] fastutil-7.1.0.pom:2:1: Content is not allowed in prolog. Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.pom] Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar] Cached resource https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom is up-to-date (lastModified: Sun Feb 26 23:54:08 GMT 2017). [Fatal Error] log4j-api-2.8.1.pom:2:1: Content is not allowed in prolog. Cached resource https://libraries.minecraft.net/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom is up-to-date (lastModified: Fri Mar 31 11:01:44 BST 2017). [Fatal Error] log4j-api-2.8.1.pom:2:1: Content is not allowed in prolog. Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom] Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar] Cached resource https://repo1.maven.org/maven2/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.pom is up-to-date (lastModified: Mon Sep 08 18:28:16 BST 2014). [Fatal Error] java-objc-bridge-1.0.0.pom:2:1: Content is not allowed in prolog. Cached resource https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.pom is up-to-date (lastModified: Thu Dec 08 09:03:34 GMT 2016). [Fatal Error] java-objc-bridge-1.0.0.pom:2:1: Content is not allowed in prolog. Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.pom] Resource missing. [HTTP HEAD: http://files.minecraftforge.net/maven/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar] :decompileMc FAILED :decompileMc (Thread[Daemon worker,5,main]) completed. Took 1.759 secs.
  7. I'm still having this issue, please could someone help me resolve it?
  8. I'm trying to setup ForgeGradle for the 14.23.0.2491-mdk and I keep receiving the same error when I try to run setupDecompWorkspace: To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14/userguide/gradle_daemon.html. This mapping 'snapshot_20170624' was designed for MC 1.12! Use at your own peril. ################################################# ForgeGradle 2.3-SNAPSHOT-3a113e5 https://github.com/MinecraftForge/ForgeGradle ################################################# Powered by MCP unknown http://modcoderpack.com by: Searge, ProfMobius, Fesh0r, R4wk, ZeuX, IngisKahn, bspkrs ################################################# :cleanCache :deobfCompileDummyTask :deobfProvidedDummyTask :getVersionJson :extractUserdev :extractDependencyATs SKIPPED :extractMcpData :extractMcpMappings :genSrgs :downloadClient :downloadServer :splitServerJar :mergeJars :deobfMcSRG Applying SpecialSource... Applying Exceptor... :decompileMc [Fatal Error] fastutil-7.1.0.pom:2:1: Content is not allowed in prolog. [Fatal Error] fastutil-7.1.0.pom:2:1: Content is not allowed in prolog. [Fatal Error] log4j-api-2.8.1.pom:2:1: Content is not allowed in prolog. [Fatal Error] log4j-api-2.8.1.pom:2:1: Content is not allowed in prolog. [Fatal Error] java-objc-bridge-1.0.0.pom:2:1: Content is not allowed in prolog. [Fatal Error] java-objc-bridge-1.0.0.pom:2:1: Content is not allowed in prolog. :decompileMc FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':decompileMc'. > Could not resolve all dependencies for configuration ':forgeGradleMcDeps'. > Could not resolve it.unimi.dsi:fastutil:7.1.0. Required by: com.yourname.modid:MYMOD:1.0 > Could not resolve it.unimi.dsi:fastutil:7.1.0. > Could not parse POM https://repo1.maven.org/maven2/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.pom > Content is not allowed in prolog. > Could not resolve it.unimi.dsi:fastutil:7.1.0. > Could not parse POM https://libraries.minecraft.net/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.pom > Content is not allowed in prolog. > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. Required by: com.yourname.modid:MYMOD:1.0 com.yourname.modid:MYMOD:1.0 > com.mojang:authlib:1.5.25 com.yourname.modid:MYMOD:1.0 > org.apache.logging.log4j:log4j-core:2.8.1 > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. > Could not parse POM https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom > Content is not allowed in prolog. > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. > Could not parse POM https://libraries.minecraft.net/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom > Content is not allowed in prolog. > Could not resolve ca.weblite:java-objc-bridge:1.0.0. Required by: com.yourname.modid:MYMOD:1.0 > com.mojang:text2speech:1.10.3 > Could not resolve ca.weblite:java-objc-bridge:1.0.0. > Could not parse POM https://repo1.maven.org/maven2/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.pom > Content is not allowed in prolog. > Could not resolve ca.weblite:java-objc-bridge:1.0.0. > Could not parse POM https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.pom > Content is not allowed in prolog. > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. Required by: com.yourname.modid:MYMOD:1.0 > com.mojang:text2speech:1.10.3 com.yourname.modid:MYMOD:1.0 > net.minecraft:launchwrapper:1.12 > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. > Could not parse POM https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom > Content is not allowed in prolog. > Could not resolve org.apache.logging.log4j:log4j-api:2.8.1. > Could not parse POM https://libraries.minecraft.net/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.pom > Content is not allowed in prolog. I don't understand why it can't download the necessary files. I've tried clearing the cache and refreshing the dependencies with no luck. What should I do?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.