-
-
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
22 changed files
with
656 additions
and
5 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
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,18 @@ | ||
metadata("lol.bai.megane.module.resourcechickens") { | ||
waila("MeganeResourceChickens") | ||
language() | ||
|
||
fmj { | ||
depends( | ||
"resourcechickens" to any | ||
) | ||
} | ||
} | ||
|
||
repositories { | ||
curseApi() | ||
} | ||
|
||
dependencies { | ||
modImplementation(deps.fabric.resourceChickens) | ||
} |
46 changes: 46 additions & 0 deletions
46
...chickens/src/main/java/lol/bai/megane/module/resourcechickens/MeganeResourceChickens.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,46 @@ | ||
package lol.bai.megane.module.resourcechickens; | ||
|
||
import lol.bai.megane.module.resourcechickens.provider.ChickenProvider; | ||
import lol.bai.megane.module.resourcechickens.provider.NestProvider; | ||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import mcp.mobius.waila.api.TooltipPosition; | ||
import net.minecraft.resources.ResourceLocation; | ||
import wallywhip.resourcechickens.blocks.NestTileEntity; | ||
import wallywhip.resourcechickens.entity.ResourceChickenEntity; | ||
|
||
public class MeganeResourceChickens implements IWailaPlugin { | ||
|
||
public static final ResourceLocation CONFIG_SHOW_GAIN = new ResourceLocation("megane:resource_chickens.gain"); | ||
public static final ResourceLocation CONFIG_SHOW_GROWTH = new ResourceLocation("megane:resource_chickens.growth"); | ||
public static final ResourceLocation CONFIG_SHOW_STRENGTH = new ResourceLocation("megane:resource_chickens.strength"); | ||
public static final ResourceLocation CONFIG_SHOW_GROW = new ResourceLocation("megane:resource_chickens.grow"); | ||
public static final ResourceLocation CONFIG_SHOW_DROP = new ResourceLocation("megane:resource_chickens.drop"); | ||
public static final ResourceLocation CONFIG_SHOW_NEST_FOOD = new ResourceLocation("megane:resource_chickens.food"); | ||
public static final ResourceLocation CONFIG_SHOW_CONVERSION = new ResourceLocation("megane:resource_chickens.conversion"); | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
registrar.addFeatureConfig(CONFIG_SHOW_GAIN, true); | ||
registrar.addFeatureConfig(CONFIG_SHOW_GROWTH, true); | ||
registrar.addFeatureConfig(CONFIG_SHOW_STRENGTH, true); | ||
|
||
registrar.addFeatureConfig(CONFIG_SHOW_GROW, false); | ||
registrar.addFeatureConfig(CONFIG_SHOW_DROP, false); | ||
registrar.addFeatureConfig(CONFIG_SHOW_NEST_FOOD, false); | ||
registrar.addFeatureConfig(CONFIG_SHOW_CONVERSION, false); | ||
|
||
var nestProvider = new NestProvider(); | ||
registrar.addDataType(NestProvider.DATA, NestProvider.Data.class, NestProvider.Data::new); | ||
registrar.addBlockData(nestProvider, NestTileEntity.class); | ||
registrar.addComponent(nestProvider, TooltipPosition.HEAD, NestTileEntity.class); | ||
registrar.addComponent(nestProvider, TooltipPosition.BODY, NestTileEntity.class); | ||
|
||
var chickenProvider = new ChickenProvider(); | ||
registrar.addDataType(ChickenProvider.DATA_TIMER, ChickenProvider.Timer.class, ChickenProvider.Timer::new); | ||
registrar.addDataType(ChickenProvider.DATA_MUTATION, ChickenProvider.Mutation.class, ChickenProvider.Mutation::new); | ||
registrar.addEntityData(chickenProvider, ResourceChickenEntity.class); | ||
registrar.addComponent(chickenProvider, TooltipPosition.BODY, ResourceChickenEntity.class); | ||
} | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
...ickens/src/main/java/lol/bai/megane/module/resourcechickens/provider/ChickenProvider.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,115 @@ | ||
package lol.bai.megane.module.resourcechickens.provider; | ||
|
||
import lol.bai.megane.module.resourcechickens.MeganeResourceChickens; | ||
import mcp.mobius.waila.api.IData; | ||
import mcp.mobius.waila.api.IDataProvider; | ||
import mcp.mobius.waila.api.IDataWriter; | ||
import mcp.mobius.waila.api.IEntityAccessor; | ||
import mcp.mobius.waila.api.IEntityComponentProvider; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import mcp.mobius.waila.api.IServerAccessor; | ||
import mcp.mobius.waila.api.ITooltip; | ||
import mcp.mobius.waila.api.component.BarComponent; | ||
import mcp.mobius.waila.api.component.PairComponent; | ||
import mcp.mobius.waila.api.component.WrappedComponent; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import wallywhip.resourcechickens.ResourceChickens; | ||
import wallywhip.resourcechickens.compat.modmenu.ModMenuManager; | ||
import wallywhip.resourcechickens.entity.ResourceChickenEntity; | ||
import wallywhip.resourcechickens.init.initChickenRegistry; | ||
|
||
public class ChickenProvider implements IEntityComponentProvider, IDataProvider<ResourceChickenEntity> { | ||
|
||
public static final ResourceLocation DATA_TIMER = new ResourceLocation("megane:resource_chickens.chicken.timer"); | ||
public static final ResourceLocation DATA_MUTATION = new ResourceLocation("megane:resource_chickens.chicken.mutation"); | ||
|
||
@Override | ||
public void appendBody(ITooltip tooltip, IEntityAccessor accessor, IPluginConfig config) { | ||
var chicken = accessor.<ResourceChickenEntity>getEntity(); | ||
|
||
if (chicken.getEntityData().get(ResourceChickenEntity.ANALYZED)) { | ||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_GAIN)) tooltip.addLine(new PairComponent( | ||
Component.translatable("megane.resource_chickens.gain"), | ||
Component.literal(String.valueOf(chicken.getEntityData().get(ResourceChickenEntity.GAIN))))); | ||
|
||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_GROWTH)) tooltip.addLine(new PairComponent( | ||
Component.translatable("megane.resource_chickens.growth"), | ||
Component.literal(String.valueOf(chicken.getEntityData().get(ResourceChickenEntity.GROWTH))))); | ||
|
||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_STRENGTH)) tooltip.addLine(new PairComponent( | ||
Component.translatable("megane.resource_chickens.strength"), | ||
Component.literal(String.valueOf(chicken.getEntityData().get(ResourceChickenEntity.STRENGTH))))); | ||
} | ||
|
||
var timer = accessor.getData().get(Timer.class); | ||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_DROP) && timer != null && ModMenuManager.getConfig().isAllowInWorldDrops() && !chicken.isBaby() && timer.eggLayTime != 0) { | ||
tooltip.addLine(new PairComponent( | ||
Component.translatable("megane.resource_chickens.next_drop"), | ||
Component.literal(ResourceChickens.formatTime(timer.eggTime)))); | ||
} | ||
|
||
var mutation = accessor.getData().get(Mutation.class); | ||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_CONVERSION) && mutation != null) { | ||
var target = initChickenRegistry.getChickenDataFromName(mutation.type); | ||
if (target != null) { | ||
tooltip.addLine(new PairComponent( | ||
Component.translatable("megane.resource_chickens.conversion"), | ||
target.displayName)); | ||
|
||
tooltip.addLine(new PairComponent( | ||
new WrappedComponent(Component.translatable("megane.resource_chickens.progress")), | ||
new BarComponent((float) mutation.count / target.conversionRequired, 0xff89710f, Component.literal(mutation.count + "/" + target.conversionRequired)))); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void appendData(IDataWriter data, IServerAccessor<ResourceChickenEntity> accessor, IPluginConfig config) { | ||
var chicken = accessor.getTarget(); | ||
|
||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_DROP) && ModMenuManager.getConfig().isAllowInWorldDrops()) { | ||
data.addImmediate(new Timer(chicken.chickenData.eggLayTime, chicken.eggTime)); | ||
} | ||
|
||
if (config.getBoolean(MeganeResourceChickens.CONFIG_SHOW_CONVERSION) && chicken.conversionProgress != 0) { | ||
data.addImmediate(new Mutation(chicken.conversionProgress, chicken.conversionType)); | ||
} | ||
} | ||
|
||
public record Timer( | ||
int eggLayTime, | ||
int eggTime | ||
) implements IData { | ||
|
||
public Timer(FriendlyByteBuf buf) { | ||
this(buf.readVarInt(), buf.readVarInt()); | ||
} | ||
|
||
@Override | ||
public void write(FriendlyByteBuf buf) { | ||
buf.writeVarInt(eggLayTime); | ||
buf.writeVarInt(eggTime); | ||
} | ||
|
||
} | ||
|
||
public record Mutation( | ||
int count, | ||
String type | ||
) implements IData { | ||
|
||
public Mutation(FriendlyByteBuf buf) { | ||
this(buf.readVarInt(), buf.readUtf()); | ||
} | ||
|
||
@Override | ||
public void write(FriendlyByteBuf buf) { | ||
buf.writeVarInt(count); | ||
buf.writeUtf(type); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.