Jump to content

Wuble

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Wuble

  1. I am having an issue with my mod where there will be chat messages that repeat, though I can't seem to find it. There's no issue in single player, but on multiplayer, this happens: This server has an anti-spam, where 2 messages in a row can't be the same, therefore it's repeating messages. However, I can't figure out where in the code it would do that (I'm probably missing something obvious). [spoiler=Main]package com.wuble.chattranslate; import com.wuble.chattranslate.handler.ChatHandler; import com.wuble.chattranslate.handler.ConfigurationHandler; import com.wuble.chattranslate.proxy.IProxy; import com.wuble.chattranslate.reference.ClassReference; import com.wuble.chattranslate.reference.NameReference; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import com.memetix.mst.translate.Translate; @Mod(modid = NameReference.MODID, name = NameReference.MODNAME, version = NameReference.VERSION) public class ChatTranslate { public static String langDefault, clientId, clientSecret; @Mod.Instance(NameReference.MODID) public static ChatTranslate instance; @SidedProxy(clientSide = ClassReference.CLIENT_PROXY_CLASS, serverSide = ClassReference.SERVER_PROXY_CLASS) public static IProxy proxy; @Mod.EventHandler public static void preInit (FMLPreInitializationEvent event){ ConfigurationHandler.init(event.getSuggestedConfigurationFile()); FMLCommonHandler.instance().bus().register(new ConfigurationHandler()); try{ initializeTranslate(); } catch (Exception e) {e.printStackTrace(); } MinecraftForge.EVENT_BUS.register(new ChatHandler()); } @Mod.EventHandler public static void init(FMLInitializationEvent event){ } @Mod.EventHandler public static void postInit(FMLPostInitializationEvent event){ } public static void initializeTranslate() throws Exception { Translate.setClientId(ConfigurationHandler.clientId); Translate.setClientSecret(ConfigurationHandler.clientSecret); } } [spoiler=Thread]package com.wuble.chattranslate.thread; import com.memetix.mst.detect.Detect; import com.memetix.mst.language.Language; import com.memetix.mst.translate.Translate; import com.wuble.chattranslate.handler.ChatHandler; import com.wuble.chattranslate.handler.ConfigurationHandler; import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; public class TranslateThread extends Thread { public static String receivedMessage, receivedFormatted; private static Language from, langDefault; @Override public void run(){ receivedMessage = ChatHandler.receivedMessage; receivedFormatted = ChatHandler.receivedFormatted; langDefault = Language.fromString(ConfigurationHandler.langDefault); try {from = Detect.execute(receivedMessage);} catch(Exception e){e.printStackTrace();} if (from == langDefault){ Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(receivedFormatted)); } else { try {Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(Translate.execute(receivedMessage, from, langDefault) + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + " [From: " + from.getName(langDefault) + "]" ).setChatStyle(ChatHandler.clickableChat)); } catch(Exception e) { e.printStackTrace(); } } } } [spoiler=ChatHandler]package com.wuble.chattranslate.handler; import com.wuble.chattranslate.thread.TranslateThread; import net.minecraft.event.HoverEvent; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatStyle; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ChatHandler { public static String receivedMessage, receivedFormatted; public static ChatStyle clickableChat; @SubscribeEvent public void onClientChatReceived(ClientChatReceivedEvent event){ receivedFormatted = event.message.getFormattedText(); receivedMessage = event.message.getUnformattedText(); HoverEvent chatHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(receivedFormatted)); clickableChat = new ChatStyle().setChatHoverEvent(chatHover); event.setCanceled(true); new TranslateThread().start(); } } ^^ This appears to have been the issue.
  2. Hello! I am currently developing a mod which will translate chat that is received to the chosen language (currently hard-coded to English). I am doing this with Microsoft translate. I've come across the issue that, upon receiving a chat message, the game will temporarily lag. If I'm correct, this is due to waiting to get the detect result for every message (Detect.execute). Would there be a way to fix this so that it doesn't lag the game? VIDEO: https://www.youtube.com/watch?v=vleaJqNftCE (Though it's short, it's visible that every received chat message lags the game.) [spoiler=Code] package com.wuble.chattranslate.handler; import com.memetix.mst.translate.Translate; import com.memetix.mst.detect.Detect; import com.memetix.mst.language.Language; import net.minecraft.util.*; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ChatHandler { public static String receivedMessage, sentMessage; public static Language from; @SubscribeEvent public void onClientChatReceived(ClientChatReceivedEvent event){ receivedMessage = event.message.getUnformattedText(); try {from = Detect.execute(receivedMessage); } catch (Exception e) { } if (from == Language.ENGLISH) { } else { try { sentMessage = Translate.execute(receivedMessage, from, Language.ENGLISH) + " §7§o[From: " + from.getName(Language.ENGLISH) + "§7§o]"; event.message = new ChatComponentText(sentMessage); } catch (Exception e) { } } } }
  3. It works! Thank you so much! I forgot to put the = new Random() at the end. By the way, you can't use player.getRNG() in that format because it's a random and it doesn't like to be used with floats.
  4. I've tried this, this is what my code looks like so far (I changed the particle position and velocity code to match that of an enderman) package selfparticlesmod.main; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class PlayerTickHandler { public int particleNumber = 1; public Random rand; private Minecraft mc; public PlayerTickHandler(Minecraft mc) { this.mc = mc; } public World world; @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { if(event.side.isClient()) { EntityPlayer player = (EntityPlayer) event.player; short short1 = 128; for (int l = 0; l < 2; l++) { double d3 = player.posX; double d4 = player.posY; double d5 = player.posZ; double d6 = (double)l / ((double)short1 - 1.0D); float f = (rand.nextFloat() - 0.5F) * 0.2F; float f1 = (rand.nextFloat() - 0.5F) * 0.2F; float f2 = (rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (player.posX - d3) * d6 + (rand .nextDouble() - 0.5D) * (double)player.width * 2.0D; double d8 = d4 + (player.posY - d4) * d6 - rand.nextDouble() * (double)player.height; double d9 = d5 + (player.posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * (double)player.width * 2.0D; player.worldObj.spawnParticle("portal", d7, d8, d9, (double)f, (double)f1, (double)f2); player.addChatMessage(new ChatComponentText("Particle spawned")); } } } } The only problem is that, upon loading a world, it crashes when it reaches line 40. Line 40: float f = (rand.nextFloat() - 0.5F) * 0.2F; Because of: java.lang.NullPointerException: Ticking entity [spoiler=Crash Report]---- Minecraft Crash Report ---- // Shall we play a game? Time: 9/16/14 5:11 PM Description: Ticking entity java.lang.NullPointerException: Ticking entity at selfparticlesmod.main.PlayerTickHandler.onPlayerTick(PlayerTickHandler.java:40) at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_PlayerTickHandler_onPlayerTick_PlayerTickEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:344) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:273) at net.minecraft.client.entity.EntityClientPlayerMP.onUpdate(EntityClientPlayerMP.java:100) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2253) at net.minecraft.world.World.updateEntity(World.java:2213) at net.minecraft.world.World.updateEntities(World.java:2063) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) at net.minecraft.client.Minecraft.run(Minecraft.java:961) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at GradleStart.bounce(GradleStart.java:107) at GradleStart.startClient(GradleStart.java:100) at GradleStart.main(GradleStart.java:55) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at selfparticlesmod.main.PlayerTickHandler.onPlayerTick(PlayerTickHandler.java:40) at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_PlayerTickHandler_onPlayerTick_PlayerTickEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:344) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:273) at net.minecraft.client.entity.EntityClientPlayerMP.onUpdate(EntityClientPlayerMP.java:100) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2253) at net.minecraft.world.World.updateEntity(World.java:2213) -- Entity being ticked -- Details: Entity Type: null (net.minecraft.client.entity.EntityClientPlayerMP) Entity ID: 421 Entity Name: ForgeDevName Entity's Exact location: -293.49, 74.62, 262.99 Entity's Block location: World: (-294,74,262), Chunk: (at 10,4,6 in -19,16; contains blocks -304,0,256 to -289,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0.00, 0.00, 0.00 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2063) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['ForgeDevName'/421, l='MpServer', x=-293.49, y=74.62, z=262.99]] Chunk stats: MultiplayerChunkCache: 85, 85 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (-256,64,232), Chunk: (at 0,4,8 in -16,14; contains blocks -256,0,224 to -241,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 5476 game time, 5476 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 113 total; [EntitySpider['Spider'/256, l='MpServer', x=-225.47, y=51.00, z=321.53], EntitySkeleton['Skeleton'/63, l='MpServer', x=-366.50, y=46.00, z=239.50], EntityCreeper['Creeper'/62, l='MpServer', x=-364.28, y=45.00, z=239.50], EntityZombie['Zombie'/61, l='MpServer', x=-364.63, y=50.00, z=214.03], EntityChicken['Chicken'/68, l='MpServer', x=-363.47, y=73.00, z=282.16], EntitySheep['Sheep'/69, l='MpServer', x=-362.63, y=73.00, z=282.16], EntityCreeper['Creeper'/70, l='MpServer', x=-362.56, y=31.00, z=290.97], EntitySkeleton['Skeleton'/64, l='MpServer', x=-367.50, y=46.00, z=241.50], EntityEnderman['Enderman'/65, l='MpServer', x=-356.44, y=41.00, z=240.84], EntityZombie['Zombie'/66, l='MpServer', x=-359.41, y=20.00, z=266.69], EntitySkeleton['Skeleton'/67, l='MpServer', x=-352.53, y=28.00, z=276.93], EntitySheep['Sheep'/72, l='MpServer', x=-367.72, y=75.00, z=296.81], EntitySheep['Sheep'/73, l='MpServer', x=-353.00, y=76.00, z=314.38], EntityBat['Bat'/85, l='MpServer', x=-343.01, y=18.07, z=254.55], EntityBat['Bat'/84, l='MpServer', x=-347.38, y=42.10, z=231.47], EntitySheep['Sheep'/87, l='MpServer', x=-347.19, y=76.00, z=319.09], EntitySheep['Sheep'/86, l='MpServer', x=-351.25, y=72.00, z=274.66], EntitySheep['Sheep'/81, l='MpServer', x=-342.13, y=68.00, z=204.13], EntitySkeleton['Skeleton'/83, l='MpServer', x=-338.14, y=15.00, z=234.35], EntitySheep['Sheep'/82, l='MpServer', x=-342.56, y=68.00, z=208.75], EntitySheep['Sheep'/89, l='MpServer', x=-343.34, y=68.00, z=334.47], EntitySheep['Sheep'/88, l='MpServer', x=-348.06, y=76.00, z=327.50], EntitySheep['Sheep'/102, l='MpServer', x=-331.81, y=72.00, z=196.53], EntitySheep['Sheep'/103, l='MpServer', x=-320.38, y=72.00, z=200.09], EntitySkeleton['Skeleton'/100, l='MpServer', x=-330.50, y=26.00, z=193.84], EntitySkeleton['Skeleton'/101, l='MpServer', x=-329.50, y=26.00, z=200.50], EntitySkeleton['Skeleton'/98, l='MpServer', x=-331.50, y=30.00, z=195.50], EntitySkeleton['Skeleton'/99, l='MpServer', x=-330.47, y=20.00, z=193.84], EntitySheep['Sheep'/111, l='MpServer', x=-334.66, y=70.00, z=335.50], EntitySheep['Sheep'/108, l='MpServer', x=-334.34, y=74.00, z=262.88], EntityChicken['Chicken'/109, l='MpServer', x=-329.88, y=72.00, z=268.53], EntitySheep['Sheep'/106, l='MpServer', x=-321.50, y=71.00, z=212.59], EntitySheep['Sheep'/107, l='MpServer', x=-327.06, y=75.00, z=253.09], EntitySheep['Sheep'/104, l='MpServer', x=-331.31, y=70.00, z=207.25], EntitySheep['Sheep'/105, l='MpServer', x=-335.34, y=70.00, z=200.50], EntitySheep['Sheep'/119, l='MpServer', x=-308.38, y=74.00, z=211.19], EntitySheep['Sheep'/118, l='MpServer', x=-307.88, y=74.00, z=220.13], EntitySheep['Sheep'/117, l='MpServer', x=-317.34, y=74.00, z=195.56], EntityZombie['Zombie'/127, l='MpServer', x=-317.50, y=63.00, z=319.31], EntitySheep['Sheep'/126, l='MpServer', x=-308.13, y=76.00, z=292.09], EntityHorse['Horse'/125, l='MpServer', x=-316.66, y=77.00, z=281.66], EntitySheep['Sheep'/124, l='MpServer', x=-319.63, y=76.00, z=259.81], EntitySheep['Sheep'/123, l='MpServer', x=-306.75, y=72.00, z=241.31], EntitySheep['Sheep'/122, l='MpServer', x=-313.38, y=72.00, z=245.34], EntitySheep['Sheep'/121, l='MpServer', x=-313.59, y=72.00, z=239.22], EntitySheep['Sheep'/120, l='MpServer', x=-307.16, y=73.00, z=238.91], EntitySheep['Sheep'/139, l='MpServer', x=-301.47, y=75.00, z=213.34], EntitySheep['Sheep'/141, l='MpServer', x=-302.78, y=73.00, z=266.34], EntitySheep['Sheep'/140, l='MpServer', x=-303.34, y=72.00, z=246.38], EntityHorse['Horse'/143, l='MpServer', x=-289.66, y=73.00, z=265.60], EntitySheep['Sheep'/142, l='MpServer', x=-298.22, y=73.00, z=266.63], EntityItem['item.item.seeds'/152, l='MpServer', x=-288.97, y=72.13, z=317.41], EntityBat['Bat'/153, l='MpServer', x=-301.10, y=27.48, z=330.29], EntityHorse['Horse'/144, l='MpServer', x=-292.44, y=73.00, z=282.44], EntityHorse['Horse'/145, l='MpServer', x=-288.72, y=74.00, z=279.00], EntityHorse['Horse'/146, l='MpServer', x=-288.41, y=72.00, z=295.78], EntitySheep['Sheep'/147, l='MpServer', x=-297.38, y=73.00, z=289.78], EntityHorse['Horse'/148, l='MpServer', x=-290.19, y=73.00, z=289.19], EntitySkeleton['Skeleton'/149, l='MpServer', x=-288.53, y=42.00, z=306.97], EntityItem['item.item.seeds'/150, l='MpServer', x=-292.19, y=73.13, z=309.44], EntitySheep['Sheep'/151, l='MpServer', x=-301.28, y=73.00, z=306.50], EntitySheep['Sheep'/171, l='MpServer', x=-286.52, y=75.00, z=217.44], EntitySheep['Sheep'/170, l='MpServer', x=-275.09, y=72.00, z=206.03], EntityChicken['Chicken'/175, l='MpServer', x=-282.56, y=74.00, z=251.53], EntityChicken['Chicken'/174, l='MpServer', x=-284.56, y=74.00, z=234.16], EntityChicken['Chicken'/173, l='MpServer', x=-276.44, y=73.00, z=213.41], EntitySheep['Sheep'/172, l='MpServer', x=-285.78, y=74.00, z=222.59], EntityCreeper['Creeper'/187, l='MpServer', x=-263.00, y=26.00, z=216.53], EntitySheep['Sheep'/190, l='MpServer', x=-262.22, y=77.00, z=256.03], EntityZombie['Zombie'/188, l='MpServer', x=-260.91, y=35.00, z=215.47], EntitySheep['Sheep'/189, l='MpServer', x=-269.28, y=73.00, z=219.59], EntityClientPlayerMP['ForgeDevName'/421, l='MpServer', x=-293.49, y=74.62, z=262.99], EntitySkeleton['Skeleton'/205, l='MpServer', x=-254.69, y=23.92, z=214.47], EntityBat['Bat'/204, l='MpServer', x=-246.25, y=26.10, z=217.53], EntitySkeleton['Skeleton'/207, l='MpServer', x=-247.59, y=22.00, z=217.31], EntitySkeleton['Skeleton'/206, l='MpServer', x=-248.09, y=23.00, z=216.38], EntityCreeper['Creeper'/203, l='MpServer', x=-256.00, y=25.00, z=206.44], EntitySheep['Sheep'/220, l='MpServer', x=-244.53, y=77.00, z=277.47], EntityCreeper['Creeper'/216, l='MpServer', x=-252.50, y=49.00, z=272.50], EntityCreeper['Creeper'/217, l='MpServer', x=-251.66, y=49.00, z=272.63], EntitySheep['Sheep'/218, l='MpServer', x=-244.33, y=75.00, z=287.85], EntitySheep['Sheep'/219, l='MpServer', x=-244.53, y=77.00, z=277.47], EntitySkeleton['Skeleton'/212, l='MpServer', x=-242.88, y=19.00, z=259.38], EntityCreeper['Creeper'/213, l='MpServer', x=-251.97, y=49.00, z=269.56], EntitySheep['Sheep'/214, l='MpServer', x=-248.56, y=79.00, z=271.47], EntitySheep['Sheep'/215, l='MpServer', x=-253.56, y=80.00, z=261.81], EntityCreeper['Creeper'/208, l='MpServer', x=-245.53, y=23.00, z=216.84], EntityCreeper['Creeper'/209, l='MpServer', x=-248.28, y=21.00, z=255.06], EntitySheep['Sheep'/210, l='MpServer', x=-241.53, y=82.00, z=249.16], EntitySheep['Sheep'/211, l='MpServer', x=-241.53, y=81.00, z=246.13], EntitySheep['Sheep'/239, l='MpServer', x=-232.47, y=82.00, z=246.53], EntitySheep['Sheep'/238, l='MpServer', x=-233.53, y=82.00, z=245.47], EntityBat['Bat'/237, l='MpServer', x=-236.25, y=19.10, z=244.25], EntityBat['Bat'/236, l='MpServer', x=-230.19, y=23.96, z=235.25], EntityCreeper['Creeper'/235, l='MpServer', x=-228.66, y=22.00, z=219.31], EntityZombie['Zombie'/234, l='MpServer', x=-224.53, y=20.00, z=222.91], EntityBat['Bat'/233, l='MpServer', x=-224.84, y=22.10, z=214.91], EntityChicken['Chicken'/254, l='MpServer', x=-234.47, y=71.00, z=317.47], EntityZombie['Zombie'/255, l='MpServer', x=-228.09, y=27.00, z=322.41], EntityChicken['Chicken'/252, l='MpServer', x=-231.38, y=72.00, z=300.44], EntityZombie['Zombie'/253, l='MpServer', x=-234.97, y=17.00, z=318.44], EntitySheep['Sheep'/250, l='MpServer', x=-230.53, y=81.92, z=272.53], EntitySheep['Sheep'/251, l='MpServer', x=-236.97, y=74.00, z=296.97], EntityChicken['Chicken'/248, l='MpServer', x=-230.41, y=75.00, z=282.41], EntityChicken['Chicken'/249, l='MpServer', x=-236.56, y=75.00, z=281.53], EntitySheep['Sheep'/246, l='MpServer', x=-238.25, y=85.00, z=267.19], EntitySheep['Sheep'/247, l='MpServer', x=-234.94, y=76.00, z=278.69], EntityChicken['Chicken'/244, l='MpServer', x=-225.75, y=85.00, z=261.56], EntityChicken['Chicken'/245, l='MpServer', x=-235.47, y=86.00, z=265.47], EntityChicken['Chicken'/242, l='MpServer', x=-233.25, y=85.00, z=257.84], EntityChicken['Chicken'/243, l='MpServer', x=-231.53, y=87.00, z=269.59], EntitySheep['Sheep'/240, l='MpServer', x=-235.47, y=82.00, z=246.47], EntityCreeper['Creeper'/241, l='MpServer', x=-225.62, y=62.00, z=270.47]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:417) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2568) at net.minecraft.client.Minecraft.run(Minecraft.java:982) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at GradleStart.bounce(GradleStart.java:107) at GradleStart.startClient(GradleStart.java:100) at GradleStart.main(GradleStart.java:55)
  5. Although that seems as it would work, I think it registers the player before opening the world, so it can't spawn the world. Would I also be able to check if a world is loaded and rendering?
  6. So, I believe I have fixed this issue, as it now goes into the code and crashes upon reaching "thePlayer", as it's not in game and it is attempting to run it. Is there any way I can fix this? Basically, it can't find the mc.thePlayer, and it's crashing upon the first frame of the menu. Is there a check I can have to see if they're in the game before running the code to spawn particles? [spoiler=Crash log]java.lang.NullPointerException at selfparticlesmod.main.RenderTickHandler.onRenderTick(RenderTickHandler.java:31) ~[RenderTickHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_RenderTickHandler_onRenderTick_RenderTickEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.onRenderTickStart(FMLCommonHandler.java:334) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1065) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:961) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67] at GradleStart.bounce(GradleStart.java:107) [start/:?] at GradleStart.startClient(GradleStart.java:100) [start/:?] at GradleStart.main(GradleStart.java:55) [start/:?]
  7. So, the basic gist of it is I'm trying to spawn particles on the client side, just a test, see if I can get it to spawn when you're on a server, as it's just client side. The problem is that I can't get it to spawn in the first place. I may be going about this all wrong, but I'm trying to make a RenderTickHandler to spawn 2 "portal" particles (like the Enderman) each tick. (I've taken the velocity and spawning from there as well). I've done google searches a lot, and I don't know if I've even done the start of the spawning correct, so any feedback would be appreciated. I didn't register it in my main mod class as I read that it was done in the ClientProxy. VV ClientProxy VV package selfparticlesmod.client; import net.minecraft.client.Minecraft; import cpw.mods.fml.common.FMLCommonHandler; import selfparticlesmod.main.RenderTickHandler; import selfparticlesmod.main.CommonProxy; public class ClientProxy extends CommonProxy{ public static void registerRenderers(){ } @Override public void initialize() { super.initialize(); FMLCommonHandler.instance().bus().register(new RenderTickHandler(Minecraft.getMinecraft())); } } VV RenderTickHandler VV package selfparticlesmod.main; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.world.World; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderTickHandler { public int particleNumber = 1; public Random rand; private Minecraft mc; public RenderTickHandler(Minecraft mc) { this.mc = mc; } public World world; @SubscribeEvent public void onRenderTick(RenderTickEvent event) { for (int countparticles = 0; countparticles < 2; countparticles++) { mc.thePlayer.worldObj.spawnParticle("portal", mc.thePlayer.posX + (rand.nextDouble() - 0.5D) * (double)mc.thePlayer.width, mc.thePlayer.posY + rand.nextDouble() * (double)mc.thePlayer.height - 0.25D, mc.thePlayer.posZ + (rand.nextDouble() - 0.5D) * (double)mc.thePlayer.width, (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2.0D); } } }
  8. So, I've been trying to make a backpack... How would you make a backpack, exactly? I want it so that if you pick up an item that's in the backpack, it'll get sucked into the backpack. Is there a way to check what item you picked up, then move it into the backpack? Also, would there be a way to make it auto-craft when it gets in there? Like, if I had an item in there that says "If you can, use items to craft this!"? Thanks! Sincerely, Wub
  9. I've been trying to make an umbrella hat mod (for fun), and I've been coming across the problem that I can't seem to get an umbrella to appear above my head when I look up. Is there any good way to do this? I've searched and couldn't really find anything. Thanks, Wub
  10. I've been making a mod, and I've come across something. I want to keep the amount of classes in my mod to a minimal, but I still need all of the items(derr). I'm making swords, and don't want to make a class for every single recipe of every item. Is there a way to make it check what the item's made of (including custom materials) and name/texture it appropriately, along with the mob damage, durability, etc? Thanks -Wub
×
×
  • Create New...

Important Information

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