From 9b2ab15201b6f79524e1b5e8cffd3a02129c348d Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 9 Nov 2024 15:20:15 +0100 Subject: [PATCH 1/6] Add REI to build.gradle --- build.gradle | 8 ++++++++ gradle.properties | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6a566fa5..3d3e79ab 100644 --- a/build.gradle +++ b/build.gradle @@ -99,6 +99,10 @@ repositories { maven { url = "https://minecraft.curseforge.com/api/maven/" } + maven { + name "REI" + url "https://maven.shedaniel.me/" + } } dependencies { @@ -142,6 +146,10 @@ dependencies { }*/ implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${project.terrablender_version}") + + compileOnly fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:${rei_version}") // https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-forge/ + compileOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:$cloth_config_version"); + compileOnly fg.deobf("dev.architectury:architectury-forge:$architectury_version"); } minecraft { diff --git a/gradle.properties b/gradle.properties index 2cf0977d..16b5e117 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ mod_version=1.0.0 minecraft_version=1.19.2 -forge_version=43.0.8 +forge_version=43.4.4 cyclopscore_version=1.17.0-237 integrateddynamics_version=1.19.2-1.11.8-362 release_type=release -commoncapabilities_version=1.19.2-2.8.3-71 +commoncapabilities_version=1.19.2-2.9.0-88 mcmultipart_version=1.2.1_78 waila_version=1.10.8:B72_1.15.2 jei_version=1.19.2-forge:11.2.0.247 @@ -23,6 +23,9 @@ crafttweakerapi_version=4.1.6.457 crafttweakermain_version=1.12-4.1.6.457 signals_version=1.12.2:1.1.0-2 terrablender_version=1.19.2-2.0.1.166 +rei_version=9.2.779 +cloth_config_version=8.3.134 +architectury_version=6.6.92 # Workaround for Spotless bug # https://github.com/diffplug/spotless/issues/834 From a9d85b19150ec5656c2cc63cdbec5e2318a99a12 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 5 Dec 2024 15:17:37 +0100 Subject: [PATCH 2/6] Restore Jade/Waila integration, Closes CyclopsMC/IntegratedDynamics#1413 --- build.gradle | 11 ++- gradle.properties | 2 +- .../jade/DryingBasinDataProvider.java | 57 +++++++++++++++ .../jade/JadeIntegratedDynamicsConfig.java | 45 ++++++++++++ .../MechanicalDryingBasinDataProvider.java | 71 +++++++++++++++++++ .../jade/MechanicalSqueezerDataProvider.java | 67 +++++++++++++++++ .../{waila => jade}/PartDataProvider.java | 43 ++++++----- .../modcompat/jade/ProxyDataProvider.java | 44 ++++++++++++ .../modcompat/jade/SqueezerDataProvider.java | 57 +++++++++++++++ .../waila/DryingBasinDataProvider.java | 52 -------------- .../MechanicalDryingBasinDataProvider.java | 69 ------------------ .../waila/MechanicalSqueezerDataProvider.java | 64 ----------------- .../modcompat/waila/ProxyDataProvider.java | 41 ----------- .../modcompat/waila/SqueezerDataProvider.java | 52 -------------- .../modcompat/waila/Waila.java | 56 --------------- .../integrateddynamicscompat/lang/en_us.json | 6 ++ 16 files changed, 381 insertions(+), 356 deletions(-) create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/DryingBasinDataProvider.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/JadeIntegratedDynamicsConfig.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalDryingBasinDataProvider.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalSqueezerDataProvider.java rename src/main/java/org/cyclops/integrateddynamicscompat/modcompat/{waila => jade}/PartDataProvider.java (52%) create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/ProxyDataProvider.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/SqueezerDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/DryingBasinDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalDryingBasinDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalSqueezerDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/ProxyDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/SqueezerDataProvider.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/Waila.java diff --git a/build.gradle b/build.gradle index 3d3e79ab..0715a7ca 100644 --- a/build.gradle +++ b/build.gradle @@ -103,6 +103,12 @@ repositories { name "REI" url "https://maven.shedaniel.me/" } + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } } dependencies { @@ -138,7 +144,7 @@ dependencies { /*runtimeOnly(fg.deobf("mcjty.theoneprobe:theoneprobe:${project.theoneprobe_version}")) { // https://maven.k-4u.nl transitive = false }*/ - //implementation fg.deobf("hwyla:Hwyla-forge-${project.waila_version}") // https://www.curseforge.com/minecraft/mc-mods/hwyla/files/ https://github.com/TehNut/HWYLA and https://github.com/TehNut/temporary-maven-thing/tree/master/maven/mcp/mobius/waila/Hwyla + //compileOnly "com.refinedmods:refinedstorage:${project.refinedstorage_version}" // https://github.com/refinedmods/refinedstorage/packages/1145536 // TODO: for some reason using the following in runtime breaks ForgeGradle /*runtimeOnly(fg.deobf("com.refinedmods:refinedstorage:${project.refinedstorage_version}")) { // https://repo.refinedmods.com/com/refinedmods/refinedstorage/ @@ -150,6 +156,8 @@ dependencies { compileOnly fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:${rei_version}") // https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-forge/ compileOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:$cloth_config_version"); compileOnly fg.deobf("dev.architectury:architectury-forge:$architectury_version"); + + implementation fg.deobf("curse.maven:jade-324717:${jade_version}") } minecraft { @@ -340,7 +348,6 @@ spotless { exclude '**/modcompat/tconstruct/**' exclude '**/modcompat/tesla/**' exclude '**/modcompat/thaumcraft/**' - exclude '**/modcompat/waila/**' exclude '**/modcompat/refinedstorage/**' } diff --git a/gradle.properties b/gradle.properties index 16b5e117..8b0badf3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,6 @@ release_type=release commoncapabilities_version=1.19.2-2.9.0-88 mcmultipart_version=1.2.1_78 -waila_version=1.10.8:B72_1.15.2 jei_version=1.19.2-forge:11.2.0.247 rfapi_version=1.8.9R1.2.0B1.1 teslaapi_version=1.12.2:1.0.63 @@ -26,6 +25,7 @@ terrablender_version=1.19.2-2.0.1.166 rei_version=9.2.779 cloth_config_version=8.3.134 architectury_version=6.6.92 +jade_version=4914105 # Workaround for Spotless bug # https://github.com/diffplug/spotless/issues/834 diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/DryingBasinDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/DryingBasinDataProvider.java new file mode 100644 index 00000000..ff2f8777 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/DryingBasinDataProvider.java @@ -0,0 +1,57 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import com.google.common.collect.Lists; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.cyclops.cyclopscore.persist.nbt.NBTClassType; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.blockentity.BlockEntityDryingBasin; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.IBlockComponentProvider; +import snownee.jade.api.IServerDataProvider; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; + +import java.util.List; + +/** + * Waila data provider for the drying basin. + * @author rubensworks + * + */ +public class DryingBasinDataProvider implements IBlockComponentProvider, IServerDataProvider { + + public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "drying_basin"); + + @Override + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { + if(config.get(DryingBasinDataProvider.ID)) { + tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + BlockEntityDryingBasin tile = (BlockEntityDryingBasin) blockEntity; + List tooltip = Lists.newArrayList(); + if (!tile.getInventory().getItem(0).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item", + tile.getInventory().getItem(0).getDisplayName())); + } + if (!tile.getTank().isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.fluid", + tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); + } + NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/JadeIntegratedDynamicsConfig.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/JadeIntegratedDynamicsConfig.java new file mode 100644 index 00000000..7ae189f0 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/JadeIntegratedDynamicsConfig.java @@ -0,0 +1,45 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import org.cyclops.integrateddynamics.block.*; +import org.cyclops.integrateddynamics.blockentity.*; +import org.cyclops.integrateddynamics.core.blockentity.BlockEntityMultipartTicking; +import snownee.jade.api.IWailaClientRegistration; +import snownee.jade.api.IWailaCommonRegistration; +import snownee.jade.api.IWailaPlugin; +import snownee.jade.api.WailaPlugin; + +/** + * Waila support class. + * @author rubensworks + * + */ +@WailaPlugin +public class JadeIntegratedDynamicsConfig implements IWailaPlugin { + + @Override + public void register(IWailaCommonRegistration registrar) { + registrar.registerBlockDataProvider(new PartDataProvider(), BlockEntityMultipartTicking.class); + registrar.registerBlockDataProvider(new SqueezerDataProvider(), BlockEntitySqueezer.class); + registrar.registerBlockDataProvider(new DryingBasinDataProvider(), BlockEntityDryingBasin.class); + registrar.registerBlockDataProvider(new MechanicalSqueezerDataProvider(), BlockEntityMechanicalSqueezer.class); + registrar.registerBlockDataProvider(new MechanicalDryingBasinDataProvider(), BlockEntityMechanicalDryingBasin.class); + registrar.registerBlockDataProvider(new ProxyDataProvider(), BlockEntityProxy.class); + } + + @Override + public void registerClient(IWailaClientRegistration registrar) { + registrar.addConfig(PartDataProvider.ID, true); + registrar.addConfig(SqueezerDataProvider.ID, true); + registrar.addConfig(DryingBasinDataProvider.ID, true); + registrar.addConfig(MechanicalSqueezerDataProvider.ID, true); + registrar.addConfig(MechanicalDryingBasinDataProvider.ID, true); + registrar.addConfig(ProxyDataProvider.ID, true); + + registrar.registerBlockComponent(new PartDataProvider(), BlockCable.class); + registrar.registerBlockComponent(new SqueezerDataProvider(), BlockSqueezer.class); + registrar.registerBlockComponent(new DryingBasinDataProvider(), BlockDryingBasin.class); + registrar.registerBlockComponent(new MechanicalSqueezerDataProvider(), BlockMechanicalSqueezer.class); + registrar.registerBlockComponent(new MechanicalDryingBasinDataProvider(), BlockMechanicalDryingBasin.class); + registrar.registerBlockComponent(new ProxyDataProvider(), BlockProxy.class); + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalDryingBasinDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalDryingBasinDataProvider.java new file mode 100644 index 00000000..ce138fbb --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalDryingBasinDataProvider.java @@ -0,0 +1,71 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import com.google.common.collect.Lists; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.cyclops.cyclopscore.persist.nbt.NBTClassType; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.blockentity.BlockEntityMechanicalDryingBasin; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; + +import java.util.List; + +/** + * Waila data provider for the mechanical drying basin. + * @author rubensworks + * + */ +public class MechanicalDryingBasinDataProvider extends SqueezerDataProvider { + + public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "mechanical_drying_basin"); + + @Override + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { + if(config.get(MechanicalDryingBasinDataProvider.ID)) { + tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + BlockEntityMechanicalDryingBasin tile = (BlockEntityMechanicalDryingBasin) blockEntity; + List tooltip = Lists.newArrayList(); + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.energy", + tile.getEnergyStored(), tile.getMaxEnergyStored())); + if (!tile.getInventory().getItem(0).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item.in", + tile.getInventory().getItem(0).getDisplayName())); + } + for (int i = 1; i < tile.getInventory().getContainerSize(); i++) { + if (!tile.getInventory().getItem(i).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item.out", + tile.getInventory().getItem(i).getDisplayName())); + } + } + if (!tile.getTankInput().isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.fluid.in", + tile.getTankInput().getFluid().getDisplayName(), tile.getTankInput().getFluidAmount())); + } + if (!tile.getTankOutput().isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.fluid.out", + tile.getTankOutput().getFluid().getDisplayName(), tile.getTankOutput().getFluidAmount())); + } + if (tile.getProgress() > 0) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.progress", + tile.getProgress() * 100 / tile.getMaxProgress())); + } + NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalSqueezerDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalSqueezerDataProvider.java new file mode 100644 index 00000000..094eaf93 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalSqueezerDataProvider.java @@ -0,0 +1,67 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import com.google.common.collect.Lists; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.cyclops.cyclopscore.persist.nbt.NBTClassType; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.blockentity.BlockEntityMechanicalSqueezer; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; + +import java.util.List; + +/** + * Waila data provider for the mechanical squeezer. + * @author rubensworks + * + */ +public class MechanicalSqueezerDataProvider extends SqueezerDataProvider { + + public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "mechanical_squeezer"); + + @Override + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { + if(config.get(MechanicalSqueezerDataProvider.ID)) { + tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + BlockEntityMechanicalSqueezer tile = (BlockEntityMechanicalSqueezer) blockEntity; + List tooltip = Lists.newArrayList(); + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.energy", + tile.getEnergyStored(), tile.getMaxEnergyStored())); + if (!tile.getInventory().getItem(0).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item.in", + tile.getInventory().getItem(0).getDisplayName())); + } + for (int i = 1; i < tile.getInventory().getContainerSize(); i++) { + if (!tile.getInventory().getItem(i).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item.out", + tile.getInventory().getItem(i).getDisplayName())); + } + } + if (!tile.getTank().isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.fluid", + tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); + } + if (tile.getProgress() > 0) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.progress", + tile.getProgress() * 100 / tile.getMaxProgress())); + } + NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/PartDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java similarity index 52% rename from src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/PartDataProvider.java rename to src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java index eca53ac4..f6a287cc 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/PartDataProvider.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java @@ -1,23 +1,23 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; +package org.cyclops.integrateddynamicscompat.modcompat.jade; import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; import org.cyclops.cyclopscore.persist.nbt.NBTClassType; import org.cyclops.integrateddynamics.api.part.IPartState; import org.cyclops.integrateddynamics.api.part.IPartType; import org.cyclops.integrateddynamics.core.helper.PartHelpers; -import org.cyclops.integrateddynamics.core.tileentity.BlockEntityMultipartTicking; import org.cyclops.integrateddynamicscompat.Reference; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.IBlockComponentProvider; +import snownee.jade.api.IServerDataProvider; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; import java.util.List; @@ -26,29 +26,34 @@ * @author rubensworks * */ -public class PartDataProvider implements IComponentProvider, IServerDataProvider { +public class PartDataProvider implements IBlockComponentProvider, IServerDataProvider { public static final ResourceLocation ID = new ResourceLocation(Reference.MOD_ID, "part"); @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { if(config.get(PartDataProvider.ID)) { tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); } } @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tile) { - PartHelpers.getPartContainer(world, tile.getPos(), null) + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + PartHelpers.getPartContainer(world, blockEntity.getBlockPos(), null) .ifPresent(partContainer -> { - Direction side = partContainer.getWatchingSide(world, tile.getPos(), player); + Direction side = partContainer.getWatchingSide(world, blockEntity.getBlockPos(), player); if (side != null && partContainer.hasPart(side)) { IPartType partType = partContainer.getPart(side); IPartState partState = partContainer.getPartState(side); - List tooltip = Lists.newArrayList(); + List tooltip = Lists.newArrayList(); partType.loadTooltip(partState, tooltip); NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); } }); } + + @Override + public ResourceLocation getUid() { + return ID; + } } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/ProxyDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/ProxyDataProvider.java new file mode 100644 index 00000000..0ff68c1f --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/ProxyDataProvider.java @@ -0,0 +1,44 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.cyclops.integrateddynamics.blockentity.BlockEntityProxy; +import org.cyclops.integrateddynamics.core.helper.L10NValues; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.IBlockComponentProvider; +import snownee.jade.api.IServerDataProvider; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; + +/** + * Waila data provider for proxies. + * @author rubensworks + * + */ +public class ProxyDataProvider implements IBlockComponentProvider, IServerDataProvider { + + public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "proxy"); + + @Override + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { + if(config.get(ProxyDataProvider.ID)) { + tooltip.add(Component.translatable(L10NValues.GENERAL_ITEM_ID, accessor.getServerData().getInt("id"))); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + BlockEntityProxy tile = (BlockEntityProxy) blockEntity; + tag.putInt("id", tile.getProxyId()); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/SqueezerDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/SqueezerDataProvider.java new file mode 100644 index 00000000..974ac23f --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/SqueezerDataProvider.java @@ -0,0 +1,57 @@ +package org.cyclops.integrateddynamicscompat.modcompat.jade; + +import com.google.common.collect.Lists; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.cyclops.cyclopscore.persist.nbt.NBTClassType; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.blockentity.BlockEntitySqueezer; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.IBlockComponentProvider; +import snownee.jade.api.IServerDataProvider; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; + +import java.util.List; + +/** + * Waila data provider for the squeezer. + * @author rubensworks + * + */ +public class SqueezerDataProvider implements IBlockComponentProvider, IServerDataProvider { + + public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "squeezer"); + + @Override + public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { + if(config.get(SqueezerDataProvider.ID)) { + tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, BlockEntity blockEntity, boolean showDetails) { + BlockEntitySqueezer tile = (BlockEntitySqueezer) blockEntity; + List tooltip = Lists.newArrayList(); + if (!tile.getInventory().getItem(0).isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.item", + tile.getInventory().getItem(0).getDisplayName())); + } + if (!tile.getTank().isEmpty()) { + tooltip.add(Component.translatable("gui." + Reference.MOD_ID + ".waila.fluid", + tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); + } + NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/DryingBasinDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/DryingBasinDataProvider.java deleted file mode 100644 index 59580f12..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/DryingBasinDataProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import org.cyclops.cyclopscore.persist.nbt.NBTClassType; -import org.cyclops.integrateddynamics.Reference; -import org.cyclops.integrateddynamics.tileentity.BlockEntityDryingBasin; - -import java.util.List; - -/** - * Waila data provider for the drying basin. - * @author rubensworks - * - */ -public class DryingBasinDataProvider implements IComponentProvider, IServerDataProvider { - - public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "drying_basin"); - - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - if(config.get(DryingBasinDataProvider.ID)) { - tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); - } - } - - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tileEntity) { - BlockEntityDryingBasin tile = (BlockEntityDryingBasin) tileEntity; - List tooltip = Lists.newArrayList(); - if (!tile.getInventory().getStackInSlot(0).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item", - tile.getInventory().getStackInSlot(0).getDisplayName())); - } - if (!tile.getTank().isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.fluid", - tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); - } - NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalDryingBasinDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalDryingBasinDataProvider.java deleted file mode 100644 index 8db2fe3f..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalDryingBasinDataProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import org.cyclops.cyclopscore.persist.nbt.NBTClassType; -import org.cyclops.integrateddynamics.Reference; -import org.cyclops.integrateddynamics.tileentity.BlockEntityMechanicalDryingBasin; -import org.cyclops.integrateddynamics.tileentity.BlockEntityMechanicalSqueezer; - -import java.util.List; - -/** - * Waila data provider for the mechanical drying basin. - * @author rubensworks - * - */ -public class MechanicalDryingBasinDataProvider extends SqueezerDataProvider implements IComponentProvider, IServerDataProvider { - - public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "mechanical_drying_basin"); - - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - if(config.get(MechanicalDryingBasinDataProvider.ID)) { - tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); - } - } - - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tileEntity) { - BlockEntityMechanicalDryingBasin tile = (BlockEntityMechanicalDryingBasin) tileEntity; - List tooltip = Lists.newArrayList(); - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.energy", - tile.getEnergyStored(), tile.getMaxEnergyStored())); - if (!tile.getInventory().getStackInSlot(0).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item.in", - tile.getInventory().getStackInSlot(0).getDisplayName())); - } - for (int i = 1; i < tile.getInventory().getSizeInventory(); i++) { - if (!tile.getInventory().getStackInSlot(i).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item.out", - tile.getInventory().getStackInSlot(i).getDisplayName())); - } - } - if (!tile.getTankInput().isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.fluid.in", - tile.getTankInput().getFluid().getDisplayName(), tile.getTankInput().getFluidAmount())); - } - if (!tile.getTankOutput().isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.fluid.out", - tile.getTankOutput().getFluid().getDisplayName(), tile.getTankOutput().getFluidAmount())); - } - if (tile.getProgress() > 0) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.progress", - tile.getProgress() * 100 / tile.getMaxProgress())); - } - NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalSqueezerDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalSqueezerDataProvider.java deleted file mode 100644 index bdbd2c8c..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/MechanicalSqueezerDataProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import org.cyclops.cyclopscore.persist.nbt.NBTClassType; -import org.cyclops.integrateddynamics.Reference; -import org.cyclops.integrateddynamics.tileentity.BlockEntityMechanicalSqueezer; - -import java.util.List; - -/** - * Waila data provider for the mechanical squeezer. - * @author rubensworks - * - */ -public class MechanicalSqueezerDataProvider extends SqueezerDataProvider implements IComponentProvider, IServerDataProvider { - - public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "mechanical_squeezer"); - - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - if(config.get(MechanicalSqueezerDataProvider.ID)) { - tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); - } - } - - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tileEntity) { - BlockEntityMechanicalSqueezer tile = (BlockEntityMechanicalSqueezer) tileEntity; - List tooltip = Lists.newArrayList(); - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.energy", - tile.getEnergyStored(), tile.getMaxEnergyStored())); - if (!tile.getInventory().getStackInSlot(0).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item.in", - tile.getInventory().getStackInSlot(0).getDisplayName())); - } - for (int i = 1; i < tile.getInventory().getSizeInventory(); i++) { - if (!tile.getInventory().getStackInSlot(i).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item.out", - tile.getInventory().getStackInSlot(i).getDisplayName())); - } - } - if (!tile.getTank().isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.fluid", - tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); - } - if (tile.getProgress() > 0) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.progress", - tile.getProgress() * 100 / tile.getMaxProgress())); - } - NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/ProxyDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/ProxyDataProvider.java deleted file mode 100644 index 4c079969..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/ProxyDataProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import org.cyclops.integrateddynamics.core.helper.L10NValues; -import org.cyclops.integrateddynamics.tileentity.BlockEntityProxy; - -import java.util.List; - -/** - * Waila data provider for proxies. - * @author rubensworks - * - */ -public class ProxyDataProvider implements IComponentProvider, IServerDataProvider { - - public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "proxy"); - - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - if(config.get(ProxyDataProvider.ID)) { - tooltip.add(new TranslationTextComponent(L10NValues.GENERAL_ITEM_ID, accessor.getServerData().getInt("id"))); - } - } - - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tileEntity) { - BlockEntityProxy tile = (BlockEntityProxy) tileEntity; - tag.putInt("id", tile.getProxyId()); - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/SqueezerDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/SqueezerDataProvider.java deleted file mode 100644 index 02e77a99..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/SqueezerDataProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.BlockEntityEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import org.cyclops.cyclopscore.persist.nbt.NBTClassType; -import org.cyclops.integrateddynamics.Reference; -import org.cyclops.integrateddynamics.tileentity.BlockEntitySqueezer; - -import java.util.List; - -/** - * Waila data provider for the squeezer. - * @author rubensworks - * - */ -public class SqueezerDataProvider implements IComponentProvider, IServerDataProvider { - - public static final ResourceLocation ID = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "squeezer"); - - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - if(config.get(SqueezerDataProvider.ID)) { - tooltip.addAll(NBTClassType.getClassType(List.class).readPersistedField("tooltip", accessor.getServerData())); - } - } - - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, BlockEntityEntity tileEntity) { - BlockEntitySqueezer tile = (BlockEntitySqueezer) tileEntity; - List tooltip = Lists.newArrayList(); - if (!tile.getInventory().getStackInSlot(0).isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.item", - tile.getInventory().getStackInSlot(0).getDisplayName())); - } - if (!tile.getTank().isEmpty()) { - tooltip.add(new TranslationTextComponent("gui." + Reference.MOD_ID + ".waila.fluid", - tile.getTank().getFluid().getDisplayName(), tile.getTank().getFluidAmount())); - } - NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/Waila.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/Waila.java deleted file mode 100644 index 014b309b..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/waila/Waila.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.waila; - -import mcp.mobius.waila.api.IRegistrar; -import mcp.mobius.waila.api.IWailaPlugin; -import mcp.mobius.waila.api.TooltipPosition; -import mcp.mobius.waila.api.WailaPlugin; -import org.cyclops.integrateddynamics.core.tileentity.BlockEntityMultipartTicking; -import org.cyclops.integrateddynamics.tileentity.BlockEntityDryingBasin; -import org.cyclops.integrateddynamics.tileentity.BlockEntityMechanicalDryingBasin; -import org.cyclops.integrateddynamics.tileentity.BlockEntityMechanicalSqueezer; -import org.cyclops.integrateddynamics.tileentity.BlockEntityProxy; -import org.cyclops.integrateddynamics.tileentity.BlockEntitySqueezer; - -/** - * Waila support class. - * @author rubensworks - * - */ -@WailaPlugin -public class Waila implements IWailaPlugin { - - @Override - public void register(IRegistrar registrar) { - registrar.addConfig(PartDataProvider.ID, true); - registrar.addConfig(SqueezerDataProvider.ID, true); - registrar.addConfig(DryingBasinDataProvider.ID, true); - registrar.addConfig(MechanicalSqueezerDataProvider.ID, true); - registrar.addConfig(MechanicalDryingBasinDataProvider.ID, true); - registrar.addConfig(ProxyDataProvider.ID, true); - - PartDataProvider partDataProvider = new PartDataProvider(); - registrar.registerBlockDataProvider(partDataProvider, BlockEntityMultipartTicking.class); - registrar.registerComponentProvider(partDataProvider, TooltipPosition.BODY, BlockEntityMultipartTicking.class); - - SqueezerDataProvider squeezerDataProvider = new SqueezerDataProvider(); - registrar.registerBlockDataProvider(squeezerDataProvider, BlockEntitySqueezer.class); - registrar.registerComponentProvider(squeezerDataProvider, TooltipPosition.BODY, BlockEntitySqueezer.class); - - DryingBasinDataProvider dryingBasinDataProvider = new DryingBasinDataProvider(); - registrar.registerBlockDataProvider(dryingBasinDataProvider, BlockEntityDryingBasin.class); - registrar.registerComponentProvider(dryingBasinDataProvider, TooltipPosition.BODY, BlockEntityDryingBasin.class); - - MechanicalSqueezerDataProvider mechanicalSqueezerDataProvider = new MechanicalSqueezerDataProvider(); - registrar.registerBlockDataProvider(mechanicalSqueezerDataProvider, BlockEntityMechanicalSqueezer.class); - registrar.registerComponentProvider(mechanicalSqueezerDataProvider, TooltipPosition.BODY, BlockEntityMechanicalSqueezer.class); - - MechanicalDryingBasinDataProvider mechanicalDryingBasinDataProvider = new MechanicalDryingBasinDataProvider(); - registrar.registerBlockDataProvider(mechanicalDryingBasinDataProvider, BlockEntityMechanicalDryingBasin.class); - registrar.registerComponentProvider(mechanicalDryingBasinDataProvider, TooltipPosition.BODY, BlockEntityMechanicalDryingBasin.class); - - ProxyDataProvider proxyDataProvider = new ProxyDataProvider(); - registrar.registerBlockDataProvider(proxyDataProvider, BlockEntityProxy.class); - registrar.registerComponentProvider(proxyDataProvider, TooltipPosition.BODY, BlockEntityProxy.class); - } - -} diff --git a/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json b/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json index b5de8a7c..4d305cb6 100644 --- a/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json +++ b/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json @@ -17,6 +17,12 @@ "gui.integrateddynamics.waila.fluid.in": "Input Fluid: %s (%s mB)", "gui.integrateddynamics.waila.fluid.out": "Input Fluid: %s (%s mB)", "gui.integrateddynamics.waila.progress": "Progress: %s / 100", + "config.jade.plugin_integrateddynamicscompat.squeezer": "Squeezer", + "config.jade.plugin_integrateddynamicscompat.drying_basin": "Drying Basin", + "config.jade.plugin_integrateddynamicscompat.mechanical_squeezer": "Mechanical Squeezer", + "config.jade.plugin_integrateddynamicscompat.mechanical_drying_basin": "Mechanical Drying Basin", + "config.jade.plugin_integrateddynamicscompat.proxy": "Proxy", + "config.jade.plugin_integrateddynamicscompat.part": "Part", "_comment": "# ----- JEI ----- ##", From 4bd775ce706e2701c2200c07b0381c99d89797ae Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 5 Dec 2024 15:31:31 +0100 Subject: [PATCH 3/6] Restore Refined Storage integration --- build.gradle | 4 +--- gradle.properties | 2 +- .../IntegratedDynamicsCompat.java | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 0715a7ca..e67739b2 100644 --- a/build.gradle +++ b/build.gradle @@ -150,6 +150,7 @@ dependencies { /*runtimeOnly(fg.deobf("com.refinedmods:refinedstorage:${project.refinedstorage_version}")) { // https://repo.refinedmods.com/com/refinedmods/refinedstorage/ transitive = false }*/ + implementation fg.deobf("curse.maven:refinedstorage-243076:${refinedstorage_version}") implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${project.terrablender_version}") @@ -327,8 +328,6 @@ sourceSets { exclude '**/modcompat/tconstruct/**' exclude '**/modcompat/tesla/**' exclude '**/modcompat/thaumcraft/**' - exclude '**/modcompat/waila/**' - exclude '**/modcompat/refinedstorage/**' } } } @@ -348,7 +347,6 @@ spotless { exclude '**/modcompat/tconstruct/**' exclude '**/modcompat/tesla/**' exclude '**/modcompat/thaumcraft/**' - exclude '**/modcompat/refinedstorage/**' } endWithNewline() diff --git a/gradle.properties b/gradle.properties index 8b0badf3..b2e1716a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ forestry_version=1.12:5.4.3.129 charset_version=0.4.0-pre10 IC2_version=2.8.7-ex112 theoneprobe_version=1.19-6.2.0-6 -refinedstorage_version=1.10.2 +refinedstorage_version=4861827 ie_version=0.12-90-521 crafttweakerapi_version=4.1.6.457 crafttweakermain_version=1.12-4.1.6.457 diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java index cc9ea72d..313ea87c 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java @@ -9,15 +9,12 @@ import org.cyclops.cyclopscore.modcompat.ModCompatLoader; import org.cyclops.cyclopscore.proxy.IClientProxy; import org.cyclops.cyclopscore.proxy.ICommonProxy; -import org.cyclops.integrateddynamics.blockentity.BlockEntityCoalGenerator; -import org.cyclops.integrateddynamics.blockentity.BlockEntityDryingBasin; -import org.cyclops.integrateddynamics.blockentity.BlockEntityMechanicalDryingBasin; -import org.cyclops.integrateddynamics.blockentity.BlockEntityMechanicalSqueezer; -import org.cyclops.integrateddynamics.blockentity.BlockEntitySqueezer; +import org.cyclops.integrateddynamics.blockentity.*; import org.cyclops.integrateddynamicscompat.modcompat.capabilities.WorkerCoalGeneratorBlockEntityCompat; import org.cyclops.integrateddynamicscompat.modcompat.capabilities.WorkerDryingBasinBlockEntityCompat; import org.cyclops.integrateddynamicscompat.modcompat.capabilities.WorkerMechanicalMachineBlockEntityCompat; import org.cyclops.integrateddynamicscompat.modcompat.capabilities.WorkerSqueezerBlockEntityCompat; +import org.cyclops.integrateddynamicscompat.modcompat.refinedstorage.RefinedStorageModCompat; import org.cyclops.integrateddynamicscompat.modcompat.terrablender.TerrablenderCompat; import org.cyclops.integrateddynamicscompat.modcompat.top.TopModCompat; import org.cyclops.integrateddynamicscompat.proxy.ClientProxy; @@ -42,9 +39,9 @@ protected void loadModCompats(ModCompatLoader modCompatLoader) { super.loadModCompats(modCompatLoader); modCompatLoader.addModCompat(new TopModCompat()); modCompatLoader.addModCompat(new TerrablenderCompat()); + modCompatLoader.addModCompat(new RefinedStorageModCompat()); // TODO: temporarily disable some mod compats // Mod compats -// modCompatLoader.addModCompat(new RefinedStorageModCompat()); // modCompatLoader.addModCompat(new CharsetPipesModCompat()); // modCompatLoader.addModCompat(new McMultiPartModCompat()); // modCompatLoader.addModCompat(new ThaumcraftModCompat()); From 5e294299e666420c1bcc2f16f7cd95822af84654 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 5 Dec 2024 15:33:07 +0100 Subject: [PATCH 4/6] Remove old minetweaker and tesla code --- build.gradle | 4 - gradle.properties | 3 - .../IntegratedDynamicsCompat.java | 2 - .../minetweaker/CraftTweakerModCompat.java | 33 ---- .../handlers/DryingBasinHandler.java | 55 ------ .../MechanicalDryingBasinHandler.java | 55 ------ .../handlers/MechanicalSqueezerHandler.java | 181 ------------------ .../minetweaker/handlers/SqueezerHandler.java | 180 ----------------- .../modcompat/tesla/EnergyStorageTesla.java | 86 --------- .../modcompat/tesla/TeslaApiCompat.java | 162 ---------------- .../modcompat/tesla/aspect/TeslaAspects.java | 166 ---------------- .../TeslaConsumerEnergyBatteryTileCompat.java | 43 ----- ...eslaConsumerEnergyContainerItemCompat.java | 45 ----- .../TeslaHolderEnergyBatteryTileCompat.java | 48 ----- .../TeslaHolderEnergyContainerItemCompat.java | 50 ----- .../TeslaProducerCoalGeneratorTileCompat.java | 36 ---- .../TeslaProducerEnergyBatteryTileCompat.java | 43 ----- ...eslaProducerEnergyContainerItemCompat.java | 45 ----- .../tesla/operator/OperatorBuilders.java | 51 ----- 19 files changed, 1288 deletions(-) delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/CraftTweakerModCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/DryingBasinHandler.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalDryingBasinHandler.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalSqueezerHandler.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/SqueezerHandler.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/EnergyStorageTesla.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/TeslaApiCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/aspect/TeslaAspects.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyBatteryTileCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyContainerItemCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyBatteryTileCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyContainerItemCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerCoalGeneratorTileCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyBatteryTileCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyContainerItemCompat.java delete mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/operator/OperatorBuilders.java diff --git a/build.gradle b/build.gradle index e67739b2..69d4604d 100644 --- a/build.gradle +++ b/build.gradle @@ -323,10 +323,8 @@ sourceSets { exclude '**/modcompat/ic2/**' exclude '**/modcompat/immersiveengineering/**' exclude '**/modcompat/mcmultipart/**' - exclude '**/modcompat/minetweaker/**' exclude '**/modcompat/signals/**' exclude '**/modcompat/tconstruct/**' - exclude '**/modcompat/tesla/**' exclude '**/modcompat/thaumcraft/**' } } @@ -342,10 +340,8 @@ spotless { exclude '**/modcompat/ic2/**' exclude '**/modcompat/immersiveengineering/**' exclude '**/modcompat/mcmultipart/**' - exclude '**/modcompat/minetweaker/**' exclude '**/modcompat/signals/**' exclude '**/modcompat/tconstruct/**' - exclude '**/modcompat/tesla/**' exclude '**/modcompat/thaumcraft/**' } diff --git a/gradle.properties b/gradle.properties index b2e1716a..c00ab038 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,6 @@ commoncapabilities_version=1.19.2-2.9.0-88 mcmultipart_version=1.2.1_78 jei_version=1.19.2-forge:11.2.0.247 rfapi_version=1.8.9R1.2.0B1.1 -teslaapi_version=1.12.2:1.0.63 mantle_version=1.12-1.3.1.22 tconstruct_version=1.12-2.7.4.37 forestry_version=1.12:5.4.3.129 @@ -18,8 +17,6 @@ IC2_version=2.8.7-ex112 theoneprobe_version=1.19-6.2.0-6 refinedstorage_version=4861827 ie_version=0.12-90-521 -crafttweakerapi_version=4.1.6.457 -crafttweakermain_version=1.12-4.1.6.457 signals_version=1.12.2:1.1.0-2 terrablender_version=1.19.2-2.0.1.166 rei_version=9.2.779 diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java index 313ea87c..6d3da534 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/IntegratedDynamicsCompat.java @@ -48,9 +48,7 @@ protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new TConstructModCompat()); // modCompatLoader.addModCompat(new ForestryModCompat()); // modCompatLoader.addModCompat(new Ic2ModCompat()); -// modCompatLoader.addModCompat(new TeslaApiCompat()); // modCompatLoader.addModCompat(new ImmersiveEngineeringModCompat()); -// modCompatLoader.addModCompat(new CraftTweakerModCompat()); // modCompatLoader.addModCompat(new SignalsModCompat()); } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/CraftTweakerModCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/CraftTweakerModCompat.java deleted file mode 100644 index fcde36e2..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/CraftTweakerModCompat.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.minetweaker; - -import org.cyclops.cyclopscore.modcompat.IModCompat; -import org.cyclops.integrateddynamicscompat.Reference; - -/** - * Config for the JEI integration of this mod. - * @author rubensworks - * - */ -public class CraftTweakerModCompat implements IModCompat { - - @Override - public void onInit(Step initStep) { - - } - - @Override - public String getModID() { - return Reference.MOD_CRAFTTWEAKER; - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getComment() { - return "Integration for Integrated Dynamics recipes."; - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/DryingBasinHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/DryingBasinHandler.java deleted file mode 100644 index c6f1bd23..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/DryingBasinHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.minetweaker.handlers; - -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.liquid.ILiquidStack; -import org.cyclops.cyclopscore.modcompat.crafttweaker.handlers.RecipeRegistryHandler; -import org.cyclops.cyclopscore.recipe.custom.Recipe; -import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientAndFluidStackRecipeComponent; -import org.cyclops.integrateddynamics.block.BlockDryingBasin; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -@ZenClass("mods.integrateddynamics.DryingBasin") -@ZenRegister -public class DryingBasinHandler extends RecipeRegistryHandler { - - private static final DryingBasinHandler INSTANCE = new DryingBasinHandler(); - - @Override - protected BlockDryingBasin getMachine() { - return BlockDryingBasin.getInstance(); - } - - @Override - protected String getRegistryName() { - return "DryingBasin"; - } - - @ZenMethod - public static void addRecipe(@Optional IItemStack inputStack, @Optional ILiquidStack inputFluid, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - INSTANCE.add(new Recipe<>( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true, RecipeRegistryHandler.toFluid(inputFluid)), - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipe(@Optional IItemStack inputStack, @Optional ILiquidStack inputFluid, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - INSTANCE.remove(new Recipe<>( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true, RecipeRegistryHandler.toFluid(inputFluid)), - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack, @Optional ILiquidStack outputFluid) { - INSTANCE.remove( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)) - ); - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalDryingBasinHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalDryingBasinHandler.java deleted file mode 100644 index 185ebb4d..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalDryingBasinHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.minetweaker.handlers; - -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.liquid.ILiquidStack; -import org.cyclops.cyclopscore.modcompat.crafttweaker.handlers.RecipeRegistryHandler; -import org.cyclops.cyclopscore.recipe.custom.Recipe; -import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientAndFluidStackRecipeComponent; -import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasin; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -@ZenClass("mods.integrateddynamics.MechanicalDryingBasin") -@ZenRegister -public class MechanicalDryingBasinHandler extends RecipeRegistryHandler { - - private static final MechanicalDryingBasinHandler INSTANCE = new MechanicalDryingBasinHandler(); - - @Override - protected BlockMechanicalDryingBasin getMachine() { - return BlockMechanicalDryingBasin.getInstance(); - } - - @Override - protected String getRegistryName() { - return "MechanicalDryingBasin"; - } - - @ZenMethod - public static void addRecipe(@Optional IItemStack inputStack, @Optional ILiquidStack inputFluid, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - INSTANCE.add(new Recipe<>( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true, RecipeRegistryHandler.toFluid(inputFluid)), - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipe(@Optional IItemStack inputStack, @Optional ILiquidStack inputFluid, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - INSTANCE.remove(new Recipe<>( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true, RecipeRegistryHandler.toFluid(inputFluid)), - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack, @Optional ILiquidStack outputFluid) { - INSTANCE.remove( - new IngredientAndFluidStackRecipeComponent(RecipeRegistryHandler.toStack(outputStack), RecipeRegistryHandler.toFluid(outputFluid)) - ); - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalSqueezerHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalSqueezerHandler.java deleted file mode 100644 index acb3acd8..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/MechanicalSqueezerHandler.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.minetweaker.handlers; - -import com.google.common.collect.Lists; -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.liquid.ILiquidStack; -import net.minecraft.item.crafting.Ingredient; -import org.cyclops.cyclopscore.modcompat.crafttweaker.handlers.RecipeRegistryHandler; -import org.cyclops.cyclopscore.recipe.custom.Recipe; -import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientsAndFluidStackRecipeComponent; -import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezer; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -import java.util.List; - -@ZenClass("mods.integrateddynamics.MechanicalSqueezer") -@ZenRegister -public class MechanicalSqueezerHandler extends RecipeRegistryHandler { - - private static final MechanicalSqueezerHandler INSTANCE = new MechanicalSqueezerHandler(); - - @Override - protected BlockMechanicalSqueezer getMachine() { - return BlockMechanicalSqueezer.getInstance(); - } - - @Override - protected String getRegistryName() { - return "MechanicalSqueezer"; - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, - @Optional(valueLong = 10) int duration) { - addRecipe(inputStack, outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - addRecipe(inputStack, outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - addRecipe(inputStack, outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack1))); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack2))); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack3))); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.add(new Recipe<>( - new IngredientRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true), - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - removeRecipe(inputStack, outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - removeRecipe(inputStack, outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - removeRecipe(inputStack, outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid, duration); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid, @Optional(valueLong = 10) int duration) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack1))); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack2))); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack3))); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.remove(new Recipe<>( - new IngredientRecipeComponent(RecipeRegistryHandler.toStack(inputStack)), - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)), - new DurationRecipeProperties(duration))); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack, @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack1))); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack2))); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack3))); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.remove( - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)) - ); - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/SqueezerHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/SqueezerHandler.java deleted file mode 100644 index fecacc73..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/minetweaker/handlers/SqueezerHandler.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.minetweaker.handlers; - -import com.google.common.collect.Lists; -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.liquid.ILiquidStack; -import net.minecraft.item.crafting.Ingredient; -import org.cyclops.cyclopscore.modcompat.crafttweaker.handlers.RecipeRegistryHandler; -import org.cyclops.cyclopscore.recipe.custom.Recipe; -import org.cyclops.cyclopscore.recipe.custom.component.DummyPropertiesComponent; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent; -import org.cyclops.cyclopscore.recipe.custom.component.IngredientsAndFluidStackRecipeComponent; -import org.cyclops.integrateddynamics.block.BlockSqueezer; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -import java.util.List; - -@ZenClass("mods.integrateddynamics.Squeezer") -@ZenRegister -public class SqueezerHandler extends RecipeRegistryHandler { - - private static final SqueezerHandler INSTANCE = new SqueezerHandler(); - - @Override - protected BlockSqueezer getMachine() { - return BlockSqueezer.getInstance(); - } - - @Override - protected String getRegistryName() { - return "Squeezer"; - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid) { - addRecipe(inputStack, outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid) { - addRecipe(inputStack, outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid) { - addRecipe(inputStack, outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void addRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(RecipeRegistryHandler.toStack(outputStack1)); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(RecipeRegistryHandler.toStack(outputStack2)); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(RecipeRegistryHandler.toStack(outputStack3)); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.add(new Recipe<>( - new IngredientRecipeComponent(RecipeRegistryHandler.toStack(inputStack), true), - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)), - new DummyPropertiesComponent())); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - @Optional IItemStack outputStack, @Optional ILiquidStack outputFluid) { - removeRecipe(inputStack, outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid) { - removeRecipe(inputStack, outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid) { - removeRecipe(inputStack, outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipe(IItemStack inputStack, - IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack1))); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack2))); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack3))); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.remove(new Recipe<>( - new IngredientRecipeComponent(RecipeRegistryHandler.toStack(inputStack)), - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)), - new DummyPropertiesComponent())); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack, @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack, 1.0F, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack1, outputStackChance1, null, 1.0F, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - @Optional ILiquidStack outputFluid) { - removeRecipesWithOutput(outputStack1, outputStackChance1, outputStack2, outputStackChance2, null, 1.0F, outputFluid); - } - - @ZenMethod - public static void removeRecipesWithOutput(IItemStack outputStack1, float outputStackChance1, - IItemStack outputStack2, float outputStackChance2, - IItemStack outputStack3, float outputStackChance3, - @Optional ILiquidStack outputFluid) { - List outputComponents = Lists.newArrayList(); - if (outputStack1 != null) { - IngredientRecipeComponent outputComponent1 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack1))); - outputComponent1.setChance(outputStackChance1); - outputComponents.add(outputComponent1); - } - if (outputStack2 != null) { - IngredientRecipeComponent outputComponent2 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack2))); - outputComponent2.setChance(outputStackChance2); - outputComponents.add(outputComponent2); - } - if (outputStack3 != null) { - IngredientRecipeComponent outputComponent3 = new IngredientRecipeComponent(Ingredient.fromStacks(RecipeRegistryHandler.toStack(outputStack3))); - outputComponent3.setChance(outputStackChance3); - outputComponents.add(outputComponent3); - } - - INSTANCE.remove( - new IngredientsAndFluidStackRecipeComponent(outputComponents, RecipeRegistryHandler.toFluid(outputFluid)) - ); - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/EnergyStorageTesla.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/EnergyStorageTesla.java deleted file mode 100644 index e8c5814b..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/EnergyStorageTesla.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.darkhax.tesla.api.ITeslaHolder; -import net.darkhax.tesla.api.ITeslaProducer; -import net.darkhax.tesla.capability.TeslaCapabilities; -import net.minecraft.core.Direction; -import net.minecraft.core.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.energy.IEnergyStorage; -import org.cyclops.cyclopscore.helper.BlockEntityHelpers; - -import IBlockAccess; -import ITeslaConsumer; -import ITeslaHolder; -import ITeslaProducer; - -/** - * Energy Storage wrapper for Tesla. - * @author rubensworks - */ -public class EnergyStorageTesla implements IEnergyStorage { - - private final IBlockAccess world; - private final BlockPos pos; - private final Direction facing; - - private ITeslaHolder energyStorage = null; - private ITeslaConsumer energyReceiver = null; - private ITeslaProducer energyProvider = null; - - public EnergyStorageTesla(IBlockAccess world, BlockPos pos, Direction facing) { - this.world = world; - this.pos = pos; - this.facing = facing; - } - - protected ITeslaHolder getEnergyStorage() { - if (energyStorage != null) return energyStorage; - return energyStorage = BlockEntityHelpers.getCapability(world, pos, facing, TeslaCapabilities.CAPABILITY_HOLDER); - } - - protected ITeslaConsumer getEnergyReceiver() { - if (energyReceiver != null) return energyReceiver; - return energyReceiver = BlockEntityHelpers.getCapability(world, pos, facing, TeslaCapabilities.CAPABILITY_CONSUMER); - } - - protected ITeslaProducer getEnergyProvider() { - if (energyProvider != null) return energyProvider; - return energyProvider = BlockEntityHelpers.getCapability(world, pos, facing, TeslaCapabilities.CAPABILITY_PRODUCER); - } - - @Override - public int receiveEnergy(int maxReceive, boolean simulate) { - ITeslaConsumer energyReceiver = getEnergyReceiver(); - return energyReceiver != null ? (int) energyReceiver.givePower(maxReceive, simulate) : 0; - } - - @Override - public int extractEnergy(int maxExtract, boolean simulate) { - ITeslaProducer energyProvider = getEnergyProvider(); - return energyProvider != null ? (int) energyProvider.takePower(maxExtract, simulate) : 0; - } - - @Override - public int getEnergyStored() { - ITeslaHolder energyStorage = getEnergyStorage(); - return energyStorage != null ? (int) Math.min(Integer.MAX_VALUE, energyStorage.getStoredPower()) : 0; - } - - @Override - public int getMaxEnergyStored() { - ITeslaHolder energyStorage = getEnergyStorage(); - return energyStorage != null ? (int) Math.min(Integer.MAX_VALUE, energyStorage.getCapacity()) : 0; - } - - @Override - public boolean canExtract() { - return getEnergyProvider() != null; - } - - @Override - public boolean canReceive() { - return getEnergyReceiver() != null; - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/TeslaApiCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/TeslaApiCompat.java deleted file mode 100644 index 4504dadd..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/TeslaApiCompat.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla; - -import com.google.common.collect.Lists; -import net.darkhax.tesla.api.ITeslaConsumer; -import net.darkhax.tesla.api.ITeslaHolder; -import net.darkhax.tesla.api.ITeslaProducer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.energy.IEnergyStorage; -import org.cyclops.cyclopscore.modcompat.IModCompat; -import org.cyclops.integrateddynamics.Reference; -import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; -import org.cyclops.integrateddynamics.api.part.aspect.IAspect; -import org.cyclops.integrateddynamics.core.evaluate.IOperatorValuePropagator; -import org.cyclops.integrateddynamics.core.evaluate.operator.Operators; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes; -import org.cyclops.integrateddynamics.core.helper.EnergyHelpers; -import org.cyclops.integrateddynamics.core.part.PartTypes; -import org.cyclops.integrateddynamicscompat.modcompat.tesla.aspect.TeslaAspects; -import org.cyclops.integrateddynamicscompat.modcompat.tesla.operator.OperatorBuilders; -import org.cyclops.integrateddynamics.part.aspect.Aspects; - -import javax.annotation.Nullable; - -/** - * Mod compat for the Tesla API. - * @author rubensworks - * - */ -public class TeslaApiCompat implements IModCompat { - - @Override - public void onInit(final Step initStep) { - if(initStep == Step.PREINIT) { - // Aspects - Aspects.REGISTRY.register(PartTypes.MACHINE_READER, Lists.newArrayList( - TeslaAspects.Read.Energy.BOOLEAN_ISAPPLICABLE, - TeslaAspects.Read.Energy.BOOLEAN_ISRECEIVER, - TeslaAspects.Read.Energy.BOOLEAN_ISPROVIDER, - TeslaAspects.Read.Energy.BOOLEAN_CANEXTRACT, - TeslaAspects.Read.Energy.BOOLEAN_CANINSERT, - TeslaAspects.Read.Energy.BOOLEAN_ISFULL, - TeslaAspects.Read.Energy.BOOLEAN_ISEMPTY, - TeslaAspects.Read.Energy.BOOLEAN_ISNONEMPTY, - TeslaAspects.Read.Energy.LONG_STORED, - TeslaAspects.Read.Energy.LONG_CAPACITY, - TeslaAspects.Read.Energy.DOUBLE_FILLRATIO, - TeslaAspects.Read.Energy.STRING_STORED, - TeslaAspects.Read.Energy.STRING_CAPACITY - )); - - // Operators - /* Check if the item is a Tesla container item */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_container").operatorName("isteslacontainer") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder input) throws EvaluationException { - return input != null; - } - })).build()); - - /* Get the storage energy */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.LONG).symbol("stored_tesla").operatorName("teslastored") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_LONG.build(new IOperatorValuePropagator() { - @Override - public Long getOutput(ITeslaHolder input) throws EvaluationException { - return input != null ? input.getStoredPower() : 0; - } - })).build()); - /* Get the energy capacity */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.LONG).symbol("capacity_tesla").operatorName("teslacapacity") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_LONG.build(new IOperatorValuePropagator() { - @Override - public Long getOutput(ITeslaHolder input) throws EvaluationException { - return input != null ? input.getCapacity() : 0; - } - })).build()); - /* If the item is an energy receiver */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_receiver").operatorName("isteslareceiver") - .function(OperatorBuilders.FUNCTION_CONSUMER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaConsumer input) throws EvaluationException { - return input != null; - } - })).build()); - /* If the item is an energy provider */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_provider").operatorName("isteslaprovider") - .function(OperatorBuilders.FUNCTION_PRODUCER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaProducer input) throws EvaluationException { - return input != null; - } - })).build()); - /* If the item is full */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_full").operatorName("isteslafull") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder input) throws EvaluationException { - return input != null && input.getStoredPower() == input.getCapacity(); - } - })).build()); - /* If the item is empty */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_empty").operatorName("isteslaempty") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder input) throws EvaluationException { - return input != null && input.getStoredPower() == 0; - } - })).build()); - /* If the item is not empty */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.BOOLEAN).symbol("is_tesla_nonempty").operatorName("isteslanonempty") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_BOOLEAN.build(new IOperatorValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder input) throws EvaluationException { - return input != null && input.getStoredPower() != 0; - } - })).build()); - /* The fill ratio */ - Operators.REGISTRY.register(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG - .output(ValueTypes.DOUBLE).symbol("tesla_fill_ratio").operatorName("teslafillratio") - .function(OperatorBuilders.FUNCTION_HOLDER_TO_DOUBLE.build(new IOperatorValuePropagator() { - @Override - public Double getOutput(ITeslaHolder input) throws EvaluationException { - return input != null ? (((double) input.getStoredPower()) / input.getCapacity()) : 0.0D; - } - })).build()); - - EnergyHelpers.addEnergyStorageProxy(new EnergyHelpers.IEnergyStorageProxy() { - @Nullable - @Override - public IEnergyStorage getEnergyStorageProxy(IBlockAccess world, BlockPos pos, Direction facing) { - return new EnergyStorageTesla(world, pos, facing); - } - }); - } - } - - @Override - public String getModID() { - return Reference.MOD_TESLA; - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getComment() { - return "Tesla readers aspects and operators."; - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/aspect/TeslaAspects.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/aspect/TeslaAspects.java deleted file mode 100644 index dac38dd3..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/aspect/TeslaAspects.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.aspect; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.darkhax.tesla.api.ITeslaHolder; -import net.darkhax.tesla.api.ITeslaProducer; -import net.darkhax.tesla.lib.TeslaUtils; -import org.apache.commons.lang3.tuple.Pair; -import org.cyclops.cyclopscore.datastructure.DimPos; -import org.cyclops.cyclopscore.helper.BlockEntityHelpers; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.api.part.PartTarget; -import org.cyclops.integrateddynamics.api.part.aspect.IAspectRead; -import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeBoolean; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeDouble; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeLong; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeString; -import org.cyclops.integrateddynamics.core.part.aspect.build.AspectBuilder; -import org.cyclops.integrateddynamics.core.part.aspect.build.IAspectValuePropagator; -import org.cyclops.integrateddynamics.part.aspect.read.AspectReadBuilders; - -/** - * Builders for RF API aspects - * @author rubensworks - */ -public class TeslaAspects { - - public static final class Read { - - public static final class Energy { - - public static final IAspectValuePropagator, ITeslaConsumer> PROP_GET_RECEIVER = new IAspectValuePropagator, ITeslaConsumer>() { - @Override - public ITeslaConsumer getOutput(Pair input) { - DimPos pos = input.getLeft().getTarget().getPos(); - return BlockEntityHelpers.getCapability(pos, input.getLeft().getTarget().getSide(), Capabilities.TESLA_CONSUMER); - } - }; - public static final IAspectValuePropagator, ITeslaProducer> PROP_GET_PROVIDER = new IAspectValuePropagator, ITeslaProducer>() { - @Override - public ITeslaProducer getOutput(Pair input) { - DimPos pos = input.getLeft().getTarget().getPos(); - return BlockEntityHelpers.getCapability(pos, input.getLeft().getTarget().getSide(), Capabilities.TESLA_PRODUCER); - } - }; - public static final IAspectValuePropagator, ITeslaHolder> PROP_GET_HOLDER = new IAspectValuePropagator, ITeslaHolder>() { - @Override - public ITeslaHolder getOutput(Pair input) { - DimPos pos = input.getLeft().getTarget().getPos(); - return BlockEntityHelpers.getCapability(pos, input.getLeft().getTarget().getSide(), Capabilities.TESLA_HOLDER); - } - }; - - public static final AspectBuilder - BUILDER_BOOLEAN_RECEIVER = AspectReadBuilders.BUILDER_BOOLEAN.handle(PROP_GET_RECEIVER, "tesla"); - public static final AspectBuilder - BUILDER_BOOLEAN_PROVIDER = AspectReadBuilders.BUILDER_BOOLEAN.handle(PROP_GET_PROVIDER, "tesla"); - public static final AspectBuilder - BUILDER_BOOLEAN_HOLDER = AspectReadBuilders.BUILDER_BOOLEAN.handle(PROP_GET_HOLDER, "tesla"); - public static final AspectBuilder - BUILDER_LONG_HOLDER = AspectReadBuilders.BUILDER_LONG.handle(PROP_GET_HOLDER, "tesla"); - public static final AspectBuilder - BUILDER_DOUBLE_HOLDER = AspectReadBuilders.BUILDER_DOUBLE.handle(PROP_GET_HOLDER, "tesla"); - public static final AspectBuilder - BUILDER_STRING_HOLDER = AspectReadBuilders.BUILDER_STRING.handle(PROP_GET_HOLDER, "tesla"); - - public static final IAspectRead BOOLEAN_ISAPPLICABLE = - BUILDER_BOOLEAN_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder data) { - return data != null; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "applicable").buildRead(); - public static final IAspectRead BOOLEAN_ISRECEIVER = - BUILDER_BOOLEAN_RECEIVER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaConsumer data) { - return data != null; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "isreceiver").buildRead(); - public static final IAspectRead BOOLEAN_ISPROVIDER = - BUILDER_BOOLEAN_PROVIDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaProducer data) { - return data != null; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "isprovider").buildRead(); - public static final IAspectRead BOOLEAN_CANEXTRACT = - BUILDER_BOOLEAN_PROVIDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaProducer data) { - return data != null && data.takePower(1, true) == 1; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "canextract").buildRead(); - public static final IAspectRead BOOLEAN_CANINSERT = - BUILDER_BOOLEAN_RECEIVER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaConsumer data) { - return data != null && data.givePower(1, true) == 1; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "caninsert").buildRead(); - public static final IAspectRead BOOLEAN_ISFULL = - BUILDER_BOOLEAN_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder data) { - return data != null && data.getStoredPower() == data.getStoredPower(); - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "isfull").buildRead(); - public static final IAspectRead BOOLEAN_ISEMPTY = - BUILDER_BOOLEAN_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder data) { - return data != null && data.getStoredPower() == 0; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "isempty").buildRead(); - public static final IAspectRead BOOLEAN_ISNONEMPTY = - BUILDER_BOOLEAN_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Boolean getOutput(ITeslaHolder data) { - return data != null && data.getStoredPower() != 0; - } - }).handle(AspectReadBuilders.PROP_GET_BOOLEAN, "isnonempty").buildRead(); - - public static final IAspectRead LONG_STORED = - BUILDER_LONG_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Long getOutput(ITeslaHolder data) { - return data != null ? data.getStoredPower() : 0; - } - }).handle(AspectReadBuilders.PROP_GET_LONG, "amount").buildRead(); - public static final IAspectRead LONG_CAPACITY = - BUILDER_LONG_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Long getOutput(ITeslaHolder data) { - return data != null ? data.getCapacity() : 0; - } - }).handle(AspectReadBuilders.PROP_GET_LONG, "capacity").buildRead(); - - public static final IAspectRead DOUBLE_FILLRATIO = - BUILDER_DOUBLE_HOLDER.handle(new IAspectValuePropagator() { - @Override - public Double getOutput(ITeslaHolder data) { - return data != null ? (((double) data.getStoredPower()) / data.getCapacity()) : 0.0D; - } - }).handle(AspectReadBuilders.PROP_GET_DOUBLE, "fillratio").buildRead(); - - public static final IAspectRead STRING_STORED = - BUILDER_STRING_HOLDER.handle(new IAspectValuePropagator() { - @Override - public String getOutput(ITeslaHolder data) { - return TeslaUtils.getDisplayableTeslaCount(data != null ? data.getStoredPower() : 0); - } - }).handle(AspectReadBuilders.PROP_GET_STRING, "amount").buildRead(); - public static final IAspectRead STRING_CAPACITY = - BUILDER_STRING_HOLDER.handle(new IAspectValuePropagator() { - @Override - public String getOutput(ITeslaHolder data) { - return TeslaUtils.getDisplayableTeslaCount(data != null ? data.getCapacity() : 0); - } - }).handle(AspectReadBuilders.PROP_GET_STRING, "capacity").buildRead(); - - } - - } - -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyBatteryTileCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyBatteryTileCompat.java deleted file mode 100644 index b8f38d0a..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyBatteryTileCompat.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.tileentity.BlockEntityEnergyBattery; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery tesla consumer capability. - * @author rubensworks - */ -public class TeslaConsumerEnergyBatteryBlockEntityCompat extends SimpleCapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_CONSUMER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(BlockEntityEnergyBattery host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_CONSUMER, new TeslaConsumer(host)); - } - - public static class TeslaConsumer implements ITeslaConsumer { - - private final BlockEntityEnergyBattery provider; - - public TeslaConsumer(BlockEntityEnergyBattery provider) { - this.provider = provider; - } - - @Override - public long givePower(long power, boolean simulated) { - return provider.receiveEnergy((int) Math.min(power, Integer.MAX_VALUE), simulated); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyContainerItemCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyContainerItemCompat.java deleted file mode 100644 index 29b711d6..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaConsumerEnergyContainerItemCompat.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.CapabilityEnergy; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.core.item.ItemBlockEnergyContainer; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery item tesla holder capability. - * @author rubensworks - */ -public class TeslaConsumerEnergyContainerItemCompat implements ICapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_CONSUMER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(ItemBlockEnergyContainer hostType, ItemStack host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_CONSUMER, new TeslaHolder(host)); - } - - public static class TeslaHolder implements ITeslaConsumer { - - private final ItemStack provider; - - public TeslaHolder(ItemStack provider) { - this.provider = provider; - } - - @Override - public long givePower(long power, boolean simulated) { - return provider.getCapability(CapabilityEnergy.ENERGY, null).receiveEnergy((int) Math.min(power, Integer.MAX_VALUE), simulated); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyBatteryTileCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyBatteryTileCompat.java deleted file mode 100644 index 359c7fce..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyBatteryTileCompat.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaHolder; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.tileentity.BlockEntityEnergyBattery; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery tesla holder capability. - * @author rubensworks - */ -public class TeslaHolderEnergyBatteryBlockEntityCompat extends SimpleCapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_HOLDER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(BlockEntityEnergyBattery host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_HOLDER, new TeslaHolder(host)); - } - - public static class TeslaHolder implements ITeslaHolder { - - private final BlockEntityEnergyBattery provider; - - public TeslaHolder(BlockEntityEnergyBattery provider) { - this.provider = provider; - } - - @Override - public long getStoredPower() { - return provider.getEnergyStored(); - } - - @Override - public long getCapacity() { - return provider.getMaxEnergyStored(); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyContainerItemCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyContainerItemCompat.java deleted file mode 100644 index 22a5b14a..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaHolderEnergyContainerItemCompat.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaHolder; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.CapabilityEnergy; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.core.item.ItemBlockEnergyContainer; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery item tesla holder capability. - * @author rubensworks - */ -public class TeslaHolderEnergyContainerItemCompat implements ICapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_HOLDER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(ItemBlockEnergyContainer hostType, ItemStack host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_HOLDER, new TeslaHolder(host)); - } - - public static class TeslaHolder implements ITeslaHolder { - - private final ItemStack provider; - - public TeslaHolder(ItemStack provider) { - this.provider = provider; - } - - @Override - public long getStoredPower() { - return provider.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored(); - } - - @Override - public long getCapacity() { - return provider.getCapability(CapabilityEnergy.ENERGY, null).getMaxEnergyStored(); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerCoalGeneratorTileCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerCoalGeneratorTileCompat.java deleted file mode 100644 index bd2c7822..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerCoalGeneratorTileCompat.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaProducer; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.tileentity.BlockEntityCoalGenerator; - -import javax.annotation.Nullable; - -/** - * Compatibility for coal generator tesla producer capability. - * @author rubensworks - */ -public class TeslaProducerCoalGeneratorBlockEntityCompat extends SimpleCapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_PRODUCER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(BlockEntityCoalGenerator host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_PRODUCER, new TeslaProducer()); - } - - public static class TeslaProducer implements ITeslaProducer { - @Override - public long takePower(long power, boolean simulated) { - return 0; - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyBatteryTileCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyBatteryTileCompat.java deleted file mode 100644 index 566d80e3..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyBatteryTileCompat.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaProducer; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.tileentity.BlockEntityEnergyBattery; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery tesla producer capability. - * @author rubensworks - */ -public class TeslaProducerEnergyBatteryBlockEntityCompat extends SimpleCapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_PRODUCER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(BlockEntityEnergyBattery host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_PRODUCER, new TeslaProducer(host)); - } - - public static class TeslaProducer implements ITeslaProducer { - - private final BlockEntityEnergyBattery provider; - - public TeslaProducer(BlockEntityEnergyBattery provider) { - this.provider = provider; - } - - @Override - public long takePower(long power, boolean simulated) { - return provider.extractEnergy((int) Math.min(power, Integer.MAX_VALUE), simulated); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyContainerItemCompat.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyContainerItemCompat.java deleted file mode 100644 index 3653b280..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/capabilities/TeslaProducerEnergyContainerItemCompat.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.capabilities; - -import net.darkhax.tesla.api.ITeslaProducer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.CapabilityEnergy; -import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; -import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.core.item.ItemBlockEnergyContainer; - -import javax.annotation.Nullable; - -/** - * Compatibility for energy battery item tesla holder capability. - * @author rubensworks - */ -public class TeslaProducerEnergyContainerItemCompat implements ICapabilityConstructor { - - @Override - public Capability getCapability() { - return Capabilities.TESLA_PRODUCER; - } - - @Nullable - @Override - public ICapabilityProvider createProvider(ItemBlockEnergyContainer hostType, ItemStack host) { - return new DefaultCapabilityProvider<>(Capabilities.TESLA_PRODUCER, new TeslaHolder(host)); - } - - public static class TeslaHolder implements ITeslaProducer { - - private final ItemStack provider; - - public TeslaHolder(ItemStack provider) { - this.provider = provider; - } - - @Override - public long takePower(long power, boolean simulated) { - return provider.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy((int) Math.min(power, Integer.MAX_VALUE), simulated); - } - } -} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/operator/OperatorBuilders.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/operator/OperatorBuilders.java deleted file mode 100644 index 71150ce5..00000000 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/tesla/operator/OperatorBuilders.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.cyclops.integrateddynamicscompat.modcompat.tesla.operator; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.darkhax.tesla.api.ITeslaHolder; -import net.darkhax.tesla.api.ITeslaProducer; -import net.minecraftforge.common.capabilities.Capability; -import org.cyclops.integrateddynamicscompat.Capabilities; -import org.cyclops.integrateddynamics.api.evaluate.variable.IValue; -import org.cyclops.integrateddynamics.core.evaluate.operator.IterativeFunction; - -/** - * Collection of rf operator builders. - * @author rubensworks - */ -public class OperatorBuilders { - - // --------------- Aspect builders --------------- - public static final IterativeFunction.PrePostBuilder FUNCTION_HOLDER = - org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.getItemCapability(new org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ICapabilityReference() { - @Override - public Capability getReference() { - return Capabilities.TESLA_HOLDER; - } - }); - public static final IterativeFunction.PrePostBuilder FUNCTION_CONSUMER = - org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.getItemCapability(new org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ICapabilityReference() { - @Override - public Capability getReference() { - return Capabilities.TESLA_CONSUMER; - } - }); - public static final IterativeFunction.PrePostBuilder FUNCTION_PRODUCER = - org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.getItemCapability(new org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.ICapabilityReference() { - @Override - public Capability getReference() { - return Capabilities.TESLA_PRODUCER; - } - }); - - public static final IterativeFunction.PrePostBuilder FUNCTION_HOLDER_TO_LONG = - FUNCTION_HOLDER.appendPost(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.PROPAGATOR_LONG_VALUE); - public static final IterativeFunction.PrePostBuilder FUNCTION_HOLDER_TO_BOOLEAN = - FUNCTION_HOLDER.appendPost(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.PROPAGATOR_BOOLEAN_VALUE); - public static final IterativeFunction.PrePostBuilder FUNCTION_HOLDER_TO_DOUBLE = - FUNCTION_HOLDER.appendPost(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.PROPAGATOR_DOUBLE_VALUE); - public static final IterativeFunction.PrePostBuilder FUNCTION_CONSUMER_TO_BOOLEAN = - FUNCTION_CONSUMER.appendPost(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.PROPAGATOR_BOOLEAN_VALUE); - public static final IterativeFunction.PrePostBuilder FUNCTION_PRODUCER_TO_BOOLEAN = - FUNCTION_PRODUCER.appendPost(org.cyclops.integrateddynamics.core.evaluate.OperatorBuilders.PROPAGATOR_BOOLEAN_VALUE); - -} From 3f554b17bca59fe0173645f807201c4aa9168220 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 6 Dec 2024 09:02:20 +0100 Subject: [PATCH 5/6] Fix Jade not showing part name --- .../modcompat/jade/PartDataProvider.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java index f6a287cc..065f52b3 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jade/PartDataProvider.java @@ -4,6 +4,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; @@ -46,6 +47,7 @@ public void appendServerData(CompoundTag tag, ServerPlayer player, Level world, IPartType partType = partContainer.getPart(side); IPartState partState = partContainer.getPartState(side); List tooltip = Lists.newArrayList(); + tooltip.add(Component.translatable(partType.getTranslationKey())); partType.loadTooltip(partState, tooltip); NBTClassType.getClassType(List.class).writePersistedField("tooltip", tooltip, tag); } From 6e2df56748233842055a9d35aadd5d6c619965eb Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 6 Dec 2024 14:54:49 +0100 Subject: [PATCH 6/6] Add dedicated REI support, Closes CyclopsMC/IntegratedDynamics#1348 --- build.gradle | 8 +- .../GeneralConfig.java | 3 + .../modcompat/common/JeiReiHelpers.java | 59 +++++++++ .../jei/JEIIntegratedDynamicsConfig.java | 28 +---- .../DryingBasinRecipeCategory.java | 4 +- ...LogicProgrammerGhostIngredientHandler.java | 18 +-- .../LogicProgrammerTransferHandler.java | 14 +-- .../MechanicalDryingBasinRecipeCategory.java | 6 +- .../MechanicalSqueezerRecipeCategory.java | 8 +- .../rei/ReiIntegratedDynamicsConfig.java | 86 +++++++++++++ .../dryingbasin/ReiDryingBasinCategory.java | 91 ++++++++++++++ .../rei/dryingbasin/ReiDryingBasinRecipe.java | 50 ++++++++ .../ReiDraggableStackVisitor.java | 97 +++++++++++++++ .../ReiLogicProgrammerTransferHandler.java | 114 ++++++++++++++++++ .../ReiMechanicalDryingBasinCategory.java | 95 +++++++++++++++ .../ReiMechanicalDryingBasinRecipe.java | 50 ++++++++ .../ReiMechanicalSqueezerCategory.java | 106 ++++++++++++++++ .../ReiMechanicalSqueezerRecipe.java | 51 ++++++++ .../rei/squeezer/ReiSqueezerCategory.java | 98 +++++++++++++++ .../rei/squeezer/ReiSqueezerRecipe.java | 51 ++++++++ .../integrateddynamicscompat/lang/en_us.json | 1 + 21 files changed, 973 insertions(+), 65 deletions(-) create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/common/JeiReiHelpers.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/ReiIntegratedDynamicsConfig.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinCategory.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinRecipe.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiDraggableStackVisitor.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiLogicProgrammerTransferHandler.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinCategory.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinRecipe.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerCategory.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerRecipe.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerCategory.java create mode 100644 src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerRecipe.java diff --git a/build.gradle b/build.gradle index 69d4604d..1285745a 100644 --- a/build.gradle +++ b/build.gradle @@ -136,7 +136,7 @@ dependencies { exclude group: 'org.cyclops.cyclopscore', module: 'cyclopscore' } - implementation(fg.deobf("mezz.jei:jei-${project.jei_version}")) { // https://dvs1.progwml6.com/files/maven/mezz/jei/ + compileOnly(fg.deobf("mezz.jei:jei-${project.jei_version}")) { // https://dvs1.progwml6.com/files/maven/mezz/jei/ transitive = false } compileOnly "mcjty.theoneprobe:theoneprobe:${project.theoneprobe_version}" // https://maven.k-4u.nl/mcjty/theoneprobe/theoneprobe/ @@ -154,9 +154,9 @@ dependencies { implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${project.terrablender_version}") - compileOnly fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:${rei_version}") // https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-forge/ - compileOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:$cloth_config_version"); - compileOnly fg.deobf("dev.architectury:architectury-forge:$architectury_version"); + implementation fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:${rei_version}") // https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-forge/ + implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:$cloth_config_version"); + implementation fg.deobf("dev.architectury:architectury-forge:$architectury_version"); implementation fg.deobf("curse.maven:jade-324717:${jade_version}") } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/GeneralConfig.java b/src/main/java/org/cyclops/integrateddynamicscompat/GeneralConfig.java index f00d10f2..085e2b74 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/GeneralConfig.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/GeneralConfig.java @@ -17,6 +17,9 @@ public class GeneralConfig extends DummyConfig { @ConfigurableProperty(category = "core", comment = "If JEI recipe filling should heuristically try to determine item tags from recipes.", requiresMcRestart = true) public static boolean jeiHeuristicTags = true; + @ConfigurableProperty(category = "core", comment = "If REI recipe filling should heuristically try to determine item tags from recipes.", requiresMcRestart = true) + public static boolean reiHeuristicTags = true; + /** * Create a new instance. */ diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/common/JeiReiHelpers.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/common/JeiReiHelpers.java new file mode 100644 index 00000000..08a55691 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/common/JeiReiHelpers.java @@ -0,0 +1,59 @@ +package org.cyclops.integrateddynamicscompat.modcompat.common; + +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.registries.ForgeRegistries; +import org.cyclops.cyclopscore.helper.MinecraftHelpers; +import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenLogicProgrammerBase; +import org.cyclops.integrateddynamics.core.helper.L10NValues; +import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase; +import org.cyclops.integrateddynamicscompat.IntegratedDynamicsCompat; +import org.cyclops.integrateddynamicscompat.network.packet.CPacketSetSlot; + +import java.text.DecimalFormat; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author rubensworks + */ +public class JeiReiHelpers { + + public static ResourceLocation itemsToTag(List items) { + return ForgeRegistries.ITEMS.tags().stream() + .map(tag -> { + if (tag.stream().collect(Collectors.toList()).equals(items)) { + return Optional.of(tag.getKey().location()); + } + return Optional.empty(); + }) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst() + .orElse(null); + } + + public static void setStackInSlot(ContainerScreenLogicProgrammerBase screen, int slot, ItemStack itemStack) { + ContainerLogicProgrammerBase container = screen.getMenu(); + int slotPositionsCount = container.slots.size() - 36 - 4; /* subtract player inv, and 4 fixed slots in LP */ + int slotId = container.slots.size() - 36 - slotPositionsCount + slot; + container.setItem(slotId, 0, itemStack.copy()); + IntegratedDynamicsCompat._instance.getPacketHandler().sendToServer( + new CPacketSetSlot(container.containerId, slotId, itemStack)); + } + + public static MutableComponent getDurationSecondsTextComponent(int durationTicks) { + String seconds = new DecimalFormat("#.##").format((double) durationTicks / MinecraftHelpers.SECOND_IN_TICKS); + return Component.translatable("gui.integrateddynamics.jei.category.time.seconds", seconds); + } + + public static MutableComponent getEnergyTextComponent(int durationTicks, int energyPerTick) { + return Component.literal(String.format("%,d", durationTicks * energyPerTick)) + .append(Component.translatable(L10NValues.GENERAL_ENERGY_UNIT)); + } + +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/JEIIntegratedDynamicsConfig.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/JEIIntegratedDynamicsConfig.java index 4dd7eb5f..deb73e4e 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/JEIIntegratedDynamicsConfig.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/JEIIntegratedDynamicsConfig.java @@ -2,24 +2,12 @@ import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; -import mezz.jei.api.registration.IGuiHandlerRegistration; -import mezz.jei.api.registration.IRecipeCatalystRegistration; -import mezz.jei.api.registration.IRecipeCategoryRegistration; -import mezz.jei.api.registration.IRecipeRegistration; -import mezz.jei.api.registration.IRecipeTransferRegistration; +import mezz.jei.api.registration.*; import mezz.jei.api.runtime.IJeiRuntime; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import org.cyclops.cyclopscore.helper.MinecraftHelpers; import org.cyclops.integrateddynamics.RegistryEntries; -import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenLogicProgrammer; -import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenLogicProgrammerPortable; -import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenMechanicalDryingBasin; -import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenMechanicalSqueezer; -import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenOnTheDynamicsOfIntegration; -import org.cyclops.integrateddynamics.core.helper.L10NValues; +import org.cyclops.integrateddynamics.client.gui.container.*; import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammer; import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerPortable; import org.cyclops.integrateddynamics.inventory.container.ContainerMechanicalDryingBasin; @@ -36,8 +24,6 @@ import org.cyclops.integrateddynamicscompat.modcompat.jei.squeezer.SqueezerRecipeCategory; import org.cyclops.integrateddynamicscompat.modcompat.jei.squeezer.SqueezerRecipeJEI; -import java.text.DecimalFormat; - /** * Helper for registering JEI manager. * @author rubensworks @@ -98,14 +84,4 @@ public ResourceLocation getPluginUid() { public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { this.jeiRuntime = jeiRuntime; } - - public static MutableComponent getDurationSecondsTextComponent(int durationTicks) { - String seconds = new DecimalFormat("#.##").format((double) durationTicks / MinecraftHelpers.SECOND_IN_TICKS); - return Component.translatable("gui.jei.category.smelting.time.seconds", seconds); - } - - public static MutableComponent getEnergyTextComponent(int durationTicks, int energyPerTick) { - return Component.literal(String.format("%,d", durationTicks * energyPerTick)) - .append(Component.translatable(L10NValues.GENERAL_ENERGY_UNIT)); - } } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/dryingbasin/DryingBasinRecipeCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/dryingbasin/DryingBasinRecipeCategory.java index 3d14506b..36aebbd9 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/dryingbasin/DryingBasinRecipeCategory.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/dryingbasin/DryingBasinRecipeCategory.java @@ -21,7 +21,7 @@ import net.minecraft.world.item.ItemStack; import org.cyclops.integrateddynamics.RegistryEntries; import org.cyclops.integrateddynamicscompat.Reference; -import org.cyclops.integrateddynamicscompat.modcompat.jei.JEIIntegratedDynamicsConfig; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; import javax.annotation.Nonnull; @@ -90,7 +90,7 @@ public void draw(DryingBasinRecipeJEI recipe, IRecipeSlotsView recipeSlotsView, // Draw duration Font fontRenderer = Minecraft.getInstance().font; - MutableComponent duration = JEIIntegratedDynamicsConfig.getDurationSecondsTextComponent(recipe.getDuration()); + MutableComponent duration = JeiReiHelpers.getDurationSecondsTextComponent(recipe.getDuration()); fontRenderer.draw(matrixStack, duration, (background.getWidth() - fontRenderer.width(duration)) / 2 + 3, 42, 0xFF808080); } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerGhostIngredientHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerGhostIngredientHandler.java index 2b36cb8f..65c4f2c9 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerGhostIngredientHandler.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerGhostIngredientHandler.java @@ -5,8 +5,8 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; import org.apache.commons.compress.utils.Lists; @@ -14,8 +14,7 @@ import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement; import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenLogicProgrammerBase; import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase; -import org.cyclops.integrateddynamicscompat.IntegratedDynamicsCompat; -import org.cyclops.integrateddynamicscompat.network.packet.CPacketSetSlot; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; import java.util.List; @@ -38,7 +37,7 @@ public List> getTargets(T screen, I ingredient, boolean doStart) { } else if (ingredient instanceof FluidStack) { itemStack = new ItemStack(Items.BUCKET); IFluidHandlerItem fluidHandler = itemStack - .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) + .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) .orElseThrow(() -> new IllegalStateException("Could not find a fluid handler on the bucket item, some mod must be messing with things.")); fluidHandler.fill((FluidStack) ingredient, IFluidHandler.FluidAction.EXECUTE); itemStack = fluidHandler.getContainer(); @@ -68,7 +67,7 @@ public Rect2i getArea() { @Override public void accept(I ingredient) { - setStackInSlot(screen, finalSlot, finalItemStack); + JeiReiHelpers.setStackInSlot(screen, finalSlot, finalItemStack); } }); } @@ -88,13 +87,4 @@ public void onComplete() { public boolean shouldHighlightTargets() { return true; } - - protected void setStackInSlot(T screen, int slot, ItemStack itemStack) { - ContainerLogicProgrammerBase container = screen.getMenu(); - int slotPositionsCount = container.slots.size() - 36 - 4; /* subtract player inv, and 4 fixed slots in LP */ - int slotId = container.slots.size() - 36 - slotPositionsCount + slot; - container.setItem(slotId, 0, itemStack.copy()); - IntegratedDynamicsCompat._instance.getPacketHandler().sendToServer( - new CPacketSetSlot(container.containerId, slotId, itemStack)); - } } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerTransferHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerTransferHandler.java index b9af277b..772dd0ec 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerTransferHandler.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/logicprogrammer/LogicProgrammerTransferHandler.java @@ -20,13 +20,13 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.registries.ForgeRegistries; import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement; import org.cyclops.integrateddynamics.core.ingredient.ItemMatchProperties; import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeRecipeLPElement; import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase; import org.cyclops.integrateddynamicscompat.GeneralConfig; import org.cyclops.integrateddynamicscompat.IntegratedDynamicsCompat; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; import org.cyclops.integrateddynamicscompat.network.packet.CPacketValueTypeRecipeLPElementSetRecipe; import javax.annotation.Nullable; @@ -87,17 +87,7 @@ protected ResourceLocation getHeuristicItemsTag(IRecipeSlotView jeiIngredient) { .map(ItemStack::getItem) .collect(Collectors.toList()); if (items.size() > 1) { - return ForgeRegistries.ITEMS.tags().stream() - .map(tag -> { - if (tag.stream().collect(Collectors.toList()).equals(items)) { - return Optional.of(tag.getKey().location()); - } - return Optional.empty(); - }) - .filter(Optional::isPresent) - .map(Optional::get) - .findFirst() - .orElse(null); + return JeiReiHelpers.itemsToTag(items); } return null; } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicaldryingbasin/MechanicalDryingBasinRecipeCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicaldryingbasin/MechanicalDryingBasinRecipeCategory.java index fb71445b..d2dfe656 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicaldryingbasin/MechanicalDryingBasinRecipeCategory.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicaldryingbasin/MechanicalDryingBasinRecipeCategory.java @@ -22,7 +22,7 @@ import org.cyclops.integrateddynamics.RegistryEntries; import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasinConfig; import org.cyclops.integrateddynamicscompat.Reference; -import org.cyclops.integrateddynamicscompat.modcompat.jei.JEIIntegratedDynamicsConfig; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; import javax.annotation.Nonnull; @@ -91,10 +91,10 @@ public void draw(MechanicalDryingBasinRecipeJEI recipe, IRecipeSlotsView recipeS // Draw energy and duration Font fontRenderer = Minecraft.getInstance().font; - MutableComponent energy = JEIIntegratedDynamicsConfig.getEnergyTextComponent(recipe.getDuration(), BlockMechanicalDryingBasinConfig.consumptionRate); + MutableComponent energy = JeiReiHelpers.getEnergyTextComponent(recipe.getDuration(), BlockMechanicalDryingBasinConfig.consumptionRate); fontRenderer.draw(matrixStack, energy, (background.getWidth() - fontRenderer.width(energy)) / 2 + 3, 0, 0xFF808080); - MutableComponent duration = JEIIntegratedDynamicsConfig.getDurationSecondsTextComponent(recipe.getDuration()); + MutableComponent duration = JeiReiHelpers.getDurationSecondsTextComponent(recipe.getDuration()); fontRenderer.draw(matrixStack, duration, (background.getWidth() - fontRenderer.width(duration)) / 2 + 3, 42, 0xFF808080); } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicalsqueezer/MechanicalSqueezerRecipeCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicalsqueezer/MechanicalSqueezerRecipeCategory.java index 638aac4f..ce1eb3a4 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicalsqueezer/MechanicalSqueezerRecipeCategory.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/jei/mechanicalsqueezer/MechanicalSqueezerRecipeCategory.java @@ -20,10 +20,10 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.cyclops.integrateddynamics.RegistryEntries; -import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasinConfig; +import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezerConfig; import org.cyclops.integrateddynamics.core.recipe.type.RecipeSqueezer; import org.cyclops.integrateddynamicscompat.Reference; -import org.cyclops.integrateddynamicscompat.modcompat.jei.JEIIntegratedDynamicsConfig; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; import javax.annotation.Nonnull; @@ -95,10 +95,10 @@ public void draw(MechanicalSqueezerRecipeJEI recipe, IRecipeSlotsView recipeSlot // Draw energy and duration Font fontRenderer = Minecraft.getInstance().font; - MutableComponent energy = JEIIntegratedDynamicsConfig.getEnergyTextComponent(recipe.getDuration(), BlockMechanicalDryingBasinConfig.consumptionRate); + MutableComponent energy = JeiReiHelpers.getEnergyTextComponent(recipe.getDuration(), BlockMechanicalSqueezerConfig.consumptionRate); fontRenderer.draw(matrixStack, energy, (background.getWidth() - fontRenderer.width(energy)) / 2 - 10, 0, 0xFF808080); - MutableComponent duration = JEIIntegratedDynamicsConfig.getDurationSecondsTextComponent(recipe.getDuration()); + MutableComponent duration = JeiReiHelpers.getDurationSecondsTextComponent(recipe.getDuration()); fontRenderer.draw(matrixStack, duration, (background.getWidth() - fontRenderer.width(duration)) / 2 - 10, 42, 0xFF808080); } diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/ReiIntegratedDynamicsConfig.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/ReiIntegratedDynamicsConfig.java new file mode 100644 index 00000000..42b61b7c --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/ReiIntegratedDynamicsConfig.java @@ -0,0 +1,86 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei; + +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; +import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; +import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; +import me.shedaniel.rei.api.client.registry.transfer.simple.SimpleTransferHandler; +import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.forge.REIPluginClient; +import org.cyclops.integrateddynamics.RegistryEntries; +import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenMechanicalDryingBasin; +import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenMechanicalSqueezer; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeDryingBasin; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeMechanicalDryingBasin; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeMechanicalSqueezer; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeSqueezer; +import org.cyclops.integrateddynamics.inventory.container.ContainerMechanicalDryingBasin; +import org.cyclops.integrateddynamics.inventory.container.ContainerMechanicalSqueezer; +import org.cyclops.integrateddynamicscompat.modcompat.rei.dryingbasin.ReiDryingBasinCategory; +import org.cyclops.integrateddynamicscompat.modcompat.rei.dryingbasin.ReiDryingBasinRecipe; +import org.cyclops.integrateddynamicscompat.modcompat.rei.logicprogrammer.ReiDraggableStackVisitor; +import org.cyclops.integrateddynamicscompat.modcompat.rei.logicprogrammer.ReiLogicProgrammerTransferHandler; +import org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicaldryingbasin.ReiMechanicalDryingBasinCategory; +import org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicaldryingbasin.ReiMechanicalDryingBasinRecipe; +import org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicalsqueezer.ReiMechanicalSqueezerCategory; +import org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicalsqueezer.ReiMechanicalSqueezerRecipe; +import org.cyclops.integrateddynamicscompat.modcompat.rei.squeezer.ReiSqueezerCategory; +import org.cyclops.integrateddynamicscompat.modcompat.rei.squeezer.ReiSqueezerRecipe; + +@REIPluginClient +public class ReiIntegratedDynamicsConfig implements REIClientPlugin { + @Override + public void registerTransferHandlers(TransferHandlerRegistry registry) { + registry.register(new ReiLogicProgrammerTransferHandler()); + + registry.register(SimpleTransferHandler.create( + ContainerMechanicalDryingBasin.class, + ReiMechanicalDryingBasinCategory.ID, + new SimpleTransferHandler.IntRange(0, 1) + )); + registry.register(SimpleTransferHandler.create( + ContainerMechanicalSqueezer.class, + ReiMechanicalSqueezerCategory.ID, + new SimpleTransferHandler.IntRange(0, 1) + )); + } + + @Override + public void registerScreens(ScreenRegistry registry) { + registry.registerDraggableStackVisitor(new ReiDraggableStackVisitor()); + + registry.registerContainerClickArea( + new Rectangle(84, 31, 10, 27), + ContainerScreenMechanicalDryingBasin.class, + ReiMechanicalDryingBasinCategory.ID + ); + registry.registerContainerClickArea( + new Rectangle(73, 36, 12, 18), + ContainerScreenMechanicalSqueezer.class, + ReiMechanicalSqueezerCategory.ID + ); + } + + @Override + public void registerCategories(CategoryRegistry registry) { + registry.add(new ReiDryingBasinCategory()); + registry.add(new ReiSqueezerCategory()); + registry.add(new ReiMechanicalDryingBasinCategory()); + registry.add(new ReiMechanicalSqueezerCategory()); + + registry.addWorkstations(ReiDryingBasinCategory.ID, EntryStacks.of(RegistryEntries.BLOCK_DRYING_BASIN)); + registry.addWorkstations(ReiSqueezerCategory.ID, EntryStacks.of(RegistryEntries.BLOCK_SQUEEZER)); + registry.addWorkstations(ReiMechanicalDryingBasinCategory.ID, EntryStacks.of(RegistryEntries.BLOCK_MECHANICAL_DRYING_BASIN)); + registry.addWorkstations(ReiMechanicalSqueezerCategory.ID, EntryStacks.of(RegistryEntries.BLOCK_MECHANICAL_SQUEEZER)); + } + + @Override + public void registerDisplays(DisplayRegistry registry) { + registry.registerRecipeFiller(RecipeDryingBasin.class, RegistryEntries.RECIPETYPE_DRYING_BASIN, ReiDryingBasinRecipe::new); + registry.registerRecipeFiller(RecipeSqueezer.class, RegistryEntries.RECIPETYPE_SQUEEZER, ReiSqueezerRecipe::new); + registry.registerRecipeFiller(RecipeMechanicalDryingBasin.class, RegistryEntries.RECIPETYPE_MECHANICAL_DRYING_BASIN, ReiMechanicalDryingBasinRecipe::new); + registry.registerRecipeFiller(RecipeMechanicalSqueezer.class, RegistryEntries.RECIPETYPE_MECHANICAL_SQUEEZER, ReiMechanicalSqueezerRecipe::new); + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinCategory.java new file mode 100644 index 00000000..d475d8e5 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinCategory.java @@ -0,0 +1,91 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.dryingbasin; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import org.cyclops.cyclopscore.helper.RenderHelpers; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.RegistryEntries; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiDryingBasinCategory implements DisplayCategory { + + public static final CategoryIdentifier ID = CategoryIdentifier + .of(new ResourceLocation(Reference.MOD_ID, "drying_basin")); + + private final Renderer icon; + + public ReiDryingBasinCategory() { + this.icon = EntryStacks.of(RegistryEntries.BLOCK_DRYING_BASIN); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable(RegistryEntries.BLOCK_DRYING_BASIN.getDescriptionId()); + } + + @Override + public Renderer getIcon() { + return this.icon; + } + + @Override + public List setupDisplay(ReiDryingBasinRecipe display, Rectangle bounds) { + Point startPoint = new Point(bounds.getCenterX() - 93/2, bounds.getCenterY() - 53/2); + List widgets = Lists.newArrayList(); + + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createDrawableWidget((graphics, poseStack, mouseX, mouseY, delta) -> { + ResourceLocation texture = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "textures/gui/drying_basin_gui_jei.png"); + RenderHelpers.bindTexture(texture); + + // Background + graphics.blit(poseStack, startPoint.x, startPoint.y, 0, 0, 93, 53); + + // Progress bar + int height = Mth.ceil(System.currentTimeMillis() / 250d % 18d); + graphics.blit(poseStack, startPoint.x + 43, startPoint.y + 11 + (18 - height), 94, (18 - height), 11, height); + })); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 2, startPoint.y + 8)) + .entries(display.getInputEntries().get(0)) + .markInput()); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 76, startPoint.y + 8)) + .entries(display.getOutputEntries().get(0)) + .markInput()); + + widgets.add(Widgets.createSlot(new Rectangle(startPoint.x + 6, startPoint.y + 28, 8, 9)) + .entries(display.getInputEntries().get(1)) + .markInput()); + + widgets.add(Widgets.createSlot(new Rectangle(startPoint.x + 80, startPoint.y + 28, 8, 9)) + .entries(display.getOutputEntries().get(1)) + .markInput()); + + widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 42), JeiReiHelpers.getDurationSecondsTextComponent(display.getRecipe().getDuration())) + .color(0xFF808080) + .noShadow()); + + return widgets; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinRecipe.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinRecipe.java new file mode 100644 index 00000000..1163f13b --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/dryingbasin/ReiDryingBasinRecipe.java @@ -0,0 +1,50 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.dryingbasin; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.apache.commons.compress.utils.Lists; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeDryingBasin; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiDryingBasinRecipe implements Display { + + private final RecipeDryingBasin recipe; + private final List inputs; + private final List outputs; + + public ReiDryingBasinRecipe(RecipeDryingBasin recipe) { + this.recipe = recipe; + this.inputs = Lists.newArrayList(); + this.outputs = Lists.newArrayList(); + + this.inputs.add(EntryIngredients.ofIngredient(recipe.getInputIngredient())); + this.inputs.add(EntryIngredients.of(recipe.getInputFluid().getFluid(), recipe.getInputFluid().getAmount())); + this.outputs.add(EntryIngredients.of(recipe.getOutputItemFirst())); + this.outputs.add(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())); + } + + public RecipeDryingBasin getRecipe() { + return recipe; + } + + @Override + public List getInputEntries() { + return this.inputs; + } + + @Override + public List getOutputEntries() { + return this.outputs; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ReiDryingBasinCategory.ID; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiDraggableStackVisitor.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiDraggableStackVisitor.java new file mode 100644 index 00000000..ab77e315 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiDraggableStackVisitor.java @@ -0,0 +1,97 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.logicprogrammer; + +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.drag.DraggableStack; +import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor; +import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; +import me.shedaniel.rei.api.client.gui.drag.DraggingContext; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import org.apache.commons.compress.utils.Lists; +import org.cyclops.cyclopscore.helper.GuiHelpers; +import org.cyclops.cyclopscore.inventory.slot.SlotExtended; +import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement; +import org.cyclops.integrateddynamics.client.gui.container.ContainerScreenLogicProgrammerBase; +import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.stream.Stream; + +/** + * @author rubensworks + */ +public class ReiDraggableStackVisitor implements DraggableStackVisitor> { + @Override + public boolean isHandingScreen(R r) { + return r instanceof ContainerScreenLogicProgrammerBase; + } + + @Nullable + public static ItemStack convertItemStack(DraggableStack stack) { + ItemStack itemStack = null; + if (stack.getStack().getType() == VanillaEntryTypes.ITEM) { + itemStack = stack.getStack().castValue(); + } else if (stack.getStack().getType() == VanillaEntryTypes.FLUID) { + itemStack = new ItemStack(Items.BUCKET); + IFluidHandlerItem fluidHandler = itemStack + .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) + .orElseThrow(() -> new IllegalStateException("Could not find a fluid handler on the bucket item, some mod must be messing with things.")); + fluidHandler.fill(stack.getStack().castValue(), IFluidHandler.FluidAction.EXECUTE); + itemStack = fluidHandler.getContainer(); + } + return itemStack; + } + + @Override + public Stream getDraggableAcceptingBounds(DraggingContext> context, DraggableStack stack) { + List targets = Lists.newArrayList(); + + // Determine current LP element + ContainerScreenLogicProgrammerBase screen = context.getScreen(); + ContainerLogicProgrammerBase container = screen.getMenu(); + ILogicProgrammerElement element = container.getActiveElement(); + if (element != null) { + // Determine the stack to insert in slots + ItemStack itemStack = convertItemStack(stack); + if (itemStack != null) { + // Determine slots in which the stack could be placed + int slotPositionsCount = container.slots.size() - 36 - 4; /* subtract player inv, and 4 fixed slots in LP */ + for (int slot = 0; slot < slotPositionsCount; slot++) { + int slotId = container.slots.size() - 36 - slotPositionsCount + slot; + Slot slotContainer = container.getSlot(slotId); + + Rectangle bounds = new Rectangle( + screen.getGuiLeft() + slotContainer.x - 1, + screen.getGuiTop() + slotContainer.y - 1, + GuiHelpers.SLOT_SIZE, + GuiHelpers.SLOT_SIZE + ); + if (element.isItemValidForSlot(slot, itemStack)) { + targets.add(DraggableStackVisitor.BoundsProvider.ofRectangle(bounds)); + } + } + } + } + + return targets.stream(); + } + + @Override + public DraggedAcceptorResult acceptDraggedStack(DraggingContext> context, DraggableStack stack) { + ContainerScreenLogicProgrammerBase screen = context.getScreen(); + if (screen.getSlotUnderMouse() instanceof SlotExtended slotExtended && slotExtended.isPhantom()) { + JeiReiHelpers.setStackInSlot(screen, slotExtended.getContainerSlot(), convertItemStack(stack)); + return DraggedAcceptorResult.CONSUMED; + } + + return DraggedAcceptorResult.PASS; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiLogicProgrammerTransferHandler.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiLogicProgrammerTransferHandler.java new file mode 100644 index 00000000..75155f8f --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/logicprogrammer/ReiLogicProgrammerTransferHandler.java @@ -0,0 +1,114 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.logicprogrammer; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import org.cyclops.integrateddynamics.api.logicprogrammer.ILogicProgrammerElement; +import org.cyclops.integrateddynamics.core.ingredient.ItemMatchProperties; +import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeRecipeLPElement; +import org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase; +import org.cyclops.integrateddynamicscompat.GeneralConfig; +import org.cyclops.integrateddynamicscompat.IntegratedDynamicsCompat; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; +import org.cyclops.integrateddynamicscompat.network.packet.CPacketValueTypeRecipeLPElementSetRecipe; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author rubensworks + */ +public class ReiLogicProgrammerTransferHandler implements TransferHandler { + @Override + public Result handle(Context context) { + if (context.getMenu() instanceof ContainerLogicProgrammerBase container) { + ILogicProgrammerElement element = container.getActiveElement(); + + if (element instanceof ValueTypeRecipeLPElement) { + return handleRecipeElement((ValueTypeRecipeLPElement) element, container, context.getDisplay(), context.isActuallyCrafting()); + } + } + return Result.createNotApplicable(); + } + + private Result handleRecipeElement(ValueTypeRecipeLPElement element, ContainerLogicProgrammerBase container, Display display, boolean doTransfer) { + List itemInputs = Lists.newArrayList(); + List fluidInputs = Lists.newArrayList(); + List itemOutputs = Lists.newArrayList(); + List fluidOutputs = Lists.newArrayList(); + + for (EntryIngredient entry : display.getInputEntries()) { + handleEntry(entry, true, itemInputs, fluidInputs, itemOutputs, fluidOutputs); + } + for (EntryIngredient entry : display.getOutputEntries()) { + handleEntry(entry, false, itemInputs, fluidInputs, itemOutputs, fluidOutputs); + } + + if (!element.isValidForRecipeGrid(itemInputs, fluidInputs, itemOutputs, fluidOutputs)) { + return Result.createFailed(Component.translatable("error.jei.integrateddynamics.recipetransfer.recipe.toobig.desc")); + } + + if (doTransfer) { + element.setRecipeGrid(container, itemInputs, fluidInputs, itemOutputs, fluidOutputs); + IntegratedDynamicsCompat._instance.getPacketHandler().sendToServer( + new CPacketValueTypeRecipeLPElementSetRecipe(container.containerId, itemInputs, fluidInputs, itemOutputs, fluidOutputs)); + } + + return Result.createSuccessful().blocksFurtherHandling(); + } + + private void handleEntry(EntryIngredient entry, boolean input, List itemInputs, List fluidInputs, List itemOutputs, List fluidOutputs) { + if (entry.isEmpty()) { + // We assume only item slots can be empty + itemInputs.add(new ItemMatchProperties(ItemStack.EMPTY)); + } else { + EntryStack typedIngredient = entry.stream().findFirst().get(); + if (typedIngredient.getType() == VanillaEntryTypes.ITEM) { + // Collect items + if (input) { + ResourceLocation heuristicTag = getHeuristicItemsTag(entry); + if (heuristicTag != null) { + itemInputs.add(new ItemMatchProperties(ItemStack.EMPTY, false, heuristicTag.toString(), 1)); + } else { + itemInputs.add(new ItemMatchProperties(((ItemStack) typedIngredient.castValue()).copy())); + } + } else { + itemOutputs.add(((ItemStack) typedIngredient.castValue()).copy()); + } + } else if (typedIngredient.getType() == VanillaEntryTypes.FLUID) { + // Collect fluids + if (input) { + fluidInputs.add(((FluidStack) typedIngredient.castValue()).copy()); + } else { + fluidOutputs.add(((FluidStack) typedIngredient.castValue()).copy()); + } + } + } + } + + @Nullable + protected ResourceLocation getHeuristicItemsTag(EntryIngredient jeiIngredient) { + // Allow disabling this heuristic + if (!GeneralConfig.reiHeuristicTags) { + return null; + } + + List items = jeiIngredient.stream() + .map(typedIngredient -> (ItemStack) typedIngredient.castValue()) + .map(ItemStack::getItem) + .collect(Collectors.toList()); + if (items.size() > 1) { + return JeiReiHelpers.itemsToTag(items); + } + return null; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinCategory.java new file mode 100644 index 00000000..fe981b3e --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinCategory.java @@ -0,0 +1,95 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicaldryingbasin; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import org.cyclops.cyclopscore.helper.RenderHelpers; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.RegistryEntries; +import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasinConfig; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiMechanicalDryingBasinCategory implements DisplayCategory { + + public static final CategoryIdentifier ID = CategoryIdentifier + .of(new ResourceLocation(Reference.MOD_ID, "mechanical_drying_basin")); + + private final Renderer icon; + + public ReiMechanicalDryingBasinCategory() { + this.icon = EntryStacks.of(RegistryEntries.BLOCK_MECHANICAL_DRYING_BASIN); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable(RegistryEntries.BLOCK_MECHANICAL_DRYING_BASIN.getDescriptionId()); + } + + @Override + public Renderer getIcon() { + return this.icon; + } + + @Override + public List setupDisplay(ReiMechanicalDryingBasinRecipe display, Rectangle bounds) { + Point startPoint = new Point(bounds.getCenterX() - 93/2, bounds.getCenterY() - 53/2); + List widgets = Lists.newArrayList(); + + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createDrawableWidget((graphics, poseStack, mouseX, mouseY, delta) -> { + ResourceLocation texture = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "textures/gui/drying_basin_gui_jei.png"); + RenderHelpers.bindTexture(texture); + + // Background + graphics.blit(poseStack, startPoint.x, startPoint.y, 0, 0, 93, 53); + + // Progress bar + int height = Mth.ceil(System.currentTimeMillis() / 250d % 18d); + graphics.blit(poseStack, startPoint.x + 43, startPoint.y + 11 + (18 - height), 94, (18 - height), 11, height); + })); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 2, startPoint.y + 8)) + .entries(display.getInputEntries().get(0)) + .markInput()); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 76, startPoint.y + 8)) + .entries(display.getOutputEntries().get(0)) + .markInput()); + + widgets.add(Widgets.createSlot(new Rectangle(startPoint.x + 6, startPoint.y + 28, 8, 9)) + .entries(display.getInputEntries().get(1)) + .markInput()); + + widgets.add(Widgets.createSlot(new Rectangle(startPoint.x + 80, startPoint.y + 28, 8, 9)) + .entries(display.getOutputEntries().get(1)) + .markInput()); + + widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y), JeiReiHelpers.getEnergyTextComponent(display.getRecipe().getDuration(), BlockMechanicalDryingBasinConfig.consumptionRate)) + .color(0xFF808080) + .noShadow()); + widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 42), JeiReiHelpers.getDurationSecondsTextComponent(display.getRecipe().getDuration())) + .color(0xFF808080) + .noShadow()); + + return widgets; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinRecipe.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinRecipe.java new file mode 100644 index 00000000..5c7a8b65 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicaldryingbasin/ReiMechanicalDryingBasinRecipe.java @@ -0,0 +1,50 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicaldryingbasin; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.apache.commons.compress.utils.Lists; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeMechanicalDryingBasin; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiMechanicalDryingBasinRecipe implements Display { + + private final RecipeMechanicalDryingBasin recipe; + private final List inputs; + private final List outputs; + + public ReiMechanicalDryingBasinRecipe(RecipeMechanicalDryingBasin recipe) { + this.recipe = recipe; + this.inputs = Lists.newArrayList(); + this.outputs = Lists.newArrayList(); + + this.inputs.add(EntryIngredients.ofIngredient(recipe.getInputIngredient())); + this.inputs.add(EntryIngredients.of(recipe.getInputFluid().getFluid(), recipe.getInputFluid().getAmount())); + this.outputs.add(EntryIngredients.of(recipe.getOutputItemFirst())); + this.outputs.add(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())); + } + + public RecipeMechanicalDryingBasin getRecipe() { + return recipe; + } + + @Override + public List getInputEntries() { + return this.inputs; + } + + @Override + public List getOutputEntries() { + return this.outputs; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ReiMechanicalDryingBasinCategory.ID; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerCategory.java new file mode 100644 index 00000000..628ce202 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerCategory.java @@ -0,0 +1,106 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicalsqueezer; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Dimension; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import org.cyclops.cyclopscore.helper.RenderHelpers; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.RegistryEntries; +import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezerConfig; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeMechanicalSqueezer; +import org.cyclops.integrateddynamicscompat.modcompat.common.JeiReiHelpers; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiMechanicalSqueezerCategory implements DisplayCategory { + + public static final CategoryIdentifier ID = CategoryIdentifier + .of(new ResourceLocation(Reference.MOD_ID, "mechanical_squeezer")); + + private final Renderer icon; + + public ReiMechanicalSqueezerCategory() { + this.icon = EntryStacks.of(RegistryEntries.BLOCK_MECHANICAL_SQUEEZER); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable(RegistryEntries.BLOCK_MECHANICAL_SQUEEZER.getDescriptionId()); + } + + @Override + public Renderer getIcon() { + return this.icon; + } + + @Override + public List setupDisplay(ReiMechanicalSqueezerRecipe display, Rectangle bounds) { + RecipeMechanicalSqueezer recipe = display.getRecipe(); + Point startPoint = new Point(bounds.getCenterX() - 116/2, bounds.getCenterY() - 53/2); + List widgets = Lists.newArrayList(); + + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createDrawableWidget((graphics, poseStack, mouseX, mouseY, delta) -> { + ResourceLocation texture = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "textures/gui/mechanical_squeezer_gui_jei.png"); + RenderHelpers.bindTexture(texture); + + // Background + graphics.blit(poseStack, startPoint.x, startPoint.y, 0, 0, 116, 53); + + // Progress bar + int height = Mth.ceil(System.currentTimeMillis() / 250d % 11d); + graphics.blit(poseStack, startPoint.x + 45, startPoint.y + 21, 116, 0, 4, height); + })); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 2, startPoint.y + 18)) + .entries(display.getInputEntries().get(0)) + .markInput()); + + int offset = 0; + for (int i = 0; i < recipe.getOutputItems().size(); i++) { + RecipeMechanicalSqueezer.IngredientChance outputItem = recipe.getOutputItems().get(i); + Point point = new Point(startPoint.x + 76 + (i % 2 > 0 ? 22 : 0), startPoint.y + 8 + offset + (i > 1 ? 22 : 0)); + widgets.add(Widgets.createSlot(point.clone()) + .entries(EntryIngredients.of(outputItem.getIngredientFirst())) + .markOutput()); + point.translate(8, 8); + widgets.add(Widgets.createTooltip( + new Rectangle(point, new Dimension(8, 8)), + Component.literal("Chance: " + (outputItem.getChance() * 100.0F) + "%").withStyle(ChatFormatting.GRAY) + )); + } + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 98, startPoint.y + 30)) + .entries(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())) + .markInput()); + + widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y), JeiReiHelpers.getEnergyTextComponent(display.getRecipe().getDuration(), BlockMechanicalSqueezerConfig.consumptionRate)) + .color(0xFF808080) + .noShadow()); + widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 42), JeiReiHelpers.getDurationSecondsTextComponent(display.getRecipe().getDuration())) + .color(0xFF808080) + .noShadow()); + + return widgets; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerRecipe.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerRecipe.java new file mode 100644 index 00000000..974894f0 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/mechanicalsqueezer/ReiMechanicalSqueezerRecipe.java @@ -0,0 +1,51 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.mechanicalsqueezer; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.apache.commons.compress.utils.Lists; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeMechanicalSqueezer; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiMechanicalSqueezerRecipe implements Display { + + private final RecipeMechanicalSqueezer recipe; + private final List inputs; + private final List outputs; + + public ReiMechanicalSqueezerRecipe(RecipeMechanicalSqueezer recipe) { + this.recipe = recipe; + this.inputs = Lists.newArrayList(); + this.outputs = Lists.newArrayList(); + + this.inputs.add(EntryIngredients.ofIngredient(recipe.getInputIngredient())); + for (RecipeMechanicalSqueezer.IngredientChance outputItem : recipe.getOutputItems()) { + this.outputs.add(EntryIngredients.of(outputItem.getIngredientFirst())); + } + this.outputs.add(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())); + } + + public RecipeMechanicalSqueezer getRecipe() { + return recipe; + } + + @Override + public List getInputEntries() { + return this.inputs; + } + + @Override + public List getOutputEntries() { + return this.outputs; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ReiMechanicalSqueezerCategory.ID; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerCategory.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerCategory.java new file mode 100644 index 00000000..5e61d637 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerCategory.java @@ -0,0 +1,98 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.squeezer; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Dimension; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import org.cyclops.cyclopscore.helper.RenderHelpers; +import org.cyclops.integrateddynamics.Reference; +import org.cyclops.integrateddynamics.RegistryEntries; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeSqueezer; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiSqueezerCategory implements DisplayCategory { + + public static final CategoryIdentifier ID = CategoryIdentifier + .of(new ResourceLocation(Reference.MOD_ID, "squeezer")); + + private final Renderer icon; + + public ReiSqueezerCategory() { + this.icon = EntryStacks.of(RegistryEntries.BLOCK_SQUEEZER); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable(RegistryEntries.BLOCK_SQUEEZER.getDescriptionId()); + } + + @Override + public Renderer getIcon() { + return this.icon; + } + + @Override + public List setupDisplay(ReiSqueezerRecipe display, Rectangle bounds) { + RecipeSqueezer recipe = display.getRecipe(); + Point startPoint = new Point(bounds.getCenterX() - 116/2, bounds.getCenterY() - 53/2); + List widgets = Lists.newArrayList(); + + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createDrawableWidget((graphics, poseStack, mouseX, mouseY, delta) -> { + ResourceLocation texture = new ResourceLocation(org.cyclops.integrateddynamicscompat.Reference.MOD_ID, "textures/gui/squeezer_gui_jei.png"); + RenderHelpers.bindTexture(texture); + + // Background + graphics.blit(poseStack, startPoint.x, startPoint.y, 0, 0, 116, 53); + + // Progress bar + int height = Mth.ceil(Minecraft.getInstance().level.getGameTime() / 4d % 7d); + graphics.blit(poseStack, startPoint.x + 41, startPoint.y + 18 + height * 2, 41, 32, 13, 2); + })); + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 2, startPoint.y + 18)) + .entries(display.getInputEntries().get(0)) + .markInput()); + + int offset = 0; + for (int i = 0; i < recipe.getOutputItems().size(); i++) { + RecipeSqueezer.IngredientChance outputItem = recipe.getOutputItems().get(i); + Point point = new Point(startPoint.x + 76 + (i % 2 > 0 ? 22 : 0), startPoint.y + 8 + offset + (i > 1 ? 22 : 0)); + widgets.add(Widgets.createSlot(point.clone()) + .entries(EntryIngredients.of(outputItem.getIngredientFirst())) + .markOutput()); + point.translate(8, 8); + widgets.add(Widgets.createTooltip( + new Rectangle(point, new Dimension(8, 8)), + Component.literal("Chance: " + (outputItem.getChance() * 100.0F) + "%").withStyle(ChatFormatting.GRAY) + )); + } + + widgets.add(Widgets.createSlot(new Point(startPoint.x + 98, startPoint.y + 30)) + .entries(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())) + .markInput()); + + return widgets; + } +} diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerRecipe.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerRecipe.java new file mode 100644 index 00000000..b90a46a0 --- /dev/null +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/rei/squeezer/ReiSqueezerRecipe.java @@ -0,0 +1,51 @@ +package org.cyclops.integrateddynamicscompat.modcompat.rei.squeezer; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.apache.commons.compress.utils.Lists; +import org.cyclops.integrateddynamics.core.recipe.type.RecipeSqueezer; + +import java.util.List; + +/** + * @author rubensworks + */ +public class ReiSqueezerRecipe implements Display { + + private final RecipeSqueezer recipe; + private final List inputs; + private final List outputs; + + public ReiSqueezerRecipe(RecipeSqueezer recipe) { + this.recipe = recipe; + this.inputs = Lists.newArrayList(); + this.outputs = Lists.newArrayList(); + + this.inputs.add(EntryIngredients.ofIngredient(recipe.getInputIngredient())); + for (RecipeSqueezer.IngredientChance outputItem : recipe.getOutputItems()) { + this.outputs.add(EntryIngredients.of(outputItem.getIngredientFirst())); + } + this.outputs.add(EntryIngredients.of(recipe.getOutputFluid().getFluid(), recipe.getOutputFluid().getAmount())); + } + + public RecipeSqueezer getRecipe() { + return recipe; + } + + @Override + public List getInputEntries() { + return this.inputs; + } + + @Override + public List getOutputEntries() { + return this.outputs; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ReiSqueezerCategory.ID; + } +} diff --git a/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json b/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json index 4d305cb6..790dd9f9 100644 --- a/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json +++ b/src/main/resources/assets/integrateddynamicscompat/lang/en_us.json @@ -27,6 +27,7 @@ "_comment": "# ----- JEI ----- ##", "error.jei.integrateddynamics.recipetransfer.recipe.toobig.desc": "Too big for the Logic Programmer recipe pattern.", + "gui.integrateddynamics.jei.category.time.seconds": "%ss", "_comment": "# ----- Charset ----- ##",