-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.21
- Loading branch information
Showing
53 changed files
with
1,385 additions
and
1,746 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/org/cyclops/integrateddynamicscompat/modcompat/common/JeiReiHelpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.cyclops.integrateddynamicscompat.modcompat.common; | ||
|
||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
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 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<Item> items) { | ||
return BuiltInRegistries.ITEM.getTagNames() | ||
.map(tag -> BuiltInRegistries.ITEM.getTag(tag) | ||
.flatMap(t -> { | ||
if (t.stream().map(Holder::value).collect(Collectors.toList()).equals(items)) { | ||
return Optional.of(tag.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)); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...ain/java/org/cyclops/integrateddynamicscompat/modcompat/jade/DryingBasinDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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 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<BlockAccessor> { | ||
|
||
public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(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(), accessor.getLevel().registryAccess())); | ||
} | ||
} | ||
|
||
@Override | ||
public void appendServerData(CompoundTag tag, BlockAccessor accessor) { | ||
BlockEntityDryingBasin tile = (BlockEntityDryingBasin) accessor.getBlockEntity(); | ||
List<Component> 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, accessor.getLevel().registryAccess()); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getUid() { | ||
return ID; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...ava/org/cyclops/integrateddynamicscompat/modcompat/jade/JadeIntegratedDynamicsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...rg/cyclops/integrateddynamicscompat/modcompat/jade/MechanicalDryingBasinDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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 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 = ResourceLocation.fromNamespaceAndPath(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(), accessor.getLevel().registryAccess())); | ||
} | ||
} | ||
|
||
@Override | ||
public void appendServerData(CompoundTag tag, BlockAccessor accessor) { | ||
BlockEntityMechanicalDryingBasin tile = (BlockEntityMechanicalDryingBasin) accessor.getBlockEntity(); | ||
List<Component> 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, accessor.getLevel().registryAccess()); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getUid() { | ||
return ID; | ||
} | ||
|
||
} |
Oops, something went wrong.