Jump to content

DavidM

Members
  • Posts

    1830
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by DavidM

  1. 27 minutes ago, Swordsaint said:

    Well, If i rightclick the tank with a modded item like a tank from "LargeFluidTank", the game crashes due to being unable to cast the Modded Item to Bucket Item. I'll have to gain some experience and fix this bug later.

    You can either 1) Check before cast or even better 2) look for the fluid handler capability in the ItemStack. The second method is compatible with other mods (as long as the other mod creates tanks properly by giving it a fluid handler capability).

  2. 38 minutes ago, Swordsaint said:

    I have one more problem though, I don't know how to create a Bucketitem with the right fluid (the one from the tank). I fiddled around with the BucketItem constructor and how to use it, but I am unable to come up with an instruction that returns a Bucket filled with the tankfluid. If you could elaborate on how to do it I would be very thankful and this thread would probably be solved.

    BucketItem is an Item, which is singleton; there can only be one instance of it during the entire game. What you are looking for is an ItemStack of BucketItem with the correct liquid, which is done (if I recall correctly) by a capability in the ItemStack. Check out FluidBucketWrapper class.

     

    Also, currently your code executes on both the client and server; however, it should only happen on the server (since it is block placement and inventory changing). Check the side the code is on via World#isRemote (which is true on client and false on server) and only run the code when it is on server.

  3. 2 minutes ago, Swordsaint said:

    I have no clue how to check if the player is holding a bucket with fluid in it and how to access the FluidTank in the VoidCollectorTile on BlockActivation.

    Check if player is holding bucket: player.getActiveItemStack() instanced BucketItem

    Get FluidTank in tile (pseudocode):

    void onBlockActivated(args) {
    	TileEntity te = world.getTileEntity(pos);
        if (te instanceof YourTileEntity) {
        	LazyOptional<IFluidHandler> fluidHandler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
            // Do stuff
        }
    }

     

  4. Hi.

    I am creating a walking chest entity that has an inventory.

    This entity is meant to be summoned temporarily, and should disappear (die) when the chunk it is in unloads, during which it should place down a vanilla chest block at its location.

    My current idea is to subscribe to the chunk unloading event and check if my entity is in there; however, I am wondering if there are better ways (i.e. methods in LivingEntity that are triggered during unloading of the chunk it is in). There is LivingEntity#remove, but that is also fired when the entity dies, and as far as I can tell there is no way to distinguish between the two causes. 

    What would be the best way to achieve this?

  5. 2 hours ago, Skelyvelocirap said:

    Hmmm.. although, how do i check if the person is filling or draining?

    I don’t think it is possible to tell so from the tile entity with the vanilla fluid handler.

    However you could create your own fluid handler implementation that handles 2 different tanks and their insertion/extraction.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.