Skip to content

Commit

Permalink
ME Stocking Part
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer523 committed Jun 7, 2024
1 parent 4db69be commit 2760545
Show file tree
Hide file tree
Showing 53 changed files with 2,720 additions and 783 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod_authors= YourNameHere, OtherNameHere
mod_description = Example mod description.\nNewline characters can be used and will be replaced properly.
mod_license = AGPL-3.0
mod_url = https://github.com/
mod_version = 1.0.4
mod_version = 1.0.5

maven_group = com.epimorphismmc.gregiceng

Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencyResolutionManagement {
def jeiVersion = "15.2.0.27"
def reiVersion = "12.0.684"
def emiVersion = "1.1.4"
def ae2Version = "15.2.1"
def ae2Version = "15.2.2"
def gtmVersion = "1.2.3.a"

// Forge
Expand All @@ -39,7 +39,7 @@ dependencyResolutionManagement {
def configurationVersion = "2.2.0"
def ldLibVersion = "1.0.25.j"
def mixinextrasVersion = "0.3.2"
def monomorphismLibVersion = "1.0.10-build.19"
def monomorphismLibVersion = "1.1.0-build.23"

forge {
version("forgeShortVersion", forgeVersion)
Expand Down
7 changes: 7 additions & 0 deletions src/generated/resources/assets/gregiceng/lang/en_ud.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"block.gregiceng.adv_stocking_bus": "snᗺ ʇnduI buıʞɔoʇS pǝɔuɐʌpⱯ ƎW",
"block.gregiceng.adv_stocking_hatch": "ɥɔʇɐH ʇnduI buıʞɔoʇS pǝɔuɐʌpⱯ ƎW",
"block.gregiceng.crafting_io_buffer": "ɹǝɟɟnᗺ OI buıʇɟɐɹƆ ƎW",
"block.gregiceng.ev_input_buffer": "ɹǝɟɟnᗺ ʇnduI ΛƎϛ§",
"block.gregiceng.ev_output_buffer": "ɹǝɟɟnᗺ ʇndʇnO ΛƎϛ§",
Expand All @@ -12,6 +14,8 @@
"block.gregiceng.opv_input_buffer": "ɹǝɟɟnᗺ ʇnduI ΛdOן§6§",
"block.gregiceng.opv_output_buffer": "ɹǝɟɟnᗺ ʇndʇnO ΛdOן§6§",
"block.gregiceng.output_buffer.desc": "sʞɔoןqıʇןnW ɹoɟ ʇndʇnO pınןℲ puɐ ɯǝʇI",
"block.gregiceng.stocking_bus": "snᗺ ʇnduI buıʞɔoʇS ƎW",
"block.gregiceng.stocking_hatch": "ɥɔʇɐH ʇnduI buıʞɔoʇS ƎW",
"block.gregiceng.uev_input_buffer": "ɹǝɟɟnᗺ ʇnduI ΛƎ∩ɐ§",
"block.gregiceng.uev_output_buffer": "ɹǝɟɟnᗺ ʇndʇnO ΛƎ∩ɐ§",
"block.gregiceng.uhv_input_buffer": "ɹǝɟɟnᗺ ʇnduI ΛH∩ㄣ§",
Expand All @@ -26,7 +30,10 @@
"block.gregiceng.zpm_output_buffer": "ɹǝɟɟnᗺ ʇndʇnO WԀZɔ§",
"config.gregiceng.option.enableMoreAbility": "ǝʌɐןS/ɹǝɟɟnᗺ OI buıʇɟɐɹƆ ɹoɟ ʎʇıןıqⱯ ǝɹoW ǝןqɐuƎ",
"config.jade.plugin_gregiceng.crafting_io_buffer": "ɹǝɟɟnᗺ OI buıʇɟɐɹƆ",
"gui.gregiceng.automatic_return.desc.disabled": "pǝןqɐsıp sı uɹnʇǝᴚ ɔıʇɐɯoʇnⱯ",
"gui.gregiceng.automatic_return.desc.enabled": "uo sı uɹnʇǝᴚ ɔıʇɐɯoʇnⱯ",
"gui.gregiceng.refund_all.desc": "ןןnɟ uı sןɐıɹǝʇɐɯ ʍɐɹ punɟǝᴚ",
"gui.gregiceng.rename.desc": "ǝɯɐuǝᴚ",
"gui.gregiceng.share_inventory.desc": "ʎɹoʇuǝʌuı ǝɹɐɥs uǝdO",
"gui.gregiceng.share_inventory.title": "ʎɹoʇuǝʌuI ǝɹɐɥS",
"gui.gregiceng.share_tank.desc": "ʞuɐʇ ǝɹɐɥs uǝdO",
Expand Down
7 changes: 7 additions & 0 deletions src/generated/resources/assets/gregiceng/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"block.gregiceng.adv_stocking_bus": "ME Advanced Stocking Input Bus",
"block.gregiceng.adv_stocking_hatch": "ME Advanced Stocking Input Hatch",
"block.gregiceng.crafting_io_buffer": "ME Crafting IO Buffer",
"block.gregiceng.ev_input_buffer": "§5EV Input Buffer",
"block.gregiceng.ev_output_buffer": "§5EV Output Buffer",
Expand All @@ -12,6 +14,8 @@
"block.gregiceng.opv_input_buffer": "§9§lOpV Input Buffer",
"block.gregiceng.opv_output_buffer": "§9§lOpV Output Buffer",
"block.gregiceng.output_buffer.desc": "Item and Fluid Output for Multiblocks",
"block.gregiceng.stocking_bus": "ME Stocking Input Bus",
"block.gregiceng.stocking_hatch": "ME Stocking Input Hatch",
"block.gregiceng.uev_input_buffer": "§aUEV Input Buffer",
"block.gregiceng.uev_output_buffer": "§aUEV Output Buffer",
"block.gregiceng.uhv_input_buffer": "§4UHV Input Buffer",
Expand All @@ -26,7 +30,10 @@
"block.gregiceng.zpm_output_buffer": "§cZPM Output Buffer",
"config.gregiceng.option.enableMoreAbility": "Enable More Ability for Crafting IO Buffer/Slave",
"config.jade.plugin_gregiceng.crafting_io_buffer": "Crafting IO Buffer",
"gui.gregiceng.automatic_return.desc.disabled": "Automatic Return is disabled",
"gui.gregiceng.automatic_return.desc.enabled": "Automatic Return is on",
"gui.gregiceng.refund_all.desc": "Refund raw materials in full",
"gui.gregiceng.rename.desc": "Rename",
"gui.gregiceng.share_inventory.desc": "Open share inventory",
"gui.gregiceng.share_inventory.title": "Share Inventory",
"gui.gregiceng.share_tank.desc": "Open share tank",
Expand Down
7 changes: 7 additions & 0 deletions src/generated/resources/assets/gregiceng/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"block.gregiceng.adv_stocking_bus": "ME进阶存储输入总线",
"block.gregiceng.adv_stocking_hatch": "ME进阶存储输入仓",
"block.gregiceng.crafting_io_buffer": "ME样板IO总成",
"block.gregiceng.ev_input_buffer": "§5EV§r输入总成",
"block.gregiceng.ev_output_buffer": "§5EV§r输出总成",
Expand All @@ -12,6 +14,8 @@
"block.gregiceng.opv_input_buffer": "§9§lOpV§r输入总成",
"block.gregiceng.opv_output_buffer": "§9§lOpV§r输出总成",
"block.gregiceng.output_buffer.desc": "为多方块结构输出物品和流体",
"block.gregiceng.stocking_bus": "ME存储输入总线",
"block.gregiceng.stocking_hatch": "ME存储输入仓",
"block.gregiceng.uev_input_buffer": "§aUEV§r输入总成",
"block.gregiceng.uev_output_buffer": "§aUEV§r输出总成",
"block.gregiceng.uhv_input_buffer": "§4UHV§r输入总成",
Expand All @@ -26,7 +30,10 @@
"block.gregiceng.zpm_output_buffer": "§cZPM§r输出总成",
"config.gregiceng.option.enableMoreAbility": "为样板IO总成/镜像启用更多能力",
"config.jade.plugin_gregiceng.crafting_io_buffer": "样板IO总成",
"gui.gregiceng.automatic_return.desc.disabled": "自动回流已禁用",
"gui.gregiceng.automatic_return.desc.enabled": "自动回流已开启",
"gui.gregiceng.refund_all.desc": "退回所有材料",
"gui.gregiceng.rename.desc": "重命名",
"gui.gregiceng.share_inventory.desc": "打开共享库存",
"gui.gregiceng.share_inventory.title": "共享库存",
"gui.gregiceng.share_tank.desc": "打开共享储罐",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;

public class GEGuiTextures {
public static final ResourceTexture SMALL_ARROW_OVERLAY = createTexture("overlay/small_arrow_overlay.png");

public static final ResourceTexture REFUND_OVERLAY = createTexture("overlay/refund_overlay.png");
public static final ResourceTexture PATTERN_OVERLAY = createTexture("overlay/pattern_overlay.png");

public static final ResourceTexture BUTTON_AUTOMATIC_RETURN = createTexture("widget/button_automatic_return.png");
public static final ResourceTexture BUTTON_AUTO_PULL_ME = createTexture("widget/button_auto_pull_me.png");

private static ResourceTexture createTexture(String imageLocation) {
return new ResourceTexture("%s:textures/gui/%s".formatted(GregicEng.MODID, imageLocation));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.epimorphismmc.gregiceng.api.gui.wight;

import appeng.api.stacks.AEKey;
import com.epimorphismmc.gregiceng.api.misc.IConfigurableAESlot;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.utils.Position;
import com.lowdragmc.lowdraglib.utils.Size;
import lombok.Setter;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.BiConsumer;

public abstract class AESlotWidget<T extends AEKey> extends Widget {
@Setter
protected BiConsumer<AESlotWidget<T>, List<Component>> onAddedTooltips;
protected IConfigurableAESlot<T> aeSlot;
protected T key;
protected long amount;

public AESlotWidget(IConfigurableAESlot<T> aeSlot, Position selfPosition) {
super(selfPosition, new Size(18, 18));
this.aeSlot = aeSlot;
}

public AESlotWidget(IConfigurableAESlot<T> aeSlot, int x, int y) {
this(aeSlot, new Position(x, y));
}

@Override
public final void setSize(Size size) {
// you cant modify size.
}

protected abstract void fromPacket(@Nullable FriendlyByteBuf buf);

@Override
public void writeInitialData(FriendlyByteBuf buffer) {
super.writeInitialData(buffer);
this.key = aeSlot.getConfig();
this.amount = aeSlot.getAmount();
if (key != null && amount > 0){
buffer.writeBoolean(true);
key.writeToPacket(buffer);
buffer.writeVarLong(amount);
} else {
buffer.writeBoolean(false);
}
}

@OnlyIn(Dist.CLIENT)
@Override
public void readInitialData(FriendlyByteBuf buffer) {
super.readInitialData(buffer);
if (buffer.readBoolean()) {
fromPacket(buffer);
this.amount = buffer.readVarLong();
} else {
fromPacket(null);
this.amount = 0;
}
}

@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
var newKey = aeSlot.getConfig();
var newAmount = aeSlot.getAmount();
// TODO 是否用equal
if (newKey != key || amount != newAmount) {
this.key = newKey;
this.amount = newAmount;
writeUpdateInfo(1, buffer -> {
if (key != null && amount > 0) {
buffer.writeBoolean(true);
key.writeToPacket(buffer);
buffer.writeVarLong(amount);
} else {
buffer.writeBoolean(false);
}
});
}
}

@OnlyIn(Dist.CLIENT)
@Override
public void readUpdateInfo(int id, FriendlyByteBuf buffer) {
super.readUpdateInfo(id, buffer);
if (id == 1) {
if (buffer.readBoolean()) {
fromPacket(buffer);
this.amount = buffer.readVarLong();
} else {
fromPacket(null);
this.amount = 0;
}
}
}

protected List<Component> getToolTips(List<Component> list) {
if (this.onAddedTooltips != null) {
this.onAddedTooltips.accept(this, list);
}
return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.epimorphismmc.gregiceng.api.gui.wight;

import appeng.api.stacks.AEKey;
import com.epimorphismmc.gregiceng.api.misc.IConfigurableAESlotList;
import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget;
import com.lowdragmc.lowdraglib.gui.ingredient.Target;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.utils.Position;
import com.lowdragmc.lowdraglib.utils.Size;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;

import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawSolidRect;

public abstract class ConfigSlotWidget<T extends AEKey> extends Widget implements IGhostIngredientTarget {
protected final static int REMOVE_ID = 1000;
protected final static int UPDATE_ID = 1001;
protected static final int BLOCKED_OVERLAY_COLOR = 0x80404040;
protected static final int SELECTION_OVERLAY_COLOR = -0x7f000001;
protected final int index;
protected final IConfigurableAESlotList<T> slotList;
protected final Predicate<T> validator;
protected T latestConfig;
protected BooleanSupplier isBlocked = () -> false;

public ConfigSlotWidget(IConfigurableAESlotList<T> slotList, int index, Position pos, Predicate<T> validator) {
super(pos, new Size(18, 18));
this.slotList = slotList;
this.index = index;
this.validator = validator;
}

public ConfigSlotWidget(IConfigurableAESlotList<T> slotList, int index, int x, int y, Predicate<T> validator) {
this(slotList, index, new Position(x, y), validator);
}

@OnlyIn(Dist.CLIENT)
@Override
public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
if (isMouseOverElement(mouseX, mouseY)
&& getHoverElement(mouseX, mouseY) == this
&& gui != null
&& gui.getModularUIGui() != null) {
drawTooltipTexts(mouseX, mouseY);
}
}

@OnlyIn(Dist.CLIENT)
@Override
protected void drawTooltipTexts(int mouseX, int mouseY) {
gui.getModularUIGui().setHoverTooltip(getHoverTexts(new ArrayList<>()), ItemStack.EMPTY, null, null);
}

public ConfigSlotWidget<T> setIsBlocked(BooleanSupplier isBlocked) {
this.isBlocked = isBlocked;
return this;
}

protected @Nullable T getConfig() {
return slotList.getAESlot(index).getConfig();
}

protected void setConfig(@Nullable T config) {
slotList.getAESlot(index).setConfig(config);
}

protected List<Component> getHoverTexts(List<Component> hoverTexts) {
if (getConfig() == null) {
if (isBlocked.getAsBoolean()) {

} else {
hoverTexts.add(Component.translatable("gtceu.gui.config_slot"));
hoverTexts.add(Component.translatable("gtceu.gui.config_slot.set"));
hoverTexts.add(Component.translatable("gtceu.gui.config_slot.remove"));
}
hoverTexts.addAll(tooltipTexts);
}
return hoverTexts;
}

@OnlyIn(Dist.CLIENT)
protected static void drawBlockedOverlay(GuiGraphics graphics, int x, int y, int width, int height) {
RenderSystem.disableDepthTest();
RenderSystem.colorMask(true, true, true, false);
drawSolidRect(graphics, x, y, width, height, BLOCKED_OVERLAY_COLOR);
RenderSystem.colorMask(true, true, true, true);
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
}

@OnlyIn(Dist.CLIENT)
protected static void drawSelectionOverlay(GuiGraphics graphics, int x, int y, int width, int height) {
RenderSystem.disableDepthTest();
RenderSystem.colorMask(true, true, true, false);
drawSolidRect(graphics, x, y, width, height, SELECTION_OVERLAY_COLOR);
RenderSystem.colorMask(true, true, true, true);
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
}

@Override
public List<Target> getPhantomTargets(Object ingredient) {
return Collections.emptyList();
}
}
Loading

0 comments on commit 2760545

Please sign in to comment.