Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
minecraft_version=24w34a
yarn_mappings=24w34a+build.12
loader_version=0.18.4

# Mod Properties
mod_version = 0.4.0+1.21.1
mod_version = 0.4.1+1.21.1
maven_group = net.errorcraft
archives_base_name = itematic

# Dependencies
fabric_version=0.116.7+1.21.1
fabric_version=0.103.0+1.21.2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.dynamic.Codecs;
import net.minecraft.util.math.ColorHelper;

import java.util.List;

Expand All @@ -26,15 +27,17 @@ public Identifier progressTexture(ItemStack stack) {
if (progress <= 0.0f) {
return this.textures.getFirst();
}

if (progress >= 1.0f) {
return this.textures.getLast();
}

int index = (int) (progress * (this.textures.size() - 1));
return this.textures.get(index);
}

public int color(ItemStack stack) {
float progress = this.progress.get(stack);
return this.color.get(progress);
return ColorHelper.fullAlpha(this.color.get(progress));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.texture.GuiAtlasManager;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
Expand All @@ -25,14 +23,16 @@
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.function.Function;

@Mixin(DrawContext.class)
public abstract class DrawContextExtender {
@Shadow
@Final
private GuiAtlasManager guiAtlasManager;
private MatrixStack matrices;

@Shadow
public abstract void drawSprite(int x, int y, int z, int width, int height, Sprite sprite, float red, float green, float blue, float alpha);
public abstract void drawGuiTexture(Function<Identifier, RenderLayer> function, Identifier identifier, int i, int j, int k, int l, int m);

@Unique
private ItemBarStyleLoader itemBarStyles;
Expand Down Expand Up @@ -73,15 +73,22 @@ private void renderItemBarFromDataComponent(TextRenderer textRenderer, ItemStack
if (itemBarStyleId == null) {
return;
}
this.itemBarStyles.get(itemBarStyleId).ifPresent(itemBarStyle -> this.drawGuiTexture(
itemBarStyle.progressTexture(stack),
x,
y,
200,
16,
16,
itemBarStyle.color(stack)
));

this.itemBarStyles.get(itemBarStyleId).ifPresent(itemBarStyle -> {
if (stack.getCount() == 1 && countOverride == null) {
this.matrices.translate(0.0f, 0.0f, 200.0f);
}

this.drawGuiTexture(
RenderLayer::getGuiTextured,
itemBarStyle.progressTexture(stack),
x,
y,
16,
16,
itemBarStyle.color(stack)
);
});
}

@Redirect(
Expand All @@ -102,13 +109,4 @@ private void renderItemBarFromDataComponent(TextRenderer textRenderer, ItemStack
)
)
private void doNotRenderOriginalItemBar(DrawContext instance, RenderLayer layer, int x1, int y1, int x2, int y2, int color) {}

@Unique
private void drawGuiTexture(Identifier texture, int x, int y, int z, int width, int height, int color) {
float red = ((color >> 16) & 0xff) / 255.0f;
float green = ((color >> 8) & 0xff) / 255.0f;
float blue = (color & 0xff) / 255.0f;
Sprite sprite = this.guiAtlasManager.getSprite(texture);
this.drawSprite(x, y, z, width, height, sprite, red, green, blue, 1.0f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.registry.DefaultedRegistry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -73,7 +73,7 @@ private ItemStack getIconUseDynamicRegistry(ItemGroup instance, DrawContext cont
)
)
@SuppressWarnings("ConstantConditions")
private Stream<TagKey<Item>> streamTagsUseDynamicRegistry(DefaultedRegistry<Item> instance) {
private Stream<RegistryEntryList.Named<Item>> streamTagsUseDynamicRegistry(DefaultedRegistry<Item> instance) {
return this.client.world.getRegistryManager()
.get(RegistryKeys.ITEM)
.streamTags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@

import net.errorcraft.itematic.access.client.gui.screen.recipebook.RecipeBookWidgetAccess;
import net.errorcraft.itematic.item.component.ItemComponentTypes;
import net.minecraft.client.gui.screen.recipebook.AbstractFurnaceRecipeBookScreen;
import net.minecraft.client.gui.screen.recipebook.AbstractFurnaceRecipeBookWidget;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.screen.AbstractFurnaceScreenHandler;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(AbstractFurnaceRecipeBookScreen.class)
public class AbstractFurnaceRecipeBookScreenExtender extends RecipeBookWidget implements RecipeBookWidgetAccess {
import java.util.List;

@Mixin(AbstractFurnaceRecipeBookWidget.class)
public abstract class AbstractFurnaceRecipeBookScreenExtender extends RecipeBookWidget<AbstractFurnaceScreenHandler> implements RecipeBookWidgetAccess {
@Shadow
@Nullable
private Ingredient fuels;
private List<ItemStack> fuels;

public AbstractFurnaceRecipeBookScreenExtender(AbstractFurnaceScreenHandler craftingScreenHandler) {
super(craftingScreenHandler);
}

@Override
public void itematic$initializeRecipeSpecific(World world) {
this.fuels = Ingredient.ofStacks(world.itematic$getItemAccess()
this.fuels = world.itematic$getItemAccess()
.streamEntries()
.filter(reference -> reference.value().itematic$hasComponent(ItemComponentTypes.FUEL))
.map(ItemStack::new)
);
.toList();
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.errorcraft.itematic.access.client.gui.screen.recipebook.RecipeBookWidgetAccess;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.screen.AbstractRecipeScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -15,7 +14,7 @@ public class RecipeBookWidgetExtender implements RecipeBookWidgetAccess {
method = "initialize",
at = @At("TAIL")
)
private void initializeAllowRecipeSpecificInitialization(int parentWidth, int parentHeight, MinecraftClient client, boolean narrow, AbstractRecipeScreenHandler<?, ?> craftingScreenHandler, CallbackInfo info) {
private void initializeAllowRecipeSpecificInitialization(int parentWidth, int parentHeight, MinecraftClient client, boolean narrow, CallbackInfo info) {
this.itematic$initializeRecipeSpecific(client.world);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BundleTooltipComponentExtender implements BundleTooltipComponentAcc
private Fraction capacity;

@Redirect(
method = "drawItems",
method = "getProgressBarLabel",
at = @At(
value = "FIELD",
target = "Lorg/apache/commons/lang3/math/Fraction;ONE:Lorg/apache/commons/lang3/math/Fraction;",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.errorcraft.itematic.access.network.listener.ClientPlayPacketListenerAccess;
import net.errorcraft.itematic.item.ItemKeys;
import net.errorcraft.itematic.item.component.ItemComponentTypes;
import net.errorcraft.itematic.mixin.item.ItemGroupsAccessor;
import net.errorcraft.itematic.network.packet.s2c.play.TwirlS2CPacket;
import net.errorcraft.itematic.world.action.actions.TwirlPlayerAction;
import net.minecraft.client.MinecraftClient;
Expand All @@ -18,7 +19,9 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayNetworkHandler.class)
public abstract class ClientPlayNetworkHandlerExtender extends ClientCommonNetworkHandler implements ClientPlayPacketListenerAccess {
Expand All @@ -29,6 +32,17 @@ protected ClientPlayNetworkHandlerExtender(MinecraftClient client, ClientConnect
super(client, connection, connectionState);
}

@Inject(
method = "onSynchronizeTags",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/ItemGroups;getSearchGroup()Lnet/minecraft/item/ItemGroup;"
)
)
private static void resetItemGroupDisplayContext(CallbackInfo info) {
ItemGroupsAccessor.setDisplayContext(null);
}

@Redirect(
method = "getActiveTotemOfUndying",
at = @At(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Mixin(PlayerEntityRenderer.class)
public class PlayerEntityRendererExtender {
@Redirect(
method = "getArmPose",
method = "updateHandState",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z"
Expand Down
Loading