Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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.

  • Author

so how would i implement that? could you give me an example in code

as thats the best way i learn :P

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.

  • Author

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.