Jump to content

collision problems


GodOfYeti

Recommended Posts

The collision works but if you stand on it and place the same block connecting to it the collision is gone for a second letting the player fall through

 

kPH4XhX.png

 

rcrbp5E.png

 

heres my code

package com.linumhost.Blocks;

import java.util.Random;

import org.lwjgl.opengl.GL11;

import com.linumhost.CreativeTab.ServerCreativeTab;
import com.linumhost.Items.Items;
import com.linumhost.Items.Wrench;
import com.linumhost.Renderer.BasicRenderer;
import com.linumhost.TileEntity.TileEntityConduitPipe;
import com.linumhost.TileEntity.TileEntityServerCaseBlock;
import com.linumhost.TileEntity.Renderer.TileEntityConduitPipeRenderer;
import com.linumhost.lib.RefStrings;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;

public class ConduitPipe extends BlockContainer{

public ConduitPipe(Material material){
	super(material);
	setCreativeTab(ServerCreativeTab.tabBlocks);

	float pixel = 1F/16F;
	this.setBlockBounds(11*pixel/2, 11*pixel/2, 11*pixel/2, 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2);
}



    private static RenderItem renderItem = new RenderItem();

    public boolean handleRenderType(ItemStack itemStack, ItemRenderType type) {
            return type == ItemRenderType.INVENTORY;
    }

    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
            return false;
    }

    
    public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
            FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
            
            // ====================== Render item texture ======================
            IIcon icon = itemStack.getIconIndex();
            renderItem.renderIcon(0, 0, icon, 16, 16);
            
            // ====================== Render OpenGL square shape ======================
           
            BasicRenderer.drawInventoryBlock();
            
            // ====================== Render text ======================
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            String text = Integer.toString(itemStack.getItemDamage());
            fontRenderer.drawStringWithShadow(text, 1, 1, 0xFFFFFF);
    }



public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z){
	TileEntityConduitPipe conduit = (TileEntityConduitPipe)world.getTileEntity(x, y, z);

	float pixel = 1F / 16F;

	if(conduit != null){

		float minX = 11*pixel/2-(conduit.connections[5]!=null?(11*pixel/2):0);
		float minY = 11*pixel/2-(conduit.connections[1]!=null?(11*pixel/2):0);
		float minZ = 11*pixel/2-(conduit.connections[2]!=null?(11*pixel/2):0);

		float maxX = 1-11*pixel/2+(conduit.connections[3]!=null?(11*pixel/2):0);
		float maxY = 1-11*pixel/2+(conduit.connections[0]!=null?(11*pixel/2):0);
		float maxZ = 1-11*pixel/2+(conduit.connections[4]!=null?(11*pixel/2):0);

		this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);

	}
	return AxisAlignedBB.getBoundingBox(x+this.minX, y+this.minY, z+this.minZ, x+this.maxX, y+this.maxY, z+this.maxZ);

}

float pixel = 1F / 16F;

public int getRenderType(){
	return -1;
}

public Block blockDropped(int par1, int y, int par3)
    {
        return com.linumhost.Blocks.Blocks.conduit;
    }

public boolean isOpaqueCube(){
	return false;
}

public boolean renderAsNormalBlock(){
	return false;
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	return new TileEntityConduitPipe();
}


}

Link to comment
Share on other sites

Follow this tutorial,

it should help you on pipes.

 

Also from what I see you need to implement the getCollisionBoundingBoxFromPool() to set your custom collisions.

 

Also add @Override on top of Override methods :)

 

getCollisionBoundingBoxFromPool() and getCollisionBoundingBoxFromPool() are both overridden methods.

I require Java, both the coffee and the code :)

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.



×
×
  • Create New...

Important Information

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