From 3d8e2a7332df98eb49d1c2998b98d017c20f6e8d Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Wed, 9 Sep 2020 12:24:11 -0400 Subject: [PATCH 01/10] Update WrappedInvAttributeComponent.java --- .../lba/WrappedInvAttributeComponent.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java index a739e77..f710fb7 100644 --- a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java @@ -143,11 +143,62 @@ public boolean contains(Set items) { @Override public Inventory asInventory() { + //INFO: This is a very bad temporary fix. Correct it later! + System.out.println("If you ever see this things have most likely gone wrong!"); + System.out.println("Compatibility with LBA is not granted at the moment!"); return new InventoryFixedWrapper(inv) { @Override public boolean canPlayerUse(PlayerEntity player) { return true; } + + @Override + public ItemStack getStack(int slot) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isEmpty() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void markDirty() { + // TODO Auto-generated method stub + + } + + @Override + public ItemStack removeStack(int slot) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack removeStack(int slot, int amount) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setStack(int slot, ItemStack stack) { + // TODO Auto-generated method stub + + } + + @Override + public int size() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void clear() { + // TODO Auto-generated method stub + + } }; } From cc39e0b5053b77e4d91edb1d70b61319700db83f Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Thu, 10 Sep 2020 17:19:30 -0400 Subject: [PATCH 02/10] Update gradle.properties --- gradle.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9e74cd0..bb894c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.2 -yarn_build=1 -loader_version=0.9.1+build.205 +yarn_build=47 +loader_version=0.9.3+build.207 # Mod Properties mod_version = 0.7.3 @@ -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.17.2+build.396-1.16 -cardinal_version=2.5.0-nightly.1.16.2-rc2 -lba_version=0.7.1-pre.9 -fluidity_version=0.14 +fabric_version=0.20.1+build.401-1.16 +cardinal_version=2.6.0 +lba_version=0.8.2-pre.6 +fluidity_version=0.15 item_inventory_version=1.1.0 tr_energy_version=0.1.0 From 93065a5ff4807c886ca0032f5c04f0bc9b91260d Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Fri, 11 Sep 2020 18:21:27 -0400 Subject: [PATCH 03/10] actualized method naming --- .../component/compat/iteminv/WrappedItemInventory.java | 4 ++-- .../cottonmc/component/compat/lba/AttributeWrapper.java | 4 ++-- .../component/compat/lba/WrappedInvAttributeComponent.java | 4 ++-- .../component/compat/vanilla/SidedInventoryWrapper.java | 2 +- .../component/compat/vanilla/WrappedInvComponent.java | 4 ++-- .../component/compat/vanilla/WrappedSidedInvComponent.java | 4 ++-- .../github/cottonmc/component/item/InventoryComponent.java | 6 +++--- .../component/item/impl/SimpleInventoryComponent.java | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/github/cottonmc/component/compat/iteminv/WrappedItemInventory.java b/src/main/java/io/github/cottonmc/component/compat/iteminv/WrappedItemInventory.java index 7b8fd0d..fc35340 100644 --- a/src/main/java/io/github/cottonmc/component/compat/iteminv/WrappedItemInventory.java +++ b/src/main/java/io/github/cottonmc/component/compat/iteminv/WrappedItemInventory.java @@ -21,7 +21,7 @@ public WrappedItemInventory(ItemStack stack, ItemInventory inventory) { } @Override - public int getSize() { + public int size() { return inv.getInvSize(holderStack); } @@ -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()) { diff --git a/src/main/java/io/github/cottonmc/component/compat/lba/AttributeWrapper.java b/src/main/java/io/github/cottonmc/component/compat/lba/AttributeWrapper.java index 744e538..83bed4a 100644 --- a/src/main/java/io/github/cottonmc/component/compat/lba/AttributeWrapper.java +++ b/src/main/java/io/github/cottonmc/component/compat/lba/AttributeWrapper.java @@ -30,7 +30,7 @@ public ItemExtractable getExtractable() { @Override public int getSlotCount() { - return component.getSize(); + return component.size(); } @Override @@ -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 diff --git a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java index f710fb7..c275623 100644 --- a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java @@ -31,7 +31,7 @@ public WrappedInvAttributeComponent(FixedItemInv inv) { } @Override - public int getSize() { + public int size() { return view.getSlotCount(); } @@ -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)); } diff --git a/src/main/java/io/github/cottonmc/component/compat/vanilla/SidedInventoryWrapper.java b/src/main/java/io/github/cottonmc/component/compat/vanilla/SidedInventoryWrapper.java index 0704f14..dfcbb2b 100644 --- a/src/main/java/io/github/cottonmc/component/compat/vanilla/SidedInventoryWrapper.java +++ b/src/main/java/io/github/cottonmc/component/compat/vanilla/SidedInventoryWrapper.java @@ -35,7 +35,7 @@ static SidedInventoryWrapper of(Function 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 diff --git a/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedInvComponent.java b/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedInvComponent.java index 7f54ac9..7d3b8fc 100644 --- a/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedInvComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedInvComponent.java @@ -18,7 +18,7 @@ public WrappedInvComponent(Inventory inv) { } @Override - public int getSize() { + public int size() { return inv.size(); } @@ -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()) { diff --git a/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedSidedInvComponent.java b/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedSidedInvComponent.java index 5fe3d9f..605d733 100644 --- a/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedSidedInvComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/vanilla/WrappedSidedInvComponent.java @@ -23,7 +23,7 @@ public WrappedSidedInvComponent(SidedInventory inv, Direction side) { } @Override - public int getSize() { + public int size() { return inv.size(); } @@ -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()) { diff --git a/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java b/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java index 30571d4..21c2478 100644 --- a/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java +++ b/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java @@ -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. @@ -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. @@ -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); } } diff --git a/src/main/java/io/github/cottonmc/component/item/impl/SimpleInventoryComponent.java b/src/main/java/io/github/cottonmc/component/item/impl/SimpleInventoryComponent.java index 338f6fc..79a0cf2 100644 --- a/src/main/java/io/github/cottonmc/component/item/impl/SimpleInventoryComponent.java +++ b/src/main/java/io/github/cottonmc/component/item/impl/SimpleInventoryComponent.java @@ -19,7 +19,7 @@ public SimpleInventoryComponent(int size) { } @Override - public int getSize() { + public int size() { return stacks.size(); } @@ -53,7 +53,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 stack = stacks.get(slot); if (!action.shouldPerform()) { stack = stack.copy(); From ed8612688aa23718e815f6f0fb9e6ed433cca8fb Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Sun, 14 Mar 2021 08:23:28 -0400 Subject: [PATCH 04/10] Update WrappedInvAttributeComponent.java --- .../component/compat/lba/WrappedInvAttributeComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java index c275623..3929879 100644 --- a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java @@ -143,7 +143,7 @@ public boolean contains(Set items) { @Override public Inventory asInventory() { - //INFO: This is a very bad temporary fix. Correct it later! + //INFO: This is a very bad temporary fix. Correct it later! Wasn't runable without this. System.out.println("If you ever see this things have most likely gone wrong!"); System.out.println("Compatibility with LBA is not granted at the moment!"); return new InventoryFixedWrapper(inv) { From ad2e95c9ef41a8f32a24e5d30ce3f7f96b80e9ec Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Mon, 29 Mar 2021 09:36:11 -0400 Subject: [PATCH 05/10] improved naming in TankComponent --- .../java/io/github/cottonmc/component/fluid/TankComponent.java | 2 +- .../cottonmc/component/fluid/impl/SimpleTankComponent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java index 0bf324a..e49eafd 100644 --- a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java +++ b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java @@ -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); diff --git a/src/main/java/io/github/cottonmc/component/fluid/impl/SimpleTankComponent.java b/src/main/java/io/github/cottonmc/component/fluid/impl/SimpleTankComponent.java index c697a9d..8684677 100644 --- a/src/main/java/io/github/cottonmc/component/fluid/impl/SimpleTankComponent.java +++ b/src/main/java/io/github/cottonmc/component/fluid/impl/SimpleTankComponent.java @@ -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(); From 50219b74c572793bd50a40719265cbe59a86858e Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Sun, 12 Sep 2021 10:06:31 -0400 Subject: [PATCH 06/10] update to 1.16.5 phase I --- build.gradle | 6 +++--- gradle.properties | 18 ++++++++--------- .../compat/tr/WrappedEnergyHandler.java | 6 +++--- .../component/data/DataProviderComponent.java | 6 +++--- .../energy/impl/ItemCapacitorComponent.java | 9 ++++----- .../energy/impl/SimpleCapacitorComponent.java | 6 +++--- .../component/fluid/TankComponent.java | 16 +++++++-------- .../fluid/impl/ItemTankComponent.java | 6 +++--- .../component/item/InventoryComponent.java | 16 +++++++-------- .../item/impl/ItemInventoryComponent.java | 6 +++--- .../component/serializer/StackSerializer.java | 6 +++--- .../api/fluidvolume/v1/FluidVolume.java | 20 +++++++++---------- 12 files changed, 60 insertions(+), 61 deletions(-) diff --git a/build.gradle b/build.gradle index 63f2b50..b23a6ac 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ dependencies { //cardinal components include modImplementation("io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_version}") //only non-fabricmc lib we actually require at runtime - modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-block:${project.cardinal_version}" + include modImplementation("io.github.onyxstudios.Cardinal-Components-API:cardinal-components-block:${project.cardinal_version}") modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-item:${project.cardinal_version}" modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_version}" modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-chunk:${project.cardinal_version}" @@ -54,10 +54,10 @@ dependencies { modCompileOnly("grondag:fluidity-mc116:${project.fluidity_version}.+") { transitive = false } //item inventory - modCompileOnly "com.github.emilyploszaj:item-inventory:${project.item_inventory_version}" + include modImplementation("com.github.emilyploszaj:item-inventory:${project.item_inventory_version}") //techreborn energy - modCompileOnly "teamreborn:energy:${tr_energy_version}" + include modImplementation("teamreborn:energy:${tr_energy_version}") } processResources { diff --git a/gradle.properties b/gradle.properties index 7f6d96f..921d7e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ 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.6 # Mod Properties mod_version = 0.8.0 @@ -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.38.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 diff --git a/src/main/java/io/github/cottonmc/component/compat/tr/WrappedEnergyHandler.java b/src/main/java/io/github/cottonmc/component/compat/tr/WrappedEnergyHandler.java index 1bdad08..7d32f7c 100644 --- a/src/main/java/io/github/cottonmc/component/compat/tr/WrappedEnergyHandler.java +++ b/src/main/java/io/github/cottonmc/component/compat/tr/WrappedEnergyHandler.java @@ -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; @@ -79,11 +79,11 @@ public List getListeners() { } @Override - public void readFromNbt(CompoundTag tag) { + public void readFromNbt(NbtCompound tag) { } @Override - public void writeToNbt(CompoundTag tag) { + public void writeToNbt(NbtCompound tag) { } } diff --git a/src/main/java/io/github/cottonmc/component/data/DataProviderComponent.java b/src/main/java/io/github/cottonmc/component/data/DataProviderComponent.java index 6764495..42de66a 100644 --- a/src/main/java/io/github/cottonmc/component/data/DataProviderComponent.java +++ b/src/main/java/io/github/cottonmc/component/data/DataProviderComponent.java @@ -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; @@ -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) { } } diff --git a/src/main/java/io/github/cottonmc/component/energy/impl/ItemCapacitorComponent.java b/src/main/java/io/github/cottonmc/component/energy/impl/ItemCapacitorComponent.java index 4022240..895affd 100644 --- a/src/main/java/io/github/cottonmc/component/energy/impl/ItemCapacitorComponent.java +++ b/src/main/java/io/github/cottonmc/component/energy/impl/ItemCapacitorComponent.java @@ -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 key; public ItemCapacitorComponent(int maxEnergy, EnergyType type) { @@ -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); diff --git a/src/main/java/io/github/cottonmc/component/energy/impl/SimpleCapacitorComponent.java b/src/main/java/io/github/cottonmc/component/energy/impl/SimpleCapacitorComponent.java index 3a36b2f..912e6f1 100644 --- a/src/main/java/io/github/cottonmc/component/energy/impl/SimpleCapacitorComponent.java +++ b/src/main/java/io/github/cottonmc/component/energy/impl/SimpleCapacitorComponent.java @@ -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; @@ -124,7 +124,7 @@ public List 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)) { @@ -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); diff --git a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java index 25fcd17..e27a09d 100644 --- a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java +++ b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java @@ -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; @@ -87,20 +87,20 @@ default boolean contains(Set 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); + NbtCompound volTag = (NbtCompound)contents.get(i); setFluid(i, FluidVolume.fromTag(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.toTag(new NbtCompound())); } tag.put("Contents", contents); } diff --git a/src/main/java/io/github/cottonmc/component/fluid/impl/ItemTankComponent.java b/src/main/java/io/github/cottonmc/component/fluid/impl/ItemTankComponent.java index 723614d..b72e476 100644 --- a/src/main/java/io/github/cottonmc/component/fluid/impl/ItemTankComponent.java +++ b/src/main/java/io/github/cottonmc/component/fluid/impl/ItemTankComponent.java @@ -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 type; @@ -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); diff --git a/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java b/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java index 04c52d5..69cfa92 100644 --- a/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java +++ b/src/main/java/io/github/cottonmc/component/item/InventoryComponent.java @@ -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; @@ -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); } diff --git a/src/main/java/io/github/cottonmc/component/item/impl/ItemInventoryComponent.java b/src/main/java/io/github/cottonmc/component/item/impl/ItemInventoryComponent.java index c1f5ab6..1b23434 100644 --- a/src/main/java/io/github/cottonmc/component/item/impl/ItemInventoryComponent.java +++ b/src/main/java/io/github/cottonmc/component/item/impl/ItemInventoryComponent.java @@ -3,7 +3,7 @@ import dev.onyxstudios.cca.api.v3.component.ComponentKey; import io.github.cottonmc.component.UniversalComponents; import io.github.cottonmc.component.item.InventoryComponent; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import java.util.Objects; @@ -27,8 +27,8 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ItemInventoryComponent that = (ItemInventoryComponent) o; - CompoundTag tag = new CompoundTag(); - CompoundTag tag1 = new CompoundTag(); //TODO: better way to do this? + NbtCompound tag = new NbtCompound(); + NbtCompound tag1 = new NbtCompound(); //TODO: better way to do this? that.writeToNbt(tag); this.writeToNbt(tag1); return tag1.equals(tag1); diff --git a/src/main/java/io/github/cottonmc/component/serializer/StackSerializer.java b/src/main/java/io/github/cottonmc/component/serializer/StackSerializer.java index f8932aa..04f3720 100644 --- a/src/main/java/io/github/cottonmc/component/serializer/StackSerializer.java +++ b/src/main/java/io/github/cottonmc/component/serializer/StackSerializer.java @@ -2,13 +2,13 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class StackSerializer { //allows int amounts - public static CompoundTag toTag(ItemStack stack, CompoundTag tag) { + public static NbtCompound toTag(ItemStack stack, NbtCompound tag) { Identifier identifier = Registry.ITEM.getId(stack.getItem()); tag.putString("id", identifier == null ? "minecraft:air" : identifier.toString()); tag.putInt("Count", stack.getCount()); @@ -20,7 +20,7 @@ public static CompoundTag toTag(ItemStack stack, CompoundTag tag) { } //allows int amounts - public static ItemStack fromTag(CompoundTag tag) { + public static ItemStack fromTag(NbtCompound tag) { Item item = Registry.ITEM.get(new Identifier(tag.getString("id"))); int count = tag.getInt("Count"); ItemStack ret = new ItemStack(item, count); diff --git a/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java b/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java index 29b5916..f05b7f0 100644 --- a/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java +++ b/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java @@ -4,7 +4,7 @@ import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtOps; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -17,7 +17,7 @@ public final class FluidVolume { private Fluid fluid; private Fraction amount; - private CompoundTag tag; + private NbtCompound tag; private boolean empty; @@ -31,7 +31,7 @@ public FluidVolume(Fluid fluid, Fraction amount) { this.updateEmptyState(); } - private FluidVolume(CompoundTag tag) { + private FluidVolume(NbtCompound tag) { fluid = Registry.FLUID.get(new Identifier(tag.getString("Id"))); amount = Fraction.CODEC.parse(NbtOps.INSTANCE, tag.getCompound("Amount")).resultOrPartial(UniversalComponents.logger::error).orElse(Fraction.ZERO); @@ -99,19 +99,19 @@ public boolean hasTag() { return !empty && tag != null && !tag.isEmpty(); } - public CompoundTag getTag() { + public NbtCompound getTag() { return tag; } - public CompoundTag getOrCreateTag() { + public NbtCompound getOrCreateTag() { if (tag == null) { - tag = new CompoundTag(); + tag = new NbtCompound(); } return tag; } - public void setTag(CompoundTag tag) { + public void setTag(NbtCompound tag) { this.tag = tag; } @@ -122,14 +122,14 @@ public FluidVolume copy() { return stack; } - public static FluidVolume fromTag(CompoundTag tag) { + public static FluidVolume fromTag(NbtCompound tag) { return new FluidVolume(tag); } - public CompoundTag toTag(CompoundTag tag) { + public NbtCompound toTag(NbtCompound tag) { tag.putString("Id", Registry.FLUID.getId(getFluid()).toString()); - tag.put("Amount", Fraction.CODEC.encodeStart(NbtOps.INSTANCE, amount).resultOrPartial(UniversalComponents.logger::error).orElseGet(CompoundTag::new)); + tag.put("Amount", Fraction.CODEC.encodeStart(NbtOps.INSTANCE, amount).resultOrPartial(UniversalComponents.logger::error).orElseGet(NbtCompound::new)); if (this.tag != null) { tag.put("Tag", this.tag.copy()); From 2383cc3d7ffcdf28e191d8bdcc60820fb2891791 Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Sun, 12 Sep 2021 10:35:00 -0400 Subject: [PATCH 07/10] update to 1.16.5 phase II --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b23a6ac..63f2b50 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ dependencies { //cardinal components include modImplementation("io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_version}") //only non-fabricmc lib we actually require at runtime - include modImplementation("io.github.onyxstudios.Cardinal-Components-API:cardinal-components-block:${project.cardinal_version}") + modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-block:${project.cardinal_version}" modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-item:${project.cardinal_version}" modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_version}" modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-chunk:${project.cardinal_version}" @@ -54,10 +54,10 @@ dependencies { modCompileOnly("grondag:fluidity-mc116:${project.fluidity_version}.+") { transitive = false } //item inventory - include modImplementation("com.github.emilyploszaj:item-inventory:${project.item_inventory_version}") + modCompileOnly "com.github.emilyploszaj:item-inventory:${project.item_inventory_version}" //techreborn energy - include modImplementation("teamreborn:energy:${tr_energy_version}") + modCompileOnly "teamreborn:energy:${tr_energy_version}" } processResources { From 0e44cb0fc53007503449f411f2ff42e5dd8ff330 Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Sun, 12 Sep 2021 10:42:39 -0400 Subject: [PATCH 08/10] update to 1.16.5 final phase (probably) --- .../lba/WrappedInvAttributeComponent.java | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java index 3929879..3bc43ee 100644 --- a/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java +++ b/src/main/java/io/github/cottonmc/component/compat/lba/WrappedInvAttributeComponent.java @@ -143,62 +143,11 @@ public boolean contains(Set items) { @Override public Inventory asInventory() { - //INFO: This is a very bad temporary fix. Correct it later! Wasn't runable without this. - System.out.println("If you ever see this things have most likely gone wrong!"); - System.out.println("Compatibility with LBA is not granted at the moment!"); return new InventoryFixedWrapper(inv) { @Override public boolean canPlayerUse(PlayerEntity player) { return true; } - - @Override - public ItemStack getStack(int slot) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isEmpty() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void markDirty() { - // TODO Auto-generated method stub - - } - - @Override - public ItemStack removeStack(int slot) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ItemStack removeStack(int slot, int amount) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setStack(int slot, ItemStack stack) { - // TODO Auto-generated method stub - - } - - @Override - public int size() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void clear() { - // TODO Auto-generated method stub - - } }; } From a15105fc8d02cf4eab7709ca925d469523d8e928 Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Wed, 15 Sep 2021 04:06:42 -0400 Subject: [PATCH 09/10] updated some dependecies --- build.gradle | 4 ++-- gradle.properties | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 63f2b50..70c6f72 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/gradle.properties b/gradle.properties index 921d7e3..a320b19 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use minecraft_version = 1.16.5 yarn_build = 10 -loader_version = 0.11.6 +loader_version = 0.11.7 # Mod Properties mod_version = 0.8.0 @@ -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.38.0+1.16 -cardinal_version = 2.7.10 -lba_version = 0.8.5 +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 From 261f37c8c4efddc2c4be55d1e2f5a49f3b28cf0f Mon Sep 17 00:00:00 2001 From: Albert-Einholz <64534803+Albert-Einholz@users.noreply.github.com> Date: Sun, 19 Sep 2021 09:23:21 -0400 Subject: [PATCH 10/10] renamed Tag to Nbt in FluidVolume (#4) --- .../component/fluid/TankComponent.java | 4 +- .../api/fluidvolume/v1/FluidVolume.java | 50 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java index e27a09d..c4f4e1a 100644 --- a/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java +++ b/src/main/java/io/github/cottonmc/component/fluid/TankComponent.java @@ -92,7 +92,7 @@ default void readFromNbt(NbtCompound tag) { NbtList contents = tag.getList("Contents", NbtType.COMPOUND); for (int i = 0; i < contents.size(); i++) { NbtCompound volTag = (NbtCompound)contents.get(i); - setFluid(i, FluidVolume.fromTag(volTag)); + setFluid(i, FluidVolume.fromNbt(volTag)); } } @@ -100,7 +100,7 @@ default void readFromNbt(NbtCompound tag) { default void writeToNbt(NbtCompound tag) { NbtList contents = new NbtList(); for (FluidVolume vol : getAllContents()) { - contents.add(vol.toTag(new NbtCompound())); + contents.add(vol.toNbt(new NbtCompound())); } tag.put("Contents", contents); } diff --git a/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java b/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java index f05b7f0..4ec43a4 100644 --- a/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java +++ b/src/main/java/io/github/fablabsmc/fablabs/api/fluidvolume/v1/FluidVolume.java @@ -17,7 +17,7 @@ public final class FluidVolume { private Fluid fluid; private Fraction amount; - private NbtCompound tag; + private NbtCompound nbt; private boolean empty; @@ -31,12 +31,12 @@ public FluidVolume(Fluid fluid, Fraction amount) { this.updateEmptyState(); } - private FluidVolume(NbtCompound tag) { - fluid = Registry.FLUID.get(new Identifier(tag.getString("Id"))); - amount = Fraction.CODEC.parse(NbtOps.INSTANCE, tag.getCompound("Amount")).resultOrPartial(UniversalComponents.logger::error).orElse(Fraction.ZERO); + private FluidVolume(NbtCompound nbt) { + fluid = Registry.FLUID.get(new Identifier(nbt.getString("Id"))); + amount = Fraction.CODEC.parse(NbtOps.INSTANCE, nbt.getCompound("Amount")).resultOrPartial(UniversalComponents.logger::error).orElse(Fraction.ZERO); - if (tag.contains("Tag", NbtType.COMPOUND)) { - this.tag = tag.getCompound("Tag"); + if (nbt.contains("Nbt", NbtType.COMPOUND)) { + this.nbt = nbt.getCompound("Nbt"); } this.updateEmptyState(); @@ -95,46 +95,46 @@ private void updateEmptyState() { empty = isEmpty(); } - public boolean hasTag() { - return !empty && tag != null && !tag.isEmpty(); + public boolean hasNbt() { + return !empty && nbt != null && !nbt.isEmpty(); } - public NbtCompound getTag() { - return tag; + public NbtCompound getNbt() { + return nbt; } - public NbtCompound getOrCreateTag() { - if (tag == null) { - tag = new NbtCompound(); + public NbtCompound getOrCreateNbt() { + if (nbt == null) { + nbt = new NbtCompound(); } - return tag; + return nbt; } - public void setTag(NbtCompound tag) { - this.tag = tag; + public void setNbt(NbtCompound nbt) { + this.nbt = nbt; } public FluidVolume copy() { if (this.isEmpty()) return FluidVolume.EMPTY; FluidVolume stack = new FluidVolume(this.fluid, this.amount); - if (this.hasTag()) stack.setTag(this.getTag()); + if (this.hasNbt()) stack.setNbt(this.getNbt()); return stack; } - public static FluidVolume fromTag(NbtCompound tag) { - return new FluidVolume(tag); + public static FluidVolume fromNbt(NbtCompound nbt) { + return new FluidVolume(nbt); } - public NbtCompound toTag(NbtCompound tag) { - tag.putString("Id", Registry.FLUID.getId(getFluid()).toString()); + public NbtCompound toNbt(NbtCompound nbt) { + nbt.putString("Id", Registry.FLUID.getId(getFluid()).toString()); - tag.put("Amount", Fraction.CODEC.encodeStart(NbtOps.INSTANCE, amount).resultOrPartial(UniversalComponents.logger::error).orElseGet(NbtCompound::new)); + nbt.put("Amount", Fraction.CODEC.encodeStart(NbtOps.INSTANCE, amount).resultOrPartial(UniversalComponents.logger::error).orElseGet(NbtCompound::new)); - if (this.tag != null) { - tag.put("Tag", this.tag.copy()); + if (this.nbt != null) { + nbt.put("Nbt", this.nbt.copy()); } - return tag; + return nbt; } }