Jump to content

Recommended Posts

Posted

Hi again!

I have some blocks with custom tile entities rendering some models, but they both have onBlockActivated booleans, but when I right click absolutely nothing happens! and I know that on one of them I have it coded right cause it worked before i implemented the TileEnity!

Help?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

Nope, i put in

System.out.print("complete");

and when i right clicked the block and looked at the console nothing showed up!

Need code?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

okay, if your wondering why I have a modloader function its because I cant get the forge one to work for me, mainly cause i cant understand it.

BlockTowerFloorBase:

package codelyoko;

import net.minecraft.block.*;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockTowerFloorBase extends BlockContainer
implements ITileEntityProvider
{

public BlockTowerFloorBase(int id, Material par1Material)
{

	super(id, par1Material);
	this.setCreativeTab(Lyoko.tabLyoko);

}
@Override
public TileEntity createNewTileEntity(World world)
{
    return new TileEntityTowerFloor(); //Rename to your tile entity 
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
    TileEntity tile = world.getBlockTileEntity(x, y, z);  // Once again rename to your tile entity.
    if (tile instanceof TileEntityTowerFloor  && ((TileEntityTowerFloor)tile).shouldRender) {
        return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
    }
    return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
	par1World.setBlock(par2+1, par3, par4, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2+1, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2+1, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2); 
	ModLoader.openGUI(par5EntityPlayer, new GUITowerFloorCreated());
	System.out.print("complete");
	return true;
}

//This will tell minecraft not to render any side of our cube.
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
	return false;
}

//And this tell it that you can see through this block, and neighbor blocks should be rendered.
public boolean isOpaqueCube()
{
	return false;
}


}

 

BlockTowerConsole:

package codelyoko;

import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockTowerConsole extends Block
implements ITileEntityProvider{

public BlockTowerConsole(int par1, Material par2Material) {
	super(par1, par2Material);
	this.setCreativeTab(Lyoko.tabLyoko);
}

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

public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
	return false;
}

//And this tell it that you can see through this block, and neighbor blocks should be rendered.
public boolean isOpaqueCube()
{
	return false;
}

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5player){
	ModLoader.openGUI(par5player, new GuiTowerConsole());
	return true;
}
}

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

The modloader command will be what's screwing it up. Try adding a print line at the start of the method too, saying "begin". Also try temporarily commenting out or removing the modloader code

 

The Forge version of the openGUI is:

 

 

                player.openGui([your mod ID].instance, 0, world, x, y, z);

 

The 0 is the ID of the GUI, and you need a GUI handler too. This one is just copied straight out of my mod, so you'll have to modify it to suit you:

 

package co.uk.silvania.city;

import co.uk.silvania.city.tileentities.ContainerATM;
import co.uk.silvania.city.tileentities.GuiATM;
import co.uk.silvania.city.tileentities.TileEntityATMEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler {


	public GuiHandler() {
	}
        @Override
        public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
        	switch(id) {
        	case 0: {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntityATMEntity) {
                        return new ContainerATM(player.inventory, (TileEntityATMEntity) tileEntity);
                }	
        	}
        }
		return null;	
    }

        @Override
        public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
        	switch(id) {
        	case 0: {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntityATMEntity) {
                        return new GuiATM(player.inventory, (TileEntityATMEntity) tileEntity, world, x, y, z);
                }	
        	}
        }
		return null;
    }
}

 

And finally in the main class, again copied from the mod I have open at the time:

    @Instance("FlenixCities")
    public static GuiHandler roadsGuiHandler = new GuiHandler();

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	NetworkRegistry.instance().registerGuiHandler(this, roadsGuiHandler);
    }

 

 

You may need some networking code too, I can't help with that.

 

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

::), not sure if @Override can be ran inside a method but,

any way, I tried to use a System.print.out("Begin") at the begining f the method and nothing showed up still, and I tried to @Override, and it threw an error.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

::), not sure if @Override can be ran inside a method but,

