coolAlias
Members-
Posts
2805 -
Joined
-
Last visited
Everything posted by coolAlias
-
1.7.10 SimpleNetworkWrapper, Gui open packet crashing
coolAlias replied to fr0st's topic in Modder Support
Why are you sending a packet??? You can open GUIs directly, especially from a method such as onBlockActivated which gets called on both sides. The reason I made an OpenGuiPacket was so I could open a server-based GUI (such as an inventory) from a key press (i.e. client side). You don't need that here. -
For any block with metadata, I usually check the Minecraft wiki. For doors in particular, metadata is as follows: Top block = 8 + either 0 or 1 for hinge direction (so only values for top are 8 or 9) Bottom block = 0 - west, 1 - north, 2 - east, 3 - south; +4 to flag the door as open (values for bottom range from 0 to 7) Make sure that the block underneath the door is solid and placed before the door.
-
[1.7.10] Spawn Particles Around Armor When Hit
coolAlias replied to Izzy Axel's topic in Modder Support
You should not invert or remove the world.isRemote check - the whole point of it is that you MUST be on the CLIENT side when spawning particles. Not only that, but LivingHurtEvent is typically if not always posted only on the server side. If you want to spawn particles from there, your best bet would be to send a packet to all nearby clients with the data you need to spawn the particles you want. -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
Worked like a charm! Sent a packet when the Gui closes, then replied back to the client and shut the sound down from there. Thanks for getting me to use my IDE -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
Turns out that it IS playing twice, but not in the way one might think. What's happening is that the sound system sends the stop notification, but the sound entry is still in the playingSounds Map - after the Gui closes in Minecraft#displayGuiScreen, it calls SoundHandler#resumeSounds -> SoundMananger#resumeAllSounds and finds the entry still there, for which it then calls SoundSystem#play. I'm not exactly sure how "CommandQueue( new CommandObject( CommandObject.STOP, sourcename) );" works, but for whatever reason it is either not executing properly or something else is going awry. The only thing in my code different from vanilla that I can see is I'm trying to stop the sound from a Gui and the game resumes sounds after it closes, so I'm going to try sending a packet back and forth to stop the sound instead of doing it from inside the Gui. StopAllSounds clears all of the sound maps, which is why it works no matter what. I shall post back with results of my experiment shortly. Thanks again for helping out -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
I tried replacing the playRecord calls in my gui like so: private ISound songTrack; // trigger song: songTrack = PositionedSoundRecord.func_147675_a(new ResourceLocation("records.mall"), x, y, z); mc.getSoundHandler().playSound(songTrack); // turn it off: mc.getSoundHandler().stopSound(songTrack); This has the exact same behavior as everything else - the music stops but immediately restarts from the beginning, even though I'm not playing the sound from anywhere else and the gui has closed. Any ideas why it might be doing this? -
No, you can use the vanilla sounds provided you have the right sound name (which it looks like you do). Your problem is you are misunderstanding the various playSound methods; using the ones in the World class, you have World#playSoundAtEntity and World#playSoundEffect, both of which should be used on the server and will notify nearby clients of the sound to play, and then you have the Entity playSound methods, which should be used on the client and are only heard by that client. A typical example of playing a sound on the server, so everyone can here it: world.playSoundEffect(x, y, z, sound, volume, pitch); // with arguments: world.playSoundEffect(x, y, z, "random.fuse", 1.0F, 1.0F);
-
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
It sure does - I even checked if Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(isound) is returning true in my client proxy method just now, and it does; judging from the SoundManager isSoundPlaying and stopSound methods, this should be enough to guarantee that the sound system is able to stop it. EDIT: Okay, after listening carefully, the record IS stopping, but immediately starts playing again, whether using my custom method or the vanilla one... curiouser and curiouser :\ I'm 100% sure that I'm not playing the record anywhere else, but I'm going to look again anyway. So bizarre. -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
Glad it's not just me So I went ahead and created my own mapped sound positions in my ClientProxy to see more closely what's going on. Now it gets even more interesting - the sound is found playing at the position, but calling 'stopSound(isound)' does not stop it! SoundHandler#stopSounds() works, with the downside that it will stop all other sounds from playing at the same time. Code: Console Output is as expected: [11:15:33] [ZeldaSwordSkills] [iNFO] Playing record on client [11:15:33] [ZeldaSwordSkills] [iNFO] Playing sound at -417/74/838: records.cat [11:15:35] [ZeldaSwordSkills] [iNFO] Song finished - closing screen [11:15:35] [ZeldaSwordSkills] [iNFO] Gui closed, stopping song [11:15:35] [ZeldaSwordSkills] [iNFO] Sound already playing at -417/74/838; stopping sound I'm very confused why the vanilla code works, but me using what seems to be the same code fails. As far as I can tell, it should be doing exactly the same thing. -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
Exactly - WorldManager sends packets, RenderGlobal actually plays the record. In my Gui#keyTyped, I call 'mc.theWorld.playRecord("records.cat", x, y, z);', then in #onGuiClosed(), I call 'mc.theWorld.playAuxSFX(1005, x, y, z, 0);' and 'mc.theWorld.playRecord((String) null, x, y, z);', but the record keeps playing. Pastebin of Gui code; don't mind the ZeldaSongPacket - it doesn't play the record again. Thanks for the help so far. -
How to detect when a certain item entity collide a block
coolAlias replied to madmanu's topic in Modder Support
I think you should take a step back and learn more about Java here. entityItem.getEntityItem() returns an ItemStack, which you are comparing to an Item. You have to compare apples to apples, so to speak: if (entityItem.getEntityItem().getItem() == Item.getItemFromBlock(Blocks.obsidian)) Also, you are confusing both me and probably yourself by having 'entity' AND 'entityItem' - are they the same? Where are these entities coming from? -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
When I searched for references, RenderGlobal#playAuxSFX never showed up, neither from World nor IWorldAccess :\ Nevertheless, you are right - I am not very good with my IDE. Something to work on EDIT: Derp... opened up the type hierarchy and voilá. Lol. However, I'm still confused: calling WorldClient#playRecord iterates through all the IWorldAccesses and calls playRecord, so when I call mc.theWorld.playRecord(null) it should also call RenderGlobal#playRecord(null) automatically, should it not? -
[1.7.10][SOLVED] Stopping records once started
coolAlias replied to coolAlias's topic in Modder Support
RenderGlobal... lol, of course that's where the code was hiding lol. Thanks! -
How to detect when a certain item entity collide a block
coolAlias replied to madmanu's topic in Modder Support
Part of the issue is that onEntityCollidedWithBlock only gets called if the entity physically enters the block's space; for completely solid 1 meter cubes, this is impossible. -
I've been looking all over in vanilla code for how records are handled, and I'm stumped on 2 things: 1. Where do the records actually START playing in vanilla code? 2. How can I stop the record track once it starts without terminating all sounds? So far, I've looked through BlockJukebox and its nested TileEntity, ItemRecord, the World playRecord and playAuxSFX methods, and the Client and Server NetPlayHandlers for S24PacketBlockAction and S28PacketEffect, thinking that there might have been some 'special cases' tucked away in the packet handling, but nope. When ItemRecord is inserted, it plays auxiliary sound effect #1005 with the item id and sets the itemstack in the tile entity. When the record is ejected from the BlockJukebox, it plays aux #1005, with 0 as the 'id' and calls playRecord(null, x, y, z). All of that happens only on the server side, btw. I suspect that the auxiliary sound effect is what's playing the record track, since nothing in BlockJukebox appears to play the record, but I can't find where aux SFX actually get handled. Not in World, WorldClient, WorldServer, packets... Now, I'm playing the record on the client side for now from a Gui (I know how to broadcast via packets if I need), and I can play the record using mc.theWorld.playRecord, BUT I can't get it to stop! For the x/y/z coordinates, I tried using MathHelper.floor_double of mc.thePlayer's position, as well as passing in the x/y/z from the GuiHandler when the gui is opened (which are also from the player's position). I use the same coordinates for playing the song as I do for attempting to stop it. @Override public void onGuiClosed() { if (song != null) { // && ticksSinceLastNote < song.getDuration() LogHelper.info("Gui closed, stopping song"); // prints mc.theWorld.playAuxSFX(1005, x, y, z, 0); // no effect, but this is what BlockJukebox does when the disc is ejected mc.theWorld.playRecord((String) null, x, y, z); // no effect, but this is what BlockJukebox does when the disc is ejected } } I have also sent a packet to the server making the exact same method calls (obviously NOT with mc.theWorld), but to no avail. It looked so obvious when I first wrote the code, but it doesn't work at all. The record just keeps on playing. Does anyone know how the vanilla code actually works in this case?
-
Look at EntitySkeleton: it creates class fields for both the arrow attack and regular attack AI, then has a setCombatTasks method that it calls during construction, when setCurrentItemOrArmor is called, and some other places to remove the old and add the correct combat task. This is the simplest way to go about it.
-
^^^ That. And the link to FML is also posted on this page.
-
[1.7] Throwable Entity is invisible/has no hitbox
coolAlias replied to FishSauce's topic in Modder Support
For one, you didn't read all my notes: // note [b]all the values should be 0[/b] except the final argument, which is scale model.render(entity, 0.0625F, 0.0625F, 0.0625F, 0.0625F, 0.0625F, 0.0625F); Why did you put 0.0625F for ALL of them? Btw, the link to your entity class is opening up your item class rather than the entity. -
From EntityChicken's onLivingUpdate method: if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; }
-
[1.7.10] Custom Projectile hits the own Player
coolAlias replied to Kloonder's topic in Modder Support
Then why do you have a float parameter in your constructor? Just use the super constructor: public EntityBullet(World world, EntityLivingBase entity) { super(world, entity); // done, nothing else here } -
[1.7.10] Custom Projectile hits the own Player
coolAlias replied to Kloonder's topic in Modder Support
Let the super constructor do the positioning for you, and just set the damage; this will at least get the bullet not hitting yourself. If it still doesn't look right, you can try your hand again at the positioning. -
how to detect if a class implements an interface
coolAlias replied to memcallen's topic in Modder Support
In your code sample, you had y-1, but in your debug code sample, you had y+1. Is there a specific reason you did that? -
All key input is client-side only; vanilla keybindings are accessed via the game settings: Minecraft.getMinecraft().gameSettings.keyBindForward/Back/Left/Right. You can use KeyInputEvent to listen for the vanilla movement keys being pressed and send appropriate custom packets if the client player is riding your custom entity, which would basically just add velocity to it (which is usually even done from the client side - heck, you might not even need packets if you are only modifying movement). Anyway, I'd look at the Horse / Pig and see how they do it.
-
[1.7.10] Custom entity renderer isn't rendering
coolAlias replied to MikaXD's topic in Modder Support
You also need to register the entity: EntityRegistry.registerModEntity(EntityMyExplosivePrimed.class, "myexplosive", index, YourMod.instance, 160, 10, true); 'index' is simply a number for your mod entities - I always start it at 1 for my first entity and increment it for each additional entity registered. Go to net.minecraft.entity.EntityTracker to find the final values you should use; in the case of primed TNT, it uses 160 for the tracking range, 10 for the update frequency, and true to send velocity updates to nearby players.