Create Crafts & Additions

Create Crafts & Additions

51M Downloads

Tesla Coil FE charging. [FABRIC]

michlbro opened this issue · 8 comments

commented

I was just wondering if FE charging works on the fabric port. I am currently trying to charge a jetpack (Iron Jetpacks ported over to fabric.) using a tesla coil, but it isn't working (The tesla coil does cause damage to the player, so I assume it works?). shedaniel/IronJetpacks#27 (comment)

commented

Ok, so the iron jetpack mod uses Tech Reborn Energy and not Forge Energy. Since it's fabric, I assume most other mods will use Tech Reborn Energy (shedaniel/IronJetpacks#27 (comment)). If possible, could we get support for Tech Reborn Energy in the fabric port?

Edit: Just tested that the alternator is pretty much useless in fabric since it generates FE energy which cannot or (Hardly works -sometimes gives energy) with another mod (Industrial Revolution).

commented

yeah was hoping for RF gnereation as FE is a api in forge and Fabric does not have that

seems odd to make a fabric port that does work in most aspects with no energy system that works

commented

well maybe the answer is in #321
no support here for fabric

commented

Create Additions does use Tech Reborn energy, as you can use the Alternator to power Tech Reborn items, however, the Tesla coil is broken in the Fabric port.

I've been told by a Fabric contributor that the offending line may be below, as the function returns a READ ONLY version of the energy storage, meaning the Tesla Coil can read the energy of the item, but can't write to it.

EnergyStorage es = ContainerItemContext.withInitial(stack).find(EnergyStorage.ITEM);

commented

Thanks for looking into it. I am no expert in java (Trying to learn more about it, but it looks so awful compared to any other language) but I’ll see what I can do.
Tech Reborn is kind of finicky to work with in create additions, as in you must have the alternators right next to a lazuli flux container (battery block) as a pump to get energy into the cables since it wont push energy straight into them from the alternators for some reason or the cables will be stuck at a set amount. Sometimes the electric motors will consume energy whilst it’s not even running. I am only experiencing these bugs with Industrial Revolution and it’s hard to reproduce these bugs.

commented

So I've tried working on the problematic line, with no luck. No matter what I try it just won't transfer energy into the receiving block. Upon closer inspection though, if you hook a battery to the Tesla coil you can see the battery discharge as expected. I've switched from using withInital to using ofSingleSlot as such:

	protected boolean chargeStack(ItemStack stack, TransportedItemStack transported, TransportedItemStackHandlerBehaviour handler) {
		ContainerItemContext ctx = ContainerItemContext.withInitial(stack); // get stack context (not mutable)
		ContainerItemContext ctx_slot = ContainerItemContext.ofSingleSlot(ctx.getMainSlot()); // get singleSlotContext of stack (mutable?)
		EnergyStorage es = ctx_slot.find(EnergyStorage.ITEM); // get energyStorage

		long amountToUse = Math.min(getConsumption(), energy.getAmount()); // amount of energy to consume

		if (EnergyStorageUtil.isEnergyStorage(stack)) { // make sure the targeted stack is energy storage
			if(energy.getAmount() < stack.getCount())
				return false;
			try (Transaction t = TransferUtil.getTransaction()) {
				energy.internalConsumeEnergy(es.insert(amountToUse, t)); // take energy from source and place into destination
				t.commit(); // commit transaction
			}
			return true;
		} else {
			return false;
		}
	}

no dice.

commented

Thanks for looking into it. I am no expert in java (Trying to learn more about it, but it looks so awful compared to any other language) but I’ll see what I can do. Tech Reborn is kind of finicky to work with in create additions, as in you must have the alternators right next to a lazuli flux container (battery block) as a pump to get energy into the cables since it wont push energy straight into them from the alternators for some reason or the cables will be stuck at a set amount. Sometimes the electric motors will consume energy whilst it’s not even running. I am only experiencing these bugs with Industrial Revolution and it’s hard to reproduce these bugs.

I just got builds going for the mod yesterday, I'm going to poke around the fabric branch too and see if I can make something shake and bake. I'd love to see this mod back to parity with it's Forge counterpart.

commented

#468
This PR fixes Tesla FE transfer.
Thank you FluffyBumblebees, and all who tried.