mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-01-18 16:37:23 +01:00
lil push
This commit is contained in:
@@ -151,6 +151,7 @@ repositories {
|
||||
name 'Curios'
|
||||
url "https://maven.theillusivec4.top/"
|
||||
}
|
||||
maven { url 'https://maven.blamejared.com' }
|
||||
}
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
@@ -176,9 +177,10 @@ dependencies {
|
||||
|
||||
implementation fg.deobf("curse.maven:astral-sorcery-241721:3156477")
|
||||
implementation fg.deobf("curse.maven:observerlib-316833:3162044")
|
||||
|
||||
// runtime deps
|
||||
runtimeOnly fg.deobf("curse.maven:curios-309927:3231111")
|
||||
compileOnly fg.deobf("vazkii.botania:Botania:1.16.5-416:api")
|
||||
runtimeOnly fg.deobf("vazkii.botania:Botania:1.16.5-416")
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
|
||||
@@ -1 +1 @@
|
||||
rootProject.name = 'masterfulmachinery'
|
||||
rootProject.name = "masterfulmachinery"
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ticticboooom.mods.mm.client.jei.ingredients;
|
||||
|
||||
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
|
||||
import mezz.jei.api.ingredients.IIngredientHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ManaIngredientHelper implements IIngredientHelper<PressureStack> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PressureStack getMatch(Iterable<PressureStack> ingredients, PressureStack ingredientToMatch) {
|
||||
return ingredientToMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(PressureStack ingredient) {
|
||||
return "Pressure";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId(PressureStack ingredient) {
|
||||
return ingredient.getAmount() + "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId(PressureStack ingredient) {
|
||||
return "pneumaticcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceId(PressureStack ingredient) {
|
||||
return "pressure";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PressureStack copyIngredient(PressureStack ingredient) {
|
||||
return new PressureStack(ingredient.getAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorInfo(@Nullable PressureStack ingredient) {
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ticticboooom.mods.mm.ports.parser;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.ports.state.ManaPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.ManaPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ManaPortParser implements IPortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
return () -> {
|
||||
DataResult<Pair<ManaPortStorage, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(ManaPortStorage.CODEC).apply(obj);
|
||||
return apply.result().get().getFirst();
|
||||
};
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void write(PacketBuffer buf, PortState state) {
|
||||
buf.func_240629_a_(ManaPortState.CODEC, ((ManaPortState) state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(IIngredients ingredients, List<?> stacks, boolean input) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getInputOverlay() {
|
||||
return new ResourceLocation(MM.ID, "block/base_ports/mana_input_cutout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOutputOverlay() {
|
||||
return new ResourceLocation(MM.ID, "block/base_ports/mana_output_cutout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortState createState(JsonObject obj) {
|
||||
DataResult<Pair<ManaPortState, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(ManaPortState.CODEC).apply(obj);
|
||||
return apply.result().get().getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public PortState createState(PacketBuffer buf) {
|
||||
return buf.func_240628_a_(ManaPortState.CODEC);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.ticticboooom.mods.mm.ports.state;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.client.jei.category.MMJeiPlugin;
|
||||
import com.ticticboooom.mods.mm.client.jei.ingredients.model.EnergyStack;
|
||||
import com.ticticboooom.mods.mm.ports.storage.EnergyPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import lombok.Getter;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredientGroup;
|
||||
import mezz.jei.api.helpers.IJeiHelpers;
|
||||
import mezz.jei.api.ingredients.IIngredientType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ManaPortState extends PortState {
|
||||
|
||||
public static final Codec<ManaPortState> CODEC = RecordCodecBuilder.create(x -> x.group(
|
||||
Codec.INT.fieldOf("amount").forGetter(z -> z.amount)
|
||||
).apply(x, ManaPortState::new));
|
||||
|
||||
|
||||
@Getter
|
||||
private final int amount;
|
||||
|
||||
public ManaPortState(int amount) {
|
||||
this.amount = amount;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRequirement(List<PortStorage> storage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateRequirement(List<PortStorage> storage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processResult(List<PortStorage> storage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateResult(List<PortStorage> storage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return new ResourceLocation(MM.ID, "mana");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack ms, int x, int y, int mouseX, int mouseY, IJeiHelpers helpers) {
|
||||
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 18, 61, 18, 18);
|
||||
drawable.draw(ms, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRecipe(IRecipeLayout layout, Integer typeIndex, int x, int y, boolean input) {
|
||||
IGuiIngredientGroup<EnergyStack> group = layout.getIngredientsGroup(MMJeiPlugin.ENERGY_TYPE);
|
||||
group.init(typeIndex, input, x + 1, y + 1);
|
||||
group.set(typeIndex, new EnergyStack(amount));
|
||||
if (this.getChance() < 1){
|
||||
group.addTooltipCallback((s, a, b, c) -> {
|
||||
if (s == typeIndex) {
|
||||
c.add(new StringTextComponent("Chance: " + this.getChance() * 100 + "%"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredientType<?> getJeiIngredientType() {
|
||||
return MMJeiPlugin.ENERGY_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ticticboooom.mods.mm.ports.storage;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.inventory.PortEnergyInventory;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
|
||||
public class ManaPortStorage extends PortStorage {
|
||||
public static final Codec<ManaPortStorage> CODEC = RecordCodecBuilder.create(x -> x.group(
|
||||
Codec.INT.fieldOf("capacity").forGetter(z -> z.inv.getMaxEnergyStored())
|
||||
).apply(x, ManaPortStorage::new));
|
||||
|
||||
@Getter
|
||||
private final PortEnergyInventory inv;
|
||||
private final LazyOptional<PortEnergyInventory> invLO;
|
||||
|
||||
public ManaPortStorage(int capacity) {
|
||||
this.inv = new PortEnergyInventory(0, capacity);
|
||||
invLO = LazyOptional.of(() -> this.inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getLO() {
|
||||
return invLO.cast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean validate(Capability<T> cap) {
|
||||
return cap == CapabilityEnergy.ENERGY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT save(CompoundNBT nbt) {
|
||||
nbt.putInt("stored", inv.getEnergyStored());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundNBT nbt) {
|
||||
if (nbt.contains("stored")) {
|
||||
inv.setStored(nbt.getInt("stored"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
|
||||
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
|
||||
screen.blit(stack, left, top, 0, 0, 175, 256);
|
||||
int barOffsetX = 175 - 30;
|
||||
int barOffsetY = 20;
|
||||
screen.blit(stack, left + barOffsetX, top + barOffsetY, 175, 18, 18, 108);
|
||||
float amount = 0;
|
||||
if (inv.getMaxEnergyStored() > 0) {
|
||||
amount = (float)inv.getEnergyStored() / inv.getMaxEnergyStored();
|
||||
}
|
||||
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
|
||||
AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer,Math.round((float)10000 * amount) / 100.f + "%", left + 30, top + 60, 0xfefefe);
|
||||
AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getEnergyStored() + "FE", left + 30, top + 80, 0xfefefe);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user