-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for MI 0.4 and deprecate 0.3 module
- Loading branch information
Showing
20 changed files
with
393 additions
and
4 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
2 changes: 2 additions & 0 deletions
2
src/modern-industrialization/build.gradle → src/modern-industrialization-3/build.gradle
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,3 +1,5 @@ | ||
// TODO: Remove | ||
|
||
repositories { | ||
maven { | ||
url "https://mod-buildcraft.com/maven" | ||
|
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,22 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id" : "megane-modern-industrialization-3", | ||
"version" : "${version}", | ||
"authors" : ["deirn"], | ||
"license" : "MIT", | ||
"icon" : "assets/megane/icon.png", | ||
"mixins" : ["megane-modern-industrialization-3.mixins.json"], | ||
"depends" : { | ||
"megane-base" : "*", | ||
"modern_industrialization": "0.3.x" | ||
}, | ||
"custom" : { | ||
"megane:modules": [ | ||
"badasintended.megane.impl.ModernIndustrialization" | ||
], | ||
"modmenu" : { | ||
"parent": "megane", | ||
"badges": ["deprecated"] | ||
} | ||
} | ||
} |
File renamed without changes.
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,16 @@ | ||
repositories { | ||
maven { | ||
url "https://raw.githubusercontent.com/Technici4n/Technici4n-maven/master/" | ||
content { | ||
includeGroup "net.fabricmc.fabric-api" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implFor "curse.maven:modern-industrialization-405388:3321898" | ||
|
||
modCompileOnly "net.fabricmc.fabric-api:fabric-transfer-api-v1:0.1.0+7678d00a7d" | ||
} | ||
|
||
apply from: "impl.gradle" |
189 changes: 189 additions & 0 deletions
189
src/modern-industrialization-4/java/badasintended/megane/impl/ModernIndustrialization.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,189 @@ | ||
package badasintended.megane.impl; | ||
|
||
import java.util.List; | ||
|
||
import aztech.modern_industrialization.blocks.creativetank.CreativeTankBlockEntity; | ||
import aztech.modern_industrialization.blocks.tank.TankBlockEntity; | ||
import aztech.modern_industrialization.inventory.ConfigurableFluidStack; | ||
import aztech.modern_industrialization.inventory.ConfigurableItemStack; | ||
import aztech.modern_industrialization.machines.MachineBlockEntity; | ||
import aztech.modern_industrialization.machines.components.CrafterComponent; | ||
import aztech.modern_industrialization.machines.components.EnergyComponent; | ||
import aztech.modern_industrialization.machines.components.MachineInventoryComponent; | ||
import badasintended.megane.api.MeganeModule; | ||
import badasintended.megane.api.provider.EnergyProvider; | ||
import badasintended.megane.api.provider.FluidInfoProvider; | ||
import badasintended.megane.api.provider.FluidProvider; | ||
import badasintended.megane.api.provider.InventoryProvider; | ||
import badasintended.megane.api.provider.ProgressProvider; | ||
import badasintended.megane.api.registry.MeganeClientRegistrar; | ||
import badasintended.megane.api.registry.MeganeRegistrar; | ||
import badasintended.megane.impl.mixin.modern_industrialization.ACraftingFluid; | ||
import badasintended.megane.impl.mixin.modern_industrialization.ATankBlockEntity; | ||
import badasintended.megane.impl.mixin.modern_industrialization.CrafterComponentHolder; | ||
import badasintended.megane.impl.mixin.modern_industrialization.EnergyComponentHolder; | ||
import badasintended.megane.impl.mixin.modern_industrialization.EnergyInputsComponentHolder; | ||
import badasintended.megane.impl.mixin.modern_industrialization.EnergyOutputsComponentHolder; | ||
import badasintended.megane.impl.mixin.modern_industrialization.MultiblockInventoryComponentHolder; | ||
import badasintended.megane.util.MeganeUtils; | ||
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ModernIndustrialization implements MeganeModule { | ||
|
||
@Override | ||
public void register(MeganeRegistrar registrar) { | ||
registrar | ||
.energy(EnergyComponentHolder.class, EnergyProvider.of( | ||
t -> t.getEnergy().getEu(), | ||
t -> t.getEnergy().getCapacity() | ||
)) | ||
.energy(EnergyInputsComponentHolder.class, EnergyProvider.of( | ||
t -> !t.getEnergyInputs().isEmpty(), | ||
t -> t.getEnergyInputs().stream().mapToDouble(EnergyComponent::getEu).sum(), | ||
t -> t.getEnergyInputs().stream().mapToDouble(EnergyComponent::getCapacity).sum() | ||
)) | ||
.energy(EnergyOutputsComponentHolder.class, EnergyProvider.of( | ||
t -> !t.getEnergyOutputs().isEmpty(), | ||
t -> t.getEnergyOutputs().stream().mapToDouble(EnergyComponent::getEu).sum(), | ||
t -> t.getEnergyOutputs().stream().mapToDouble(EnergyComponent::getCapacity).sum() | ||
)) | ||
.fluid(TankBlockEntity.class, FluidProvider.of( | ||
t -> 1, | ||
(t, i) -> t.resource(), | ||
(t, i) -> t.amount() / 81.0, | ||
(t, i) -> ((ATankBlockEntity) t).getCapacity() / 81.0 | ||
)) | ||
.fluid(CreativeTankBlockEntity.class, FluidProvider.of( | ||
t -> 1, | ||
(t, i) -> t.resource(), | ||
(t, i) -> -1, | ||
(t, i) -> -1 | ||
)) | ||
.fluid(MachineBlockEntity.class, FluidProvider.of( | ||
t -> t.getInventory().getFluidStacks().size(), | ||
(t, i) -> t.getInventory().getFluidStacks().get(i).resource(), | ||
(t, i) -> t.getInventory().getFluidStacks().get(i).getAmount() / 81.0, | ||
(t, i) -> t.getInventory().getFluidStacks().get(i).getCapacity() / 81.0 | ||
)) | ||
.fluid(999, MultiblockInventoryComponentHolder.class, new FluidProvider<MultiblockInventoryComponentHolder>() { | ||
List<ConfigurableFluidStack> input; | ||
List<ConfigurableFluidStack> output; | ||
|
||
@Override | ||
public int getSlotCount(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder) { | ||
input = multiblockInventoryComponentHolder.getInventory().getFluidInputs(); | ||
output = multiblockInventoryComponentHolder.getInventory().getFluidOutputs(); | ||
return input.size() + output.size(); | ||
} | ||
|
||
ConfigurableFluidStack getFluidStack(int slot) { | ||
return slot < input.size() | ||
? input.get(slot) | ||
: output.get(slot - input.size()); | ||
} | ||
|
||
@Override | ||
public @Nullable Fluid getFluid(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder, int slot) { | ||
return getFluidStack(slot).getFluid(); | ||
} | ||
|
||
@Override | ||
public double getStored(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder, int slot) { | ||
return getFluidStack(slot).getAmount() / 81.0; | ||
} | ||
|
||
@Override | ||
public double getMax(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder, int slot) { | ||
return getFluidStack(slot).getCapacity() / 81.0; | ||
} | ||
}) | ||
.inventory(MachineBlockEntity.class, InventoryProvider.of( | ||
t -> t.getInventory().getItemStacks().size(), | ||
(t, i) -> { | ||
ConfigurableItemStack stack = t.getInventory().getItemStacks().get(i); | ||
return stack.resource().toStack(stack.getCount()); | ||
} | ||
)) | ||
.inventory(999, MultiblockInventoryComponentHolder.class, new InventoryProvider<MultiblockInventoryComponentHolder>() { | ||
List<ConfigurableItemStack> input; | ||
List<ConfigurableItemStack> output; | ||
|
||
@Override | ||
public int size(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder) { | ||
input = multiblockInventoryComponentHolder.getInventory().getItemInputs(); | ||
output = multiblockInventoryComponentHolder.getInventory().getItemOutputs(); | ||
return input.size() + output.size(); | ||
} | ||
|
||
@Override | ||
public @NotNull ItemStack getStack(MultiblockInventoryComponentHolder multiblockInventoryComponentHolder, int slot) { | ||
ConfigurableItemStack stack = slot < input.size() | ||
? input.get(slot) | ||
: output.get(slot - input.size()); | ||
return stack.resource().toStack(stack.getCount()); | ||
} | ||
}) | ||
.progress(CrafterComponentHolder.class, new ProgressProvider<CrafterComponentHolder>() { | ||
CrafterComponent crafter; | ||
CrafterComponent.Inventory inventory; | ||
|
||
int inputCount; | ||
|
||
boolean isNotMultiBlock = false; | ||
MachineInventoryComponent machineInventoryComponent; | ||
|
||
@Override | ||
public int[] getInputSlots(CrafterComponentHolder crafterComponentHolder) { | ||
crafter = crafterComponentHolder.getCrafter(); | ||
inventory = ((CrafterComponentHolder.Inventory) crafter).getInventory(); | ||
|
||
isNotMultiBlock = inventory instanceof MachineInventoryComponent; | ||
|
||
if (isNotMultiBlock) { | ||
machineInventoryComponent = (MachineInventoryComponent) inventory; | ||
inputCount = machineInventoryComponent.itemInputCount; | ||
} else { | ||
inputCount = inventory.getItemInputs().size(); | ||
} | ||
|
||
return MeganeUtils.intRange(0, inputCount); | ||
} | ||
|
||
@Override | ||
public int[] getOutputSlots(CrafterComponentHolder crafterComponentHolder) { | ||
return MeganeUtils.intRange(inputCount, isNotMultiBlock | ||
? machineInventoryComponent.itemOutputCount | ||
: inventory.getItemOutputs().size()); | ||
} | ||
|
||
@Override | ||
public @NotNull ItemStack getStack(CrafterComponentHolder crafterComponentHolder, int slot) { | ||
ConfigurableItemStack stack; | ||
if (isNotMultiBlock) { | ||
stack = machineInventoryComponent.inventory.getItemStacks().get(slot); | ||
} else { | ||
stack = slot < inputCount | ||
? inventory.getItemInputs().get(slot) | ||
: inventory.getItemOutputs().get(slot); | ||
} | ||
return stack.getItemKey().toStack(stack.getCount()); | ||
} | ||
|
||
@Override | ||
public int getPercentage(CrafterComponentHolder crafterComponentHolder) { | ||
return (int) (crafter.getProgress() * 100); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void registerClient(MeganeClientRegistrar registrar) { | ||
registrar | ||
.fluid(ACraftingFluid.class, FluidInfoProvider.of(f -> f.getBlock().getColor(), f -> f.getBlock().getName())) | ||
.energy("modern_industrialization", 0xB70000, "EU"); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...ation-4/java/badasintended/megane/impl/mixin/modern_industrialization/ACraftingFluid.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,14 @@ | ||
package badasintended.megane.impl.mixin.modern_industrialization; | ||
|
||
import aztech.modern_industrialization.fluid.CraftingFluid; | ||
import aztech.modern_industrialization.fluid.CraftingFluidBlock; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(CraftingFluid.class) | ||
public interface ACraftingFluid { | ||
|
||
@Accessor | ||
CraftingFluidBlock getBlock(); | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ion-4/java/badasintended/megane/impl/mixin/modern_industrialization/ATankBlockEntity.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,13 @@ | ||
package badasintended.megane.impl.mixin.modern_industrialization; | ||
|
||
import aztech.modern_industrialization.blocks.tank.TankBlockEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(TankBlockEntity.class) | ||
public interface ATankBlockEntity { | ||
|
||
@Accessor | ||
long getCapacity(); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...java/badasintended/megane/impl/mixin/modern_industrialization/CrafterComponentHolder.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,26 @@ | ||
package badasintended.megane.impl.mixin.modern_industrialization; | ||
|
||
import aztech.modern_industrialization.machines.blockentities.AbstractCraftingMachineBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.multiblocks.AbstractCraftingMultiblockBlockEntity; | ||
import aztech.modern_industrialization.machines.components.CrafterComponent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin({ | ||
AbstractCraftingMachineBlockEntity.class, | ||
AbstractCraftingMultiblockBlockEntity.class | ||
}) | ||
public interface CrafterComponentHolder { | ||
|
||
@Accessor | ||
CrafterComponent getCrafter(); | ||
|
||
@Mixin(CrafterComponent.class) | ||
interface Inventory { | ||
|
||
@Accessor | ||
CrafterComponent.Inventory getInventory(); | ||
|
||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
.../java/badasintended/megane/impl/mixin/modern_industrialization/EnergyComponentHolder.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,24 @@ | ||
package badasintended.megane.impl.mixin.modern_industrialization; | ||
|
||
import aztech.modern_industrialization.machines.blockentities.AbstractStorageMachineBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.ElectricCraftingMachineBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.ElectricWaterPumpBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.EnergyFromFluidMachineBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.hatches.EnergyHatch; | ||
import aztech.modern_industrialization.machines.components.EnergyComponent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin({ | ||
AbstractStorageMachineBlockEntity.class, | ||
ElectricCraftingMachineBlockEntity.class, | ||
ElectricWaterPumpBlockEntity.class, | ||
EnergyFromFluidMachineBlockEntity.class, | ||
EnergyHatch.class | ||
}) | ||
public interface EnergyComponentHolder { | ||
|
||
@Accessor | ||
EnergyComponent getEnergy(); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...badasintended/megane/impl/mixin/modern_industrialization/EnergyInputsComponentHolder.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,20 @@ | ||
package badasintended.megane.impl.mixin.modern_industrialization; | ||
|
||
import java.util.List; | ||
|
||
import aztech.modern_industrialization.machines.blockentities.multiblocks.ElectricBlastFurnaceBlockEntity; | ||
import aztech.modern_industrialization.machines.blockentities.multiblocks.ElectricCraftingMultiblockBlockEntity; | ||
import aztech.modern_industrialization.machines.components.EnergyComponent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin({ | ||
ElectricBlastFurnaceBlockEntity.class, | ||
ElectricCraftingMultiblockBlockEntity.class | ||
}) | ||
public interface EnergyInputsComponentHolder { | ||
|
||
@Accessor | ||
List<EnergyComponent> getEnergyInputs(); | ||
|
||
} |
Oops, something went wrong.