-
-
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.
- Loading branch information
Showing
19 changed files
with
581 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase = GRADLE_USER_HOME | ||
distributionPath = wrapper/dists | ||
distributionUrl = https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
distributionUrl = https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
zipStoreBase = GRADLE_USER_HOME | ||
zipStorePath = wrapper/dists |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
metadata("lol.bai.megane.module.productivebees") { | ||
waila("MeganeProductiveBees") { | ||
required("productivebees") | ||
} | ||
|
||
forgeFml() | ||
packMcmeta() | ||
language() | ||
|
||
modsToml{ | ||
depends("productivebees" to any) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(fg.deobf(deps.forge.productiveBees)) | ||
} |
76 changes: 76 additions & 0 deletions
76
...ductive-bees/src/main/java/lol/bai/megane/module/productivebees/MeganeProductiveBees.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,76 @@ | ||
package lol.bai.megane.module.productivebees; | ||
|
||
import cy.jdkdigital.productivebees.common.block.entity.AdvancedBeehiveBlockEntity; | ||
import cy.jdkdigital.productivebees.common.block.entity.BreedingChamberBlockEntity; | ||
import cy.jdkdigital.productivebees.common.block.entity.CentrifugeBlockEntity; | ||
import cy.jdkdigital.productivebees.common.block.entity.IncubatorBlockEntity; | ||
import cy.jdkdigital.productivebees.common.block.entity.InventoryHandlerHelper; | ||
import cy.jdkdigital.productivebees.common.block.entity.JarBlockEntity; | ||
import cy.jdkdigital.productivebees.common.block.entity.SolitaryNestBlockEntity; | ||
import cy.jdkdigital.productivebees.common.entity.bee.ProductiveBee; | ||
import it.unimi.dsi.fastutil.ints.IntList; | ||
import lol.bai.megane.module.productivebees.provider.AdvancedBeehiveProvider; | ||
import lol.bai.megane.module.productivebees.provider.JarProvider; | ||
import lol.bai.megane.module.productivebees.provider.ProductiveBeeProvider; | ||
import lol.bai.megane.module.productivebees.provider.RecipeProcessingProvider; | ||
import lol.bai.megane.module.productivebees.provider.SolitaryNestProvider; | ||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import mcp.mobius.waila.api.TooltipPosition; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class MeganeProductiveBees implements IWailaPlugin { | ||
|
||
public static final ResourceLocation CONFIG_BEE_TYPE = id("bee_type"); | ||
public static final ResourceLocation CONFIG_BEE_PRODUCTIVITY = id("bee_productivity"); | ||
public static final ResourceLocation CONFIG_BEE_TOLERANCE = id("bee_tolerance"); | ||
public static final ResourceLocation CONFIG_BEE_BEHAVIOR = id("bee_behavior"); | ||
public static final ResourceLocation CONFIG_BEE_ENDURANCE = id("bee_endurance"); | ||
public static final ResourceLocation CONFIG_BEE_TEMPER = id("bee_temper"); | ||
|
||
public static final ResourceLocation CONFIG_HIVE_HONEY_LEVEL = id("hive_honey_level"); | ||
public static final ResourceLocation CONFIG_HIVE_OCCUPANTS = id("hive_occupants"); | ||
public static final ResourceLocation CONFIG_HIVE_COOLDOWN = id("hive_cooldown"); | ||
|
||
public static ResourceLocation id(String path) { | ||
return new ResourceLocation("megane:productive_bees." + path); | ||
} | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
var jarProvider = new JarProvider(); | ||
registrar.addDataType(JarProvider.DATA, JarProvider.Data.class, JarProvider.Data::new); | ||
registrar.addBlockData(jarProvider, JarBlockEntity.class); | ||
registrar.addComponent(jarProvider, TooltipPosition.HEAD, JarBlockEntity.class); | ||
registrar.addComponent(jarProvider, TooltipPosition.TAIL, JarBlockEntity.class); | ||
|
||
var beeProvider = new ProductiveBeeProvider(); | ||
registrar.addFeatureConfig(CONFIG_BEE_TYPE, false); | ||
registrar.addFeatureConfig(CONFIG_BEE_PRODUCTIVITY, false); | ||
registrar.addFeatureConfig(CONFIG_BEE_TOLERANCE, false); | ||
registrar.addFeatureConfig(CONFIG_BEE_BEHAVIOR, false); | ||
registrar.addFeatureConfig(CONFIG_BEE_ENDURANCE, false); | ||
registrar.addFeatureConfig(CONFIG_BEE_TEMPER, false); | ||
registrar.addDataType(ProductiveBeeProvider.DATA, ProductiveBeeProvider.Data.class, ProductiveBeeProvider.Data::new); | ||
registrar.addEntityData(beeProvider, ProductiveBee.class); | ||
registrar.addComponent(beeProvider, TooltipPosition.BODY, ProductiveBee.class); | ||
|
||
var advBeehiveProvider = new AdvancedBeehiveProvider(); | ||
registrar.addFeatureConfig(CONFIG_HIVE_HONEY_LEVEL, true); | ||
registrar.addFeatureConfig(CONFIG_HIVE_OCCUPANTS, false); | ||
registrar.addDataType(AdvancedBeehiveProvider.OCCUPANTS_DATA, AdvancedBeehiveProvider.OccupantsData.class, AdvancedBeehiveProvider.OccupantsData::new); | ||
registrar.addBlockData(advBeehiveProvider, AdvancedBeehiveBlockEntity.class); | ||
registrar.addComponent(advBeehiveProvider, TooltipPosition.BODY, AdvancedBeehiveBlockEntity.class); | ||
|
||
var solitaryNestProvider = new SolitaryNestProvider(); | ||
registrar.addFeatureConfig(CONFIG_HIVE_COOLDOWN, false); | ||
registrar.addDataType(SolitaryNestProvider.DATA, SolitaryNestProvider.Data.class, SolitaryNestProvider.Data::new); | ||
registrar.addBlockData(solitaryNestProvider, SolitaryNestBlockEntity.class, 900); | ||
registrar.addComponent(solitaryNestProvider, TooltipPosition.BODY, SolitaryNestBlockEntity.class); | ||
|
||
registrar.addBlockData(new RecipeProcessingProvider<>(IntList.of(0, 1, 2, 3, 4), IntList.of(5)), BreedingChamberBlockEntity.class); | ||
registrar.addBlockData(new RecipeProcessingProvider<>(IntList.of(InventoryHandlerHelper.INPUT_SLOT), IntList.of(InventoryHandlerHelper.OUTPUT_SLOTS)), CentrifugeBlockEntity.class); | ||
registrar.addBlockData(new RecipeProcessingProvider<>(IntList.of(0, 1), IntList.of(2)), IncubatorBlockEntity.class); | ||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
.../src/main/java/lol/bai/megane/module/productivebees/provider/AdvancedBeehiveProvider.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,111 @@ | ||
package lol.bai.megane.module.productivebees.provider; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import cy.jdkdigital.productivebees.common.block.entity.AdvancedBeehiveBlockEntityAbstract; | ||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; | ||
import lol.bai.megane.module.productivebees.MeganeProductiveBees; | ||
import mcp.mobius.waila.api.IBlockAccessor; | ||
import mcp.mobius.waila.api.IBlockComponentProvider; | ||
import mcp.mobius.waila.api.IData; | ||
import mcp.mobius.waila.api.IDataProvider; | ||
import mcp.mobius.waila.api.IDataWriter; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import mcp.mobius.waila.api.IServerAccessor; | ||
import mcp.mobius.waila.api.ITooltip; | ||
import mcp.mobius.waila.api.component.PairComponent; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.level.block.BeehiveBlock; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class AdvancedBeehiveProvider implements IBlockComponentProvider, IDataProvider<AdvancedBeehiveBlockEntityAbstract> { | ||
|
||
public static final ResourceLocation OCCUPANTS_DATA = MeganeProductiveBees.id("occupants"); | ||
|
||
@Override | ||
public void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) { | ||
var occupants = accessor.getData().get(OccupantsData.class); | ||
if (occupants != null && config.getBoolean(MeganeProductiveBees.CONFIG_HIVE_OCCUPANTS)) { | ||
var names = new Object2IntLinkedOpenHashMap<String>(occupants.occupants.size()); | ||
|
||
for (var occupant : occupants.occupants) { | ||
Component component = null; | ||
if (occupant.customName != null) component = Component.Serializer.fromJson(occupant.customName); | ||
if (component == null) component = occupant.entityType.getDescription(); | ||
|
||
var name = component.getString(); | ||
names.put(name, names.getOrDefault(name, 0) + 1); | ||
} | ||
|
||
for (var entry : names.object2IntEntrySet()) { | ||
var name = entry.getKey(); | ||
var count = entry.getIntValue(); | ||
if (count > 1) tooltip.addLine(Component.literal(count + " " + name)); | ||
else tooltip.addLine(Component.literal(name)); | ||
} | ||
} | ||
|
||
if (config.getBoolean(MeganeProductiveBees.CONFIG_HIVE_HONEY_LEVEL)) { | ||
var state = accessor.getBlockState(); | ||
if (state.hasProperty(BeehiveBlock.HONEY_LEVEL)) tooltip.addLine(new PairComponent( | ||
Component.translatable("tooltip.waila.honey_level"), | ||
Component.literal(state.getValue(BeehiveBlock.HONEY_LEVEL).toString()))); | ||
} | ||
} | ||
|
||
@Override | ||
public void appendData(IDataWriter data, IServerAccessor<AdvancedBeehiveBlockEntityAbstract> accessor, IPluginConfig config) { | ||
if (config.getBoolean(MeganeProductiveBees.CONFIG_HIVE_OCCUPANTS)) data.add(OccupantsData.class, res -> { | ||
var stored = accessor.getTarget().getBeeList(); | ||
if (!stored.isEmpty()) { | ||
var occupants = new ArrayList<OccupantsData.Occupant>(stored.size()); | ||
|
||
for (var beeData : stored) { | ||
var beeNbt = beeData.nbt; | ||
|
||
var entityType = EntityType.by(beeNbt); | ||
if (entityType.isEmpty()) continue; | ||
|
||
var customName = beeNbt.contains("CustomName", Tag.TAG_STRING) | ||
? beeNbt.getString("CustomName") | ||
: null; | ||
|
||
occupants.add(new OccupantsData.Occupant(entityType.get(), customName)); | ||
} | ||
|
||
if (!occupants.isEmpty()) res.add(new OccupantsData(occupants)); | ||
} | ||
}); | ||
} | ||
|
||
public record OccupantsData( | ||
List<Occupant> occupants | ||
) implements IData { | ||
|
||
public OccupantsData(FriendlyByteBuf buf) { | ||
this(buf.readList(b -> new Occupant( | ||
b.readRegistryIdUnsafe(ForgeRegistries.ENTITY_TYPES), | ||
b.readNullable(FriendlyByteBuf::readUtf)))); | ||
} | ||
|
||
@Override | ||
public void write(FriendlyByteBuf buf) { | ||
buf.writeCollection(occupants, (b, occupant) -> { | ||
b.writeRegistryIdUnsafe(ForgeRegistries.ENTITY_TYPES, occupant.entityType); | ||
b.writeNullable(occupant.customName, FriendlyByteBuf::writeUtf); | ||
}); | ||
} | ||
|
||
public record Occupant(EntityType<?> entityType, @Nullable String customName) { | ||
|
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.