cdkrot / Mechanics

[old and abandoned] Mechanics Mod (Minecraft)
GNU General Public License v3.0
0 stars 1 forks source link

Mailing List #2

Open cdkrot opened 10 years ago

cdkrot commented 10 years ago

Mailing list for all people interested in Mechanics ( @cdkrot, @T145, @kenzierocks ). Right now we have 4 tasks to do:

Just do tasks which you want, and write here about you progress. @kenzierocks, if you want to become a contributor, say me.

octylFractal commented 10 years ago

Sure, I'd be glad to be a contributor.

cdkrot commented 10 years ago

Welcome to mechanics mod! You should be able to commit now.

cdkrot commented 10 years ago

Just added languaging.

octylFractal commented 10 years ago

Cool, thanks.

octylFractal commented 10 years ago

I'm gonna remove the duplicate resources in the java folder, they look identical to the resource ones.

cdkrot commented 10 years ago

Yes they are. I copied them when minecraft wasn't loading them. (haven't checked how it is now)

octylFractal commented 10 years ago

As long as the resources folder is included as src, then it works fine.

cdkrot commented 10 years ago

Fine, textures are still loaded.

octylFractal commented 10 years ago

I'm gonna do some bug testing, I'll report if I find anything.

cdkrot commented 10 years ago

Ok,

octylFractal commented 10 years ago

Hmmm, should we follow the vanilla hopper rule that if a chest cannot be opened by a player, it does not interact with it?

cdkrot commented 10 years ago

Mmm, can you refer a code source, please?

octylFractal commented 10 years ago

Yes, just a minute.

Also, using a filter in the allocator requires using the actual item, should it make a 'blank copy' instead so you don't have to use up an item?

cdkrot commented 10 years ago

Yes, i haven't thought about that before.

octylFractal commented 10 years ago

Okay, this seems to be the function that does it, using ISidedInventory where possible:


    public static ItemStack func_145889_a(IInventory p_145889_0_, ItemStack p_145889_1_, int p_145889_2_)
    {
        if (p_145889_0_ instanceof ISidedInventory && p_145889_2_ > -1)
        {
            ISidedInventory isidedinventory = (ISidedInventory)p_145889_0_;
            int[] aint = isidedinventory.getAccessibleSlotsFromSide(p_145889_2_);

            for (int l = 0; l < aint.length && p_145889_1_ != null && p_145889_1_.stackSize > 0; ++l)
            {
                p_145889_1_ = func_145899_c(p_145889_0_, p_145889_1_, aint[l], p_145889_2_);
            }
        }
        else
        {
            int j = p_145889_0_.getSizeInventory();

            for (int k = 0; k < j && p_145889_1_ != null && p_145889_1_.stackSize > 0; ++k)
            {
                p_145889_1_ = func_145899_c(p_145889_0_, p_145889_1_, k, p_145889_2_);
            }
        }

        if (p_145889_1_ != null && p_145889_1_.stackSize == 0)
        {
            p_145889_1_ = null;
        }

        return p_145889_1_;
    }
cdkrot commented 10 years ago

I meaned, where it used in our code.

octylFractal commented 10 years ago

Oh, okay. Hold on.

octylFractal commented 10 years ago

allocateItems:


    private void allocateItems(World world, int x, int y, int z, Random random) {
        VecI3Base d = DirectionalVecs.list[world.getBlockMetadata(x, y, z)];

        TileEntityAllocator tile = (TileEntityAllocator) world.getTileEntity(x, y, z);
        ItemStack[] filter = tile.allocatorFilterItems;
        IInventoryEX input = containerAtPos(world, x - d.x, y - d.y, z - d.z);

        if (input == null) {
            List<Entity> entities = (List<Entity>) world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double) (x - d.x), (double) y - d.y, (double) (z - d.z), (double) (x - d.x + 1), (double) (y - d.y + 1), (float) (z - d.z + 1)));
            List<IInventoryEX> invs = AllocatorRegistry.instance.getIInventoryAllInFor(entities, true);
            // TODO: entity inventories should be caught by other way
            // [REFACTORING].

            if (invs.size() > 0)
                input = invs.get(random.nextInt(invs.size()));
            else
                return;// no input.
        }
        // TODO: should be inlined here.

        int itemIndex = getRandomItemStackFromContainer(input, random, filter);

        if (itemIndex >= 0)
            if (outputItem(world, x, y, z, d, input.asIInventory().getStackInSlot(itemIndex), random))
                input.onTakenSuccessful(itemIndex, null);
    }
cdkrot commented 10 years ago

Probably yes,

Looks likes it does a pretty same things as we, but does it mentions input and output?

octylFractal commented 10 years ago

It might.

octylFractal commented 10 years ago

Okay, that function handles both input and output. It's a little complicated how it works overall, but I can describe it, give me a minute.

octylFractal commented 10 years ago

Okay: First, this code:

// func_145888_j is the "is it time to update" check, func_149917_c is a meta check for something
if (!this.func_145888_j() && BlockHopper.func_149917_c(this.getBlockMetadata()))
            {
                boolean flag = this.func_145883_k(); // output this tile entity -> inventory connected
                flag = func_145891_a(this) || flag; // input from above inventory -> this tile entity

                if (flag) // something was transferred
                {
                    this.func_145896_c(8); // reset timer
                    this.markDirty(); //save data
                    return true;
                }
            }

func_145883_k calls func_145899_a with an item stack from the tile entity. func_145891_a calls func_145899_a with an item stack from the inventory above this hopper. There's some more specifics, but that's the basics.

cdkrot commented 10 years ago

(didn't understand the code above) I think we should use a func_145889_a() (more above), it suits all our needs. I can do a required modifications if needed.

octylFractal commented 10 years ago

I'll handle it, I'll give it a more sensible name as well.

cdkrot commented 10 years ago

So right now passed 2 weeks, there was a great time, but i think it's time to think about next plan. What we should do before release:

Also i checked your mod Crystalix, i like it, cool concept :).

octylFractal commented 10 years ago

Thanks!

cdkrot commented 10 years ago

About benchmark: not a bug, just loosed some code between code cleaning, etc.

octylFractal commented 10 years ago

Okay, cool.