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.

Fruten

Members
  • Joined

  • Last visited

  1. package ru.fruten.ntc; import java.lang.reflect.Field; import java.util.ArrayList; import com.google.common.base.Throwables; import com.google.common.collect.Lists; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.inventory.ContainerWorkbench; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class NewStickIRecipe implements IRecipe { private static IRecipe rec; @Override public IRecipe setRegistryName(ResourceLocation name) { return NewStickIRecipe.rec; } @Override public ResourceLocation getRegistryName() { return NewStickIRecipe.rec.getRegistryName(); } @Override public Class<IRecipe> getRegistryType() { return NewStickIRecipe.rec.getRegistryType(); } @Override public boolean matches(InventoryCrafting inv, World worldIn) { return NewStickIRecipe.rec.matches(inv, worldIn) && findPlayer(inv).experienceLevel >= 1; } @Override public ItemStack getCraftingResult(InventoryCrafting inv) { return NewStickIRecipe.rec.getCraftingResult(inv); } @Override public boolean canFit(int width, int height) { return NewStickIRecipe.rec.canFit(width, height); } @Override public ItemStack getRecipeOutput() { return NewStickIRecipe.rec.getRecipeOutput(); } private static final Field eventHandlerField = ReflectionHelper.findField(InventoryCrafting.class, "eventHandler"); private static final Field containerPlayerPlayerField = ReflectionHelper.findField(ContainerPlayer.class, "player"); private static final Field slotCraftingPlayerField = ReflectionHelper.findField(SlotCrafting.class, "player"); private static EntityPlayer findPlayer(InventoryCrafting inv) { try { Container container = (Container) eventHandlerField.get(inv); if (container instanceof ContainerPlayer) { return (EntityPlayer) containerPlayerPlayerField.get(container); } else if (container instanceof ContainerWorkbench) { return (EntityPlayer) slotCraftingPlayerField.get(container.getSlot(0)); } else { return null; } } catch (Exception e) { throw Throwables.propagate(e); } } public static IRecipe getRecipeFromItem(Item item) { ArrayList<IRecipe> recipes = Lists.newArrayList(CraftingManager.REGISTRY.iterator()); IRecipe recipeFromItemStack; for (IRecipe recipe : recipes) { if (recipe.getRecipeOutput().getItem() == item) { recipeFromItemStack = recipe; return recipeFromItemStack; } } return null; } public static void recRecipe(IRecipe recipe) { rec = recipe; } } My IRecipe. package ru.fruten.ntc.util; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; import com.google.common.collect.Lists; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryModifiable; import ru.fruten.ntc.NewStickIRecipe; public class AllVanillaRecipes { public static void addNewStickRecipe() { ForgeRegistry<IRecipe> recipeRegistry = (ForgeRegistry<IRecipe>)ForgeRegistries.RECIPES; NewStickIRecipe recipe = new NewStickIRecipe(); recipeRegistry.register(recipe); } public static void removeStickRecipe() { ForgeRegistry<IRecipe> recipeRegistry = (ForgeRegistry<IRecipe>)ForgeRegistries.RECIPES; recipeRegistry.remove(Items.STICK.getRegistryName()); } } Methods for Init. @EventHandler public static void Init(FMLInitializationEvent event) { NewStickIRecipe.recRecipe(NewStickIRecipe.getRecipeFromItem(Items.STICK)); AllVanillaRecipes.removeStickRecipe(); AllVanillaRecipes.addNewStickRecipe(); } Himself init.
  2. I registered my IRecipe instead of a stick recipe, but in the recipe book it's empty, the stick icon itself is there. As you can see in the screenshot, the recipe icon is there, but supposedly I can do it, although I have no resources. When you click on the crafting icon, there is no reaction. How to make a normal recipe in the book?
  3. Thank you diesieben07, Draco18s
  4. I've seen it, but how do I use it in an ArrayList or List variable?
  5. Sorry, perhaps, this question already someone asked and on him someone responded, but I have very little information about this, only for old versions of. The question in the topic title. P.S. sorry for my English again.
  6. I want the player to not be able to craft the item if the condition(I don't want to say what condition) is wrong. I want other players to be able to make an item if they have a true condition.
  7. Nothing bad happened, I saw errors in the console and immediately fixed it by checking the block. if (!world.isRemote && world.getBlockState(blockPos).getBlock() == Blocks.PLANKS) { if (world.getBlockState(blockPos).getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.OAK) { world.setBlockState(blockPos, NTCBlocks.NTC_LIGHTWOOD.getDefaultState()); } }
  8. Fruten changed their profile photo
  9. I made this code and it works, thanks again! if (!world.isRemote && world.getBlockState(blockPos).getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.OAK) { world.setBlockState(blockPos, NTCBlocks.NTC_LIGHTWOOD.getDefaultState()); }
  10. Thanks so much!
  11. Look in the source code of the game?
  12. Hi, I don't speak English very well! How to check oak boards? I have this code, but it skips all kinds of planks. | I just need to check the oak planks. \ / if (!world.isRemote && world.getBlockState(blockPos).getBlock() == Blocks.PLANKS) { world.setBlockState(blockPos, NTCBlocks.NTC_LIGHTWOOD.getDefaultState()); }

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.