Skip to content

Commit

Permalink
fix bug with Botarium
Browse files Browse the repository at this point in the history
  • Loading branch information
CodexAdrian committed Mar 25, 2024
1 parent 608f25c commit efa7bde
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 38 deletions.
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# 3.2.0
# 3.2.1

- NEW Data attachment cross platform API
- Fix class loading error with Neo
- Item containers are no longer serialized. Use the new DataManager api
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public T getData(Object dataHolder) {
if (dataHolder instanceof AttachmentTarget target) {
return target.getAttached(this.attachmentType);
} else {
throw new IllegalArgumentException("Data holder is not an attachment target");
throw new IllegalArgumentException(dataHolder + " is not an attachment target");
}
}

Expand All @@ -26,7 +26,7 @@ public T setData(Object dataHolder, T data) {
if (dataHolder instanceof AttachmentTarget target) {
return target.setAttached(this.attachmentType, data);
} else {
throw new IllegalArgumentException("Data holder is not an attachment target");
throw new IllegalArgumentException(dataHolder + " is not an attachment target");
}
}

Expand All @@ -35,7 +35,7 @@ public boolean hasData(Object dataHolder) {
if (dataHolder instanceof AttachmentTarget target) {
return target.hasAttached(this.attachmentType);
} else {
throw new IllegalArgumentException("Data holder is not an attachment target");
throw new IllegalArgumentException(dataHolder + " is not an attachment target");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public void deserializeData(CompoundTag compoundTag, CallbackInfo ci) {
if (this instanceof ItemContainerBlock itemContainerBlock) {
itemContainerBlock.getContainer().deserialize(compoundTag);
}
if (this instanceof BotariumItemBlock<?> botariumItemBlock) {
ItemContainer itemContainer = botariumItemBlock.getItemContainer(this.getLevel(), this.getBlockPos(), this.getBlockState(), (BlockEntity) (Object) this, null);
if (itemContainer instanceof Serializable serializable) {
serializable.deserialize(compoundTag);
}
}
}

@Inject(method = "saveAdditional", at = @At("TAIL"))
Expand All @@ -67,11 +61,5 @@ public void serializeData(CompoundTag compoundTag, CallbackInfo ci) {
if (this instanceof ItemContainerBlock itemContainerBlock) {
itemContainerBlock.getContainer().serialize(compoundTag);
}
if (this instanceof BotariumItemBlock<?> botariumItemBlock) {
ItemContainer itemContainer = botariumItemBlock.getItemContainer(this.getLevel(), this.getBlockPos(), this.getBlockState(), (BlockEntity) (Object) this, null);
if (itemContainer instanceof Serializable serializable) {
serializable.serialize(compoundTag);
}
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx2G
enabledPlatforms=fabric,neoforge
version=3.2.0
version=3.2.1
group=earth.terrarium.botarium
minecraftVersion=1.20.4
parchmentVersion=2023.12.31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public void deserializeData(CompoundTag compoundTag, CallbackInfo ci) {
if (energyContainer != null) {
energyContainer.deserialize(compoundTag);
}
ItemContainer itemContainer = ItemApi.SIDED.find(this.getLevel(), this.getBlockPos(), this.getBlockState(), (BlockEntity) (Object) this, null);
if (itemContainer instanceof Serializable container) {
container.deserialize(compoundTag);
}

if (this instanceof ItemContainerBlock itemContainerBlock) {
itemContainerBlock.getContainer().deserialize(compoundTag);
}
Expand All @@ -63,10 +58,6 @@ public void serializeData(CompoundTag compoundTag, CallbackInfo ci) {
if (energyContainer != null) {
energyContainer.serialize(compoundTag);
}
ItemContainer itemContainer = ItemApi.SIDED.find(this.getLevel(), this.getBlockPos(), this.getBlockState(), (BlockEntity) (Object) this, null);
if (itemContainer instanceof Serializable container) {
container.serialize(compoundTag);
}
if (this instanceof ItemContainerBlock itemContainerBlock) {
itemContainerBlock.getContainer().serialize(compoundTag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import earth.terrarium.botarium.common.fluid.FluidApi;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidBlock;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidItem;
import earth.terrarium.botarium.common.item.ItemApi;
import earth.terrarium.botarium.common.item.ItemContainerBlock;
import earth.terrarium.botarium.common.item.base.BotariumItemBlock;
import earth.terrarium.botarium.common.registry.fluid.FluidBucketItem;
Expand All @@ -16,7 +15,6 @@
import earth.terrarium.botarium.neoforge.fluid.ForgeItemFluidContainer;
import earth.terrarium.botarium.neoforge.generic.NeoForgeCapsHandler;
import earth.terrarium.botarium.neoforge.item.ForgeItemContainer;
import earth.terrarium.botarium.neoforge.item.PlatformItemContainer;
import earth.terrarium.botarium.neoforge.item.ItemContainerWrapper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.neoforged.bus.api.IEventBus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package earth.terrarium.botarium.neoforge.data;

import com.mojang.datafixers.util.Pair;
import earth.terrarium.botarium.common.data.DataManager;
import net.neoforged.neoforge.attachment.AttachmentHolder;
import net.neoforged.neoforge.attachment.AttachmentType;

import javax.naming.OperationNotSupportedException;
import java.util.function.Supplier;

public class NeoDataManager<T> implements DataManager<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
import earth.terrarium.botarium.common.generic.base.BlockContainerLookup;
import earth.terrarium.botarium.common.generic.base.EntityContainerLookup;
import earth.terrarium.botarium.common.generic.base.ItemContainerLookup;
import earth.terrarium.botarium.common.item.ItemApi;
import earth.terrarium.botarium.common.item.base.ItemContainer;
import earth.terrarium.botarium.common.item.base.ItemSnapshot;
import earth.terrarium.botarium.neoforge.item.ForgeItemApiBlockLookup;
import earth.terrarium.botarium.neoforge.item.ForgeItemApiEntityAutomationLookup;
import earth.terrarium.botarium.neoforge.item.ForgeItemApiEntityLookup;
import earth.terrarium.botarium.neoforge.item.ForgeItemApiItemLookup;
import earth.terrarium.botarium.util.Snapshotable;
import earth.terrarium.botarium.util.Updatable;
import net.minecraft.core.Direction;
import net.msrandom.extensions.annotations.ClassExtension;
import net.msrandom.extensions.annotations.ImplementedByExtension;
import net.msrandom.extensions.annotations.ImplementsBaseElement;
import org.apache.commons.lang3.NotImplementedException;

@ClassExtension(ItemApiImpl.class)
@ClassExtension(ItemApi.class)
public class ItemApiImpl {

private static ItemContainerLookup<ItemContainer, Void> getItemLookup() {
Expand Down

0 comments on commit efa7bde

Please sign in to comment.