Jump to content

Recommended Posts

Posted

Hello all!

 

I am building a mod that contains a 3D model "multiblock". Basically, its a table. But as you add more tables, it changes what model gets rendered to make it look connected.

 

I know I am going to have to do something with onNeighborBlockChange() but when I do simple tests printing the block parameter, I'm getting what was there before I placed the block IE Air, not the block that was just added.

 

So my question is, how would I go about detecting all four sides for a specific block?

 

Thanks in advance.

Posted

I may have not understood your answer then. If you are saying to use onNeighborBlockChange, when I tried doing my tests, it wouldn't show the block I had placed until I removed it.

 

For example, I had a table, and when I put a table next to it, the read out on the console said tile.block.air. It wasn't until I broke the table I put down that it returned, tile.block.table.

Posted
package com.misccraft.mod.blocks;

import com.misccraft.mod.Misccraft;
import com.misccraft.mod.tileentity.TileEntityOfficeDesk;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class OfficeDesk extends BlockContainer {

private int side;

public OfficeDesk(Material material) {
	super(material);

	this.setHardness(1.0F);
	this.setResistance(5.0F); // To be changed
	this.setBlockBounds(0F, 0F, 0F, 1F, 0.8125F, 1F); // To be changed
	this.setCreativeTab(Misccraft.misccraftTab);
}

public int getRenderType() {
	return -1;
}

public boolean isOpaqueCube() {
	return false;
}

public boolean renderAsNormalBlock() {
	return false;
}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TileEntityOfficeDesk();
}

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) {
	if(entityplayer == null) {
		return;
	}

	TileEntityOfficeDesk perf = (TileEntityOfficeDesk)world.getTileEntity(x,y,z);
	perf.direction = MathHelper.floor_double((double)((entityplayer.rotationYaw*4F)/360F) + 0.5D) & 3;
	perf.side = 2; // Static for testing
}

public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
	System.out.println(block.getLocalizedName()); // Test to check neighboring block.
}
}

Posted

You said that onNeighborBlockChange is intended to work via re-checking your surroundings. I assumed this is done at the end of whatever you are processing.

 

I don't get how what I want to do is not possible. Chest's do the same thing I'm trying to do,  they detect a chest next to themselves, and alter their model accordingly. I'm new to the modding scene and not as experienced in Java as others, so when I look at the Chest/Fence/Pane source code, I see the code, but I don't understand what it is doing.

 

I guess what I am trying to say is, how would I go about detecting a CERTAIN block when its placed next to my block?

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.