Jump to content

Recommended Posts

Posted

hen .. well you implemented your class im a odd way, no render class should be called from server side, can we see that ? :)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

For example

 

BlockCode:

package netherfors.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import netherfors.main;
import netherfors.gui.GuiLavaCollector;
import netherfors.tile.TileLavaCollector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class LavaCollector extends BlockContainer{

private Icon top,bottom;

public LavaCollector(int id) {
	super(id, Material.rock);
	this.setStepSound(Block.soundStoneFootstep);
	this.setCreativeTab(main.nettab);
	this.setHardness(5f);
}

@SideOnly(Side.CLIENT)
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
    {
    	TileLavaCollector tile = (TileLavaCollector) world.getBlockTileEntity(x, y, z);
    	if(tile!=null){
    		Minecraft mc = ModLoader.getMinecraftInstance();
    		mc.displayGuiScreen(new GuiLavaCollector(player,world,tile));
    	}
    	return true;
    }
    
    public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
    	TileLavaCollector tile = (TileLavaCollector) world.getBlockTileEntity(x, y, z);
    	if(tile!=null){
    		if(tile.itemamount>0){
    			EntityItem it = new EntityItem(world, x, y, z, new ItemStack(main.craftingitems,tile.itemamount,0));
    			if(!world.isRemote){
    				world.spawnEntityInWorld(it);
    			}
    			tile.itemamount = 0;
    		}
    	}
    }
    
    public void onBlockAdded(World world, int x, int y, int z)
    {
    	TileLavaCollector t = (TileLavaCollector) world.getBlockTileEntity(x, y, z); 
    	if(t!=null){
    		t.itemamount = 0;
    		t.amount = 0;
    		t.interval = 0;
    		t.time = 0;
    	}

    }
    
    public void registerIcons(IconRegister r){
    	this.blockIcon = r.registerIcon("netherfors:lavaside");
    	this.top = r.registerIcon("netherfors:lavatop");
    	this.bottom = r.registerIcon("netherfors:lavabottom");
    }
    
    public Icon getIcon(int par1, int par2)
    {
        return par1 == 1 ? this.top : (par1 == 0 ? this.bottom : (par1 != par2 ? this.blockIcon : this.blockIcon));
    }

@Override
public TileEntity createNewTileEntity(World world) {
	return new TileLavaCollector();
}

}

 

GuiCode :

package netherfors.gui;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import netherfors.tile.TileLavaCollector;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class GuiLavaCollector extends GuiScreen{

private int wi,he;
private EntityPlayer player;
private World world;
private TileLavaCollector tile;

// 88 // 65

public GuiLavaCollector(EntityPlayer pla,World wor,TileLavaCollector ti){
	this.wi = 88;
	this.he = 90;
	this.world = wor;
	this.player = pla;
	this.tile = ti;
}

    public boolean doesGuiPauseGame()
    {
        return false;
    }

public void drawProgressBar(int i){

	if(i>65){
		i = 65;
	}

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture("/mods/netherfors/textures/gui/lavacollector.png");;
        this.drawTexturedModalRect(width/2-35, (height/2-37)+(65-i), 88, 0, 20, i);
}

public void progressOverHundred(int o){

	if(o>100){
		o = 100;
	}

	int percent = (65*o)/100;
	drawProgressBar(percent);

}


public void initGui(){

}

@SideOnly(Side.CLIENT)
public void drawScreen(int par1, int par2, float par3)
{
        this.drawGuiContainerBackgroundLayer(par3, par2, par1);
        int t = tile.amount;
        progressOverHundred(t);
        this.fontRenderer.drawSplitString("Progress\n"+Integer.toString(tile.amount)+"%\n\nAmount\n"+Integer.toString(tile.itemamount), width/2-20, height/2-34, 54, 0);
        super.drawScreen(par1, par2, par3);
}	

@SideOnly(Side.CLIENT)
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture("/mods/netherfors/textures/gui/lavacollector.png");
        int k = (this.width - this.wi) / 2;
        int l = (this.height - this.he) / 2;
        this.drawTexturedModalRect(k, l, 0, 0, this.wi, this.he);
    }

}

 

