Jump to content

Custom Block Problems


deantonious

Recommended Posts

Hi, I made my own block that gives you a random Item on right click, but there is a problem... The video shows the problem... http://deantonious.es/block.mp4

 

The Block code is this:

package deantonious.blocks;

import java.util.ArrayList;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import deantonious.ModPowderCraft;
import net.minecraft.block.material.Material;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

public class BlockMenaSubsuelo extends Block 
{

        public BlockMenaSubsuelo(int id, Material material) 
        {
                super(id, material);
        }
        
        @Override
    	public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    	{

            if(par5EntityPlayer.getHeldItem() == null)
    		{
            	if(!par1World.isRemote){
            		
            		par5EntityPlayer.addChatMessage("Necesitas un Cincel");
            	}

            	return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
    		}

    		if(par5EntityPlayer.getHeldItem().itemID == ModPowderCraft.cincel.itemID)
    		{

    			par5EntityPlayer.getHeldItem().stackSize -= 1; 
    			if(!par1World.isRemote)
    			{
    				
    				int rand = par1World.rand.nextInt(60);

    	                if(rand<=8 && rand>=0){
    	                	par5EntityPlayer.addChatMessage("You obtained a Blue Sphere");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.gemaazul));

    	                }
    	                else if(rand<=16 && rand>={
    	                	par5EntityPlayer.addChatMessage("You obtained a Red Sphere");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.gemaroja));
        	                
    	                }
    	                else if(rand<=24 && rand>=16){
    	                	par5EntityPlayer.addChatMessage("You obtained a Green Sphere");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.gemaverde));
        	                
    	                }
    	                else if(rand<=32 && rand>=24){
    	                	par5EntityPlayer.addChatMessage("You obtained a Pale Sphere");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.gemablanca));
        	                
    	                }
    	                else if(rand<=40 && rand>=32){
    	                	par5EntityPlayer.addChatMessage("You obtained a Prism Sphere");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.gemaprisma));
        	                
    	                }
    	                else if(rand<=42 && rand>=40){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.ArmorFossilCovered));
    	                
    	                }
    	                else if(rand<=44 && rand>=42){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.ClawFossilCovered));
    	                }
    	                else if(rand<=46 && rand>=44){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.CoverFossilCovered));
    	                }
    	                else if(rand<=48 && rand>=46){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.DomeFossilCovered));
    	                }
    	                else if(rand<=50 && rand>=48){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.HelixFossilCovered));
    	                }
    	                else if(rand<=52 && rand>=50){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.OldAmberCovered));
    	                }
    	                else if(rand<=54 && rand>=52){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.PlumeFossilCovered));
    	                }
    	              
    	                else if(rand<=56 && rand>=54){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.RootFossilCovered));
    	                }
    	                else if(rand<=58 && rand>=56){
    	                	par5EntityPlayer.addChatMessage("You obtained a Covered Fossil");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModPowderCraft.SkullFossilCovered));
    	                }
    	                else if(rand<=60 && rand>=58){
    	                	par5EntityPlayer.addChatMessage("You obtained a Bone");
    	                	par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bone));
    	                }          
    	                par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
    				
    			}
    			par1World.playSound((double)par2 + 0.5D, (double)par3 + 0.1D, (double)par4 + 0.5D, "random.break", 0.3F, 0.5F, blockConstructorCalled);
			par1World.playSound((double)par2 + 0.5D, (double)par3 + 0.1D, (double)par4 + 0.5D, "random.orb", 0.3F, 0.5F, blockConstructorCalled);
                 
    			return true;	            
    		}
    		return true;
    	}
          

}

 

Thanks for the help

Twitter: @deantonious || TeamSpeak Server: ts3.deantonious.es

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.