Jump to content

[Solved] [1.7.10] Changing block size when game loads


Recommended Posts

Hello, I am working on pipes, I have managed to get the game to utilize the metadata thing to point in a certain direction and even when placed the block size of when I look at them/select changes, but only when placed. When I quit the game and then come back it is the size of a normal sized block but it points in the right direction. I am pretty certain I can get it to work myself if I knew if there was a command that initiated the moment the block was summoned by the game, is there such a command or void I can utilize?

Link to comment
Share on other sites

Let's see I understand you correctly.

You set the direction of the pipe through metadata, which saves automatically,

and changed the size of the pipe but didn't save that data

and when you load the pipe again you expect the pipe size to magically still be there?


The solution is extremely simple. Look into TileEntities.

Since it is a pipe and you'll probably want it to tick at a regular pace that's the best thing anyway.

Then utilize the nbt of the entity to save your pipe size.

Link to comment
Share on other sites

Yes it is the block size, when it reloads the block size is as any ordinary block which looks ugly consideirng it is smaller than an ordinary block, I wish the size to be there hwich I can derive from the metadata with ease, what I really want to is to know if there is something that loads the moment the block is loaded into the world upon loading the chunk, if that can be found the rest is piece of cake.

Link to comment
Share on other sites

Well, considering you completely ignored my suggestion about a tile entity I will conclude that you don't want that.

How on earth you will pass data, because clearly whatever you're passing through that pipe will have to be saved too, that is if you want to make anything that somewhat resembles a pipe. So enough about tile entities and nbt, which is infinitely more convenient.

And yes, both nbt and metadata load on blockload, wouldn't those be quite pointless otherwise?


So metadata it is. If I had to find a solution for that I would do something like this(because honestly, saving three values in a number between 0 and 15 isn't quite so easy).


Things to be passed:

- Your direction

- Your size

- Your power/steam/... value


What do we allready know? You direction is 3 values: up/down - left/right - front/back, this because a pipe doesn't have a front.

So let us split the metadata into 3 parts: 0 to 4, 5 to 9 and 10 to 14 (with 15 being a restvalue, sadly this is a waste).

So the next thing to look at is the size. Basically we know if we want to distinguish between the previous values we can only use 4 values and we need to be able to fit our power into that as well. Since size would be quite pointless to save if we only have 1 value we need at least two. And we can add another one if the number is 0, 5 or 10 since that would equal a zero for the size.

Then for the power check whether a number is even or uneven. The only thing left is to reverse the last two between 5 and 9 since what is even between 0 and 4 and 10 and 14 is uneven there and vice versa.


Let us look at a few examples:


  A pipe with the metadata 8:

    We can deduce that, since 8 is more than 5 and less than 10, the direction is Left/Right.

    We can deduce that, because 8 is an even number but lies between 5 and 10 there is no power flowing.

    We can deduce that, because 8 is an even number but lies between 5 and 10 the size is 2 on a scale of 0 to 2.


A pipe with metadata 12.

    We can deduce that, since 12 is more than 10, the direction is Front/Back.

    We can deduce that, because 12 is an even number there is power flowing.

    We can deduce that, because 12 is an even number between 1 and 3(minus 10)the size is 1 on a scale of 0 to 2.


A pipe with metadata 0.

    We can deduce that, since 0 is less than 5, the direction is Front/Back.

    We can deduce that, because 0 is an even number between 0 and 4 there is no power flowing.

    We can deduce that, because 0 is an even number between 0 and 4 the size is 0 on a scale of 0 to 2.


That's about the best I can do.


0 - 5 - 10 is the directions.

1/3 - 6/8 - 11/13 is the size + previous values for zero.

even and uneven excluding 0 - 5 - 10 are set to power.


I hope you see now that, if you just use metadata you are incredibly limited.

Look up tile entities and give it a go. If you see that your pipes don't need that, then you can always try the above.


Link to comment
Share on other sites

I didn't ignore it but merely looked for what I wanted which after further testing has shown to be even worse of a situation, I will use tile entity for the steam stuff but for now I wish to resolve this issue, I realised after placing down another pipe in a different direction all the previously placed ones changes aswell in their block size (but not pointing direction)


package aerosteam.steam;

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import aerosteam.AeroSteam;
import aerosteam.tileentitty.TileEntityBoiler;
import aerosteam.tileentitty.TileEntitySteamPipeStraight;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class DeviceSteamPipe extends BlockContainer implements ITileEntityProvider{

public DeviceSteamPipe(int connection) {

public void onBlockAdded(World world, int x, int y, int z) {
	super.onBlockAdded(world, x, y, z);
	this.setDefaultOrientation(world, x, y, z);
	System.out.println("MetaAdded:" + world.getBlockMetadata(x, y, z));
// Gotta fix so the orientation of the block size remains changed
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer,ItemStack itemstack){
	int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F/360.F)+0.5D) & 3 ;
	int t = MathHelper.floor_double((double)(entityplayer.rotationPitch * 4.0F/360.F)+0.5D) & 3;
	TileEntitySteamPipeStraight tile = (TileEntitySteamPipeStraight) world.getTileEntity(x, y, z);
	if (t==0){
		if (l==1 || l==3){
			world.setBlockMetadataWithNotify(x, y, z, 1, 2);
			this.setBlockBounds(0.0F, 0.34375F, 0.34375F, 1F, 0.65625F, 0.65625F);
		}else if(l==0 || l==2){
			world.setBlockMetadataWithNotify(x, y, z, 3, 2);
			this.setBlockBounds(0.34375F, 0.34375F, 0.0F, 0.65625F, 0.65625F, 1F);
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
		this.setBlockBounds(0.34375F, 0.0F, 0.34375F, 0.65625F, 1F, 0.65625F);
private void setDefaultOrientation(World world, int x, int y, int z){
public boolean 	onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
	if (!world.isRemote){
		TileEntitySteamPipeStraight tile = (TileEntitySteamPipeStraight) world.getTileEntity(x, y, z);
		player.addChatMessage(new ChatComponentText("Metadata:" + tile.orientation));
	return true;
public int getRenderType(){
	return -1;

public boolean isOpaqueCube(){
	return false;
public boolean renderAsNormalBlock(){
	return false;
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	return new TileEntitySteamPipeStraight();

public void registerBlockIcons(IIconRegister iconregister){
	this.blockIcon = iconregister.registerIcon(AeroSteam.MODID + ":" + "SteamPipeStraight");


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.

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.

  • Create New...

Important Information

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