-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
044b454
commit 32ff3b2
Showing
7 changed files
with
89 additions
and
104 deletions.
There are no files selected for viewing
100 changes: 81 additions & 19 deletions
100
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,60 +1,122 @@ | ||
package io.wispforest.owo.itemgroup; | ||
|
||
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler; | ||
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider; | ||
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 interface OwoItemSettings { | ||
public class OwoItemSettings extends Item.Settings { | ||
|
||
default Item.Settings group(ItemGroupReference ref) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
@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; | ||
} | ||
|
||
/** | ||
* @param group The item group this item should appear in | ||
*/ | ||
default Item.Settings group(OwoItemGroup group) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public OwoItemSettings group(OwoItemGroup group) { | ||
this.group = group; | ||
return this; | ||
} | ||
|
||
default OwoItemGroup group() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public OwoItemGroup group() { | ||
return this.group; | ||
} | ||
|
||
default Item.Settings tab(int tab) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public OwoItemSettings tab(int tab) { | ||
this.tab = tab; | ||
return this; | ||
} | ||
|
||
default int tab() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public int tab() { | ||
return this.tab; | ||
} | ||
|
||
/** | ||
* @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} | ||
*/ | ||
default Item.Settings stackGenerator(BiConsumer<Item, ItemGroup.Entries> generator) { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public OwoItemSettings stackGenerator(BiConsumer<Item, ItemGroup.Entries> generator) { | ||
this.stackGenerator = generator; | ||
return this; | ||
} | ||
|
||
default BiConsumer<Item, ItemGroup.Entries> stackGenerator() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
public BiConsumer<Item, ItemGroup.Entries> stackGenerator() { | ||
return this.stackGenerator; | ||
} | ||
|
||
/** | ||
* Automatically increment {@link net.minecraft.stat.Stats#USED} | ||
* for this item every time {@link Item#use(World, PlayerEntity, Hand)} | ||
* returns an accepted result | ||
*/ | ||
default Item.Settings trackUsageStat() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
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); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings recipeRemainder(Item recipeRemainder) { | ||
return (OwoItemSettings) super.recipeRemainder(recipeRemainder); | ||
} | ||
|
||
@Override | ||
public OwoItemSettings rarity(Rarity rarity) { | ||
return (OwoItemSettings) super.rarity(rarity); | ||
} | ||
|
||
default boolean shouldTrackUsageStat() { | ||
throw new IllegalStateException("Implemented in mixin."); | ||
@Override | ||
public OwoItemSettings fireproof() { | ||
return (OwoItemSettings) super.fireproof(); | ||
} | ||
} |
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: 0 additions & 75 deletions
75
src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java
This file was deleted.
Oops, something went wrong.
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