Jump to content

Recommended Posts

Posted

Hello everyone

 

I want a block, that assumes the texture from the neighbour block...

I think I can do it in the Method

public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)

. But how can I get the block? I only know

world.getBlockId(x, y, z)

and

world.getBlockMetadata(x, y, z)

but with that I cant get the texture from the block. I know that I can get the block texture by

planks.getBlockTextureFromSide(1);

. But for that I must get first a instance of the neighbour block!

How can I do that.

If something isn't clear ask me..

Thanks in advance for every kind of help :)

 

Posted

yknow minecraft is on a 3d grid right ?

 

so the surrounding blocks are:

x+1, y, z

x-1, y, z

x, y+1, z

x, y-1, z

x, y, z+1

x, y, z-1

 

and once you get the id of surrounding blocks you can do

Block.blocksList[blockid] which will return a block that you can use like this

block.getBlockTextureFromSide(1);

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

-hydroflame, author of the forge revolution-

Posted

yeah because there is only 1 instance of each block, so if you change one you change all, either use ISBRH or TESR to have each block renderered individually

 

then use world.markBlockForUpdate in your onNeighbourBlockChange because this will ask minecraft to re-render that specific block

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

-hydroflame, author of the forge revolution-

Posted

I have an other idea...

I set the texture with a variable and the variable is stored in a TileEntity.

But i have a TileEntity:

package Cerebrum.Basis;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class TileEntityHiddenTrapDoor extends TileEntity{
   
public int texture = 1;

@Override
public void writeToNBT(NBTTagCompound par1)
{
   super.writeToNBT(par1);
}

@Override
public void readFromNBT(NBTTagCompound par1)
{
   super.readFromNBT(par1);
}
}

@Override
    public TileEntity createTileEntity(World world, int metadata)
    {
    	System.out.println("TileEntity registriert");
    	return new TileEntityHiddenTrapDoor();
    }

And I want to create the TileEntity with this Code in my Block file.

But if I print out SSystem.out.println(this.hasTileEntity()); it's always false...

And yes I have connected the tileEntity in de MainClass File.

 

GameRegistry.registerTileEntity(TileEntityHiddenTrapDoor.class, "TileEntityHiddenTrapDoor");

Posted

tile entities require a damn lot of computing cycles + lot of network traffic, not recommended since ISBRH would be enough

the wiki has a couple of tutorial on it

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

-hydroflame, author of the forge revolution-

Posted

Cant you just use the getBlockTexture method?

 

In your case you would just do something like this:

 

@Override
    public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
    {
        int meta = world.getBlockMetadata(x, y-1, z)
        int bottomId = world.getBlockId(x, y-1, z)

        switch(side)
        {
             case 0:
                    Block.blocksList[bottomId].getIcon(0, meta)
             case 1:
                    Block.blocksList[bottomId].getIcon(1, meta)
             case 2:
                    Block.blocksList[bottomId].getIcon(2, meta)
             case 3:
                    Block.blocksList[bottomId].getIcon(3, meta)
             case 4:
                    Block.blocksList[bottomId].getIcon(4, meta)
             case 5:
                    Block.blocksList[bottomId].getIcon(5, meta)
        }
    }

 

 

That would totally copy the blocks texture underneath, to change that, play a little bit with the bottomId.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted
Can you help me again?

I have to create a own render for the Block?

Isn't there an other solution?

yes, yes, no

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

-hydroflame, author of the forge revolution-

Posted
Yes I tried it my self

what exactly did you do.

 

because registering a ISimpleBlockRenderingHandler isnt particularelly hard, unless you lack the basic java knowledge to naviguate the code :\

 

did you create the new class ?

did you try to register it ?

did you debug a little to see where it could fail ?

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

-hydroflame, author of the forge revolution-

Posted

ahh, ok, well thats a good starting point, now whats the content of this class ? because if theres nothing well .. no this its going to be all invisible xD

 

also did you look on the wiki for the tessellator tutorial ? and the ISimpleBlockRenderingHandler tutorial ?

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

-hydroflame, author of the forge revolution-

Posted

ok... well not to be mean but you are kinda taking this code

 

public static void doStuff(){
//tottally empty
}

 

and expecting it to print "hello world"

 

of course if you dont ask it anything it wont do anything, its a computer, its completelly void of any intelligence, it will do exactly what you ask it to (and if its nothign well nothign will happen)

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

-hydroflame, author of the forge revolution-

Posted

No you're not mean...you're honest ;D

So my block is a custom trap door.

I looked in to the trap door class and the renderType is "0".

So I looked in to the RenderBlock class and copied the method for rendering type 0.

My class now looks so:

package Cerebrum.Basis;


import net.minecraft.block.Block;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class HiddenTrapDoorRender extends Render implements ISimpleBlockRenderingHandler{

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID,
		RenderBlocks renderer) {

}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
		Block block, int modelId, RenderBlocks renderer) {
        int l = block.colorMultiplier(world, x, y, z);
        float f = (float)(l >> 16 & 255) / 255.0F;
        float f1 = (float)(l >> 8 & 255) / 255.0F;
        float f2 = (float)(l & 255) / 255.0F;

        if (EntityRenderer.anaglyphEnable)
        {
            float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
            float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
            float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
            f = f3;
            f1 = f4;
            f2 = f5;
        }
return false;
}

@Override
public boolean shouldRender3DInInventory() {
	return false;
}

@Override
public int getRenderId() {
	return 400;
}

@Override
public void doRender(Entity entity, double d0, double d1, double d2,
		float f, float f1) {

}

}

But it don't seems to work...the trap door is invisible.

And with the tutorial http://www.minecraftforge.net/wiki/ISimpleBlockRenderingHandler the block render not correctly. So I thought I can copy from the RenderBlock renderType "0".

 

Posted

yeah thats my tutorial, i dont do the "100% correct beautiful working code" i just research on how it should work and why it works, so you can expect code from my tutorials to NOT work...

 

But it don't seems to work...the trap door is invisible.

yeah, basicly the copy you copy pasta does nothing, look at the Tessellator tutorial to see how to render a face, then you should be able to figure which face you want to render

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



×
×
  • Create New...

Important Information

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