Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

chimera27

Members
  • Joined

  • Last visited

Everything posted by chimera27

  1. Thanks, I feel pretty stupid for not realizing that
  2. You could use the items onUpdate method: int tickssinceshot = 0; @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isHeld) { if (isHeld) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (player.getHeldItem().getItem() instanceof ItemRifle) { ItemRifle rifle = (ItemRifle) player.getHeldItem().getItem(); tickssinceshot++; if(tickssinceshot >= /** TICKS BETWEEN SHOTS**/){ /**SPAWN YOUR PROJECTILE (You have to use packets for this, i'll show you below) **/ tickssinceshot = 0; } } } } } Literally just throw this into your item class and modify the few things I commented. I just realized you're gonna need packets, but they're pretty simple. To make a packet handler just register it with: public static final MODNAMEPacketPipeline packetPipeline = new MODNAMEPacketPipeline(); In your main class (not in any load method or anything) And put this: packetPipeline.initialise(); In your load method in your main class. Next, add a packet 'template' that all your packets will extend: Add a packet class that will do the bullet entity spawning: (NOTE: You can re-use the same packet in all your guns, when you run the code to send the packet you just have to add a variable for what kind of bullet to shoot, and add a switch for it in the packet. In this example, I use bulletid as the identifier of what kind of bullet to shoot) YOURMODBulletPacket: And add the class called YOURMODPacketPipline: FINALLY, add this code where I said to put the bullet spawning code in the onUpdate method: Main.packetPipeline.sendToServer(new YOURMODBulletPacket((byte) WHATEVER BULLETID YOU WANT THE PACKET TO SPAWN); Note: I used http://www.minecraftforge.net/wiki/Netty_Packet_Handling for basically all my packet stuff, take a look at it if you're still confused! (Credit to that tutorial for this explanation aswell because I used alot of their code )
  3. Hmm, this seems to be working for blocks, but is ignoring entities (the entity hit is always returning null) It might have something to do with me not using it correctly, since I can't check the partial tick time from this class I just used render tick time which I thought might work in this case, but even if I put a static number there it doesn't change anything so I don't know how much it's really doing (I did modify it to just return mc.renderViewEntity.rayTrace(d0, par1) because a movingobjectposition is much more useful then a vec3, and I removed the this.mc.pointedEntityLiving = null; because I would assumed it wouldn't do much here, but the fact it does work for blocks is puzzling...)
  4. It has a tileentity right? Check to make sure it's saving the chests inventory to NBT correctly, that's usually the problem Edit: It would be helpful if you could provide the code for the chest and it's tileentity BTW
  5. To get the world just use player.worldObj Removing the override it breaks it, you should work around it instead of remove it (for example, just use something else that runs every tick and already gives you the world object to check if the player is right clicking with your item and spawn the entity.
  6. Those seem to work quite a bit differently, and are quite complex and hard to follow... The fact that this code works sometimes makes me think i'm on the right track Edit: Managed to get pitch to work with this code: double d0 = player.posX - target.posX; double d1 = player.posY - target.posY; double d2 = player.posZ - target.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); float f = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f1 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); System.out.println("Pitchy thing: " + f1); // player.rotationPitch = f1; player.rotationYaw = f + 180; Pitch is still changing exactly the same as a graph of tan(x) as you circle the entity though.....
  7. Anyone? I really have no idea why these equations arn't working..... as far as I can tell they SHOULD.......
  8. Use MinecraftForge.EVENT_BUS.register(new IfAPlayerDie()); instead of FMLCommonHandler.instance().bus().register(new IfAPlayerDie()); I don't know about the recipies
  9. chimera27 posted a topic in Modder Support
    I'm trying to use trig to calculate the angles between the playe and an entity to change the players view angle to look at them. I'm normally pretty good at trig, but we haven't covered how to use it in 3D like this before. I gave it a shot anyway, and came up with this code: The yaw code works half the time, and pitch works maybe one percent of the time and is glitchy as hell. The yaw code works when the player is looking one side of the entity, as soon as you cross into the other it flips and gets weird (presumubly something with the range of atan being -pi/2 - pi/2). rotationPitch on the other hand almost works if you look at the entity from just the right direction, as you strafe around it left/right it moves further away from the point it's supposed to exponentally. One thing I noticed was that at least vertically, looking down increases degrees and up decreases it Anyone know what I should do?/Where i'm messing up? (also on a side note if anyone knows how to/if I can increase the range on minecraft.getMinecraft().objectMouseOver that would be awesome )
  10. Still not working Also, how do I get the player from RenderTickEvent? Is there a player render tick or something of the sort?
  11. If you can get the player variable from RenderGameOverlayEvent via event.player or something of the sort,mthen just use event.player.isPotionActive(etc.) to check. If you can't (I think you can...) you MIGHT be able to put the rendering code in a player tick hook (functions the exact same as a LivingUpdateEvent but only runs for the player, which you would want because mobs can't have an overlay, so there's no sense in running any code for them).
  12. You could just make your own by adding worldgen code that picks random spots during worldgen and puts a water source there if there's an air block on one side and stone/any other block on the others. I think there are quite a few tutorials for doing things like this, and it would seem you already have some experience with worldgen, so it shouldn't be hard
  13. I'm trying to change the players looking direction to face an entity, but don't know how. I have code to get the entity the player is looking at, and did the trig to get the angles to set it to, but can't figure out how to set it. Here's my code for handling this kind of thing (run every tick, probs because i'm stupid and don't know a better way ) Anyone know a good way to do this?
  14. *sigh You have to have a main mod class set up to do ANYTHING. Literally, ANYTHING. Here's some tutorials for setting it up: http://www.wuppy29.com/minecraft/modding-tutorials/forge-modding/ After that, learn how to use forge events via forges tutorial page, (a link to it is on the main menu for this website) and do what he said and add code for your custom title screen. Do you atleast know Java? If not learn that first. Changing the main menu is a pretty advanced thing to do, and requires a descent amount of knowledge on how forge and minecraft both work, it definitely shouldn't be the first thing you try, if you're doing a mod for a server add some items and stuff you want to add first, and get familiar with the environment. THEN maybe try to do it (again, with forge events)
  15. Doing something like this is definitely NOT the first thing you should be doing IMO, also you can fined a TON of great tutorials just by searching for them on google! Once you have a base mod setup then what TLHPoE said is DEFINITELY the way to go on remaking it, not sure if the game has other parts of it that won't get canceled like the music, but it's definitely good for a simple layout change or something of the sort!
  16. Well, to use things like this, you have to understand the code your using. First, that is definitely NOT the place to put it, not anywhere close. Let me walk you through what you have so far... Right now, what you are doing is subscribing to forges event handler (that's what the @SubscribeEvent is, it's telling forge to run that function when the kind of event you specify happens) the LivingEvent.LivingUpdateEvent tells forge every entity should run this code for itself each update. In your case, since enemies and other things shouldn't get any kind of overlay, you should change this to something else (I'll get to that). Next, it's checking if the entity it's running the code for has the buff with event.entityliving.ispotionactive, and if it has the effect then it's damaging it for 2 damage with event.entityliving.attackentityfrom (remember this code is running each tick, so 20 times a second. I would assume you don't want the attacking to happen, or at least not that rapidly, so you should remove this code. Finally, it's picking a number between 1 and 20, and if it equals 20 it's running the code in the area you think you should put the overlay, effectively rendering the overlay about once a second, for a tick (a 20th of a second). If you want something to be happening constantly (to the game every tick is constantly), don't put it in that area (infact you could probs delete that whole if statment). To do something to any entity with your effect, use event.entityLiving.INSERTWHATEVERFUNCTIONYOUWANTTOCALLHERE, or something similar. For the overlay, you'll need to make another class very similar to this, but without the code in the onEntityUpdate function. Then, you'll need to change LivingEvent.LivingUpdateEvent to RenderGameOverlayEvent. This tells forge to run your code every time it's drawing the game overlay Then you should do a check to see if the player has your potion effect (to see how, you already did it in the code you have), and you'll need to put all the rendering code in that if statment. You can find how to do the rendering online, there should be plenty of tutorials on screen overlays and HUD's (I wouldn't search for doing it with potion effects though, there might not be any for that in specific and adapting the code for something else like a helmet HUD is easy) BTW, if you're gonna use tutorials make sure you follow along and know WTF you're actually doing and pay attention to how it works while you're following it instead of just copying and pasting blindly. (Other people on these forums might not be so tolerant of people who just copy from tutorials and expect it to work )
  17. It seems like it is, I managed to track down an error log, and it never mentions a single line of my code: EDIT: Managed to track down an error log:
  18. You can check if the player has a potion effect from almost anywhere you'd need it, so you can do anything you want. If you want to do something like that, just use the PlayerTickEvent hook to render a overlay if the player has your potion effect on (which you can check with player.isPotionActive(yourpotioneffect) ) There's plenty of tutorials on the rendering part of that too btw, it's not really that complicated
  19. I wish I knew, but ATM i'm still trying to trigger it intentionally. All I know is it's happening on world load, and seems to cause world loading to fail somehow. I was just wondering if anyone knew of this or had encountered it before, because that would make debugging it immensely easier...
  20. I've come across a problem in my mod that is proving VERY difficult to debug. On a somewhat rare occasion, the players inventory is being wiped on world load. I have no idea what is causing it, it doesn't seem to be random though (opening/closing a world repeatedly a large amount of times did not produce the bug). If it generates some error it's not present in the games log files. The only thing I know about it is that whenever it happens, my first try opening a world will fail. What I mean by this is I will try to open a world, and it will go right back to the title screen. When I try to open the world again, the players inventory is empty. Has anyone encountered this before or does anyone have any ideas on what I should try? I can supply any classes if needed, and again, it doesn't produce an error or anything of the sort EDIT: Managed to track down an error log:
  21. If I'm interpreting this correctly, couldn't you just reduce its spawn rate by only making it generate X amount of the time? For example, if you wanted it to generate a quarter as much then you could generate a random number between one and four and only have it generate if the number is four? Alternatively, you could make the structure generate a specific block in the dead center of it, and each generation make sure there isn't one of those blocks within X blocks of the new generation (via 3 stacked for loops)
  22. You have 2 pushmatrix's in your render class, delete the second one!! That should fix it!
  23. Get rid of the @ForgeSubscibe and replace it with @SubscribeEvent, and register it with this in your preinit: FMLCommonHandler.instance().bus().register(new CommonTickHandler()); instead of the old way. Also change onPlayerTick(tickevent event) into onPlayerTick(TickEvent.PlayerTickEvent event){ } Hope this helps!!
  24. I just had a few questions about various things that I was unable to figure out on my own. First, I was wondering if there is a way to interrupt or stop a sound effect that's playing, like for instance start a sound effect but cut it off after X happens. As far as i've seen as soon as a sound effect starts then it just goes and there isn't a real way to stop it, but I was wondering if anyone else knew some way to do this. Another thing I was wondering (also likely impossible), was if it was possible to ignore the flashtime on a enemy and allow a projectile/item/misc damage source to hurt them faster then that. The method i've been using (entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage) Does not allow for this, neither does a standard sword. If anyone could say if either of these are possible, that would be awesome
  25. I feel SO stupid now, it just clicked for me on how this whole setup kinda functions.. thanks for the help both of you!! I think i'll leave this thread open just incase someone else has a question

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.