
pingoleon60
Members-
Posts
18 -
Joined
-
Last visited
Everything posted by pingoleon60
-
[SOLVED][1.7.10] Packet handling client error
pingoleon60 replied to pingoleon60's topic in Modder Support
So quick lol. Thank you very much! -
Hello everyone. I've been working on a server to client packet recently. So I've done this: public class SendBipedCostumes implements IMessage { public Quintet<Float,String,String,Float,Float>[] modelsDeclaration; public SendBipedCostumes() { } public SendBipedCostumes(Quintet<Float,String,String,Float,Float>[] modelsDeclaration) { this.modelsDeclaration = modelsDeclaration; } @Override public void fromBytes(ByteBuf buf) { System.out.println("Reading..."); int size = Integer.parseInt(ByteBufUtils.readUTF8String(buf)); ArrayList<Quintet<Float,String,String,Float,Float>> models = new ArrayList<Quintet<Float,String,String,Float,Float>>(); // new Object[size]; for (int i = 0; i < size; i++) models.add(Quintet.with(buf.readFloat(), ByteBufUtils.readUTF8String(buf), ByteBufUtils.readUTF8String(buf), buf.readFloat(), buf.readFloat())); this.modelsDeclaration = models.toArray(new Quintet[models.size()]); System.out.println("Read."); } @Override public void toBytes(ByteBuf buf) { System.out.println("Writing..."); ByteBufUtils.writeUTF8String(buf, String.valueOf(this.modelsDeclaration.length)); for (Quintet<Float,String,String,Float,Float> v : this.modelsDeclaration) { System.out.println(String.valueOf(v.getValue0()).length()); //ByteBufUtils.writeUTF8String(buf, String.valueOf(v.getValue0())); buf.writeFloat(v.getValue0()); System.out.println(v.getValue1().length()); ByteBufUtils.writeUTF8String(buf, v.getValue1()); System.out.println(v.getValue2().length()); ByteBufUtils.writeUTF8String(buf, v.getValue2()); System.out.println(String.valueOf(v.getValue3()).length()); //ByteBufUtils.writeUTF8String(buf, String.valueOf(v.getValue3())); buf.writeFloat(v.getValue3()); System.out.println(String.valueOf(v.getValue4()).length()); //ByteBufUtils.writeUTF8String(buf, String.valueOf(v.getValue4())); buf.writeFloat(v.getValue4()); } System.out.println("Written."); } public static class Handler implements IMessageHandler<SendBipedCostumes, IMessage> { @Override public IMessage onMessage(SendBipedCostumes m, MessageContext ctx) { LyokoCraftMod.proxy.sendBipedCostumeHandler(m, ctx); return null; } } It works perfectly in single player, the handler is executed with all the data it needs. However, when I try to do it on a server, when the packet is sent, the client gets an error : The server however just doesn't say anything. The problem is that no parameter is 25 bytes long. Actually they all are pretty small. The longest one is 19 simple characters long. I don't know anything about netty, but I figured out that the problem occurs when the client tries to understand the raw packet, but it keeps failing because 20 is an hardcoded maximal value. Do you know how I could find a way out of that problem? Thanks in advance!
-
[1.7.10][SOLVED] Problem trying to override player render
pingoleon60 replied to pingoleon60's topic in Modder Support
I found the answer myself after hours of despair lol The class ModelBiped is actually made of constant values. You have to override setRotationAngles to make it the way you want. -
Hello evevryone! Recently I've been trying to override the player render, and so I tried to change the head's rotation point, here's what I did : package justpingo.lyokocraftmod.client; import net.minecraft.client.model.ModelRenderer; public class DynaModelBiped extends net.minecraft.client.model.ModelBiped { public float size; public DynaModelBiped() { this(0.0F); } public DynaModelBiped(float p_i1148_1_) { this(p_i1148_1_, 0.0F, 64, 32, 1); } public DynaModelBiped(float size, boolean osef) { this(0.0F, 0.0F, 64, 32, size); } public DynaModelBiped(float size, float multi) { this(multi, 0.0F, 64, 32, size); } public DynaModelBiped(float p_i1149_1_, float p_i1149_2_, int p_i1149_3_, int p_i1149_4_) { this(p_i1149_1_, p_i1149_2_, p_i1149_3_, p_i1149_4_, 1F); } public DynaModelBiped(float p_i1149_1_, float p_i1149_2_, int p_i1149_3_, int p_i1149_4_, float size) { this.size = size; this.textureWidth = p_i1149_3_; this.textureHeight = p_i1149_4_; this.bipedCloak = new ModelRenderer(this, 0, 0); this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, p_i1149_1_); this.bipedEars = new ModelRenderer(this, 24, 0); this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, p_i1149_1_); this.bipedHead = new ModelRenderer(this, 0, 0); this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_); this.bipedHead.setRotationPoint(0.0F, p_i1149_2_ - 12*size, 0.0F); // INTERESTING PART this.bipedHeadwear = new ModelRenderer(this, 32, 0); this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_ + 0.5F); this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + p_i1149_2_ - 12*size, 0.0F); this.bipedBody = new ModelRenderer(this, 16, 16); this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, (int) (12*size), 4, p_i1149_1_); this.bipedBody.setRotationPoint(0.0F, 0.0F + p_i1149_2_-6*size, 0.0F); this.bipedRightArm = new ModelRenderer(this, 40, 16); this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, (int) (12*size), 4, p_i1149_1_); this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + p_i1149_2_ - 6*size, 0.0F); this.bipedLeftArm = new ModelRenderer(this, 40, 16); this.bipedLeftArm.mirror = true; this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, (int) (12*size), 4, p_i1149_1_); this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + p_i1149_2_ - 6*size, 0.0F); this.bipedRightLeg = new ModelRenderer(this, 0, 16); this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, (int) (12*size), 4, p_i1149_1_); this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + p_i1149_2_, 0.0F); this.bipedLeftLeg = new ModelRenderer(this, 0, 16); this.bipedLeftLeg.mirror = true; this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, (int) (12*size), 4, p_i1149_1_); this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + p_i1149_2_, 0.0F); } } (sorry if the code is a bit messy, I tried a lot of stuff to make it work) But when I tried to change that rotation point (by using 12*size), it just does nothing in the game. I even tried with eclipse's debug mode, but just nothing. Even weirder, it works perfectly with the arms but the same problem appears with the legs. Do you know what I did wrong? Thanks in advance!
-
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
That works great! Thanks a lot! -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Oops never mind x) When I call the quickPlay method, the game freeze like 5 seconds and then it works, even if I do it from a parrallel Thread. public class ThreadStartMusic extends Thread { private String url; private int x; private int y; private int z; private long volume; public ThreadStartMusic(String url, int x, int y, int z, long volume) { this.url = url; this.x = x; this.y = y; this.z = z; this.volume = volume; } public void run() { MusicManager.playingMusics.put(MusicManager.playMusic(this.url, this.x, this.y, this.z, this.volume), new int[] { this.x, this.y, this.z }); } } Anby idea? Thanks in advance -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Thank you very much, it now works! a) I'm quite new at packets, so that was temporal, I made a string conversion only to test it faster because I didn't know methods to treat int when I wrote it x) b) That's because I'm planning on adding other actions, but thinking of it I could only use an integer. c) Just forgot to delete that part, sorry. Thanks a lot anyway, you have been super nice in front of my stupidity See you! -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
In fact, I only forgot to delete those SideOnly annotation, because anyway it is never called by the server (only the packet handler and the client proxy interact with MusicManager). // While Writing Edit : Oh damn it forgot that MusicManager.stopMusic, sorry. Wow. I'm really dumb, indeed. I thought like only one person would be on the server. (please don't throw me to the stake ) I should save sources in a map with coordinates, that would be better. I'll follow your tip about cache. I thought it was more efficient, but eh, it seems to not be. Anyway, I did all of that (updated on the github), but that's still crashing on the same part of SoundSystem. I investigated, and it looks like SoundSystem shuts down too soon. Any idea? Thanks a lot for your lot of help ^^ -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
https://github.com/JustPingo/MineDisc-Dev That will surely be easier. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Ok, now with packets I get the exact same error. Any idea? Thanks in advance. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Oh ok. I called it from a command or from a TileEntity (in fact onNeighborChange from the Block call that function in the TileEntity). public void processCommand(ICommandSender sender, String[] args) { if (args.length == 0) { sender.addChatMessage(new ChatComponentText("Invalid arguments.")); return; } sender.addChatMessage(new ChatComponentText(args[0])); ItemStack stack = sender.getEntityWorld().getPlayerEntityByName(sender.getCommandSenderName()).getHeldItem(); if (stack != null) { if (stack.getItem() == MineDisc.wifiCD) { if (stack.stackTagCompound == null) stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("musicURL", args[0]); } } } public void onNeighborBlockChange() { if (!worldObj.isRemote && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && currentMusicURL != "") { if (!wasRunningMusic) { if (this.playingSource != null) MusicManager.stopMusic(this.playingSource); this.playingSource = ""; if (MusicManager.isLoaded(this.currentMusicURL)) this.playingSource = MusicManager.playMusic(currentMusicURL, xCoord, yCoord, zCoord, 1); else { MusicManager.loadMusic(this.currentMusicURL); this.playingSource = MusicManager.playMusic(currentMusicURL, xCoord, yCoord, zCoord, 1); } wasRunningMusic = true; } } else { if (wasRunningMusic) { if (this.playingSource != null) MusicManager.stopMusic(this.playingSource); this.playingSource = ""; wasRunningMusic = false; } } worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MineDisc.CDPlayer); } -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
a) I preload it in order to be able to play it from two different places but using only one memory space. b) private static Map<String, String> loadedMusics = new HashMap<String, String>(); private final static String[][] acceptedTypes = new String[][] { new String[] { "audio/x-wav", ".wav" } }; MusicManager.unloadMusic(urlToReach); URL url = new URL(urlToReach); String type = url.openConnection().getContentType(); for (String[] row : MusicManager.acceptedTypes ) { System.out.println("Model : " + row[0] + " comparing to " + type); if (type.equals(row[0])) { String identifier = UUID.randomUUID().toString() + row[1]; System.out.println("Music loaded as " + identifier); MusicManager.mcSndSystem.loadSound(url, identifier); MusicManager.loadedMusics.put(urlToReach, identifier); } } My bad, I should have showed you that part before, because I'm not sure if I'm really doing it ok. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Oh! I've never heard about tha Reflection stuff. But, I've never worked with that. I read stuff about it online, tried something : SoundHandler sndHandler = Minecraft.getMinecraft().getSoundHandler(); Field sndManagerField = sndHandler.getClass().getDeclaredField("sndManager"); sndManagerField.setAccessible(true); SoundManager mcSndManager = (SoundManager) sndManagerField.get(sndHandler); Field sndSystemField = mcSndManager.getClass().getDeclaredField("sndSystem"); sndSystemField.setAccessible(true); MusicManager.mcSndSystem = (SoundSystem) sndSystemField.get(mcSndManager); But it seems to not work. That does not crash, but when I call that paulscode function : public void loadSound( URL url, String identifier ) { // Queue a command to load the sound file from a URL: CommandQueue( new CommandObject( CommandObject.LOAD_SOUND, new FilenameURL( url, identifier ) ) ); // Wake the command thread to process commands: commandThread.interrupt(); } It crashes : java.lang.NullPointerException at paulscode.sound.SoundSystem.loadSound(SoundSystem.java:383) ~[soundSystem.class:?] at pingo.minedisc.common.MusicManager.loadMusic(MusicManager.java:57) ~[MusicManager.class:?] at pingo.minedisc.common.PlayMusicCommand.processCommand(PlayMusicCommand.java:54) ~[PlayMusicCommand.class:?] at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:96) [CommandHandler.class:?] at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:788) [NetHandlerPlayServer.class:?] at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:764) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:47) [C01PacketChatMessage.class:?] at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:68) [C01PacketChatMessage.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] SoundSystem's line 383 is commandThread.interrupt(); I've searched a long time, and I can't find why it does not work. Can you help me? Thanks in advance. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Well... I'm trying to make the client download an audio file and display it. For now I use this : AudioInputStream audioIn = AudioSystem.getAudioInputStream(new URL(urlToReach)); Clip clip = AudioSystem.getClip(); clip.open(audioIn); clip.start(); (not exactly, but that's the idea) EDIT : I found where the Paul'sCode SoundSystem was managed, but unfortunatly the soundsystem itself is private. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
That is that sun.* package. It's like input streams for files, but made to work with sound. Basically a Java music Object. -
How to use 3D SoundSystem with Forge 1.7
pingoleon60 replied to pingoleon60's topic in Modder Support
Thank you for your answer. Well, my case is a bit special because my sounds are not properly file. The most low level I could have is an AudioStream, so I can't create a json file. Is there an alternative? Thanks in advance! -
Hello everyone. I'm having a bit of trouble while coding my mod : I've searched a long time, but I don't see any way to use SoundSystem with Forge to display localised AudioStream like Jukeboxes do. I found some events but they're annoted as deprecated. Anyone can explain or redirect me to a tutorial? Thanks in advance!