
Hackbaellchen
Members-
Posts
111 -
Joined
-
Last visited
Converted
-
Gender
Male
Hackbaellchen's Achievements

Creeper Killer (4/8)
2
Reputation
-
[1.8] Custom CraftingManager won't consume items
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
So should I check in the container, if the items are a recipe? -
[1.8] Custom CraftingManager won't consume items
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
Because I need it for the crafting recipes. The container checks if the items are arranged as the recipes added in the constructor. Where do I have to call this? EDIT: I override the method on slot click in the container class. -
[1.8] Custom CraftingManager won't consume items
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
I added this to my constructor: public MyCraftingManager() { try { Constructor<CraftingManager> constructor = CraftingManager.class.getDeclaredConstructor(new Class[0]); constructor.setAccessible(true); CraftingManager cm = constructor.newInstance(new Object[0]); } catch (Exception e) { e.printStackTrace(); } } Should I do now cm.addRecipe instead of calling my copied method? This works, but now I can craft vanilla items too and the bigger problem is that the items are still not consumed... -
[1.8] Custom CraftingManager won't consume items
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
Yes, I just want my recipes to be crafted just in my workbench.. Could you explain that? -
[1.8] Custom CraftingManager won't consume items
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
The constructor CraftingManager is not visible -
Hey, I've got my own crafting table, with it's Gui and container. I want the crafting recipes of my mod just to be crafted in the mod's workbench. So I created my own CraftingManager and used this method in my container class: @Override public void onCraftMatrixChanged(IInventory inventoryIn) { this.craftResult.setInventorySlotContents(0, MyCraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } I copied all methods from the CraftingManager to my own one and added my recipes. When I put the items in the correct shape, the result is displayed and I can take it out, but the items in the 3x3 slots are still there. I can take tons of result items, because they are not consumed. I also tried to use the forge CraftingManager. Then all works fine... I don't know what's wrong MyCraftingManager.class (I copied all methods from the original CraftingManager): public class MyCraftingManager { private static final MyCraftingManagerinstance = new MyCraftingManager(); private final List recipes = Lists.newArrayList(); public static MyCraftingManagergetInstance() { return instance; } private MyCraftingManager() { addRecipe(new ItemStack(MyBlocks.MyBlock, 2), new Object[] { "111", "111", "111", '1', Blocks.cobblestone }); Collections.sort(this.recipes, new Comparator() { public int compare(IRecipe rec1, IRecipe rec2) { return rec1 instanceof ShapelessRecipes && rec2 instanceof ShapedRecipes ? 1 : (rec2 instanceof ShapelessRecipes && rec1 instanceof ShapedRecipes ? -1 : (rec2.getRecipeSize() < rec1.getRecipeSize() ? -1 : (rec2.getRecipeSize() > rec1.getRecipeSize() ? 1 : 0))); } public int compare(Object rec1, Object rec2) { return this.compare((IRecipe) rec1, (IRecipe) rec2); } }); } public ShapedRecipes addRecipe(ItemStack stack, Object... recipeComponents) { String s = ""; int i = 0; int j = 0; int k = 0; if (recipeComponents[i] instanceof String[]) { String[] astring = (String[]) ((String[]) recipeComponents[i++]); for (int l = 0; l < astring.length; ++l) { String s1 = astring[l]; ++k; j = s1.length(); s = s + s1; } } else { while (recipeComponents[i] instanceof String) { String s2 = (String) recipeComponents[i++]; ++k; j = s2.length(); s = s + s2; } } HashMap hashmap; for (hashmap = Maps.newHashMap(); i < recipeComponents.length; i += 2) { Character character = (Character) recipeComponents[i]; ItemStack itemstack1 = null; if (recipeComponents[i + 1] instanceof Item) { itemstack1 = new ItemStack((Item) recipeComponents[i + 1]); } else if (recipeComponents[i + 1] instanceof Block) { itemstack1 = new ItemStack((Block) recipeComponents[i + 1], 1, 32767); } else if (recipeComponents[i + 1] instanceof ItemStack) { itemstack1 = (ItemStack) recipeComponents[i + 1]; } hashmap.put(character, itemstack1); } ItemStack[] aitemstack = new ItemStack[j * k]; for (int i1 = 0; i1 < j * k; ++i1) { char c0 = s.charAt(i1); if (hashmap.containsKey(Character.valueOf(c0))) { aitemstack[i1] = ((ItemStack) hashmap.get(Character.valueOf(c0))).copy(); } else { aitemstack[i1] = null; } } ShapedRecipes shapedrecipes = new ShapedRecipes(j, k, aitemstack, stack); this.recipes.add(shapedrecipes); return shapedrecipes; } public void addShapelessRecipe(ItemStack stack, Object... recipeComponents) { ArrayList arraylist = Lists.newArrayList(); Object[] aobject = recipeComponents; int i = recipeComponents.length; for (int j = 0; j < i; ++j) { Object object1 = aobject[j]; if (object1 instanceof ItemStack) { arraylist.add(((ItemStack) object1).copy()); } else if (object1 instanceof Item) { arraylist.add(new ItemStack((Item) object1)); } else { if (!(object1 instanceof Block)) { throw new IllegalArgumentException( "Invalid shapeless recipe: unknown type " + object1.getClass().getName() + "!"); } arraylist.add(new ItemStack((Block) object1)); } } this.recipes.add(new ShapelessRecipes(stack, arraylist)); } public void addRecipe(IRecipe recipe) { this.recipes.add(recipe); } public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) { Iterator iterator = this.recipes.iterator(); IRecipe irecipe; do { if (!iterator.hasNext()) { return null; } irecipe = (IRecipe) iterator.next(); } while (!irecipe.matches(inv, world)); return irecipe.getCraftingResult(inv); } public ItemStack[] func_180303_b(InventoryCrafting inv, World world) { Iterator iterator = this.recipes.iterator(); while (iterator.hasNext()) { IRecipe irecipe = (IRecipe) iterator.next(); if (irecipe.matches(inv, world)) { return irecipe.getRemainingItems(inv); } } ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { aitemstack[i] = inv.getStackInSlot(i); } return aitemstack; } public List getRecipeList() { return this.recipes; } } I think I has to do with this method, but I'm not really sure: public ItemStack[] func_180303_b(InventoryCrafting inv, World world) {}
-
[1.7] adding potion effect to projectile
Hackbaellchen replied to iluvpie777's topic in Modder Support
What do you want to achieve? I think he wants to give the entity hit by the projectile a potion effect. -
Thank you!
-
Yes, I forgot to set the bounds. But now, the border line is smaller (it disappeared). Can I set this manually without changing the bounds?
-
This doesn't work, not with players, items, mobs.. The event seems not to be called..
-
Hey, is there an event to detect when an item (e.g. a stick) hits a block (e.g. thrown by a player)? public class MyBlock extends Block { @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { System.out.println("collide event"); } } This works fine for players and animals/monsters, but not for items..
-
[1.7.10] Invisible TNT, where to call doRender()?
Hackbaellchen replied to Exo594's topic in Modder Support
With yours, I read 3 articles about the invisible TNT. http://www.minecraftforge.net/forum/index.php/topic,18036.0.html http://www.minecraftforge.net/forum/index.php/topic,31319.0.html I've got the same issue. Anyone on this forum must know why so many modders have exactly the same coding problem! -
[1.8] [TEXTURE ERRORS]: domain minecraft is missing textures
Hackbaellchen replied to Hackbaellchen's topic in Modder Support
Where did I forget it?? I allways use MyMod.MODID + ":MyBow" EDIT: Mistake found. Json files missed it. -
Hey, I want to create my own bow. Shooting works great, texturing not. The class extends ItemBow. getModel() method: @Override public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { String modid = MyMod.MODID; ModelResourceLocation mrl = new ModelResourceLocation(modid + ":MyBow", "inventory"); useRemaining = stack.getMaxItemUseDuration() - useRemaining; if (player.getItemInUse() != null) { if (useRemaining >= 18) { mrl = new ModelResourceLocation(modid + ":MyBow3", "inventory"); } else if (useRemaining > 13) { mrl = new ModelResourceLocation(modid + ":MyBow2", "inventory"); } else if (useRemaining > 0) { mrl = new ModelResourceLocation(modid + ":MyBow1", "inventory"); } } return mrl; } init() method: ModelBakery.addVariantName(MyItems.bow, MODID + ":MyBow", MODID + ":MyBow1", MODID + ":MyBow2", MODID + ":MyBow3"); And finally the error: The textures named can all be found in my resources folder! I hope you can help me.
-
All works fine now. public class MyEntityProjectile extends EntityThrowable { public MyEntityProjectile(World par1World) { super(par1World); } public MyEntityProjectile(World par1World, EntityLivingBase par2EntityLivingBase) { super(par1World, par2EntityLivingBase); } public MyEntityProjectile(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } protected void onImpact(MovingObjectPosition movingobjectposition) { if (!this.worldObj.isRemote) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 4.5F, true); } } public class MyItem extends Item { public MyItem() { super(); this.setMaxDamage(50); this.setMaxStackSize(1); this.setFull3D(); } @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { world.spawnEntityInWorld(new MyEntityProjectile(world, player)); itemStack.damageItem(1, player); } return itemStack; } I've found my old code