If I dont put sideonly to the onBlockActivated it crashes the server :)

Posted

yeah make sens

mc.displayGuiScreen(new GuiLavaCollector(player,world,tile));

 

this is wrong, you need a IGuiHandler and call this instead

 

@Override
public boolean onBlockActivated(World world, int x, int y, int z,
		EntityPlayer player, int a, float b, float c, float d) {
	TileEntity te = world.getBlockTileEntity(x, y, z);
	if(te != null){
		TileEntityPlot tep = (TileEntityPlot)te;
		if(tep.isBought()){
			return false;
		}
		if(player.username.equals(tep.owner)){
		player.openGui(TheMod.instance, PlotSellerGui.GUI_ID, world, x, y, z);
		}else{
			player.openGui(TheMod.instance, PlotBuyerGui.GUI_ID, world, x, y, z);
		}
	}
	return true;
}

example from one of my block ^^

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

yeah make sens

mc.displayGuiScreen(new GuiLavaCollector(player,world,tile));

 

this is wrong, you need a IGuiHandler and call this instead

 

@Override
public boolean onBlockActivated(World world, int x, int y, int z,
		EntityPlayer player, int a, float b, float c, float d) {
	TileEntity te = world.getBlockTileEntity(x, y, z);
	if(te != null){
		TileEntityPlot tep = (TileEntityPlot)te;
		if(tep.isBought()){
			return false;
		}
		if(player.username.equals(tep.owner)){
		player.openGui(TheMod.instance, PlotSellerGui.GUI_ID, world, x, y, z);
		}else{
			player.openGui(TheMod.instance, PlotBuyerGui.GUI_ID, world, x, y, z);
		}
	}
	return true;
}

example from one of my block ^^

 

I converted all of my code into IGuiHandler but now world.spawnEntityInWorld() spawns fake items as well :)

Still have the problem...

Posted

what do you mean fake ? like you can walk through it and you wont pick it up ? liek a ghost ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

You cant depent on packets because players easily can exploit them :) And they are actually complicated :)

:o

Don't code a mod because players easily can exploit them :) And they are actually complicated :)

Posted
Don't.Use.SideOnly.Annotation.

never use @sideonly its only causing more confusion then anything

NEVER

 

You cant depent on packets because players easily can exploit them :) And they are actually complicated :)

with this logic the mod is un-codable, the thing you must understand is that packet are good but you MUST filter them, dont accept anything "just because"

IRL example:

in my mod people have a skill tree that they can buy spell from, but player dont tell the server "hey im now max level" when they want to buy a new skill they send a packet to the server saying "can i buy this ?" and the server will decide yes or no, so theres no way around usign a hacked client on this

 

And they are actually complicated

you feed stuff in a stream on one side and collect it on the other ....

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

yes only if you dont mind using MY classes....(located: http://www.minecraftforge.net/wiki/Organising_packet_handlers)

 

//this code client side (in your gui ?) where the button was pressed or wtv
int spawnItemId = 55;
PacketWriteStream stream = new PacketWriteStream();
stream.put(spawnItemId);
PacketDispatcher.sendPacketToServer(stream.makePacket("channel");


server side in method 
public void onPacketData(INetworkManager manager,
                        Packet250CustomPayload packet, Player playerEntity) :

int spawnItemId = 55;
PacketReadStream stream = new PacketReadStream(packet);
int packetID = stream.readInt();
if(packetID == spawnItemId){
    //make check to see if its a valid state  
    //spawn item
    //to get a reference to the player that send this:
    EntityPlayer player = (EntityPlayer)playerEntity;
   //then player.doSomething() or player.worldObj.spawnItemInWorld(new EntityItem etc)
}

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

i actually looked into thsi class later, but these utility class were already done so wtv :P

and my like 500 different packet are all written with this class ... soooo i dont want to change all that xD

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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