-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...src/main/java/dev/su5ed/sinytra/connectorextras/energybridge/FabricEnergySlotHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package dev.su5ed.sinytra.connectorextras.energybridge; | ||
|
||
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant; | ||
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage; | ||
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public class FabricEnergySlotHandler implements SingleSlotStorage<ItemVariant> { | ||
|
||
private ItemStack stack; | ||
|
||
public FabricEnergySlotHandler(ItemStack stack) { | ||
this.stack = stack; | ||
} | ||
|
||
@Override | ||
public long insert(ItemVariant resource, long maxAmount, TransactionContext transaction) { | ||
this.stack = resource.toStack(); | ||
return maxAmount; | ||
} | ||
|
||
@Override | ||
public long extract(ItemVariant resource, long maxAmount, TransactionContext transaction) { | ||
this.stack = resource.toStack(); | ||
return maxAmount; | ||
} | ||
|
||
@Override | ||
public boolean isResourceBlank() { | ||
return getResource().isBlank(); | ||
} | ||
|
||
@Override | ||
public ItemVariant getResource() { | ||
return ItemVariant.of(stack); | ||
} | ||
|
||
public ItemStack getStack() { | ||
return stack; | ||
} | ||
|
||
public void setStack(ItemStack stack) { | ||
this.stack = stack; | ||
} | ||
|
||
@Override | ||
public long getAmount() { | ||
return stack.getCount(); | ||
} | ||
|
||
@Override | ||
public long getCapacity() { | ||
return stack.getMaxStackSize(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters