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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ loom {
gametestClient {
inherit client
name "GameTest Client"
vmArg "-Dfabric-api.gametest.structures.output-dir=${file("src/gametest/resources/data/itematic/gametest/structure")}"
vmArg "-Ditematic.gametest.structure-output-directory=${file("src/gametest/resources/data")}"

runDir "run"
source sourceSets.gametest
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
minecraft_version=1.21.5
yarn_mappings=1.21.5+build.1
loader_version=0.18.4

# Mod Properties
Expand All @@ -13,4 +13,4 @@ org.gradle.jvmargs=-Xmx1G
archives_base_name = itematic

# Dependencies
fabric_version=0.119.4+1.21.4
fabric_version=0.128.2+1.21.5
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 5 additions & 9 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.errorcraft.itematic.access.client.gui.screen;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;

public interface GameModeSwitcherScreenAccess {
interface GameModeSelectionAccess {
default ItemStack itematic$icon(Registry<Item> registry) {
return ItemStack.EMPTY;
}
default void itematic$setIcon(RegistryKey<Item> item) {}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.errorcraft.itematic.mixin.client.gui.screen;


import net.errorcraft.itematic.access.client.gui.screen.GameModeSelectionScreenGameModeSelectionAccess;
import net.errorcraft.itematic.access.client.gui.screen.GameModeSwitcherScreenAccess;
import net.errorcraft.itematic.item.ItemKeys;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.minecraft.client.gui.screen.GameModeSwitcherScreen;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
Expand All @@ -20,52 +20,53 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

public class GameModeSelectionScreenExtender {
@Mixin(GameModeSelectionScreen.ButtonWidget.class)
public class GameModeSwitcherScreenExtender {
@Mixin(GameModeSwitcherScreen.ButtonWidget.class)
public static class ButtonWidgetExtender {
@Redirect(
method = "renderWidget",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;renderIcon(Lnet/minecraft/client/gui/DrawContext;II)V"
target = "Lnet/minecraft/client/gui/screen/GameModeSwitcherScreen$GameModeSelection;renderIcon(Lnet/minecraft/client/gui/DrawContext;II)V"
)
)
private void renderIconUseRegistryEntry(GameModeSelectionScreen.GameModeSelection instance, DrawContext context, int x, int y) {
private void renderIconUseRegistryEntry(GameModeSwitcherScreen.GameModeSelection instance, DrawContext context, int x, int y) {
World world = MinecraftClient.getInstance().world;
if (world == null) {
return;
}

ItemStack stack = instance.itematic$icon(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM));
context.drawItem(stack, x, y);
}
}

@Mixin(GameModeSelectionScreen.GameModeSelection.class)
public static class GameModeSelectionExtender implements GameModeSelectionScreenGameModeSelectionAccess {
@Final
@Mixin(GameModeSwitcherScreen.GameModeSelection.class)
public static class GameModeSelectionExtender implements GameModeSwitcherScreenAccess.GameModeSelectionAccess {
@Shadow
public static GameModeSelectionScreen.GameModeSelection CREATIVE;

@Final
@Shadow
public static GameModeSelectionScreen.GameModeSelection SURVIVAL;
public static GameModeSwitcherScreen.GameModeSelection CREATIVE;

@Final
@Shadow
public static GameModeSelectionScreen.GameModeSelection ADVENTURE;
@Final
public static GameModeSwitcherScreen.GameModeSelection SURVIVAL;

@Shadow
@Final
public static GameModeSwitcherScreen.GameModeSelection ADVENTURE;

@Shadow
public static GameModeSelectionScreen.GameModeSelection SPECTATOR;
@Final
public static GameModeSwitcherScreen.GameModeSelection SPECTATOR;

@Unique
private RegistryKey<Item> icon;

static {
((GameModeSelectionExtender)(Object) CREATIVE).icon = ItemKeys.GRASS_BLOCK;
((GameModeSelectionExtender)(Object) SURVIVAL).icon = ItemKeys.IRON_SWORD;
((GameModeSelectionExtender)(Object) ADVENTURE).icon = ItemKeys.MAP;
((GameModeSelectionExtender)(Object) SPECTATOR).icon = ItemKeys.ENDER_EYE;
CREATIVE.itematic$setIcon(ItemKeys.GRASS_BLOCK);
SURVIVAL.itematic$setIcon(ItemKeys.IRON_SWORD);
ADVENTURE.itematic$setIcon(ItemKeys.MAP);
SPECTATOR.itematic$setIcon(ItemKeys.ENDER_EYE);
}

@Redirect(
Expand All @@ -84,9 +85,15 @@ private static ItemStack newItemStackReturnEmptyStack(ItemConvertible item) {
if (this.icon == null) {
return ItemStack.EMPTY;
}

return registry.getOptional(this.icon)
.map(ItemStack::new)
.orElse(ItemStack.EMPTY);
}

@Override
public void itematic$setIcon(RegistryKey<Item> icon) {
this.icon = icon;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.errorcraft.itematic.item.component.ItemComponentTypes;
import net.errorcraft.itematic.item.component.components.SmithingTemplateItemComponent;
import net.errorcraft.itematic.item.component.components.SmithingTemplateProviderItemComponent;
import net.errorcraft.itematic.item.smithing.template.SmithingTemplate;
import net.minecraft.client.gui.screen.ingame.ForgingScreen;
import net.minecraft.client.gui.screen.ingame.SmithingScreen;
Expand All @@ -16,7 +16,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SmithingTemplateItem;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.screen.SmithingScreenHandler;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -44,9 +43,8 @@ public SmithingScreenExtender(SmithingScreenHandler handler, PlayerInventory pla
private void storeSmithingTemplate(CallbackInfo info, @Share("smithingTemplate") LocalRef<Optional<SmithingTemplate>> smithingTemplate) {
smithingTemplate.set(this.handler.getSlot(0)
.getStack()
.itematic$getBehavior(ItemComponentTypes.SMITHING_TEMPLATE)
.map(SmithingTemplateItemComponent::template)
.map(RegistryEntry::value)
.itematic$getBehavior(ItemComponentTypes.SMITHING_TEMPLATE_PROVIDER)
.map(SmithingTemplateProviderItemComponent::template)
);
}

Expand Down Expand Up @@ -97,9 +95,8 @@ private Object checkPresenceEquipmentBehavior(ItemStack instance, ComponentType<
)
)
private boolean instanceOfSmithingTemplateItemUseItemComponentCheck(Object reference, Class<SmithingTemplateItem> clazz, @Local(ordinal = 0) ItemStack itemStack, @Share("smithingTemplate") LocalRef<SmithingTemplate> smithingTemplate) {
Optional<SmithingTemplate> optionalSmithingTemplate = itemStack.itematic$getBehavior(ItemComponentTypes.SMITHING_TEMPLATE)
.map(SmithingTemplateItemComponent::template)
.map(RegistryEntry::value);
Optional<SmithingTemplate> optionalSmithingTemplate = itemStack.itematic$getBehavior(ItemComponentTypes.SMITHING_TEMPLATE_PROVIDER)
.map(SmithingTemplateProviderItemComponent::template);
optionalSmithingTemplate.ifPresent(smithingTemplate::set);
return optionalSmithingTemplate.isPresent();
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private int getUseTimeLeftForCrossbowUseNegatedUsedTicks(AbstractClientPlayerEnt
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
ordinal = 0
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.errorcraft.itematic.mixin.client.render.item.property.select;

import net.errorcraft.itematic.item.ItemKeys;
import net.minecraft.client.render.item.property.select.ChargeTypeProperty;
import net.minecraft.component.type.ChargedProjectilesComponent;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ChargeTypeProperty.class)
public class ChargeTypePropertyExtender {
@Redirect(
method = "getValue(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/entity/LivingEntity;ILnet/minecraft/item/ItemDisplayContext;)Lnet/minecraft/item/CrossbowItem$ChargeType;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/component/type/ChargedProjectilesComponent;contains(Lnet/minecraft/item/Item;)Z"
)
)
private boolean containsForFireworkRocketUseRegistryKeyCheck(ChargedProjectilesComponent instance, Item item) {
return instance.itematic$contains(ItemKeys.FIREWORK_ROCKET);
}
}
Loading
Loading