-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
192 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 19 additions & 83 deletions
102
src/main/java/io/wispforest/owo/itemgroup/OwoItemSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,60 @@ | ||
package io.wispforest.owo.itemgroup; | ||
|
||
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler; | ||
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider; | ||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.FoodComponent; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemGroup; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.Rarity; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class OwoItemSettings extends FabricItemSettings { | ||
public interface OwoItemSettings { | ||
|
||
@Nullable | ||
private OwoItemGroup group = null; | ||
private int tab = 0; | ||
private BiConsumer<Item, ItemGroup.Entries> stackGenerator = OwoItemGroup.DEFAULT_STACK_GENERATOR; | ||
private boolean trackUsageStat = false; | ||
|
||
public OwoItemSettings group(ItemGroupReference ref) { | ||
this.group = ref.group(); | ||
this.tab = ref.tab(); | ||
return this; | ||
default Item.Settings group(ItemGroupReference ref) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
/** | ||
* @param group The item group this item should appear in | ||
*/ | ||
public OwoItemSettings group(OwoItemGroup group) { | ||
this.group = group; | ||
return this; | ||
default Item.Settings group(OwoItemGroup group) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
public OwoItemGroup group() { | ||
return this.group; | ||
default OwoItemGroup group() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
public OwoItemSettings tab(int tab) { | ||
this.tab = tab; | ||
return this; | ||
default Item.Settings tab(int tab) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
public int tab() { | ||
return this.tab; | ||
default int tab() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
/** | ||
* @param generator The function this item uses for creating stacks in the | ||
* {@link OwoItemGroup} it is in, by default this will be {@link OwoItemGroup#DEFAULT_STACK_GENERATOR} | ||
*/ | ||
public OwoItemSettings stackGenerator(BiConsumer<Item, ItemGroup.Entries> generator) { | ||
this.stackGenerator = generator; | ||
return this; | ||
default Item.Settings stackGenerator(BiConsumer<Item, ItemGroup.Entries> generator) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
public BiConsumer<Item, ItemGroup.Entries> stackGenerator() { | ||
return this.stackGenerator; | ||
default BiConsumer<Item, ItemGroup.Entries> stackGenerator() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
/** | ||
* Automatically increment {@link net.minecraft.stat.Stats#USED} | ||
* for this item every time {@link Item#use(World, PlayerEntity, Hand)} | ||
* returns an accepted result | ||
*/ | ||
public OwoItemSettings trackUsageStat() { | ||
this.trackUsageStat = true; | ||
return this; | ||
} | ||
|
||
public boolean shouldTrackUsageStat() { | ||
return this.trackUsageStat; | ||
} | ||
|
||
@Override | ||
public OwoItemSettings equipmentSlot(EquipmentSlotProvider equipmentSlotProvider) { | ||
return (OwoItemSettings) super.equipmentSlot(equipmentSlotProvider); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings customDamage(CustomDamageHandler handler) { | ||
return (OwoItemSettings) super.customDamage(handler); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings food(FoodComponent foodComponent) { | ||
return (OwoItemSettings) super.food(foodComponent); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings maxCount(int maxCount) { | ||
return (OwoItemSettings) super.maxCount(maxCount); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings maxDamageIfAbsent(int maxDamage) { | ||
return (OwoItemSettings) super.maxDamageIfAbsent(maxDamage); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings maxDamage(int maxDamage) { | ||
return (OwoItemSettings) super.maxDamage(maxDamage); | ||
default Item.Settings trackUsageStat() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings recipeRemainder(Item recipeRemainder) { | ||
return (OwoItemSettings) super.recipeRemainder(recipeRemainder); | ||
default boolean shouldTrackUsageStat() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings rarity(Rarity rarity) { | ||
return (OwoItemSettings) super.rarity(rarity); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings fireproof() { | ||
return (OwoItemSettings) super.fireproof(); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/main/java/io/wispforest/owo/mixin/class_9320Accessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.wispforest.owo.mixin; | ||
|
||
import net.minecraft.class_9320; | ||
import net.minecraft.component.ComponentChanges; | ||
import net.minecraft.loot.condition.LootCondition; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(class_9320.class) | ||
public interface class_9320Accessor { | ||
@Invoker("<init>") | ||
static class_9320 createClass_9320(List<LootCondition> list, ComponentChanges componentChanges) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.wispforest.owo.mixin.itemgroup; | ||
|
||
import io.wispforest.owo.itemgroup.ItemGroupReference; | ||
import io.wispforest.owo.itemgroup.OwoItemGroup; | ||
import io.wispforest.owo.itemgroup.OwoItemSettings; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemGroup; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
@Mixin(Item.Settings.class) | ||
public class ItemSettingsMixin implements OwoItemSettings { | ||
private OwoItemGroup owo$group = null; | ||
private int owo$tab = 0; | ||
// TODO: OwoItemGroup.DEFAULT_STACK_GENERATOR was inlined to not cause clinit issues. fix. | ||
private BiConsumer<Item, ItemGroup.Entries> owo$stackGenerator = (item, stacks) -> stacks.add(item.getDefaultStack()); | ||
private boolean owo$trackUsageStat = false; | ||
|
||
@Override | ||
public Item.Settings group(ItemGroupReference ref) { | ||
this.owo$group = ref.group(); | ||
this.owo$tab = ref.tab(); | ||
|
||
return (Item.Settings)(Object) this; | ||
} | ||
|
||
@Override | ||
public Item.Settings group(OwoItemGroup group) { | ||
this.owo$group = group; | ||
|
||
return (Item.Settings)(Object) this; | ||
} | ||
|
||
@Override | ||
public OwoItemGroup group() { | ||
return owo$group; | ||
} | ||
|
||
@Override | ||
public Item.Settings tab(int tab) { | ||
this.owo$tab = tab; | ||
|
||
return (Item.Settings)(Object) this; | ||
} | ||
|
||
@Override | ||
public int tab() { | ||
return owo$tab; | ||
} | ||
|
||
@Override | ||
public Item.Settings stackGenerator(BiConsumer<Item, ItemGroup.Entries> generator) { | ||
this.owo$stackGenerator = generator; | ||
|
||
return (Item.Settings)(Object) this; | ||
} | ||
|
||
@Override | ||
public BiConsumer<Item, ItemGroup.Entries> stackGenerator() { | ||
return owo$stackGenerator; | ||
} | ||
|
||
@Override | ||
public Item.Settings trackUsageStat() { | ||
this.owo$trackUsageStat = true; | ||
|
||
return (Item.Settings)(Object) this; | ||
} | ||
|
||
@Override | ||
public boolean shouldTrackUsageStat() { | ||
return owo$trackUsageStat; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.