Jump to content

Angercraft

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by Angercraft

  1. I've increased the amount of damage the player does, but this results in the damage indicator particles spawning in very large numbers. Any ideas on how I can reduce the number of these particles spawned? They're spawned in the PlayerEntity#attackTargetEntityWithCurrentItem line 1209. Only way I can think of is modifying the base class, but that is a bad idea.
  2. Using the event, just check for who the player is, using their unique id. And you can get the custom name for a mob by using the Entity#getCustomNameTag which you can easily do by getting the killed entity in the event.
  3. You cannot call Minecraft.getMinecraft().thePlayer if you are on the server side. As you're already using the LivingDeathEvent you can call event.getSource().getTrueSource() to get the player who killed the enderman.
  4. Yeah I meant the capabilities. So no argument against using, for example MongoDB, to persist data?
  5. I'm just curious, I've seen some few places, people trying to use databases such as MySQL to persist data for their mods. I know forge already has systems to save data, but would there be a use case, in which you can argue for using a database? From wow private servers I always see the data for items, creatures, and so on saved in a MySQL table, mongodb or something similar. I'd guess this is because there's a lot of data, in which case, could I argue for using a database, if I have a lot of data to save, for example about players? Just curious, and for now the normal systems are great, but for future reference, I would like to know if it is a bad idea to use 3rd party databases, to not make that mistake. Thanks in advance!
  6. Alright, I got it to work. You can detect if a sound is done playing, when it is removed from the Map<ISound, Integer> playingSoundsStopTime located in the SoundEngine. Needed to use reflection to get it working, but for now it seems like a good workaround. Thank you for your time.
  7. Yeah, sorry about the exception, I know about that one, but when just testing I don't worry too much about them. Thank you for the help, I still need to figure out how to check if my custom track is done playing.
  8. Alright, got it all to work, and so far I've got a hacky solution to stop the normal music from playing. But how would I go about detecting when the song is done playing? As I need to return the timeUntilNextMusic to its normal value. private static Field timeUntilNextMusic = null; public static void playTrack() { Minecraft mc = Minecraft.getInstance(); MusicTicker musicTicker = mc.getMusicTicker(); if(timeUntilNextMusic == null) { timeUntilNextMusic = ObfuscationReflectionHelper.findField(MusicTicker.class, "field_147676_d"); } musicTicker.stop(); try { timeUntilNextMusic.setInt(musicTicker, 10000); } catch (IllegalAccessException e) { e.printStackTrace(); } mc.player.playSound(PostCreditsMusic.sound, 1.0F, 1.0F); }
  9. Thank you for your help. Regarding the SoundEvent, will the following be good manners, or should it be registered differently? public static SoundEvent sound; @SubscribeEvent public void registerMusic(RegistryEvent.Register<SoundEvent> event) { sound = new SoundEvent(new ResourceLocation(PostCreditsMusic.MOD_ID, "track")); event.getRegistry().register(sound); }
  10. I'm trying to play a custom piece of music, but would like to not have the background music from the game play, whilst my track is playing. I would like for other sounds, such as mob sounds, doors, and all other sounds than music to still play. As seen below, I tried using the soundhandler, but this doesn't seem to pause the sounds, whilst I play my own track. Any ideas for how I can pause only the background music, only while my own track is playing? import angercraft.postcreditsmusic.PostCreditsMusic; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SoundHandler; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; public class ClientHandler { static Minecraft mc = Minecraft.getInstance(); static SoundEvent sound = new SoundEvent(new ResourceLocation(PostCreditsMusic.MOD_ID, "track")); public static void playTrack() { SoundHandler soundHandler = mc.getSoundHandler(); soundHandler.pause(); mc.player.playSound(sound, 1.0F, 1.0F); } }
  11. I'm using the recommended 1.14.4 - 28.1.0. I just tried with the latest 1.14.4 - 28.1.17, and the problem seems to be fixed now. It probably fixed it, by reimporting the Gradle project, so I will keep that in mind next time. Thank you for your help!
  12. You can retrieve the default textures in "C:\Users\<Username>\AppData\Roaming\.minecraft\versions\1.14.4\minecraft\textures"
  13. @Mod.EventBusSubscriber(modid = Reference.MOD_ID) public class Eventlistener { @SubscribeEvent public static void onRenderGui(GuiOpenEvent event) { if(event.getGui() instanceof EditSignScreen) { if(Keybinds.noSignGui.isKeyDown()) { event.setCanceled(true); } } } @SubscribeEvent public static void onRightClickEmpty(PlayerInteractEvent.RightClickEmpty event) { System.out.println("Empty event"); } @SubscribeEvent public static void onRightClicked(PlayerInteractEvent.RightClickBlock event) { System.out.println("Right click block"); } } The first method onRenderGui(GuiOpenEvent event) does trigger correctly, but I cannot seem to get the other two to trigger, no matter what I do. I tried having it as an object method and registrering it manually, I've tried registering the class with static methods manually, and I've tried the above.
  14. Alright, thank you for your time, and have a great day.
  15. Fantastic, thank you so much for the help. If you have time, could you answer what the best way is to disable the rendering of the original healthbar? Right now I use the event to check if the ElementType is of HEALTH, as can be seen in RPGHUD.java above. But I can see you can set GuiIngameForge.renderHealth = false; which I tried in my FMLPostInitializationEvent for the client side, and this seems to work. But does one of them have a downside, which should deter me from using them?
  16. I'm trying various things whilst modding and thought it would be fun to create a new health bar, like the one found in Diablo 2. https://imgur.com/a/Glwv8pZ The problem is the food bar doesn't render it's textures. Both the code for the Gui class, which is what seems to be breaking the food bar when calling renderHealthBar(), and the code from where I call the method is found below. GuiRPGHealth.java RPGHud.java And the RPGHud is registered on the event bus, on the client side. Thank you in advance!
  17. Okay, I've tried various things, and the only thing I got to work was the following: private static Minecraft minecraft = Minecraft.getMinecraft(); private static Method renderFire1st = ObfuscationReflectionHelper.findMethod(ItemRenderer.class, "func_78442_d", void.class); @SubscribeEvent public static void renderFirstPersonEffect(RenderHandEvent event) { if(minecraft.gameSettings.thirdPersonView == 0) { if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(minecraft.player, event.getPartialTicks())) { try { renderFire1st.invoke(minecraft.getItemRenderer()); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } } } } But this seems like a hacky solution, and I would like to know if I should use an alternative way to do this. Maybe another event to subscribe to.
  18. I've found the method ItemRenderer#renderFireInFirstPerson() and using reflection I can use it, but the fire is not actually shown on the screen. Should I use a different way to render the fire? This is what I have done so far: private static Minecraft minecraft = Minecraft.getMinecraft(); private static Method renderFire1st = ObfuscationReflectionHelper.findMethod(minecraft.getItemRenderer().getClass(), "func_78442_d", void.class); @SubscribeEvent public static void renderEffect(RenderLivingEvent.Post event) { try { if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(minecraft.player, event.getPartialRenderTick())) renderFire1st.invoke(minecraft.getItemRenderer()); } catch (IllegalAccessException | InvocationTargetException e) { System.out.println("Forge was not present."); } } Thank you in advance!
  19. Okay I've gotten it to work, thank you very much! Now I don't have much experience with reflection in Java as it is not covered in my university, but I've read about it and would just like to know if this is considered good practice. @SubscribeEvent @SideOnly(Side.CLIENT) public static void renderEffect(RenderLivingEvent.Post event) { if(affected.contains(event.getEntity())) { Class c = Render.class; try { Method method = c.getDeclaredMethod("renderEntityOnFire", Entity.class, double.class, double.class, double.class, float.class); method.setAccessible(true); method.invoke(event.getRenderer(), event.getEntity(), event.getX(), event.getY(), event.getZ(), event.getPartialRenderTick()); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { System.out.println("Forge was not present, or method name 'renderEntityOnFire' was changed."); } } } I know the exception handling is not proper, but I would like to know if I've handled the reflection properly?
  20. I've seen loads of examples and looked at the documentation found here but I just can't figure out how to play a sound with this. To test with, I've tried the following: @SubscribeEvent public static void brokeBlock(BlockEvent.BreakEvent event) { double x = event.getPlayer().posX; double y = event.getPlayer().posY; double z = event.getPlayer().posZ; event.getWorld().playSound(null, x,y,z, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.PLAYERS, 1.0F, 1.0F); Which may not trigger on both sides, and if not, how would I go about triggering this on both sides? My final goal is having the extinguish sound effect play with certain conditions, but for now I would be happy just getting any sound to play... Thank you in advance! EDIT: Apparently the above works, somehow the changes just didn't make it into the game, until after I restarted...
  21. Appreciate the help, will try it out tomorrow. Thank you very much.
  22. How would I go about manually rendering the fire effect on an entity? I've tried using Entity#setFire but do not want to damage the entity.
  23. How do you do this? I tried reading the guide at https://mcforge.readthedocs.io/en/latest/gettingstarted/dependencymanagement/ but I can't really figure it out. It says we have to drop the jar into our own jar, but where should we place it? The ContainedDeps manifest attribute should hold a list of our .jar dependencies, but should we manually add this to our builded mods manifest, inside the mod jar, or how do we handle this? Thank you in advance!
  24. Okay, it seems one way to do it is, with this: https://github.com/PaleoCrafter/Dependency-Extraction-Example/tree/library-embedding Hope it works out, or someone else can answer this with more knowledge.
  25. I tried a bit, both with a maven repository as a dependency, but also using a jdbc jar file in the root of the file, and it seems that neither of those solutions build the mod with the dependency included. I'm not sure how to solve this and perhaps someone else have a solution, as I couldn't find anyone with quite the same problem as you.
×
×
  • Create New...

Important Information

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