mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 21:39:40 +00:00
Save infusion storage and gas tanks in machines. Fixes #4819
This commit is contained in:
1 parent
e21e72052f
commit
c481c70c6c
5 files changed
+94
-4
No files matched your search
@@ -1,8 +1,12 @@
|
||||
package mekanism.common;
|
||||
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InfuseStorage
|
||||
public class InfuseStorage implements ISustainedData
|
||||
{
|
||||
public InfuseType type;
|
||||
|
||||
@@ -32,4 +36,28 @@ public class InfuseStorage
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if (type != null && amount > 0)
|
||||
{
|
||||
ItemDataUtils.setString(itemStack, "infuseType", type.name);
|
||||
ItemDataUtils.setInt(itemStack, "infuseAmount", amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if (ItemDataUtils.hasData(itemStack, "infuseType") && ItemDataUtils.hasData(itemStack, "infuseAmount")){
|
||||
type = InfuseRegistry.get(ItemDataUtils.getString(itemStack, "infuseType"));
|
||||
if (type != null){
|
||||
amount = ItemDataUtils.getInt(itemStack, "infuseAmount");
|
||||
}
|
||||
} else {
|
||||
type = null;
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user