Skip to content

Commit

Permalink
Add option to crystalshot for randomized colors
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Dec 25, 2022
1 parent 0fe5c32 commit 437bc47
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 2 deletions.
@@ -0,0 +1,51 @@
{
"type": "tconstruct:swappable_modifier",
"inputs": [
{
"ingredient": [
{
"item": "tconstruct:earth_slime_crystal_cluster"
},
{
"item": "tconstruct:sky_slime_crystal_cluster"
}
]
},
{
"ingredient": [
{
"item": "minecraft:amethyst_cluster"
},
{
"item": "minecraft:nether_quartz_ore"
}
]
},
{
"ingredient": [
{
"item": "tconstruct:ichor_slime_crystal_cluster"
},
{
"item": "tconstruct:ender_slime_crystal_cluster"
}
]
},
{
"tag": "forge:ingots/manyullyn"
},
{
"tag": "forge:ingots/manyullyn"
}
],
"tools": {
"tag": "tconstruct:modifiable/ranged/bows"
},
"slots": {
"abilities": 1
},
"result": {
"name": "tconstruct:crystalshot",
"value": "random"
}
}
Expand Up @@ -595,6 +595,15 @@ private void addModifierRecipes(Consumer<FinishedRecipe> consumer) {
crystalshotRecipe.accept(TinkerWorld.ichorGeode.getBud(BudSize.CLUSTER), "ichor");
crystalshotRecipe.accept(TinkerWorld.enderGeode.getBud(BudSize.CLUSTER), "enderslime");
crystalshotRecipe.accept(Items.NETHER_QUARTZ_ORE, "quartz");
SwappableModifierRecipeBuilder.modifier(TinkerModifiers.crystalshot, "random")
.addInput(Ingredient.of(TinkerWorld.earthGeode.getBud(BudSize.CLUSTER), TinkerWorld.skyGeode.getBud(BudSize.CLUSTER)))
.addInput(Ingredient.of(Items.AMETHYST_CLUSTER, Items.NETHER_QUARTZ_ORE))
.addInput(Ingredient.of(TinkerWorld.ichorGeode.getBud(BudSize.CLUSTER), TinkerWorld.enderGeode.getBud(BudSize.CLUSTER)))
.addInput(TinkerMaterials.manyullyn.getIngotTag())
.addInput(TinkerMaterials.manyullyn.getIngotTag())
.setTools(TinkerTags.Items.BOWS)
.setSlots(SlotType.ABILITY, 1)
.save(consumer, wrap(TinkerModifiers.crystalshot, abilityFolder, "_random"));
ModifierRecipeBuilder.modifier(TinkerModifiers.crystalshot)
.setSlots(SlotType.ABILITY, 1)
.setTools(TinkerTags.Items.BOWS)
Expand Down
Expand Up @@ -16,8 +16,23 @@
import net.minecraft.world.level.Level;
import slimeknights.tconstruct.tools.TinkerTools;

import java.util.ArrayList;
import java.util.List;

/** Internal item used by crystalshot modifier */
public class CrystalshotItem extends ArrowItem {
/** Possible variants for a random crystalshot, so addons can register their own if desired */
public static final List<String> RANDOM_VARIANTS;
static {
RANDOM_VARIANTS = new ArrayList<>();
RANDOM_VARIANTS.add("amethyst");
RANDOM_VARIANTS.add("earthslime");
RANDOM_VARIANTS.add("skyslime");
RANDOM_VARIANTS.add("ichor");
RANDOM_VARIANTS.add("enderslime");
RANDOM_VARIANTS.add("quartz");
}
/** NBT key for variants on the stack and entity */
private static final String TAG_VARIANT = "variant";
public CrystalshotItem(Properties props) {
super(props);
Expand All @@ -26,10 +41,15 @@ public CrystalshotItem(Properties props) {
@Override
public AbstractArrow createArrow(Level pLevel, ItemStack pStack, LivingEntity pShooter) {
CrystalshotEntity arrow = new CrystalshotEntity(pLevel, pShooter);
String variant = "random";
CompoundTag tag = pStack.getTag();
if (tag != null) {
arrow.setVariant(tag.getString(TAG_VARIANT));
variant = tag.getString(TAG_VARIANT);
}
if ("random".equals(variant)) {
variant = RANDOM_VARIANTS.get(pShooter.getRandom().nextInt(RANDOM_VARIANTS.size()));
}
arrow.setVariant(variant);
return arrow;
}

Expand Down
Expand Up @@ -17,6 +17,7 @@
import java.util.function.Predicate;

public class CrystalshotModifier extends NoLevelsModifier implements BowAmmoModifierHook {

@Override
protected void registerHooks(Builder hookBuilder) {
hookBuilder.addHook(this, TinkerHooks.BOW_AMMO);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/tconstruct/mantle/colors.json
Expand Up @@ -42,6 +42,7 @@
"crystalshot.ichor": "#FF8324",
"crystalshot.skyslime": "#82D7D5",
"crystalshot.quartz": "#B6A48E",
"crystalshot.random": "#FFFFFF",

"__armor_abilities__": null,
"ambidextrous": "#AA7D66",
Expand Down
Expand Up @@ -2,7 +2,7 @@
"loader": "mantle:nbt_key",
"parent": "forge:item/default",
"textures": {
"default": "tconstruct:item/arrow/amethyst",
"default": "tconstruct:item/arrow/crystalshot_random",
"amethyst": "tconstruct:item/arrow/amethyst",
"earthslime": "tconstruct:item/arrow/earthslime",
"enderslime": "tconstruct:item/arrow/enderslime",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 437bc47

Please sign in to comment.