Jump to content

[1.7.10] Custom rendered block pushable by piston. [Abandoned]


Alphafox_13

Recommended Posts

I am very new to modding so I went on to youtube and watched a few tutorials and I now have two blocks in my mod one extends Block and the other extends BlockContainer.

The problem is that my regular block has no custom rendering I can however be pushed. as soon as i convert it to a BlockContainer (hence a tile entity the piston can no longer pushed it, now this doesnt seem right as rails and pane glass (blocks I am using as reference) can both be pushed by pistons and both are definitely custom rendered.

As i understand it the blocks can't be moved because of the attached data, so i would be in favour of removing tileentity completetly, however http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/mods-discussion/1410896-question-custom-rendered-block-without-tile suggest that its not possible to have custom rendering without tileentity.

Link to comment
Share on other sites

Hi

 

Looking at the way the piston is implemented, I don't think it will be able to push blocks which have TileEntity information (it will cause the TileEntity to be destroyed/overwritten).

This might perhaps be ok if your TileEntity doesn't actually have any data stored in it - it might automatically discard & regenerate your TileEntity - but I'm not sure.

 

You could perhaps try it and see - just provide a simple TileEntity for your Block (don't use BlockContainer) and make sure Block.getMobilityFlag() returns 0.  No guarantees though.

 

I think you are right, you need a TileEntity to render using a TileEntitySpecialRenderer.  In 1.8 it's difficult to do custom block render without it (other choices are: ISmartBlockModel in some cases, or using ASM+Reflection to insert your custom rendering code into the vanilla code - which can be rather hard to get right).

 

What's the "custom" rendering actually do?

 

-TGG

Link to comment
Share on other sites

In 1.7.10, it's possible to render a non-tile-entity block with ISimpleBlockRenderingHandler.

In 1.8, json models is good in most cases. In other cases I use ISmartBlockModel and ExtendedBlockState together to customize rendering.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

Link to comment
Share on other sites

Hi

 

Looking at the way the piston is implemented, I don't think it will be able to push blocks which have TileEntity information (it will cause the TileEntity to be destroyed/overwritten).

This might perhaps be ok if your TileEntity doesn't actually have any data stored in it - it might automatically discard & regenerate your TileEntity - but I'm not sure.

 

You could perhaps try it and see - just provide a simple TileEntity for your Block (don't use BlockContainer) and make sure Block.getMobilityFlag() returns 0.  No guarantees though.

 

I think you are right, you need a TileEntity to render using a TileEntitySpecialRenderer.  In 1.8 it's difficult to do custom block render without it (other choices are: ISmartBlockModel in some cases, or using ASM+Reflection to insert your custom rendering code into the vanilla code - which can be rather hard to get right).

 

What's the "custom" rendering actually do?

 

-TGG

 

I dont really want to render it a different way as it sounds harder

also are you sure i should be extending TileEntity

http://www.minecraftforge.net/wiki/Tile_Entities

say i need to Extend either BlockContainer or ITileEntityProvider

 

"You do not have to do it by extending BlockContainer (Despite it giving some useful methods); instead you could implement ITileEntityProvider into your block class."

 

public class BlockSail extends TileEntity{
public BlockSail(){
	/**super(material);
        this.isBlockContainer = false;
	this.setBlockName("sail");
	this.setCreativeTab(CreativeTabs.tabTransport);
	this.setHardness(0.5F);
	this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
	this.setBlockTextureName("sailsaddon"+":"+"sail");*/

}
/*public void setBlockBoundsForItemRender(){
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}*/
public int getRenderType(){
	return -1;
}
public boolean isOpaqueCube(){
	return false;
}
public boolean renderAsNormalBlock(){
	return true;
}
//**
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player){
        int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        switch (dir){
        case 0:
        	world.setBlockMetadataWithNotify(x, y, z, dir, 0);
        break;
        case 1:
        	world.setBlockMetadataWithNotify(x, y, z, dir, 1);
        break;
        case 2:
        	world.setBlockMetadataWithNotify(x, y, z, dir, 0);
        break;
        case 3:
        	world.setBlockMetadataWithNotify(x, y, z, dir, 1);
        break;
        }
        
}//*/
/*@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TEsail();
}*/
}

That is the block class the problem is that it doesn't allow me to use the createNewTileEntity()

do i need to change  public class BlockSail extends TileEntity so that it implements something?

 

also i had to change the register type

public class RegisterBlocksItems {

public static Item TestItem;
public static void initItems(){
	TestItem = new ItemTestItem(); GameRegistry.registerItem(TestItem, "test");
}

public static TileEntity Sail;
public static Block Mast;
public static void initBlocks(){
	Sail = new BlockSail(); GameRegistry.registerTileEntity(BlockSail.class, "sail");
	Mast = new BlockMast(Material.wood); GameRegistry.registerBlock(Mast, "mast");

}
}

however that has caused my Recipies to fail

	GameRegistry.addShapedRecipe(new ItemStack(RegisterBlocksItems.Sail,9), new Object[]{
		"C",
		"C",
		'C',new ItemStack(Blocks.carpet)
	});

Download:

http://www.mediafire.com/download/h2quv5hqxfuq2ah/Sails.zip

What i plan to achieve:

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2384775-sails-masts-addon-for-ships-mod-help-needed

Link to comment
Share on other sites

 

I dont really want to render it a different way as it sounds harder

also are you sure i should be extending TileEntity

No, you're right, that won't work if you try to have your Block extend TileEntity, because it will then be a TileEntity not a Block....

Your block needs to implement ITileEntityProvider.  It will need to provide a method for

TileEntity createNewTileEntity(World world, int metadata);

 

where the TileEntity it returns should be your very simple TileEntity class.

 

I would definitely recommend you use a TileEntity for what you're trying to do.  I don't think an ISimpleBlockRenderingHandler will work how you want.

 

Why do you worry about your TileEntity being pushable by pistons?  I don't think that is necessary for a ship?

 

-TGG

 

 

Link to comment
Share on other sites

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.