any way, I tried to use a System.print.out("Begin") at the begining f the method and nothing showed up still, and I tried to @Override, and it threw an error.

 

I don't know what you mean by "inside a method" - Your override should be like this:

        @Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
	blah
        }

 

I never noticed it wasn't there before :P

 

In relation to containers; you need to have one. BlockContainer is what you need to use for rendering models.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Okay, is i okay to have a "blank" container?

and I mean that thier cant be say public void blah(parameters){

@override

blahblah

}

so yeah, and I tried putting an override on onBlockAtivated, and it said no.

 

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

Okay, well get this, the @Override annotation you told me to put in, eclipse tole me to either remove it, or edit a base file!

So you need to check your stuff, cause you're being the dumbest modder ever if you think the answer is to edit a base file.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

Sorry to burst your bubble but its a block no need to @override that if you did my spawnes would fail because I don't override onaddedtoworld().

Posted

Figured this should be cleaned up just in case someone needs the info  ;)

 

KeeganDeathman was using:

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5player)

 

While this use to work the parameters have changed in 1.6 and is now viewed as a new method in KeeganDeathman's code, one which Minecraft never calls.

 

As diesieben07 pointed out, every time you override an existing method mark it with @Override .

With an @Override Elicpse will inform you the old method doesn't exist, this is a big hint to you to find the replacement and fix your code.

 

in this case onBlockActivated changed from

onBlockActivated(World, int, int, int, EntityPlayer)

to

onBlockActivated(World, int, int, int, EntityPlayer, int, float, float, float)

Posted

What makes you think i dodn't edit the method sig.?

i meant he was wrong about me not being able to do this cause im an idiot(how it came a cross to me)

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

Im pretty sure it changed to:

 

public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Posted

Okay, is i okay to have a "blank" container?

and I mean that thier cant be say public void blah(parameters){

@override

blahblah

}

so yeah, and I tried putting an override on onBlockAtivated, and it said no.

 

Override goes outside the function, dimwit.

 

@Override

public void blah(parameters){

  blahblah

}

 

If it throws errors, then your function isn't overriding anything.  Functions aren't magic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Just made a mental note to not help you in the future with issues, if this is how you're acting. I can tell you right now that both Draco18s and diesieben07 are infinitely better than you (and me) at modding, and probably Java in general. They're not the kind of people you want to be on the wrong side of if you need help in the future.

 

You can't deny you were using the override function wrongly in this post. Even right after I said:

I don't know what you mean by "inside a method" - Your override should be like this:

        @Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
	blah
        }

 

You put it in the wrong place in the next post:

 

Okay, is i okay to have a "blank" container?

and I mean that thier cant be say

 

public void blah(parameters){

@override //See how it's in the wrong place?

blahblah

}

so yeah, and I tried putting an override on onBlockAtivated, and it said no.

 

Then when people tried to correct you you turned hostile and yeah, you know the rest.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

i was saying that does not work read the post next time.

 

1) "Does not work" does not help anyone solve the problem

2) @Override throwing an error means that you, as the programmer, have done something wrong

3) I have lost all sympathy for you and will no longer reply to any post you make on any topic for any reason

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You had sympathy for me? Wierd. Any way, i didn't mean to be rude, it's just, he was confusing, and I did figure something out, i was missing parms.

 

Like to point out some stuff,

A. Im awesome okay

B. When i put an annotation in a method, I WAS SHOWING IT DIDN'T WORK, IT WAS AN EXAMPLE OF WHAT NOT TO DO. (caps cause ive said this 3 TIMES!)

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

*Breaks the ignore rule*

 

B. When i put an annotation in a method, I WAS SHOWING IT DIDN'T WORK, IT WAS AN EXAMPLE OF WHAT NOT TO DO. (caps cause ive said this 3 TIMES!)

 

Actually, that was the annotation DOING ITS GAWD DANG JOB!  It was alerting you to the fact that something about your function was different than the function in the base class.  As several people have said more than once.

 

Which is why I've blocked you.

 

Good day, sir.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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