Jump to content

Recommended Posts

Posted

i got my pick smelting the ore when broken but it has a graphical glitch that it drops 2 ingots and when i break stuff that cant be smelted say Dirt it crashes the game.

 

Code:

 

package com.ProjectTronopolis.PTmod.Items.Tools;

 

import java.util.ArrayList;

 

import net.minecraft.block.Block;

import net.minecraft.enchantment.Enchantment;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemPickaxe;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.world.World;

 

public class redstonePick extends ItemPickaxe {

 

public redstonePick(ToolMaterial p_i45347_1_) {

super(p_i45347_1_);

// TODO Auto-generated constructor stub

}

    @Override

    public boolean onBlockStartBreak(ItemStack itemstack, int i, int j, int k, EntityPlayer player)

    {

return bFull3D;

    }

        @Override

        public boolean onBlockDestroyed(ItemStack itemStack, World world,

        Block block, int x, int y,

        int z, EntityLivingBase player) {

       

        ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block)).copy();

 

        if (stack != null) {

        System.out.println(stack);

        world.setBlockToAir(x, y, z);

        player.entityDropItem(stack, 1);

        }

       

       

        return true;

        }

}

 

Please help

Thanks

Tom

Posted

You need to do !world.isRemote check to run the code only on server side.

 

For e.g dirt-crash. You need to check if item can be smelted (has smelting result) obviously :P

1.7.10 is no longer supported by forge, you are on your own.

Posted

public void method(World world)
{
if (!world.isRemote)
{
//runs on server
}
else //runs on client
}

 

When you spawn entity (item in this case) you always do it on server only.

1.7.10 is no longer supported by forge, you are on your own.

Posted

So like this?

 

        public void method(World world)

        {

        if (!world.isRemote)

        {

            @Override

            public boolean onBlockStartBreak(ItemStack itemstack, int i, int j, int k, EntityPlayer player)

            {

        return bFull3D;}

       

        else

            {

                @Override

                public boolean onBlockDestroyed(ItemStack itemStack, World world,

                Block block, int x, int y,

                int z, EntityLivingBase player) {

               

                }

            ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block)).copy();

 

            if (stack != null) {

            System.out.println(stack);

            world.setBlockToAir(x, y, z);

            player.entityDropItem(stack, 1);

            {

           

            return true;

        }

 

Or am i doing it wrong?

:P

Posted

Or am i doing it wrong?

:P

Yes, very much so.

Please learn at least the absolute basics of Java before starting to make a mod.

 

Welp in that case got any suggestions where to start as im willing to learn anything and woudlnt know where to start any books/sites/vids on teaching java that you would highly reccommend?

 

OR even a teacher that would do it through skype or something :P

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.