-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
- Loading branch information
1 parent
fc35cf3
commit 443d10a
Showing
13 changed files
with
242 additions
and
7 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...n/java/com/blamejared/contenttweaker/vanilla/api/zen/builder/item/AxeToolItemBuilder.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,51 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.zen.builder.item; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectHolder; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceFragment; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceManager; | ||
import com.blamejared.contenttweaker.core.api.resource.StandardResourceFragmentKeys; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.ItemModel; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.Language; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.PathHelper; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.ContentTweakerVanillaConstants; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.object.ItemReference; | ||
import com.blamejared.contenttweaker.vanilla.object.VanillaObjectTypes; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.AxeItem; | ||
import net.minecraft.world.item.Item; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
@ZenCodeType.Name(ContentTweakerVanillaConstants.ITEM_BUILDER_PACKAGE + ".Axe") | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public final class AxeToolItemBuilder extends ToolItemBuilder<AxeToolItemBuilder> { | ||
private static final class TotallyNotAnAxe extends AxeItem { | ||
TotallyNotAnAxe(final ToolData data, final Supplier<Properties> properties) { | ||
super(data.tier(), data.baseAttackDamage(), data.attackSpeed(), properties.get()); | ||
} | ||
} | ||
|
||
public AxeToolItemBuilder(final BiFunction<ObjectHolder<? extends Item>, Consumer<ResourceManager>, ItemReference> registrationManager) { | ||
super(registrationManager); | ||
} | ||
|
||
@Override | ||
public ObjectHolder<? extends Item> createTool(final ResourceLocation name, final ToolData toolData, final Supplier<Item.Properties> builtProperties) { | ||
return ObjectHolder.of(VanillaObjectTypes.ITEM, name, () -> new TotallyNotAnAxe(toolData, builtProperties)); | ||
} | ||
|
||
@Override | ||
public void provideResources(final ResourceLocation name, final ResourceManager manager) { | ||
final ResourceFragment cotAssets = manager.fragment(StandardResourceFragmentKeys.CONTENT_TWEAKER_ASSETS); | ||
final ResourceLocation texture = new ResourceLocation(name.getNamespace(), "item/%s".formatted(name.getPath())); | ||
|
||
cotAssets.provideTemplated(PathHelper.texture(texture), ContentTweakerVanillaConstants.itemTemplate("axe")); | ||
cotAssets.provideFixed(PathHelper.itemModel(name), ItemModel.of(new ResourceLocation("item/handheld")).layer(0, texture), ItemModel.SERIALIZER); | ||
cotAssets.provideOrAlter(PathHelper.usLang(), Language::of, it -> it.item(name, "Custom Axe"), Language.SERIALIZER); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...n/java/com/blamejared/contenttweaker/vanilla/api/zen/builder/item/HoeToolItemBuilder.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,55 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.zen.builder.item; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectHolder; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceFragment; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceManager; | ||
import com.blamejared.contenttweaker.core.api.resource.StandardResourceFragmentKeys; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.ItemModel; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.Language; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.PathHelper; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.ContentTweakerVanillaConstants; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.object.ItemReference; | ||
import com.blamejared.contenttweaker.vanilla.object.VanillaObjectTypes; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.item.HoeItem; | ||
import net.minecraft.world.item.Item; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
@ZenCodeType.Name(ContentTweakerVanillaConstants.ITEM_BUILDER_PACKAGE + ".Hoe") | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public final class HoeToolItemBuilder extends ToolItemBuilder<HoeToolItemBuilder> { | ||
private static final class TotallyNotAHoe extends HoeItem { | ||
TotallyNotAHoe(final ToolData data, final Supplier<Properties> properties) { | ||
super(data.tier(), (int) data.baseAttackDamage(), data.attackSpeed(), properties.get()); | ||
} | ||
} | ||
|
||
public HoeToolItemBuilder(final BiFunction<ObjectHolder<? extends Item>, Consumer<ResourceManager>, ItemReference> registrationManager) { | ||
super(registrationManager); | ||
} | ||
|
||
@Override | ||
public ObjectHolder<? extends Item> createTool(final ResourceLocation name, final ToolData toolData, final Supplier<Item.Properties> builtProperties) { | ||
if (Mth.floor(toolData.baseAttackDamage()) != toolData.baseAttackDamage()) { | ||
throw new IllegalStateException("Unable to create a hoe item with a non-whole attack damage"); | ||
} | ||
return ObjectHolder.of(VanillaObjectTypes.ITEM, name, () -> new TotallyNotAHoe(toolData, builtProperties)); | ||
} | ||
|
||
@Override | ||
public void provideResources(final ResourceLocation name, final ResourceManager manager) { | ||
final ResourceFragment cotAssets = manager.fragment(StandardResourceFragmentKeys.CONTENT_TWEAKER_ASSETS); | ||
final ResourceLocation texture = new ResourceLocation(name.getNamespace(), "item/%s".formatted(name.getPath())); | ||
|
||
cotAssets.provideTemplated(PathHelper.texture(texture), ContentTweakerVanillaConstants.itemTemplate("hoe")); | ||
cotAssets.provideFixed(PathHelper.itemModel(name), ItemModel.of(new ResourceLocation("item/handheld")).layer(0, texture), ItemModel.SERIALIZER); | ||
cotAssets.provideOrAlter(PathHelper.usLang(), Language::of, it -> it.item(name, "Custom Hoe"), Language.SERIALIZER); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
...ava/com/blamejared/contenttweaker/vanilla/api/zen/builder/item/ShovelToolItemBuilder.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,52 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.zen.builder.item; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectHolder; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceFragment; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceManager; | ||
import com.blamejared.contenttweaker.core.api.resource.StandardResourceFragmentKeys; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.ItemModel; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.Language; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.PathHelper; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.ContentTweakerVanillaConstants; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.object.ItemReference; | ||
import com.blamejared.contenttweaker.vanilla.object.VanillaObjectTypes; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.AxeItem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ShovelItem; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
@ZenCodeType.Name(ContentTweakerVanillaConstants.ITEM_BUILDER_PACKAGE + ".Shovel") | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public final class ShovelToolItemBuilder extends ToolItemBuilder<ShovelToolItemBuilder> { | ||
private static final class TotallyNotAShovel extends ShovelItem { | ||
TotallyNotAShovel(final ToolData data, final Supplier<Properties> properties) { | ||
super(data.tier(), data.baseAttackDamage(), data.attackSpeed(), properties.get()); | ||
} | ||
} | ||
|
||
public ShovelToolItemBuilder(final BiFunction<ObjectHolder<? extends Item>, Consumer<ResourceManager>, ItemReference> registrationManager) { | ||
super(registrationManager); | ||
} | ||
|
||
@Override | ||
public ObjectHolder<? extends Item> createTool(final ResourceLocation name, final ToolData toolData, final Supplier<Item.Properties> builtProperties) { | ||
return ObjectHolder.of(VanillaObjectTypes.ITEM, name, () -> new TotallyNotAShovel(toolData, builtProperties)); | ||
} | ||
|
||
@Override | ||
public void provideResources(final ResourceLocation name, final ResourceManager manager) { | ||
final ResourceFragment cotAssets = manager.fragment(StandardResourceFragmentKeys.CONTENT_TWEAKER_ASSETS); | ||
final ResourceLocation texture = new ResourceLocation(name.getNamespace(), "item/%s".formatted(name.getPath())); | ||
|
||
cotAssets.provideTemplated(PathHelper.texture(texture), ContentTweakerVanillaConstants.itemTemplate("shovel")); | ||
cotAssets.provideFixed(PathHelper.itemModel(name), ItemModel.of(new ResourceLocation("item/handheld")).layer(0, texture), ItemModel.SERIALIZER); | ||
cotAssets.provideOrAlter(PathHelper.usLang(), Language::of, it -> it.item(name, "Custom Shovel"), Language.SERIALIZER); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...ain/java/com/blamejared/contenttweaker/vanilla/api/zen/builder/item/SwordItemBuilder.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,81 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.zen.builder.item; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectHolder; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceFragment; | ||
import com.blamejared.contenttweaker.core.api.resource.ResourceManager; | ||
import com.blamejared.contenttweaker.core.api.resource.StandardResourceFragmentKeys; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.ItemModel; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.Language; | ||
import com.blamejared.contenttweaker.vanilla.api.resource.PathHelper; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.ContentTweakerVanillaConstants; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.object.ItemReference; | ||
import com.blamejared.contenttweaker.vanilla.object.VanillaObjectTypes; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.SwordItem; | ||
import net.minecraft.world.item.Tier; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
import java.util.Objects; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
@ZenCodeType.Name(ContentTweakerVanillaConstants.ITEM_BUILDER_PACKAGE + ".Sword") | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public final class SwordItemBuilder extends ItemBuilder<SwordItemBuilder> { | ||
private Integer attackDamageBase; | ||
private Float attackDamageSpeed; | ||
private Tier tier; | ||
|
||
public SwordItemBuilder(final BiFunction<ObjectHolder<? extends Item>, Consumer<ResourceManager>, ItemReference> registrationManager) { | ||
super(registrationManager); | ||
this.attackDamageBase = null; | ||
this.attackDamageSpeed = null; | ||
this.tier = null; | ||
} | ||
|
||
@ZenCodeType.Method("baseAttackDamage") | ||
public SwordItemBuilder baseAttackDamage(final int attackDamageBase) { | ||
this.attackDamageBase = attackDamageBase; | ||
return this; | ||
} | ||
|
||
@ZenCodeType.Method("attackSpeed") | ||
public SwordItemBuilder attackSpeed(final float attackSpeed) { | ||
this.attackDamageSpeed = attackSpeed; | ||
return this; | ||
} | ||
|
||
@ZenCodeType.Method("tier") | ||
public SwordItemBuilder tier(final Tier tier) { | ||
this.tier = Objects.requireNonNull(tier); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ObjectHolder<? extends Item> create(final ResourceLocation name, final Supplier<Item.Properties> builtProperties) { | ||
if (this.tier == null) { | ||
throw new IllegalStateException("Unable to create a sword item without a tier"); | ||
} | ||
if (this.attackDamageBase == null) { | ||
throw new IllegalStateException("Unable to create a sword without a base attack damage"); | ||
} | ||
if (this.attackDamageSpeed == null) { | ||
throw new IllegalStateException("Unable to create a sword item without attack speed"); | ||
} | ||
return ObjectHolder.of(VanillaObjectTypes.ITEM, name, () -> new SwordItem(this.tier, this.attackDamageBase, this.attackDamageSpeed, builtProperties.get())); | ||
} | ||
|
||
@Override | ||
public void provideResources(final ResourceLocation name, final ResourceManager manager) { | ||
final ResourceFragment cotAssets = manager.fragment(StandardResourceFragmentKeys.CONTENT_TWEAKER_ASSETS); | ||
final ResourceLocation texture = new ResourceLocation(name.getNamespace(), "item/%s".formatted(name.getPath())); | ||
|
||
cotAssets.provideTemplated(PathHelper.texture(texture), ContentTweakerVanillaConstants.itemTemplate("katana")); | ||
cotAssets.provideFixed(PathHelper.itemModel(name), ItemModel.of(new ResourceLocation("item/handheld")).layer(0, texture), ItemModel.SERIALIZER); | ||
cotAssets.provideOrAlter(PathHelper.usLang(), Language::of, it -> it.item(name, "Custom Sword"), Language.SERIALIZER); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.