• 0

    posted a message on Problem With Custom Crafting Manager
    Quote from undefined

    I actually took this bit of code out completely as it seemed to cause more problems that it solved. As well, no where do I have direct access to slots as an array, only as a list through the interface.

    P.S.
    I still have this problem and I apologize for not responding sooner.

    Posted in: Modification Development
  • 1

    posted a message on Problem With Custom Crafting Manager

    No worries, Ill take whatever help I can get on this, not in a rush.

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    Honestly that would be amazing if you could send on even part of a working example in 1.8.

    Thank you so much!

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager
    Quote from SlackAttack3»

    Interesting, although I'm not entirely sure I follow. If you wouldn't mind sharing some code or insight into where you would call the onUpdate method, and/or how you detect if the output is emptied by the player?


    Would the onUpdate in the tileentity be a @SubscribeEvent?

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    Interesting, although I'm not entirely sure I follow. If you wouldn't mind sharing some code or insight into where you would call the onUpdate method, and/or how you detect if the output is emptied by the player?

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    Hmm, I'm not really sure what to add to the TileEntity class as I don't have any examples to go by. Is there a specific interface I should implement as TileEntity doesn't have a onUpdate method to be overriden, nor does IInventory (my best guess at the interface to use).

    I'm not really sure where to go, aside from now in my block class I added in an override for createTileEntity().

    Also not sure where else I need to "wire in" the tile entity now.

    Sorry for struggling with this, but thank you so much for helping.

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    It's not a TileEntity, I'm trying (was able to do it in 1.7.2) as a crafting table where there is no tile entity associated, just a container like a crafting table does. Has it changed in 1.8 where a tileentity is now required for such a thing even though vanilla crafting table doesn't use one?


    I posted more in-depth information on the forge forum: http://www.minecraftforge.net/forum/index.php/topic,30417.0.html
    That's all the classes aside from the Block, but the GUI and such opens fine so block code isn't suspect

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    Anyone got any ideas or supplementary material on custom crafting tables?

    Posted in: Modification Development
  • 0

    posted a message on Problem With Custom Crafting Manager

    I have everything up and running for a custom crafting table, except when I craft a recipe, the items in the crafting slot don't decrement in stack size,
    as well, when doing shapeless crafting the stack size will get set to 0, but the item will still appear in the grid.

    I'm not sure how well I explained the issue, however this wasn't a problem in 1.7.2 which is where I am updating the code from.

    EDIT: Could it have something to do with the implemented method getRemainingItems() inside the ShapedRecipe and ShapelessRecipe classes?

    EDIT 2: The above appears to not be the case, as it never seems to execute when crafting an item.


    Crafting Manager: (Formatted Version: http://pastebin.com/SUFNTkUb)


    public class KnappingStoneCraftingManager
    {
    private static final KnappingStoneCraftingManager instance = new KnappingStoneCraftingManager();

    private List recipies = new ArrayList();

    private KnappingStoneCraftingManager()
    {
    recipies = new ArrayList();

    //Add recipies here I guess?
    this.addRecipe(new ItemStack(SurvivalPlusItems.heavy_tool_binding, 2), new Object[] {"R R R", 'R', SurvivalPlusItems.rock_item});
    this.addShapelessRecipie(new ItemStack(SurvivalPlusItems.heavy_tool_binding, 1), new Object[]{SurvivalPlusItems.rock_item});

    Collections.sort(this.recipies, new KnappingStoneRecipeSorter(this));
    }

    public KnappingStoneShapedRecipies addRecipe(ItemStack result, Object ... objArray)
    {
    String str = "";
    int i = 0;
    int j = 0;
    int k = 0;

    if(objArray instanceof String[])
    {
    String[] astr = (String[])(String[])objArray[i++];

    for(int l = 0; l < astr.length; ++l)
    {
    String str1 = astr[l];
    ++k;
    j = str1.length();
    str += str1;
    }
    }
    else
    {
    while(objArray instanceof String)
    {
    String str2 = (String)objArray[i++];
    ++k;
    j = str2.length();
    str += str2;
    }
    }

    HashMap hashmap;

    for(hashmap = new HashMap(); i < objArray.length; i+= 2)
    {
    Character character = (Character)objArray;
    ItemStack itemstack1 = null;

    if(objArray[i+1] instanceof Item)
    {
    itemstack1 = new ItemStack((Item)objArray[i + 1]);
    }
    else if(objArray[i+1] instanceof Block)
    {
    itemstack1 = new ItemStack((Block)objArray[i + 1]);
    }
    else if(objArray[i+1] instanceof ItemStack)
    {
    itemstack1 = (ItemStack)objArray[i + 1];
    }

    hashmap.put(character, itemstack1);
    }

    ItemStack[] aitemstack = new ItemStack[j * k];

    for(int m = 0; m < j * k; ++m)
    {
    char c = str.charAt(m);

    if(hashmap.containsKey(Character.valueOf(c)))
    {
    aitemstack[m] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
    }
    else
    {
    aitemstack[m] = null;
    }
    }

    KnappingStoneShapedRecipies shapedRecipies = new KnappingStoneShapedRecipies(j, k, aitemstack, result);
    this.recipies.add(shapedRecipies);
    return shapedRecipies;
    }

    public void addShapelessRecipie(ItemStack itemstack, Object ... objArray)
    {
    ArrayList alist = new ArrayList();
    Object[] aobj = objArray;
    int i = objArray.length;

    for(int j = 0; j < i; ++j)
    {
    Object obj = aobj[j];

    if(obj instanceof ItemStack)
    {
    alist.add(((ItemStack)obj).copy());
    }
    else if(obj instanceof Item)
    {
    alist.add(new ItemStack((Item)obj));
    }
    else
    {
    if(!(obj instanceof Block))
    {
    throw new RuntimeException("Invalid Shapeless Recipe");
    }

    alist.add(new ItemStack((Block)obj));
    }
    }

    this.recipies.add(new ShapelessRecipes(itemstack, alist));
    }

    public ItemStack findMatchingRecipe(InventoryCrafting inventory, World world)
    {
    int i = 0;
    ItemStack is1 = null;
    ItemStack is2 = null;
    int j;

    for(j = 0; j < inventory.getSizeInventory(); ++j)
    {
    ItemStack is3 = inventory.getStackInSlot(j);

    if(is3 != null)
    {
    if(i == 0)
    is1 =is3;
    if(i == 1)
    is2 = is3;
    ++i;
    }
    }

    if(i == 2 && is1.getIsItemStackEqual(is2) && is1.stackSize == 1 && is2.stackSize == 1 && is1.getItem().isRepairable())
    {
    Item item = is1.getItem();
    int h = item.getMaxDamage() - is1.getItemDamage(); //TODO: Might have some oddity here since getItemDamageForDisplay doesn't exist
    int k = item.getMaxDamage() - is2.getItemDamage();
    int l = h + k + item.getMaxDamage() * 5/100;
    int m = item.getMaxDamage() - l;

    if(m < 0)
    m = 0;

    return new ItemStack(is1.getItem(), 1, m);
    }
    else
    {
    for(j = 0; j < this.recipies.size(); ++j)
    {
    IRecipe irecipie = (IRecipe)this.recipies.get(j);
    if(irecipie.matches(inventory, world))
    {
    return irecipie.getCraftingResult(inventory);
    }
    }
    return null;
    }
    }

    public List getRecipies()
    {
    return this.recipies;
    }

    public static final KnappingStoneCraftingManager getInstance()
    {
    return instance;
    }
    }


    Container Class: (Formatted Version: http://pastebin.com/i24HMpWW)


    package net.nod3.survivalplus.container;

    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.InventoryCraftResult;
    import net.minecraft.inventory.InventoryCrafting;
    import net.minecraft.inventory.Slot;
    import net.minecraft.inventory.SlotCrafting;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.BlockPos;
    import net.minecraft.world.World;
    import net.nod3.survivalplus.crafting.KnappingStoneCraftingManager;
    import net.nod3.survivalplus.init.SurvivalPlusBlocks;

    public class ContainerKnappingStone extends Container
    {
    public InventoryCrafting craftMatrix;
    public IInventory craftResult;
    private World world;
    private BlockPos pos;

    private int verticalSlots = 5;
    private int horizontalSlots = 5;

    public ContainerKnappingStone(InventoryPlayer inventory, World world, BlockPos pos)
    {
    craftMatrix = new InventoryCrafting(this, horizontalSlots, verticalSlots);
    craftResult = new InventoryCraftResult();
    this.world = world;
    this.pos = pos;

    //Output Slot
    this.addSlotToContainer(new SlotCrafting(inventory.player, craftMatrix, craftResult, 0, 140, 54));

    //Crafting Grid
    for(int y = 0; y < verticalSlots; y++)
    {
    for(int x = 0; x < horizontalSlots; x++)
    {
    this.addSlotToContainer(new Slot(craftMatrix, x + y * horizontalSlots, 8 + x * 18, 17 + y * 18));
    }
    }

    //Inventory
    for(int y = 0; y < 3; y++)
    {
    for(int x = 0; x < 9; x++)
    {
    this.addSlotToContainer(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 120 + y * 18));
    }
    }

    //Hotbar
    for(int x = 0; x < 9; x++)
    {
    this.addSlotToContainer(new Slot(inventory, x, 8 + x * 18, 178));
    }

    onCraftMatrixChanged(craftMatrix);
    }

    @Override
    public void onCraftMatrixChanged(IInventory iinventory)
    {
    craftResult.setInventorySlotContents(0, KnappingStoneCraftingManager.getInstance().findMatchingRecipe(craftMatrix, world));
    }

    //XXX Even More Broken
    /* @Override
    public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn)
    {
    super.slotClick(slotId, clickedButton, mode, playerIn);

    if(slotId == 0)
    {
    for(int j = 0; j < verticalSlots * horizontalSlots; j++)
    {
    this.craftMatrix.decrStackSize(j, 1);
    }
    }

    return ItemStack.copyItemStack(craftMatrix.getStackInSlot(slotId));
    }*/

    @Override
    public void onContainerClosed(EntityPlayer player)
    {
    super.onContainerClosed(player);
    if(!world.isRemote)
    {
    for(int i = 0; i < verticalSlots * horizontalSlots; i++)
    {
    ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);

    if(itemstack != null)
    {
    player.dropPlayerItemWithRandomChoice(itemstack, false);
    }
    }
    }
    }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
    if(world.getBlockState(pos).getBlock() != SurvivalPlusBlocks.knapping_stone)
    {
    return false;
    }
    else
    {
    return player.getDistanceSq((double)pos.getX() + 0.5d, (double)pos.getY() + 0.5d, (double)pos.getZ() + 0.5d) <= 64.0d;
    }
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int index)
    {
    ItemStack itemstack = null;
    Slot slot = (Slot) inventorySlots.get(index);

    if(slot != null && slot.getHasStack())
    {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();

    if(index == 0)
    {
    if(!mergeItemStack(itemstack1, 26, 62, true))
    {
    return null;
    }

    slot.onSlotChange(itemstack1, itemstack);
    }
    else if(index >= 26 && index < 53)
    {
    if (!mergeItemStack(itemstack1, 53, 62, false))
    {
    return null;
    }
    }
    else if(index >= 53 && index < 62)
    {
    if (!mergeItemStack(itemstack1, 26, 53, false))
    {
    return null;
    }
    }
    else if(!mergeItemStack(itemstack1, 26, 62, false))
    {
    return null;
    }

    if(itemstack1.stackSize == 0)
    {
    slot.putStack(null);
    }
    else
    {
    slot.onSlotChanged();
    }

    if(itemstack1.stackSize == itemstack.stackSize)
    {
    return null;
    }

    slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
    }

    }


    Any help on where/how to properly decrease stack sizes and such would be great!
    Thanks.

    Posted in: Modification Development
  • 0

    posted a message on Help with rendering a throwable item like an egg or snowball

    Thank you so much!

    Posted in: Modification Development
  • 0

    posted a message on Help with rendering a throwable item like an egg or snowball

    I've looked at the existing code for throwable items and I have it to the point where the item can be thrown,

    and it does what I want on impact. Only thing is, in 1.8 I'm not sure how to set up things so that the item renders while its flying,

    as well, I can't get it to render the particle effect that should happen when it hits something.


    So far I've tried this code in my preInit() stage to set up the render, but it doesn't do anything.


    preInit(), inside ClientProxy:


    registerRenderer(rock_item);

    RenderingRegistry.registerEntityRenderingHandler(EntityRock.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), rock_item, Minecraft.getMinecraft().getRenderItem()));


    registerRenderer function used for regular items:


    public static void registerRenderer(Item item)
    {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
    }


    Any help would be appreciated!
    Thanks

    Posted in: Modification Development
  • 0

    posted a message on LivingDropsEvent Help? (SOLVED)
    Hey, is there a way to remove drops from mobs? Also I can't seem to get this called when I kill something, I am registering it as "FMLCommonHandler.instance().bus().register(new DropHandler());" in my main class.

    Any help would be great, thanks!
    Posted in: Modification Development
  • 0

    posted a message on PowerCrystals' mods - MineFactoryReloaded, PowerCrystalsCore, and NetherOres updated! - MFR 2.7.9 released
    Quote from quintine

    What version of IC2 are you using?

    Edit: Also I noticed that planters/harvesters do not work on Biomes o Plenty Turnip seeds/plants


    If this is a reply to my post;

    We are using IC2NuclearControl-1.6.2e-ic2-experimental, and we don't have Biomes o Plenty installed.

    Thanks.
    Posted in: Minecraft Mods
  • 0

    posted a message on PowerCrystals' mods - MineFactoryReloaded, PowerCrystalsCore, and NetherOres updated! - MFR 2.7.9 released
    I seem to continually have this error pop up in the server console. What can I do to fix this?
    09.04 20:30:38 [Server] WARNING EnergyNet.removeTileEntity: powercrystals.minefactoryreloaded.tile.machine.TileEntityGrinder@7b7863b1 (powercrystals.minefactoryreloaded.tile.machine.TileEntityGrinder@7b7863b1) wasn't found (added), skipping

    the code following the "TileEntityGrinder@ " Changes between 5 or 6 different ones, and I believe this error may be causing End of Stream when trying to connect...

    I know we have some grinders in the end and quite frequently I have to restore the end from a backup as a chunk that contains one of the grinders is deleted.

    Any help would be appreciated!
    Thanks,
    Nodnarb3
    Posted in: Minecraft Mods
  • To post a comment, please .