Skip to content

Commit

Permalink
fix progress bar
Browse files Browse the repository at this point in the history
fix indrev impl (#16)
update dependencies
  • Loading branch information
deirn committed Mar 26, 2021
1 parent 762ef71 commit fd6d857
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 56 deletions.
11 changes: 3 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'maven-publish'
id 'fabric-loom' version '0.5-SNAPSHOT' apply false
id 'fabric-loom' version '0.6-SNAPSHOT' apply false
}

def versionEnv = System.getenv("MOD_VERSION")
Expand All @@ -18,12 +18,7 @@ allprojects {
targetCompatibility = 1.8

repositories {
maven {
url "https://jitpack.io"
content {
includeGroup "com.github.badasintended"
}
}
maven { url "https://bai.jfrog.io/artifactory/maven" }
}

dependencies {
Expand All @@ -33,7 +28,7 @@ allprojects {

modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric}"

modApi "com.github.badasintended:wthit:${rootProject.wthit}"
modApi "mcp.mobius.waila:wthit-fabric:${rootProject.wthit}"
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ group = com.github.badasintended
archivesBaseName = megane

# Dependencies
fabric = 0.30.3+1.16
wthit = 2.2.1
fabric = 0.32.0+1.16
wthit = 2.5.4
trEnergy = 0.1.0
lba = 0.8.4
modmenu = 1.14.6+build.31
lba = 0.8.7
modmenu = 1.16.8

# Databreaker
databreaker = 0.2.6
Expand Down
4 changes: 3 additions & 1 deletion megane-api/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"waila": "*"
},
"custom" : {
"modmenu:parent": "megane"
"modmenu": {
"parent": "megane"
}
}
}
22 changes: 11 additions & 11 deletions megane-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ repositories {
maven { url "https://raw.githubusercontent.com/Technici4n/Technici4n-maven/master/" }
maven { url "https://server.bbkr.space/artifactory/libs-release" }
maven { url "https://mod-buildcraft.com/maven" }
maven { url "https://dl.bintray.com/ladysnake/libs" }
maven { url "https://ladysnake.jfrog.io/artifactory/mods" }
maven { url "https://www.cursemaven.com" }
}

