Skip to content

Commit

Permalink
Some Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ALongStringOfNumbers committed Nov 30, 2023
1 parent c386e1c commit 210ee39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DamageSourceMixin {
private static DamageSource modifyPlayerDamageWithTool(DamageSource originalReturnValue, EntityPlayer source) {
ItemStack stack = source != null ? source.getHeldItemMainhand() : ItemStack.EMPTY;
if (!stack.isEmpty() && stack.getItem() instanceof IGTTool tool) {
return new DamageSourceTool("player", source, String.format("death.attack.%s", tool.getId()));
return new DamageSourceTool("player", source, String.format("death.attack.%s", tool.getToolId()));
}
return originalReturnValue;
}
Expand All @@ -30,7 +30,7 @@ private static DamageSource modifyPlayerDamageWithTool(DamageSource originalRetu
private static DamageSource modifyMobDamageWithTool(DamageSource originalReturnValue, EntityLivingBase source) {
ItemStack stack = source != null ? source.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) : ItemStack.EMPTY;
if (!stack.isEmpty() && stack.getItem() instanceof IGTTool tool) {
return new DamageSourceTool("mob", source, String.format("death.attack.%s", tool.getId()));
return new DamageSourceTool("mob", source, String.format("death.attack.%s", tool.getToolId()));
}
return new EntityDamageSource("mob", source);

Expand Down
26 changes: 16 additions & 10 deletions src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
@Mixin(RecipeRepairItem.class)
public class RecipeRepairItemMixin {

@Inject(method = "Lnet/minecraft/item/crafting/RecipeRepairItem;matches(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Z",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;"))
public static void gregtechCEu$matches(InventoryCrafting inv, World worldIn, CallbackInfoReturnable<Boolean> cir,
@Inject(method = "matches(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Z",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), cancellable = true)
public void gregtechCEu$matches(InventoryCrafting inv, World worldIn, CallbackInfoReturnable<Boolean> cir,
@Local LocalRef<ItemStack> itemstack, @Local LocalRef<ItemStack> itemstack1) {
if (itemstack.get().getItem() instanceof IGTTool first && itemstack1.get().getItem() instanceof IGTTool second) {
if (first.isElectric() || second.isElectric()) {
Expand All @@ -35,9 +35,9 @@ public class RecipeRepairItemMixin {
}
}

@Inject(method = "Lnet/minecraft/item/crafting/RecipeRepairItem;getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", ordinal = 0))
public static void gregtechCEu$getCraftingResultFirst(InventoryCrafting inv, CallbackInfoReturnable<ItemStack> cir,
@Inject(method = "getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", ordinal = 0), cancellable = true)
public void gregtechCEu$getCraftingResultFirst(InventoryCrafting inv, CallbackInfoReturnable<ItemStack> cir,
@Local(ordinal = 0) LocalRef<ItemStack> itemstack, @Local(ordinal = 1) LocalRef<ItemStack> itemstack1) {
if (itemstack.get().getItem() instanceof IGTTool tool && tool.isElectric()) {
cir.setReturnValue(ItemStack.EMPTY);
Expand All @@ -46,9 +46,9 @@ public class RecipeRepairItemMixin {
}
}

@Inject(method = "Lnet/minecraft/item/crafting/RecipeRepairItem;getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;",
at = @At(value = "RETURN", ordinal = 1))
public static void gregtechCEu$getCraftingResultSecond(InventoryCrafting inv, CallbackInfoReturnable<ItemStack> cir,
@Inject(method = "getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;",
at = @At(value = "RETURN", ordinal = 1), cancellable = true)
public void gregtechCEu$getCraftingResultSecond(InventoryCrafting inv, CallbackInfoReturnable<ItemStack> cir,
@Local(ordinal = 4) LocalIntRef i1, @Local(ordinal = 2) LocalRef<ItemStack> itemstack2,
@Local(ordinal = 3) LocalRef<ItemStack> itemstack3) {
if (itemstack2.get().getItem() instanceof IGTTool first && itemstack3.get().getItem() instanceof IGTTool) {
Expand All @@ -64,8 +64,14 @@ public class RecipeRepairItemMixin {
}
}

// TODO, see if we can change this from an overwrite

/**
* @author GregTech CEu
* @reason Properly account for GT Tools in Crafting Recipes
*/
@Overwrite
public static NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
NonNullList<ItemStack> list = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
for (int i = 0; i < list.size(); i++) {
ItemStack stack = inv.getStackInSlot(i);
Expand Down

0 comments on commit 210ee39

Please sign in to comment.