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

Hi all!

 

So last night, I received some help on another forum creating an auto-smelt enchantment. What currently happens with the enchantment is that if you mine a block with a smelting recipe, it'll only drop the smelted result. However, this only works the first time you use the enchantment on a block. What I mean is that if you mine a block of Gold Ore with auto-smelt, it'll drop a Gold Ingot. Then you could go and mine an Iron Ore and it would drop an Iron Ingot. If you were to then mine Gold Ore again, nothing would be dropped at all. Here is the event code (apologies, couldn't get the code button to work):

 

package SkyeStark.Rhencraft.main;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import net.minecraft.enchantment.EnchantmentHelper;

import net.minecraft.init.Items;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraftforge.event.world.BlockEvent;

import scala.actors.threadpool.Arrays;

 

public class AutoSmelt {

 

int j = 0;

int i;

 

@SubscribeEvent

public void onHarvestDrops(BlockEvent.HarvestDropsEvent event)

{

System.out.println(event.drops);

System.out.println("Event has started");

 

if(event.harvester != null){

System.out.println("Harvester exists");

ItemStack heldItem = event.harvester.inventory.getCurrentItem();

 

if (heldItem != null && heldItem.getItem() == MainClass.toolRheniumPickaxe)

{

System.out.println("Found Pickaxe");

int enchantmentLevel = EnchantmentHelper.getEnchantmentLevel(MainClass.autoSmelt.effectId, heldItem);

 

if (enchantmentLevel > 0 && event.harvester.inventory.hasItem(Items.coal))

{

System.out.println("Level is more than 0");

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

 

if (smelted != null)

{

 

System.out.println("" + smelted + " will be added to the drops");

event.drops.clear();

j = j + 1;

 

if(j >= 8){

 

j = 0;

event.harvester.inventory.consumeInventoryItem(Items.coal);

 

}

System.out.println("J is equal to " + j);

event.drops.add(smelted);

 

}

}

}

}

 

}

}

 

There is no reason why the smelted item should not be dropped, is there?

You have a lot of debug statements in there.  When you mine a block and it doesn't drop the right thing, what does the console say?

 

(Also, what is the name of your enchantment? This is for purposes unrelated to your bug.  e.g. whatever you pass to

setName()

in your enchantment constructor).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.