Jump to content

onVoid

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by onVoid

  1.   On 5/21/2016 at 5:10 PM, diesieben07 said:

    Why in the world are

    charging

    ,

    chargingDC

    ,

    chargingDC2

    and

    storage

    static? Right, because you are using them statically in

    GuiCharger#drawGuiContainerForegroundLayer

    . But GuiCharger has the TE instance available...

    I guess from me being oblivious. chargingDC and chargingDC2 are from a complicated method of keeping track of energy being used that I attempted. I removed static tags, running a test now.

  2.   On 5/21/2016 at 4:50 AM, Draco18s said:

    Presumably the method returns a value, that value being the amount inserted.

    The method is an int, but I can't see a correlation. This is the code:

    	int x = 0;
    x = ((IEnergyContainerItem)slots[10].getItem()).receiveEnergy(slots[10], 7000, false);
    extractEnergy(x, false);

    When finishing the charging an item with max 250,000 RF (and my storage has 600,000 RF in it), the storage is left with 95,000 RF (it's using 505,000).

  3.   On 5/13/2016 at 6:23 AM, Choonster said:

    Are there any errors in the log? Have you registered your

    TileEntity

    class?

    I can't see the log since I am testing the mod outside of the modding environment (if anyone wants to help me get mods working in the environment that would be great), and my TileEntity is registered in initialization

    		GameRegistry.registerTileEntity(ChargerTileEntity.class, "Charger");

    . It also has working features.

  4.   On 5/13/2016 at 5:06 AM, Choonster said:

    Assuming you have an

    EnergyStorage

    field in your

    TileEntity

    , call its

    readFromNBT

    and

    writeToNBT

    methods in your overrides of the corresponding

    TileEntity

    methods. You can also extend

    [url=https://github.com/CoFH/RedstoneFlux-API/blob/10e10af21489e351624813120ed6474c44b09ff6/src/main/java/cofh/api/energy/TileEnergyHandler.java]TileEnergyHandler[/url]

    and let it handle the NBT reading/writing for you.

    I have this

        @Override
        public void readFromNBT(NBTTagCompound nbt) {
            super.readFromNBT(nbt);
            storage.readFromNBT(nbt);
        }
    
        @Override
        public void writeToNBT(NBTTagCompound nbt) {
            super.writeToNBT(nbt);
            storage.writeToNBT(nbt);
        }

    and it isn't saving. I also attempted making it a TileEnergyHandler, also nothing. What am I missing?

  5.   On 5/5/2016 at 5:16 AM, Draco18s said:

    If you're trying to charge another mod's items, there is no need to mess with the durability bar.  That should happen on the other mod item's end.  YOU just need to use the existent API to call ISomeInterface#someAddPowerMethod on the item (you will need to explicitly cast the Item)

    Alright. I will begin searching for that method in CoFHLib. In the meantime, if anyone knows it, please inform me. Thanks!

  6.   On 5/5/2016 at 2:01 AM, Draco18s said:

    Specifically, <Class>#<method> refers to a method that requires an object instance, rather then a static method.

      Quote

    You will see a lot of <Class>#<method> references on this board and that's exactly what that format is. So in those references, "Item" is a reference to your presumed item's super class (net.minecraft.item.Item) and "showDurabilityBar" is a method within that class.

    Either way, as I said, the items I am trying to charge aren't my items, so I can't do anything to the item class.

  7.   On 5/5/2016 at 12:15 AM, p455w0rd said:

    In my previous post I posted the methods necessary to get your display bar working. Apparently you didn't feel like doing your own research into them, so I will spell it out for you.

     

    Item#showDurabilityBar

    In your item class override this method and return true when you want the durability bar to display. You can use conditionals to not display the bar when your item has max energy.

    @Override
    public boolean showDurabilityBar(ItemStack is) {
    	if (getEnergyStored(is) >= getMaxEnergyStored(is)) {
    		return false;
    	}
    	return true;
    }
    

     

     

    Item#getDurabilityForDisplay

    In your item class override this method and return a double value in a percentage value of 1 for the current stored energy. So if you're using purely RF (no conversions) it would look something like this:

    @Override
    public double getDurabilityForDisplay(ItemStack is) {
    	return (double) (1 - getEnergyStored(is) / getMaxEnergyStored(is));
    }
    

     

    Item#isDamageable

    This isn't required as it is true by default. What this does is set whether or not your item has durability. My item, the AE2 Wireless Crafting Terminal, has this set to false simply so "Durability 32/32" isn't displayed in the tooltip.

    Thank you, kind sir. I was just a bit unsure about the things you were saying. I will test this out in a bit.

     

    EDIT: The items I am charging aren't my items, they are items from EnderIO and Thermal Expansion. So I don't really have an item class...

  8.   On 5/4/2016 at 8:42 PM, shadowfacts said:

    Why are you storing the energy as a string in NBT then calling parseInt instead of just storing it as an int (using setInteger & getInteger)?

    Thank you so much for pointing out my mistake! I got it working.

    EDIT: The item charges and the charges displays in the item lore, but when taking it out of the machine it resets. Also, the durability bar still doesn't work.

  9. I have this custom Redstone Flux charger (with usage of the CoFHLib) and it gets powered and such perfectly. I am unsure how to go about getting it to charge items, though.

    I have attempted to edit the NBT tag of the item (all of the items have a "Energy" NBT tag), and editing it works, but it doesn't change the charge bar of item lore. Any help? Thanks!

     

    Current code:

    			if (slots[10].hasTagCompound()){
    			NBTTagCompound  = slots[10].getTagCompound();
    			if (.hasKey("Energy")){
    .setString("Energy", Integer.parseInt(.getString("Energy"))+20 + "");
    				slots[10].setTagCompound();
    			}
    		}

×
×
  • Create New...

Important Information

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