dependencies {
implementation project(":megane-api")

modCompileOnly "dev.technici4n:FastTransferLib:0.2.1"
modCompileOnly "dev.technici4n:FastTransferLib:0.3.1"

modCompileOnly "alexiil.mc.lib:libblockattributes-fluids:0.8.4"
modCompileOnly "alexiil.mc.lib:libblockattributes-items:0.8.4"
modCompileOnly "alexiil.mc.lib:libblockattributes-fluids:0.8.7"
modCompileOnly "alexiil.mc.lib:libblockattributes-items:0.8.7"

modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.7.4"
modCompileOnly "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.7.13"

modCompileOnly "io.github.cottonmc:LibGui:3.2.2+1.16.3"
modCompileOnly "io.github.cottonmc:LibGui:3.3.5+1.16.5"

modCompileOnly "teamreborn:energy:0.1.0"
modCompileOnly "TechReborn:TechReborn-1.16:3.8.0+build.205"
modCompileOnly "TechReborn:TechReborn-1.16:3.8.2+build.220"

modCompileOnly "curse.maven:applied-energistics-2-223794:3117933"
modCompileOnly "curse.maven:applied-energistics-2-223794:3225596"

modCompileOnly "curse.maven:astromine-core-405058:3080151"
modCompileOnly "curse.maven:astromine-foundations-404374:3080153"
modCompileOnly "curse.maven:astromine-technologies-404376:3080154"

modCompileOnly "curse.maven:fabric-furnaces-315534:3155774"

modCompileOnly "curse.maven:indrev-391708:3207757"
modCompileOnly "curse.maven:indrev-391708:3233516"

modCompileOnly "curse.maven:modern-industrialization-405388:3186480"
modCompileOnly "curse.maven:modern-industrialization-405388:3232104"

modCompileOnly "curse.maven:art-of-alchemy-415339:3106070"

modCompileOnly "curse.maven:kibe-388832:3183761"
modCompileOnly "curse.maven:kibe-388832:3239422"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import badasintended.megane.api.provider.FluidProvider;
import badasintended.megane.api.provider.ProgressProvider;
import me.steven.indrev.blockentities.MachineBlockEntity;
import me.steven.indrev.blockentities.crafters.CompressorFactoryBlockEntity;
import me.steven.indrev.blockentities.crafters.CraftingMachineBlockEntity;
import me.steven.indrev.blockentities.crafters.ElectricFurnaceFactoryBlockEntity;
import me.steven.indrev.blockentities.crafters.SolidInfuserFactoryBlockEntity;
import me.steven.indrev.blockentities.modularworkbench.ModularWorkbenchBlockEntity;
import me.steven.indrev.blockentities.storage.TankBlockEntity;
import me.steven.indrev.fluids.BaseFluid;
import net.fabricmc.api.EnvType;
Expand All @@ -22,25 +26,38 @@

public class IndustrialRevolution implements MeganeModule {

@Override
@SuppressWarnings("ConstantConditions")
public void initialize() {
ENERGY.register(MachineBlockEntity.class, EnergyProvider.of(
MachineBlockEntity::getEnergy,
MachineBlockEntity::getEnergyCapacity
));

PROGRESS.register(CraftingMachineBlockEntity.class, ProgressProvider.of(
public <T extends MachineBlockEntity<?>> void progress(Class<T> clazz, int amount, int currentIndex, int maxIndex) {
PROGRESS.register(clazz, ProgressProvider.of(
b -> b.getInventoryComponent().getInventory().getInputSlots(),
b -> b.getInventoryComponent().getInventory().getOutputSlots(),
(b, i) -> b.getInventoryComponent().getInventory().getStack(i),
b -> {
PropertyDelegate property = b.getPropertyDelegate();
double max = property.get(4);
double current = property.get(3);
return (int) ((max - current) / max * 100);
int result = 0;
int j = 1;
for (int i = 0; i < amount; i++) {
double current = property.get(currentIndex + (i * 2));
double max = property.get(maxIndex + (i * 2));
result = Math.max(result, (int) (current / max * 100));
}
return result;
}
));
}

@Override
public void initialize() {
ENERGY.register(MachineBlockEntity.class, EnergyProvider.of(
MachineBlockEntity::getEnergy,
MachineBlockEntity::getEnergyCapacity
));

progress(CraftingMachineBlockEntity.class, 1, 4, 5);
progress(CompressorFactoryBlockEntity.class, 5, 4, 5);
progress(CompressorFactoryBlockEntity.class, 5, 4, 5);
progress(SolidInfuserFactoryBlockEntity.class, 5, 4, 5);
progress(ElectricFurnaceFactoryBlockEntity.class, 5, 4, 5);
progress(ModularWorkbenchBlockEntity.class, 1, 2, 3);

FLUID.register(MachineBlockEntity.class, FluidProvider.of(
t -> t.getFluidComponent() != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Set;

import mcp.mobius.waila.utils.JsonConfig;
import net.fabricmc.loader.api.FabricLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
Expand All @@ -16,7 +17,10 @@ public class MixinPlugin implements IMixinConfigPlugin {

private static final Logger LOGGER = LogManager.getLogger("megane-impl-mixin");
private static final String PREFIX = "badasintended.megane.impl.mixin.";
private static final JsonConfig<Config> CONFIG = new JsonConfig<>("waila/megane-impl-mixin", Config.class);
private static final JsonConfig<Config> CONFIG = new JsonConfig<>(
FabricLoader.getInstance().getConfigDir().resolve("waila/megane-impl-mixin.json").toFile(),
Config.class
);

@Override
public void onLoad(String mixinPackage) {
Expand Down
4 changes: 3 additions & 1 deletion megane-impl/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"init": "badasintended.megane.impl.TechReborn"
}
],
"modmenu:parent": "megane"
"modmenu": {
"parent": "megane"
}
}
}
2 changes: 1 addition & 1 deletion megane-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ dependencies {

modImplementation "teamreborn:energy:${rootProject.trEnergy}"
modImplementation("alexiil.mc.lib:libblockattributes-fluids:${rootProject.lba}") { exclude group: "net.fabricmc.fabric-api" }
modImplementation("io.github.prospector:modmenu:${rootProject.modmenu}") { exclude group: "net.fabricmc.fabric-api" }
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu}") { exclude group: "net.fabricmc.fabric-api" }
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package badasintended.megane.runtime.config;

import badasintended.megane.runtime.config.screen.MeganeConfigScreen;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;

public class MeganeModMenu implements ModMenuApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,36 @@ public boolean append(CompoundTag data, ServerPlayerEntity player, World world,

int[] inputs = provider.getInputSlots(blockEntity);
int[] outputs = provider.getOutputSlots(blockEntity);
data.putInt(P_I_SIZE, inputs.length);
data.putInt(P_O_SIZE, outputs.length);

int i = 0;
for (int input : inputs) {
ItemStack stack = provider.getStack(blockEntity, input);
if (stack.isEmpty()) {
continue;
}
CompoundTag tag = stack.getTag();
data.putInt(P_I_ID, Registry.ITEM.getRawId(stack.getItem()));
data.putInt(P_I_COUNT, stack.getCount());
data.put(P_I_NBT, tag == null ? EMPTY_TAG : tag);
data.putInt(P_I_ID + i, Registry.ITEM.getRawId(stack.getItem()));
data.putInt(P_I_COUNT + i, stack.getCount());
data.put(P_I_NBT + i, tag == null ? EMPTY_TAG : tag);
i++;
}
data.putInt(P_I_SIZE, i);

data.putInt(P_PERCENT, provider.getPercentage(blockEntity));

i = 0;
for (int output : outputs) {
ItemStack stack = provider.getStack(blockEntity, output);
if (stack.isEmpty()) {
continue;
}
CompoundTag tag = stack.getTag();
data.putInt(P_O_ID, Registry.ITEM.getRawId(stack.getItem()));
data.putInt(P_O_COUNT, stack.getCount());
data.put(P_O_NBT, tag == null ? EMPTY_TAG : tag);
data.putInt(P_O_ID + i, Registry.ITEM.getRawId(stack.getItem()));
data.putInt(P_O_COUNT + i, stack.getCount());
data.put(P_O_NBT + i, tag == null ? EMPTY_TAG : tag);
i++;
}
data.putInt(P_O_SIZE, outputs.length);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MGuiConfigPlugins {

@Inject(method = "getOptions", at = @At("TAIL"), remap = false)
private void add(CallbackInfoReturnable<OptionsListWidget> cir) {
cir.getReturnValue().children().add(0, new OptionsEntryButton("config.waila.megane", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w ->
cir.getReturnValue().children().add(1, new OptionsEntryButton("config.waila.megane", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w ->
MinecraftClient.getInstance().openScreen(new MeganeConfigScreen((GuiConfigPlugins) (Object) this))
)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void draw(MatrixStack matrices, CompoundTag data, ICommonAccessor accesso

for (int i = 0; i < inputCount; i++) {
ItemStack stack = new ItemStack(Registry.ITEM.get(data.getInt(P_I_ID + i)), data.getInt(P_I_COUNT + i));
stack.setTag(data.getCompound(P_I_NBT));
stack.setTag(data.getCompound(P_I_NBT + i));
if (stack.isEmpty()) {
inputCount--;
i--;
Expand All @@ -54,7 +54,7 @@ public void draw(MatrixStack matrices, CompoundTag data, ICommonAccessor accesso

for (int i = 0; i < outputCount; i++) {
ItemStack stack = new ItemStack(Registry.ITEM.get(data.getInt(P_O_ID + i)), data.getInt(P_O_COUNT + i));
stack.setTag(data.getCompound(P_O_NBT));
stack.setTag(data.getCompound(P_O_NBT + i));
drawStack(stack, x + (inputCount * 18) + 26 + (i * 18), y + 1);
}
}
Expand Down
6 changes: 4 additions & 2 deletions megane-runtime/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"deirn"
],
"contributors" : [
"qsefthuopq - Simplified Chinese Translator"
"qsefthuopq"
],
"contact" : {
"homepage": "https://github.com/badasintended/megane",
Expand Down Expand Up @@ -39,6 +39,8 @@
"id" : "megane:plugin",
"initializer": "badasintended.megane.runtime.MeganeWaila"
},
"modmenu:parent": "megane"
"modmenu": {
"parent": "megane"
}
}
}
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"name" : "megane",
"description" : "hwyla plugin that shows more tooltip than you'll ever want",
"authors" : ["deirn"],
"contributors" : [
"qsefthuopq"
],
"contact" : {
"homepage": "https://github.com/badasintended/megane",
"sources" : "https://github.com/badasintended/megane",
Expand All @@ -19,6 +22,6 @@
"depends" : {
"fabricloader": ">=0.7.4",
"minecraft" : "1.16.x",
"waila" : "*"
"wthit" : "*"
}
}

0 comments on commit fd6d857

Please sign in to comment.