Jump to content

Recommended Posts

Posted

Im trying to spawn entities using a gui for my laser designator

 

When i click the button, the entity appears, but it doesnt react  with anything.  I tried adding the if(par2World.isRemote) and if(!par2World.isRemote) statements but it didnt work.

 

GUI Code

package lazerman47.weaponsplus.GUI;

import lazerman47.weaponsplus.Entity.EntityLaserDesignation;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

public class GUILaserDesignator extends GuiScreen
{

public GUILaserDesignator(EntityPlayer par1EntityPlayer)
{

}

public final int xSizeOfTexture = 176;
public final int ySizeOfTexture = 180;
protected int type = 0;
@Override
public void drawScreen(int x, int y, float f)
{
	drawDefaultBackground();

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

	int posX = (this.width - xSizeOfTexture) / 2;
	int posY = (this.height - ySizeOfTexture) / 2;

	this.mc.renderEngine.bindTexture(new ResourceLocation("weaponsplus:textures/gui/guiLaserDesg.png"));

	drawTexturedModalRect(posX, posY, 0, 0, xSizeOfTexture, ySizeOfTexture);

	drawString(fontRendererObj, "Type: " + type, posX + 15, posY + 30, 0xFF0000);

	this.initGui();

	super.drawScreen(x, y, f);
}
public void initGui()
{
	int posX = (this.width - xSizeOfTexture) / 2;
	int posY = (this.height - ySizeOfTexture) / 2;

	this.buttonList.add(new GuiButton(0, posX + 15, posY + 60, 150, 20, "Send Conventional Missile"));
	this.buttonList.add(new GuiButton(1, posX + 15, posY + 100, 150, 20, "Send Incindeary Missile"));
	this.buttonList.add(new GuiButton(2, posX + 15, posY + 140, 150, 20, "Send Nuclear Missile"));
}

public void actionPerformed(GuiButton button)
{
	switch(button.id)
	{
	case 0:  
		this.type = 0;
		this.mc.theWorld.spawnEntityInWorld(new EntityLaserDesignation(this.mc.theWorld, this.mc.thePlayer.posX, this.mc.thePlayer.posY, this.mc.thePlayer.posZ));
		this.mc.thePlayer.closeScreen();
		break;
	case 1:
		this.type = 1;
		this.mc.thePlayer.closeScreen();
		break;
	case 2:
		this.type = 2;
		this.mc.thePlayer.closeScreen();
		break;
	}
}
@Override
public boolean doesGuiPauseGame()
{
	return false;
}
}

Creator Of Weapons+ Mod & Sword Art Online HUD Mod

Posted

I checked the tutorials and made these 2 classes

 

AbstractPacket

 

  Reveal hidden contents

Creator Of Weapons+ Mod & Sword Art Online HUD Mod

Posted

Ive figured out packets!!!  ;D

 

I am now able to use them to call the addChatMessage() method, but there is no world variable

 

public void handleServerSide(EntityPlayer player)  <<---- There is no World par2World in there

 

 

My Custom Packet Class:

package lazerman47.weaponsplus.PacketHandling;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;

public class PacketGUI extends AbstractPacket
{

@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
	// TODO Auto-generated method stub

}

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
	// TODO Auto-generated method stub

}

@Override
public void handleClientSide(EntityPlayer player) {
	// TODO Auto-generated method stub

}

@Override
public void handleServerSide(EntityPlayer player) 
{
	player.addChatMessage(new ChatComponentText("PACKETS WORK!!!"));
}

}

Creator Of Weapons+ Mod & Sword Art Online HUD Mod

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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