-
Posts
107 -
Joined
-
Last visited
Everything posted by tebreca
-
[SOLVED] [1.12] NoSuchMethodError for getSlotFor
tebreca replied to IceMetalPunk's topic in Modder Support
it says at net.minecraft.world.World.func_72939_s(World.java:1755) at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:612) maybe you need to do a !World.isRemote statement -
[SOLVED] [1.12] NoSuchMethodError for getSlotFor
tebreca replied to IceMetalPunk's topic in Modder Support
Did you try to run the func on the server side only?? -
your obsidian ingot
-
and in your ModItems try to use ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID + ":" + item.getUnlocalizedName().substring(5)), "inventory")); instead of ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory")); I think that would work
-
try this.setRegistryName(new ResourceLocation(Reference.MODID + ":" + registryName)); instead of this.setRegistryName(new ResourceLocation(Reference.MODID, registryName));
-
you use a @SubscribeEvent public static void onHit(LivingHurtEvent event) { } but you cant specify the type of weapon
-
Some people dont seem to understand you need Java knowledge before being able to program Java, but we dont need to forget to respect everyone who tries to learn java at least, and i am helping people not only with things i know, but i use the things i know to solve others problems, they all seem to forget this is a helping For rhe Forgde sources and not for java, they can better go to codecademy, stackoverflow or sololearn, and also stackoverflow will help them. Creating errors helps you prograss further in programming, never be scared of some typ of code and be never scared of asking a question: No question ever was stupid. why am i writing this? well, because i want to let evryone know that this forum needs java knowledge but you aint dumb if you ask questions about forge
-
Ok so first dont be scared to ask, you can better ask then just stop with what you dont understand. First create a new class in your handlers package named "EventHandler" make it have the @EventBusSubscriber annonation Next up make a public static void method called: onBlockBreak make it have this parameter : BlockEvent.BreakEvent event put the @SubscribeEvent annonation before the method get those variables in your method: BlockPos pos = event.getPos(); World world = event.getWorld(); ItemStack stack = event.getPlayer().getHeldItem(event.getPlayer().getActiveHand()); Item item = stack.getItem(); finally paste in this bit of code to see if the block is broken by the tool you want and drop the item if (item == Items.WOODEN_AXE || item == Items.STONE_AXE || item == Items.IRON_AXE || item == Items.GOLDEN_AXE || item == Items.DIAMOND_AXE) { if (world.getBlockState(pos).getBlock() == Blocks.PLANKS) { event.setCanceled(true); world.setBlockToAir(pos); world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.DIAMOND /* your item here*/))); event.getPlayer().getHeldItem(event.getPlayer().getActiveHand()).setItemDamage(stack.getItemDamage() + 1); }else { event.setCanceled(false); } }else { event.setCanceled(false); } It would look something like this package bte.util.handlers; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.network.ForgeMessage; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @EventBusSubscriber public class EventHandler { @SubscribeEvent public static void onBlockBreak(BlockEvent.BreakEvent event) { BlockPos pos = event.getPos(); World world = event.getWorld(); System.out.println("LEL you broke a block"); ItemStack stack = event.getPlayer().getHeldItem(event.getPlayer().getActiveHand()); Item item = stack.getItem(); if (item == Items.WOODEN_AXE || item == items.dia) { if (world.getBlockState(pos).getBlock() == Blocks.PLANKS) { event.setCanceled(true); world.setBlockToAir(pos); world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.DIAMOND /* your item here*/))); event.getPlayer().getHeldItem(event.getPlayer().getActiveHand()).setItemDamage(stack.getItemDamage() + 1); }else { event.setCanceled(false); } }else { event.setCanceled(false); } } }
-
could you send the code??
-
[SOLVED][1.12.2] How to remove vanilla recipes?
tebreca replied to WiseNoobCrusher's topic in Modder Support
Would you like me to add it to your Github as a commit?? -
[SOLVED][1.12.2] How to remove vanilla recipes?
tebreca replied to WiseNoobCrusher's topic in Modder Support
Here you go, You first need to make a class inside you util.handlers package called: "CraftingHandler.java" Inside that class create 2 public static void methods: 1. registerRecipes 2. removeRecipes In the removeRecipes class create 2 variables like this: ForgeRegistry<IRecipe> recipeRegistry = (ForgeRegistry<IRecipe>)ForgeRegistries.RECIPES; ArrayList<IRecipe> recipes = Lists.newArrayList(recipeRegistry.getValues()); Next up make a for loop to loop trough all the recipes make a variable Itemstack stack from IRecipe.getRecipeOutput(); create a if statement which checks if stack.getoutput(); is equal to Item.getItemFromBlock(Blocks.wood) then paste this code: recipeRegistry.remove(r.getRegistryName()); recipeRegistry.register(DummyRecipe.from(r)); your class would look something like this now: package bte.util.handlers; import java.util.ArrayList; import com.google.common.collect.Lists; import bte.util.DummyRecipe; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; public class CraftingHandler { public static void RegisterRecipes() { } public static void removeRecipes() { ForgeRegistry<IRecipe> recipeRegistry = (ForgeRegistry<IRecipe>)ForgeRegistries.RECIPES; ArrayList<IRecipe> recipes = Lists.newArrayList(recipeRegistry.getValues()); for (IRecipe r : recipes) { ItemStack output = r.getRecipeOutput(); if (output.getItem() == Item.getItemFromBlock(Blocks.PLANKS)) { recipeRegistry.remove(r.getRegistryName()); recipeRegistry.register(DummyRecipe.from(r)); } } } } Now you need to create a class in your package called Dummyrecipe paste this code in: public class DummyRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { private final ItemStack output; public DummyRecipe(ItemStack output) { this.output = output; } public static IRecipe from(IRecipe other) { return new DummyRecipe(other.getRecipeOutput()).setRegistryName(other.getRegistryName()); } @Override public boolean matches(InventoryCrafting inv, World worldIn) { return false; } @Override public ItemStack getCraftingResult(InventoryCrafting inv) { return ItemStack.EMPTY; } @Override public boolean canFit(int width, int height) { return false; } @Override public ItemStack getRecipeOutput() { return output; } } this just makes sure the output is empty now finally call the removerecipes in you main class at the init event -
thats bad though, but i can only help you with sending a website which helps a lot if you understand java good enough, https://shadowfacts.net/tutorials/forge-modding-112/ succes with modding, always ask help if you need there will be people around who can help you
-
also you need to register your class as a @EventBusSubscriber is pretty easy with just the @mod.eventbussubsriber annonation
-
I send this to some other people too but, In the new 1.12.2 version you need to use the new way of registering with the new RegistryEvent<T> Try and read the documentation on at mcforge.readthedocs.io/en/latest/concepts/registries/ If you arent known with events check out this https://mcforge.readthedocs.io/en/latest/events/intro/ I could advice you to check out this repo from Harry'sTechreviews: a youtuber, you can also check out his video on it https://github.com/HarryTechRevs/MinecraftModding/tree/HarryTechRevs-1.12.2-Tutorials/main/java/harry/mod
-
thx, yes i meant the boxes
-
thx, that was some handy info,i think i can figure it out myselves, only how can i adjust where the boxes are going to be in the container/gui?
-
PS i had the same issue
-
I dont really understand the part of creating the instance of the container, drawing the inventory, i got a advanced inventory looking like this I get that he draws the inventory but i cant really get how i add the places in my own inventory gui and do the progression bar i also cant find anything i at the docs
-
In the new 1.12.2 version you need to use the new way of registering with the new RegistryEvent<T> Try and read the documentation on at mcforge.readthedocs.io/en/latest/concepts/registries/ If you arent known with events check out this https://mcforge.readthedocs.io/en/latest/events/intro/ I could advice you to check out this repo from Harry'sTechreviews: a youtuber, you can also check out his video on it https://github.com/HarryTechRevs/MinecraftModding/tree/HarryTechRevs-1.12.2-Tutorials/main/java/harry/mod