Skip to content

Commit

Permalink
Merge branch 'mc1.18/fabric/dev' into mc1.19/fabric/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Mar 24, 2024
2 parents d9a7d04 + c9155a7 commit b750261
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions FABRIC_CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Change logging starts below:
- fix ingredients of sequenced assembly recipes not being properly linked to their uses (#1394)
- marked known outdated broken addon versions as incompatible
- marked Sound Physics Remastered as broken due to calling non thread safe code off thread
- add cycling to the block displayed in manual item application in EMI
22 changes: 22 additions & 0 deletions src/main/java/com/simibubi/create/compat/emi/CyclingDrawable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.simibubi.create.compat.emi;

import com.mojang.blaze3d.vertex.PoseStack;

import dev.emi.emi.api.widget.DrawableWidget.DrawableWidgetConsumer;

import java.util.List;

public record CyclingDrawable(List<? extends DrawableWidgetConsumer> children) implements DrawableWidgetConsumer {
@Override
public void render(PoseStack matrices, int x, int y, float delta) {
this.choose().render(matrices, x, y, delta);
}

private DrawableWidgetConsumer choose() {
// ticks are not available, use system time.
long millis = System.currentTimeMillis();
long seconds = millis / 1000;
int index = (int) (seconds % this.children.size());
return this.children.get(index);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.simibubi.create.compat.emi.recipes;

import com.simibubi.create.compat.emi.CreateEmiPlugin;
import com.simibubi.create.compat.emi.CyclingDrawable;
import com.simibubi.create.compat.emi.RenderedBlock;
import com.simibubi.create.content.kinetics.deployer.ItemApplicationRecipe;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.Lang;

import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.widget.DrawableWidget.DrawableWidgetConsumer;
import dev.emi.emi.api.widget.SlotWidget;
import dev.emi.emi.api.widget.WidgetHolder;
import net.minecraft.ChatFormatting;

import java.util.List;
import java.util.Objects;

public class ManualItemApplicationEmiRecipe extends CreateEmiRecipe<ItemApplicationRecipe> {
public ManualItemApplicationEmiRecipe(ItemApplicationRecipe recipe) {
super(CreateEmiPlugin.ITEM_APPLICATION, recipe, 177, 60);
Expand All @@ -21,8 +26,13 @@ public void addWidgets(WidgetHolder widgets) {
EmiIngredient base = input.get(0);
addSlot(widgets, base, 27, 38);

RenderedBlock block = RenderedBlock.of(base);
if (block != null) {
List<? extends DrawableWidgetConsumer> blocks = base.getEmiStacks().stream()
.map(RenderedBlock::of)
.filter(Objects::nonNull)
.toList();

if (!blocks.isEmpty()) {
CyclingDrawable block = new CyclingDrawable(blocks);
widgets.addDrawable(0, 0, 0, 0, block);
}

Expand Down

0 comments on commit b750261

Please sign in to comment.