Skip to content
Open
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ repositories {
maven { url "https://server.bbkr.space/artifactory/libs-release" } // Cotton maven - home of Cotton projects
maven { url "https://dl.bintray.com/ladysnake/libs" } // Onyx Studios maven - home of Cardinal Components
maven { url "https://alexiil.uk/maven/" } // Alexiil's maven - home of Lib Block Attributes
maven { url "https://maven.dblsaiko.net/" } //Grondag's maven - home of Fluidity
maven { url "https://jitpack.io" }
maven { url "https://maven.dblsaiko.net/" } // Grondag's maven - home of Fluidity
maven { url "https://jitpack.io" } // Emily Rose Ploszaj's maven - home of Item Inventory
}

dependencies {
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx3G
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.4
yarn_build=7
loader_version=0.10.8
minecraft_version = 1.16.5
yarn_build = 10
loader_version = 0.11.7

# Mod Properties
mod_version = 0.8.0
Expand All @@ -14,9 +14,9 @@ archives_base_name = universalcomponents

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.29.0+1.16
cardinal_version=2.7.10
lba_version=0.8.5
fluidity_version=0.16
item_inventory_version=1.1.0
tr_energy_version=0.1.1
fabric_version = 0.40.1+1.16
cardinal_version = 2.8.3
lba_version = 0.8.8
fluidity_version = 0.16
item_inventory_version = 1.1.0
tr_energy_version = 0.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public WrappedItemInventory(ItemStack stack, ItemInventory inventory) {
}

@Override
public int getSize() {
public int size() {
return inv.getInvSize(holderStack);
}

Expand Down Expand Up @@ -55,7 +55,7 @@ public boolean canExtract(int slot) {
}

@Override
public ItemStack takeStack(int slot, int amount, ActionType action) {
public ItemStack removeStack(int slot, int amount, ActionType action) {
ItemStack original = inv.getStack(holderStack, slot).copy();
ItemStack ret = inv.getStack(holderStack, slot).split(amount);
if (!action.shouldPerform()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ItemExtractable getExtractable() {

@Override
public int getSlotCount() {
return component.getSize();
return component.size();
}

@Override
Expand Down Expand Up @@ -62,7 +62,7 @@ public ListenerToken addListener(InvMarkDirtyListener listener, ListenerRemovalT

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
return component.takeStack(0, maxAmount, actionForSim(simulation)); //TODO: fix
return component.removeStack(0, maxAmount, actionForSim(simulation)); //TODO: fix
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public WrappedInvAttributeComponent(FixedItemInv inv) {
}

@Override
public int getSize() {
public int size() {
return view.getSlotCount();
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public boolean canExtract(int slot) {
}

@Override
public ItemStack takeStack(int slot, int amount, ActionType action) {
public ItemStack removeStack(int slot, int amount, ActionType action) {
return extractable.attemptExtraction(createFilterForSlot(slot), amount, simForAction(action));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.github.cottonmc.component.api.ActionType;
import io.github.cottonmc.component.energy.CapacitorComponent;
import io.github.cottonmc.component.energy.type.EnergyType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction;
import team.reborn.energy.EnergyHandler;

Expand Down Expand Up @@ -79,11 +79,11 @@ public List<Runnable> getListeners() {
}

@Override
public void readFromNbt(CompoundTag tag) {
public void readFromNbt(NbtCompound tag) {

}

@Override
public void writeToNbt(CompoundTag tag) {
public void writeToNbt(NbtCompound tag) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static SidedInventoryWrapper of(Function<Direction, InventoryComponent> func) {
default int[] getAvailableSlots(Direction side) {
InventoryComponent component = getComponent(side);
if (component == null) return new int[0];
return IntStream.range(0, component.getSize()).filter(slot -> component.canInsert(slot) || component.canExtract(slot)).toArray();
return IntStream.range(0, component.size()).filter(slot -> component.canInsert(slot) || component.canExtract(slot)).toArray();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public WrappedInvComponent(Inventory inv) {
}

@Override
public int getSize() {
public int size() {
return inv.size();
}

Expand Down Expand Up @@ -52,7 +52,7 @@ public boolean canExtract(int slot) {
}

@Override
public ItemStack takeStack(int slot, int amount, ActionType action) {
public ItemStack removeStack(int slot, int amount, ActionType action) {
ItemStack original = inv.getStack(slot).copy();
ItemStack ret = inv.removeStack(slot, amount);
if (!action.shouldPerform()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public WrappedSidedInvComponent(SidedInventory inv, Direction side) {
}

@Override
public int getSize() {
public int size() {
return inv.size();
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public boolean canExtract(int slot) {
}

@Override
public ItemStack takeStack(int slot, int amount, ActionType action) {
public ItemStack removeStack(int slot, int amount, ActionType action) {
ItemStack original = inv.getStack(slot).copy();
ItemStack ret = inv.removeStack(slot, amount);
if (!action.shouldPerform()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.github.cottonmc.component.data.api.DataElement;
import io.github.cottonmc.component.data.api.Unit;
import dev.onyxstudios.cca.api.v3.component.Component;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;

import javax.annotation.Nullable;
import java.util.List;
Expand Down Expand Up @@ -35,8 +35,8 @@ public interface DataProviderComponent extends Component {
DataElement getElementFor(Unit unit);

@Override
default void readFromNbt(CompoundTag tag) { }
default void readFromNbt(NbtCompound tag) { }

@Override
default void writeToNbt(CompoundTag tag) { }
default void writeToNbt(NbtCompound tag) { }
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.github.cottonmc.component.energy.impl;

import dev.onyxstudios.cca.api.v3.component.Component;
import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import io.github.cottonmc.component.UniversalComponents;
import io.github.cottonmc.component.energy.CapacitorComponent;
import io.github.cottonmc.component.energy.type.EnergyType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;

public class ItemCapacitorComponent extends SimpleCapacitorComponent implements Component {
public class ItemCapacitorComponent extends SimpleCapacitorComponent {
private ComponentKey<CapacitorComponent> key;

public ItemCapacitorComponent(int maxEnergy, EnergyType type) {
Expand All @@ -24,8 +23,8 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ItemCapacitorComponent that = (ItemCapacitorComponent) o;
CompoundTag tag = new CompoundTag();
CompoundTag tag1 = new CompoundTag();
NbtCompound tag = new NbtCompound();
NbtCompound tag1 = new NbtCompound();
that.writeToNbt(tag);
this.writeToNbt(tag1);
return tag1.equals(tag1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.github.cottonmc.component.energy.CapacitorComponent;
import io.github.cottonmc.component.energy.type.EnergyType;
import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;

import javax.annotation.Nonnull;
import java.util.ArrayList;
Expand Down Expand Up @@ -124,7 +124,7 @@ public List<Runnable> getListeners() {
}

@Override
public void readFromNbt(CompoundTag tag) {
public void readFromNbt(NbtCompound tag) {
currentEnergy = tag.getInt("Energy");
maxEnergy = tag.getInt("MaxEnergy");
if (tag.contains("Harm", NbtType.NUMBER)) {
Expand All @@ -133,7 +133,7 @@ public void readFromNbt(CompoundTag tag) {
}

@Override
public void writeToNbt(CompoundTag tag) {
public void writeToNbt(NbtCompound tag) {
tag.putInt("Energy", currentEnergy);
tag.putInt("MaxEnergy", maxEnergy);
tag.putInt("Harm", harm);
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/github/cottonmc/component/fluid/TankComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import dev.onyxstudios.cca.api.v3.component.Component;
import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.fluid.Fluid;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -39,7 +39,7 @@ default boolean isEmpty() {

boolean canExtract(int tank);

FluidVolume takeFluid(int tank, Fraction amount, ActionType action);
FluidVolume removeFluid(int tank, Fraction amount, ActionType action);

FluidVolume removeFluid(int tank, ActionType action);

Expand Down Expand Up @@ -87,20 +87,20 @@ default boolean contains(Set<Fluid> fluids) {
}

@Override
default void readFromNbt(CompoundTag tag) {
default void readFromNbt(NbtCompound tag) {
clear();
ListTag contents = tag.getList("Contents", NbtType.COMPOUND);
NbtList contents = tag.getList("Contents", NbtType.COMPOUND);
for (int i = 0; i < contents.size(); i++) {
CompoundTag volTag = (CompoundTag)contents.get(i);
setFluid(i, FluidVolume.fromTag(volTag));
NbtCompound volTag = (NbtCompound)contents.get(i);
setFluid(i, FluidVolume.fromNbt(volTag));
}
}

@Override
default void writeToNbt(CompoundTag tag) {
ListTag contents = new ListTag();
default void writeToNbt(NbtCompound tag) {
NbtList contents = new NbtList();
for (FluidVolume vol : getAllContents()) {
contents.add(vol.toTag(new CompoundTag()));
contents.add(vol.toNbt(new NbtCompound()));
}
tag.put("Contents", contents);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.github.cottonmc.component.UniversalComponents;
import io.github.cottonmc.component.fluid.TankComponent;
import io.github.fablabsmc.fablabs.api.fluidvolume.v1.Fraction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;

public class ItemTankComponent extends SimpleTankComponent {
private ComponentKey<TankComponent> type;
Expand All @@ -23,8 +23,8 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ItemTankComponent that = (ItemTankComponent) o;
CompoundTag tag = new CompoundTag();
CompoundTag tag1 = new CompoundTag();
NbtCompound tag = new NbtCompound();
NbtCompound tag1 = new NbtCompound();
that.writeToNbt(tag);
this.writeToNbt(tag1);
return tag1.equals(tag1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean canExtract(int slot) {
}

@Override
public FluidVolume takeFluid(int slot, Fraction amount, ActionType action) {
public FluidVolume removeFluid(int slot, Fraction amount, ActionType action) {
FluidVolume vol = contents.get(slot);
if (!action.shouldPerform()) {
vol = vol.copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
Expand All @@ -26,7 +26,7 @@ public interface InventoryComponent extends Component, Observable {
/**
* @return How many slots are in this inventory.
*/
int getSize();
int size();

/**
* @return Whether this inventory is empty or not.
Expand Down Expand Up @@ -75,7 +75,7 @@ default boolean isEmpty() {
* @param action The type of action to perform.
* @return The stack that was successfully removed.
*/
ItemStack takeStack(int slot, int amount, ActionType action);
ItemStack removeStack(int slot, int amount, ActionType action);

/**
* Remove an entire item stack.
Expand Down Expand Up @@ -113,7 +113,7 @@ default boolean isEmpty() {
* Empty this inventory, removing all stacks.
*/
default void clear() {
for (int i = 0; i < getSize(); i++) {
for (int i = 0; i < size(); i++) {
removeStack(i, ActionType.PERFORM);
}
}
Expand Down Expand Up @@ -200,20 +200,20 @@ default SidedInventory asLocalInventory(WorldAccess world, BlockPos pos) {
}

@Override
default void readFromNbt(CompoundTag tag) {
default void readFromNbt(NbtCompound tag) {
clear();
ListTag items = tag.getList("Items", NbtType.COMPOUND);
NbtList items = tag.getList("Items", NbtType.COMPOUND);
for (int i = 0; i < items.size(); i++) {
CompoundTag stackTag = (CompoundTag) items.get(i);
NbtCompound stackTag = (NbtCompound) items.get(i);
setStack(i, StackSerializer.fromTag(stackTag));
}
}

@Override
default void writeToNbt(CompoundTag tag) {
ListTag items = new ListTag();
default void writeToNbt(NbtCompound tag) {
NbtList items = new NbtList();
for (ItemStack stack : getStacks()) {
items.add(StackSerializer.toTag(stack, new CompoundTag()));
items.add(StackSerializer.toTag(stack, new NbtCompound()));
}
tag.put("Items", items);
}
Expand Down
Loading