diff --git a/README.md b/README.md new file mode 100644 index 0000000..44f994c --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +this entire fork is a joke and a test for how much weird stuff i could add + +mostly drugs lmao diff --git a/src/client/java/llevc/ballistics/BallisticsDataGenerator.java b/src/client/java/llevc/ballistics/BallisticsDataGenerator.java index d68ae11..523a672 100644 --- a/src/client/java/llevc/ballistics/BallisticsDataGenerator.java +++ b/src/client/java/llevc/ballistics/BallisticsDataGenerator.java @@ -6,6 +6,6 @@ public class BallisticsDataGenerator implements DataGeneratorEntrypoint { @Override public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { - + FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); } } diff --git a/src/client/resources/assets/ballistics/items/cartridge.json b/src/client/resources/assets/ballistics/items/cartridge.json new file mode 100644 index 0000000..a9d3139 --- /dev/null +++ b/src/client/resources/assets/ballistics/items/cartridge.json @@ -0,0 +1,12 @@ +{ + "model": { + "type": "minecraft:model", + "model": "ballistics:item/cartridge", + "tints": [ + { + "type": "minecraft:potion", + "default": 16777215 + } + ] + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/items/cig.json b/src/client/resources/assets/ballistics/items/cig.json new file mode 100644 index 0000000..ae0ea6c --- /dev/null +++ b/src/client/resources/assets/ballistics/items/cig.json @@ -0,0 +1,45 @@ +{ + "model": { + "type": "minecraft:condition", + "property": "minecraft:using_item", + "on_true": { + "type": "minecraft:composite", + "models": [ + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/cig" + }, + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/cig_overlay" + } + ] + }, + "on_false": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": "head", + "model": { + "type": "minecraft:composite", + "models": [ + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/cig" + }, + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/cig_overlay" + } + ] + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "ballistics:item/smoke/cig" + } + } + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/items/pick.json b/src/client/resources/assets/ballistics/items/pick.json new file mode 100644 index 0000000..84b2b27 --- /dev/null +++ b/src/client/resources/assets/ballistics/items/pick.json @@ -0,0 +1,31 @@ +{ + "model": { + "type": "minecraft:condition", + "property": "minecraft:has_component", + "component": "minecraft:potion_contents", + "ignore_default": true, + "on_true": { + "type": "minecraft:composite", + "models": [ + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/pick" + }, + { + "type": "minecraft:model", + "model": "ballistics:item/smoke/pick_overlay", + "tints": [ + { + "type": "minecraft:potion", + "default": 16777215 + } + ] + } + ] + }, + "on_false": { + "type": "minecraft:model", + "model": "ballistics:item/smoke/pick" + } + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/items/snortable.json b/src/client/resources/assets/ballistics/items/snortable.json new file mode 100644 index 0000000..70400a4 --- /dev/null +++ b/src/client/resources/assets/ballistics/items/snortable.json @@ -0,0 +1,12 @@ +{ + "model": { + "type": "minecraft:model", + "model": "minecraft:item/sugar", + "tints": [ + { + "type": "minecraft:dye", + "default": 16777215 + } + ] + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/items/vape.json b/src/client/resources/assets/ballistics/items/vape.json new file mode 100644 index 0000000..2c898bb --- /dev/null +++ b/src/client/resources/assets/ballistics/items/vape.json @@ -0,0 +1,12 @@ +{ + "model": { + "type": "minecraft:model", + "model": "ballistics:item/smoke/vape", + "tints": [ + { + "type": "minecraft:potion", + "default": 16777215 + } + ] + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/lang/en_us.json b/src/client/resources/assets/ballistics/lang/en_us.json index bdedd86..e063f49 100644 --- a/src/client/resources/assets/ballistics/lang/en_us.json +++ b/src/client/resources/assets/ballistics/lang/en_us.json @@ -4,6 +4,7 @@ "item.ballistics.rh_glove": "Rocket Handling Glove", "itemGroup.ballistics": "Ballistics", "itemGroup.ballistics_flasks": "Ballistics Flasks", + "itemGroup.ballistics_geeked": "Ballistics Baked", "item.ballistics.prick": "Prick", "item.ballistics.drink_mixer": "Drink Mixer", "item.ballistics.flintlock_barrel": "Flintlock Barrel", @@ -16,6 +17,12 @@ "item.minecraft.lingering_potion.effect.mixed": "Mixed Lingering Potion", "item.minecraft.tipped_arrow.effect.mixed": "Mixed Arrow", "item.ballistics.flask.effect.mixed": "Mixed Flask", + "effect.ballistics.explode": "Explode", + "item.minecraft.potion.effect.explode": "Exploding Potion", + "item.minecraft.splash_potion.effect.explode": "Exploding Splash Potion", + "item.minecraft.lingering_potion.effect.explode": "Exploding Lingering Potion", + "item.minecraft.tipped_arrow.effect.explode": "Exploding Arrow", + "item.ballistics.flask.effect.explode": "Exploding Flask", "item.ballistics.flask": "Flask", "item.ballistics.flask.effect.awkward": "Awkward Flask", @@ -43,5 +50,12 @@ "item.ballistics.flask.effect.water_breathing": "Flask of Water Breathing", "item.ballistics.flask.effect.weakness": "Flask of Weakness", "item.ballistics.flask.effect.weaving": "Flask of Weaving", - "item.ballistics.flask.effect.wind_charged": "Flask of Wind Charging" + "item.ballistics.flask.effect.wind_charged": "Flask of Wind Charging", + + "item.ballistics.snortable": "Snortable ", + "item.ballistics.custom_cig": "Custom Cig", + "item.ballistics.cig": "Cig", + "item.ballistics.vape": "Vape", + "item.ballistics.pick": "Pick", + "item.ballistics.cartridge": "Cartridge" } \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/cartridge.json b/src/client/resources/assets/ballistics/models/item/cartridge.json new file mode 100644 index 0000000..abb63a7 --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/cartridge.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "ballistics:item/cartridge" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/smoke/cig.json b/src/client/resources/assets/ballistics/models/item/smoke/cig.json new file mode 100644 index 0000000..898f812 --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/smoke/cig.json @@ -0,0 +1,35 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "parent": "minecraft:item/generated", + "textures": { + "layer0": "ballistics:item/smoke/cig" + }, + "display": { + "thirdperson_righthand": { + "rotation": [0, -90, 0], + "translation": [-1, -0.5, 0], + "scale": [0.55, 0.55, 0.55] + }, + "thirdperson_lefthand": { + "rotation": [0, 90, 0], + "translation": [-1, -0.5, 0], + "scale": [0.55, 0.55, 0.55] + }, + "firstperson_righthand": { + "rotation": [0, -90, 0], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, 90, 0], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "head": { + "rotation": [-111.92, -22.6, -146.7], + "translation": [3.25, -5.25, -8.5], + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/smoke/cig_overlay.json b/src/client/resources/assets/ballistics/models/item/smoke/cig_overlay.json new file mode 100644 index 0000000..f687d94 --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/smoke/cig_overlay.json @@ -0,0 +1,8 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "parent": "ballistics:item/smoke/cig", + "textures": { + "layer0": "ballistics:item/smoke/cig_overlay" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/smoke/pick.json b/src/client/resources/assets/ballistics/models/item/smoke/pick.json new file mode 100644 index 0000000..826f493 --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/smoke/pick.json @@ -0,0 +1,8 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "parent": "ballistics:item/smoke/cig", + "textures": { + "layer0": "ballistics:item/smoke/pick" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/smoke/pick_overlay.json b/src/client/resources/assets/ballistics/models/item/smoke/pick_overlay.json new file mode 100644 index 0000000..3cde251 --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/smoke/pick_overlay.json @@ -0,0 +1,8 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "parent": "ballistics:item/smoke/cig", + "textures": { + "layer0": "ballistics:item/smoke/pick_overlay" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/models/item/smoke/vape.json b/src/client/resources/assets/ballistics/models/item/smoke/vape.json new file mode 100644 index 0000000..3b6308e --- /dev/null +++ b/src/client/resources/assets/ballistics/models/item/smoke/vape.json @@ -0,0 +1,9 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "parent": "ballistics:item/smoke/cig", + "textures": { + "layer0": "ballistics:item/smoke/vape_overlay", + "layer1": "ballistics:item/smoke/vape" + } +} \ No newline at end of file diff --git a/src/client/resources/assets/ballistics/textures/item/cartridge.png b/src/client/resources/assets/ballistics/textures/item/cartridge.png new file mode 100644 index 0000000..edc27a8 Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/cartridge.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/cig.png b/src/client/resources/assets/ballistics/textures/item/smoke/cig.png new file mode 100644 index 0000000..74eebe2 Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/cig.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/cig_overlay.png b/src/client/resources/assets/ballistics/textures/item/smoke/cig_overlay.png new file mode 100644 index 0000000..b5176ed Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/cig_overlay.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/pick.png b/src/client/resources/assets/ballistics/textures/item/smoke/pick.png new file mode 100644 index 0000000..1552d64 Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/pick.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/pick_overlay.png b/src/client/resources/assets/ballistics/textures/item/smoke/pick_overlay.png new file mode 100644 index 0000000..20ec984 Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/pick_overlay.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/vape.png b/src/client/resources/assets/ballistics/textures/item/smoke/vape.png new file mode 100644 index 0000000..29090b0 Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/vape.png differ diff --git a/src/client/resources/assets/ballistics/textures/item/smoke/vape_overlay.png b/src/client/resources/assets/ballistics/textures/item/smoke/vape_overlay.png new file mode 100644 index 0000000..994f39c Binary files /dev/null and b/src/client/resources/assets/ballistics/textures/item/smoke/vape_overlay.png differ diff --git a/src/main/java/llevc/ballistics/Ballistics.java b/src/main/java/llevc/ballistics/Ballistics.java index b50038f..9a84e02 100644 --- a/src/main/java/llevc/ballistics/Ballistics.java +++ b/src/main/java/llevc/ballistics/Ballistics.java @@ -1,9 +1,6 @@ package llevc.ballistics; -import llevc.ballistics.recipes.DrinkMixerRecipeSerializer; -import llevc.ballistics.recipes.FlaskRecipeSerializer; -import llevc.ballistics.recipes.FlintlockLoadRecipeSerializer; -import llevc.ballistics.recipes.MixedDrinkRecipeSerializer; +import llevc.ballistics.recipes.*; import net.fabricmc.api.ModInitializer; import net.minecraft.core.Registry; @@ -30,6 +27,10 @@ public void onInitialize() { Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, FlaskRecipeSerializer.ID, FlaskRecipeSerializer.INSTANCE); Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, DrinkMixerRecipeSerializer.ID, DrinkMixerRecipeSerializer.INSTANCE); Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, MixedDrinkRecipeSerializer.ID, MixedDrinkRecipeSerializer.INSTANCE); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, SnortableRecipeSerializer.ID, SnortableRecipeSerializer.INSTANCE); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, PickRecipeSerializer.ID, PickRecipeSerializer.INSTANCE); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, CartridgeRecipeSerializer.ID, CartridgeRecipeSerializer.INSTANCE); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, GeekedRecipeSerializer.ID, GeekedRecipeSerializer.INSTANCE); Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, FlintlockLoadRecipeSerializer.ID, FlintlockLoadRecipeSerializer.INSTANCE); LOGGER.info("if you read this you're prolly gonna be touched within the next 16 hours"); diff --git a/src/main/java/llevc/ballistics/ModItems.java b/src/main/java/llevc/ballistics/ModItems.java index c501539..ea96b1f 100644 --- a/src/main/java/llevc/ballistics/ModItems.java +++ b/src/main/java/llevc/ballistics/ModItems.java @@ -1,7 +1,11 @@ package llevc.ballistics; +import llevc.ballistics.effects.Explode; import llevc.ballistics.items.FlintlockItem; import llevc.ballistics.items.PerfectParryItem; +import llevc.ballistics.items.SmokeItem; +import llevc.ballistics.recipes.SnortableRecipe; +import llevc.ballistics.recipes.SnortableRecipeSerializer; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.core.Holder; @@ -15,15 +19,24 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.DamageTypeTags; import net.minecraft.tags.ItemTags; +import net.minecraft.util.CommonColors; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectCategory; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.*; import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.alchemy.Potions; -import net.minecraft.world.item.component.BlocksAttacks; -import net.minecraft.world.item.component.Consumables; +import net.minecraft.world.item.component.*; +import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect; +import net.minecraft.world.item.consume_effects.ConsumeEffect; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BannerPatternLayers; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.Function; @@ -39,6 +52,7 @@ public static GenericItem register(String name, Funct public static void initialize() { Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB,BallisticsItemGroupKey,BallisticsItemGroup); Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB,BallisticsFlaskItemGroupKey,BallisticsFlaskItemGroup); + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB,BallisticsBakedItemGroupKey,BallisticsBakedItemGroup); ItemGroupEvents.modifyEntriesEvent(BallisticsItemGroupKey).register(itemGroup -> { itemGroup.accept(rhGlove); @@ -50,6 +64,11 @@ public static void initialize() { itemGroup.accept(EmptyFlask); itemGroup.accept(DragonsFlask); itemGroup.accept(PotionContents.createItemStack(ModItems.Flask, Potions.WATER)); + itemGroup.accept(snortable); + itemGroup.accept(pick); + itemGroup.accept(cig); + itemGroup.accept(vape); + itemGroup.accept(cartridge); }); ItemGroupEvents.modifyEntriesEvent(BallisticsFlaskItemGroupKey).register(itemGroup -> { itemGroup.accept(DrinkMixer); @@ -63,6 +82,60 @@ public static void initialize() { } } }); + ItemGroupEvents.modifyEntriesEvent(BallisticsBakedItemGroupKey).register(itemGroup -> { + itemGroup.accept(pick); + for (int i = 0; i < BuiltInRegistries.POTION.size(); i++) { + Optional> wchat = BuiltInRegistries.POTION.get(i); + if (wchat.isPresent()) { + Potion hey = wchat.get().value(); + itemGroup.accept(PotionContents.createItemStack(pick,Holder.direct(hey))); + } + } + itemGroup.accept(cig); + for (int i = 0; i < BuiltInRegistries.POTION.size(); i++) { + Optional> wchat = BuiltInRegistries.POTION.get(i); + if (wchat.isPresent()) { + Potion hey = wchat.get().value(); + ItemStack yo = PotionContents.createItemStack(cig,Holder.direct(hey)); + yo.set(DataComponents.ITEM_NAME,Component.translatable("item.ballistics.custom_cig")); + itemGroup.accept(yo); + } + } + itemGroup.accept(vape); + for (int i = 0; i < BuiltInRegistries.POTION.size(); i++) { + Optional> wchat = BuiltInRegistries.POTION.get(i); + if (wchat.isPresent()) { + Potion hey = wchat.get().value(); + itemGroup.accept(PotionContents.createItemStack(vape,Holder.direct(hey))); + } + } + itemGroup.accept(cartridge); + for (int i = 0; i < BuiltInRegistries.POTION.size(); i++) { + Optional> wchat = BuiltInRegistries.POTION.get(i); + if (wchat.isPresent()) { + Potion hey = wchat.get().value(); + itemGroup.accept(PotionContents.createItemStack(cartridge,Holder.direct(hey))); + } + } + itemGroup.accept(snortable); + for (int i = 0; i < BuiltInRegistries.BLOCK.size(); i++) { + Optional> wchat = BuiltInRegistries.BLOCK.get(i); + if (wchat.isPresent()) { + Block hey = wchat.get().value(); + itemGroup.accept(createSnortable(hey)); + } + } + for (int i = 0; i < BuiltInRegistries.POTION.size(); i++) { + Optional> wchat = BuiltInRegistries.POTION.get(i); + if (wchat.isPresent()) { + Potion hey = wchat.get().value(); + ItemStack yo = PotionContents.createItemStack(snortable,Holder.direct(hey)); + yo.set(DataComponents.DYED_COLOR,new DyedItemColor(yo.getOrDefault(DataComponents.POTION_CONTENTS,PotionContents.EMPTY).getColorOr(CommonColors.WHITE))); + yo.set(DataComponents.ITEM_NAME, Component.translatable("item.ballistics.snortable").append(hey.name())); + itemGroup.accept(yo); + } + } + }); } public static final Item EmptyFlask = register( @@ -124,9 +197,91 @@ public static void initialize() { ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "mixed"), new Potion("mixed") ); + public static final Holder ExplodePotionEffect = + Registry.registerForHolder(BuiltInRegistries.MOB_EFFECT, ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "explode"), new Explode(MobEffectCategory.HARMFUL, CommonColors.SOFT_RED)); + public static final Potion ExplosionPotion = Registry.register( + BuiltInRegistries.POTION, + ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "explode"), + new Potion("explode",new MobEffectInstance(ExplodePotionEffect)) + ); + + //the baked shi + public static final Item snortable = register( + "snortable", + Item::new, + new Item.Properties().stacksTo(16) + .component(DataComponents.CONSUMABLE, Consumables.defaultFood().consumeSeconds(0.8f).animation(ItemUseAnimation.SPYGLASS).build()) + .component(DataComponents.TOOLTIP_DISPLAY, TooltipDisplay.DEFAULT.withHidden(DataComponents.DYED_COLOR,true)) + .component(DataComponents.POTION_CONTENTS, PotionContents.EMPTY) + .component(DataComponents.DYED_COLOR,new DyedItemColor(CommonColors.WHITE)) + ); + public static final PotionContents cigContents = new PotionContents(Optional.empty(),Optional.empty(),List.of( + new MobEffectInstance(MobEffects.REGENERATION,45*20), + new MobEffectInstance(MobEffects.NAUSEA,45*20) + ),Optional.empty()); + public static final Item cig = register( + "cig", + SmokeItem::new, + new Item.Properties().durability(32).component(DataComponents.POTION_CONTENTS, cigContents).equippable(EquipmentSlot.HEAD) + ); + public static final Item vape = register( + "vape", + SmokeItem::new, + new Item.Properties().durability(64).component(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).repairable(ItemTags.REPAIRS_IRON_ARMOR) + ); + public static final Item pick = register( + "pick", + SmokeItem::new, + new Item.Properties().durability(8).component(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).equippable(EquipmentSlot.HEAD) + ); + public static final Item cartridge = register( + "cartridge", + Item::new, + new Item.Properties().component(DataComponents.POTION_CONTENTS, PotionContents.EMPTY) + ); + public static ItemStack createSnortable(Block block) { + ItemStack yes = new ItemStack(ModItems.snortable); + List effectInstanceList = new ArrayList<>(); + + if (block.getFriction() > 0.75) { // slippppery + effectInstanceList.add(new MobEffectInstance(MobEffects.SPEED, (int) Math.ceil(400/block.getFriction()))); + } + if (block.getSpeedFactor() < 1) { // is it sticky? + effectInstanceList.add(new MobEffectInstance(MobEffects.SLOWNESS, (int) Math.ceil(200/block.getSpeedFactor()))); + } + if (block.getJumpFactor() < 1) { // sticky 2, only honey has this one + effectInstanceList.add(new MobEffectInstance(MobEffects.SLOW_FALLING,(int) Math.ceil(200/block.getJumpFactor()))); + } else if (block.getJumpFactor() > 1) { // bouncy but not bouncy + effectInstanceList.add(new MobEffectInstance(MobEffects.JUMP_BOOST,(int) Math.ceil(200*block.getJumpFactor()))); + } + if (block instanceof InfestedBlock) { // is infested? + effectInstanceList.add(new MobEffectInstance(MobEffects.INFESTED,60*20)); + } else if (block instanceof SlimeBlock) { // slimme + effectInstanceList.add(new MobEffectInstance(MobEffects.OOZING,600)); + } else if (block instanceof TntBlock) { + effectInstanceList.add(new MobEffectInstance(ModItems.ExplodePotionEffect)); + } else if (block instanceof WebBlock) { // cobweb + effectInstanceList.add(new MobEffectInstance(MobEffects.WEAVING,1200)); + } + if (block.defaultDestroyTime() > 20 || block.defaultDestroyTime() < 0) { // long/impossible to break + effectInstanceList.add(new MobEffectInstance(MobEffects.MINING_FATIGUE, 1000)); + effectInstanceList.add(new MobEffectInstance(MobEffects.RESISTANCE,1000)); + } else if (block.defaultDestroyTime() < 0.5 && block.defaultDestroyTime() >= 0) { // instant break + effectInstanceList.add(new MobEffectInstance(MobEffects.HASTE, (int) Math.ceil(200/(0.5+block.defaultDestroyTime())))); + } + + PotionContents huh = new PotionContents(Optional.of(BuiltInRegistries.POTION.wrapAsHolder(ModItems.MixedPotion)),Optional.empty(),effectInstanceList,Optional.empty()); + yes.set(DataComponents.POTION_CONTENTS,huh); + yes.set(DataComponents.DYED_COLOR, new DyedItemColor(block.defaultMapColor().col)); + yes.set(DataComponents.ITEM_NAME, Component.translatable("item.ballistics.snortable").append(block.getName())); + yes.set(DataComponents.CONSUMABLE, Consumables.defaultFood().consumeSeconds(Math.abs(block.defaultDestroyTime()/3)).animation(ItemUseAnimation.SPYGLASS).build()); + return yes; + } public static final ResourceKey BallisticsItemGroupKey = ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "ballistics")); public static final CreativeModeTab BallisticsItemGroup = FabricItemGroup.builder().icon(() -> new ItemStack(Items.FIREWORK_ROCKET)).title(Component.translatable("itemGroup.ballistics")).build(); public static final ResourceKey BallisticsFlaskItemGroupKey = ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "ballistics_flasks")); public static final CreativeModeTab BallisticsFlaskItemGroup = FabricItemGroup.builder().icon(() -> new ItemStack(EmptyFlask)).title(Component.translatable("itemGroup.ballistics_flasks")).build(); + public static final ResourceKey BallisticsBakedItemGroupKey = ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.fromNamespaceAndPath(Ballistics.MOD_ID, "ballistics_geeked")); + public static final CreativeModeTab BallisticsBakedItemGroup = FabricItemGroup.builder().icon(() -> new ItemStack(vape)).title(Component.translatable("itemGroup.ballistics_geeked")).build(); } diff --git a/src/main/java/llevc/ballistics/effects/Explode.java b/src/main/java/llevc/ballistics/effects/Explode.java new file mode 100644 index 0000000..73e0d35 --- /dev/null +++ b/src/main/java/llevc/ballistics/effects/Explode.java @@ -0,0 +1,27 @@ +package llevc.ballistics.effects; + +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.effect.InstantenousMobEffect; +import net.minecraft.world.effect.MobEffectCategory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; + +public class Explode extends InstantenousMobEffect { + public Explode(MobEffectCategory mobEffectCategory, int i) { + super(mobEffectCategory, i); + } + + @Override + public boolean applyEffectTick(ServerLevel serverLevel, LivingEntity livingEntity, int i) { + return true; + } + + @Override + public void applyInstantenousEffect(ServerLevel serverLevel, @Nullable Entity entity, @Nullable Entity entity2, LivingEntity livingEntity, int i, double d) { + serverLevel.explode(livingEntity, livingEntity.damageSources().explosion(entity,entity2), null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), 6.0F, false, Level.ExplosionInteraction.TNT); + livingEntity.hurtServer(serverLevel,livingEntity.damageSources().explosion(entity,entity2),40); + } +} diff --git a/src/main/java/llevc/ballistics/items/SmokeItem.java b/src/main/java/llevc/ballistics/items/SmokeItem.java new file mode 100644 index 0000000..c47a038 --- /dev/null +++ b/src/main/java/llevc/ballistics/items/SmokeItem.java @@ -0,0 +1,163 @@ +package llevc.ballistics.items; + +import llevc.ballistics.Ballistics; +import llevc.ballistics.ModItems; +import net.minecraft.core.BlockPos; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUseAnimation; +import net.minecraft.world.item.alchemy.PotionContents; +import net.minecraft.world.item.enchantment.effects.SpawnParticlesEffect; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Iterator; +import java.util.List; + +public class SmokeItem extends Item { + + public SmokeItem(Properties properties) { + super(properties); + } + + public boolean smokeParticles() { + if (this.equals(ModItems.pick)) { + return false; + } + return true; + } + + public float applyRate() { + return 40; + } + + @Override + public InteractionResult use(Level level, Player player, InteractionHand interactionHand) { + if (!level.isClientSide()) { + player.startUsingItem(interactionHand); + } + return InteractionResult.CONSUME; + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack itemStack, int i) { + if (level.isClientSide()) { + return; + } + Ballistics.LOGGER.info(String.valueOf(i)); + if (Math.round(i/applyRate()) == i/applyRate() || i <= 1) { + for (MobEffectInstance nah : itemStack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).getAllEffects()) { + MobEffectInstance yah = nah.withScaledDuration(1 / 5f); + livingEntity.forceAddEffect(yah,livingEntity); + } + itemStack.hurtAndBreak(1,livingEntity,livingEntity.getUsedItemHand()); + if (i <= 1) { + livingEntity.stopUsingItem(); + if (livingEntity instanceof Player player) { + player.getCooldowns().addCooldown(itemStack,getUseDuration(itemStack, livingEntity)*2); + } + } + } + } + + public void spawnSmokeParticles(Level level, LivingEntity livingEntity) { + if (smokeParticles()) { + for (int j = 0; j < 5; j++) { + ParticleUtils.spawnParticleBelow(level, new BlockPos((int) livingEntity.getEyePosition().x, (int) livingEntity.getEyePosition().y, (int) livingEntity.getEyePosition().z), RandomSource.create(), ParticleTypes.POOF); + } + } + } + + public void sendSmokeParticles(ServerLevel serverLevel, LivingEntity livingEntity) { + if (smokeParticles()) { + for (int j = 0; j < 5; j++) { + RandomSource randomSource = RandomSource.create(); + serverLevel.sendParticles(ParticleTypes.POOF,livingEntity.getEyePosition().x+randomSource.nextDouble()-0.5, livingEntity.getEyePosition().y, livingEntity.getEyePosition().z+randomSource.nextDouble()-0.5,0,0,0,0,0); + //ParticleUtils.spawnParticleBelow(level, new BlockPos((int) livingEntity.getEyePosition().x, (int) livingEntity.getEyePosition().y, (int) livingEntity.getEyePosition().z), RandomSource.create(), ParticleTypes.POOF); + } + } + } + + @Override + public boolean releaseUsing(ItemStack itemStack, Level level, LivingEntity livingEntity, int i) { + if (level.isClientSide()) { + //spawnSmokeParticles(level,livingEntity); + return false; + } + if (level instanceof ServerLevel serverLevel) { + sendSmokeParticles(serverLevel,livingEntity); + } + if (livingEntity instanceof Player player) { + player.getCooldowns().addCooldown(itemStack,(getUseDuration(itemStack, livingEntity)-i)*2); + } + return false; + } + + @Override + public ItemUseAnimation getUseAnimation(ItemStack itemStack) { + return ItemUseAnimation.TOOT_HORN; + } + + @Override + public int getUseDuration(ItemStack itemStack, LivingEntity livingEntity) { + if (itemStack.is(ModItems.pick)) { + return 20*2; + } else if (itemStack.is(ModItems.vape)) { + return 20*12; + } + return 20*6; + } + + public int ticksUsed = 0; + @Override + public void inventoryTick(ItemStack itemStack, ServerLevel serverLevel, Entity entity, @Nullable EquipmentSlot equipmentSlot) { + if (equipmentSlot == EquipmentSlot.HEAD) { + if (entity instanceof LivingEntity livingEntity) { + boolean cooldown = false; + int woah = getUseDuration(itemStack, livingEntity) - ticksUsed; + + if (entity instanceof Player player) { + cooldown = player.getCooldowns().isOnCooldown(itemStack); + } + + if (livingEntity.isCrouching() && !cooldown) { + Ballistics.LOGGER.info(String.valueOf(getUseDuration(itemStack, livingEntity))); + if (Math.round(woah / applyRate()) == woah / applyRate() || woah <= 1) { + for (MobEffectInstance nah : itemStack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).getAllEffects()) { + MobEffectInstance yah = nah.withScaledDuration(1 / 5f); + livingEntity.forceAddEffect(yah, livingEntity); + } + if (!(itemStack.is(ModItems.pick) && itemStack.getOrDefault(DataComponents.POTION_CONTENTS,PotionContents.EMPTY) == PotionContents.EMPTY)) { + itemStack.hurtAndBreak(1, livingEntity, equipmentSlot); + } + if (woah <= 1) { + livingEntity.stopUsingItem(); + if (livingEntity instanceof Player player) { + player.getCooldowns().addCooldown(itemStack, getUseDuration(itemStack, livingEntity) * 2); + } + } + } + ticksUsed++; + } else if ((!livingEntity.isCrouching() || cooldown) && ticksUsed > 0) { + ticksUsed = 0; + releaseUsing(itemStack,serverLevel,livingEntity,woah); + } + } + } + } +} diff --git a/src/main/java/llevc/ballistics/recipes/CartridgeRecipe.java b/src/main/java/llevc/ballistics/recipes/CartridgeRecipe.java new file mode 100644 index 0000000..3c6b23a --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/CartridgeRecipe.java @@ -0,0 +1,102 @@ +package llevc.ballistics.recipes; + +import llevc.ballistics.ModItems; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionContents; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.Level; + +import java.util.List; +import java.util.Objects; + +public class CartridgeRecipe extends CustomRecipe { + public CartridgeRecipe(CraftingBookCategory craftingBookCategory) { + super(craftingBookCategory); + } + + public boolean matches(CraftingInput recipeInput, Level level) { + boolean potion = false; + boolean flask = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(Items.POTION)) { + if (!potion) { + potion = true; + } else { + return false; + } + } else if (itemStack.is(ModItems.cartridge)) { + if (!flask) { + flask = true; + } else { + return false; + } + } else { + return false; + } + } + return (potion && flask && recipeInput.ingredientCount() <= 2); + } + + public ItemStack assemble(CraftingInput recipeInput, HolderLookup.Provider provider) { + ItemStack result = ItemStack.EMPTY; + ItemStack potion = ItemStack.EMPTY; + boolean flask = false; + boolean overflow = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(Items.POTION)) { + + if (potion.isEmpty()) { + potion = itemStack; + } else { + overflow = true; + } + + } else if (itemStack.is(ModItems.cartridge)) { + + if (!flask) { + flask = true; + } else { + overflow = true; + } + } else if (!itemStack.isEmpty()) { + overflow = true; + } + } + + if (!potion.isEmpty() && flask && !overflow) { + PotionContents death = Objects.requireNonNull(potion.get(DataComponents.POTION_CONTENTS)); + double level = 0; + List effects = new java.util.ArrayList<>(List.of()); + for (MobEffectInstance mobEffectInstance : death.getAllEffects()) { + level = level+mobEffectInstance.getAmplifier()+1; + if (!effects.contains(mobEffectInstance.getEffect().getRegisteredName())) { + effects.add(mobEffectInstance.getEffect().getRegisteredName()); + } + } + //Ballistics.LOGGER.info(String.valueOf(death)); + ItemStack gamer; + gamer = PotionContents.createItemStack(ModItems.cartridge, death.potion().orElse(Potions.WATER)); + gamer.set(DataComponents.POTION_CONTENTS, death); + result = gamer; + } + + return result; + } + + @Override + public RecipeSerializer getSerializer() { + return CartridgeRecipeSerializer.INSTANCE; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/CartridgeRecipeSerializer.java b/src/main/java/llevc/ballistics/recipes/CartridgeRecipeSerializer.java new file mode 100644 index 0000000..aac1309 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/CartridgeRecipeSerializer.java @@ -0,0 +1,40 @@ +package llevc.ballistics.recipes; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; + +public class CartridgeRecipeSerializer implements RecipeSerializer { + public static final CartridgeRecipeSerializer INSTANCE = new CartridgeRecipeSerializer(CartridgeRecipe::new); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("ballistics","crafting_special_cartridge_fill"); + + + + private final MapCodec codec; + private final StreamCodec streamCodec; + + public CartridgeRecipeSerializer(CustomRecipe.Serializer.Factory factory) { + this.codec = RecordCodecBuilder.mapCodec( + instance -> instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)) + .apply(instance, factory::create) + ); + this.streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, factory::create); + } + + @Override + public @NotNull MapCodec codec() { + return codec; + } + + @Override + public @NotNull StreamCodec streamCodec() { + return streamCodec; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/GeekedRecipe.java b/src/main/java/llevc/ballistics/recipes/GeekedRecipe.java new file mode 100644 index 0000000..d9ecbb9 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/GeekedRecipe.java @@ -0,0 +1,103 @@ +package llevc.ballistics.recipes; + +import llevc.ballistics.ModItems; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionContents; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.Level; + +import java.util.List; +import java.util.Objects; + +public class GeekedRecipe extends CustomRecipe { + public GeekedRecipe(CraftingBookCategory craftingBookCategory) { + super(craftingBookCategory); + } + + public boolean matches(CraftingInput recipeInput, Level level) { + boolean potion = false; + boolean flask = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(ModItems.cartridge)) { + if (!potion) { + potion = true; + } else { + return false; + } + } else if (itemStack.is(ModItems.vape)) { + if (!flask) { + flask = true; + } else { + return false; + } + } else { + return false; + } + } + return (potion && flask && recipeInput.ingredientCount() <= 2); + } + + public ItemStack assemble(CraftingInput recipeInput, HolderLookup.Provider provider) { + ItemStack result = ItemStack.EMPTY; + ItemStack potion = ItemStack.EMPTY; + ItemStack geek = ItemStack.EMPTY; + boolean overflow = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(ModItems.cartridge)) { + + if (potion.isEmpty()) { + potion = itemStack; + } else { + overflow = true; + } + + } else if (itemStack.is(ModItems.vape)) { + + if (geek.isEmpty()) { + geek = itemStack; + } else { + overflow = true; + } + + } else if (!itemStack.isEmpty()) { + overflow = true; + } + } + + if (!potion.isEmpty() && !geek.isEmpty() && !overflow) { + PotionContents death = Objects.requireNonNull(potion.get(DataComponents.POTION_CONTENTS)); + double level = 0; + List effects = new java.util.ArrayList<>(List.of()); + for (MobEffectInstance mobEffectInstance : death.getAllEffects()) { + level = level+mobEffectInstance.getAmplifier()+1; + if (!effects.contains(mobEffectInstance.getEffect().getRegisteredName())) { + effects.add(mobEffectInstance.getEffect().getRegisteredName()); + } + } + //Ballistics.LOGGER.info(String.valueOf(death)); + ItemStack gamer; + gamer = geek.copy(); + gamer.set(DataComponents.POTION_CONTENTS, death); + result = gamer; + } + + return result; + } + + @Override + public RecipeSerializer getSerializer() { + return GeekedRecipeSerializer.INSTANCE; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/GeekedRecipeSerializer.java b/src/main/java/llevc/ballistics/recipes/GeekedRecipeSerializer.java new file mode 100644 index 0000000..e729305 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/GeekedRecipeSerializer.java @@ -0,0 +1,40 @@ +package llevc.ballistics.recipes; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; + +public class GeekedRecipeSerializer implements RecipeSerializer { + public static final GeekedRecipeSerializer INSTANCE = new GeekedRecipeSerializer(GeekedRecipe::new); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("ballistics","crafting_special_geeked"); + + + + private final MapCodec codec; + private final StreamCodec streamCodec; + + public GeekedRecipeSerializer(CustomRecipe.Serializer.Factory factory) { + this.codec = RecordCodecBuilder.mapCodec( + instance -> instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)) + .apply(instance, factory::create) + ); + this.streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, factory::create); + } + + @Override + public @NotNull MapCodec codec() { + return codec; + } + + @Override + public @NotNull StreamCodec streamCodec() { + return streamCodec; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/PickRecipe.java b/src/main/java/llevc/ballistics/recipes/PickRecipe.java new file mode 100644 index 0000000..696e068 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/PickRecipe.java @@ -0,0 +1,103 @@ +package llevc.ballistics.recipes; + +import llevc.ballistics.ModItems; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.alchemy.PotionContents; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.Level; + +import java.util.List; +import java.util.Objects; + +public class PickRecipe extends CustomRecipe { + public PickRecipe(CraftingBookCategory craftingBookCategory) { + super(craftingBookCategory); + } + + public boolean matches(CraftingInput recipeInput, Level level) { + boolean potion = false; + boolean flask = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(Items.POTION)) { + if (!potion) { + potion = true; + } else { + return false; + } + } else if (itemStack.is(ModItems.pick)) { + if (!flask) { + flask = true; + } else { + return false; + } + } else { + return false; + } + } + return (potion && flask && recipeInput.ingredientCount() <= 2); + } + + public ItemStack assemble(CraftingInput recipeInput, HolderLookup.Provider provider) { + ItemStack result = ItemStack.EMPTY; + ItemStack potion = ItemStack.EMPTY; + boolean flask = false; + boolean overflow = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + if (itemStack.is(Items.POTION)) { + + if (potion.isEmpty()) { + potion = itemStack; + } else { + overflow = true; + } + + } else if (itemStack.is(ModItems.pick)) { + + if (!flask) { + flask = true; + } else { + overflow = true; + } + } else if (!itemStack.isEmpty()) { + overflow = true; + } + } + + if (!potion.isEmpty() && flask && !overflow) { + PotionContents death = Objects.requireNonNull(potion.get(DataComponents.POTION_CONTENTS)); + double level = 0; + List effects = new java.util.ArrayList<>(List.of()); + for (MobEffectInstance mobEffectInstance : death.getAllEffects()) { + level = level+mobEffectInstance.getAmplifier()+1; + if (!effects.contains(mobEffectInstance.getEffect().getRegisteredName())) { + effects.add(mobEffectInstance.getEffect().getRegisteredName()); + } + } + //Ballistics.LOGGER.info(String.valueOf(death)); + ItemStack gamer; + gamer = PotionContents.createItemStack(ModItems.pick, death.potion().orElse(Potions.WATER)); + gamer.set(DataComponents.POTION_CONTENTS, death); + result = gamer; + } + + return result; + } + + @Override + public RecipeSerializer getSerializer() { + return PickRecipeSerializer.INSTANCE; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/PickRecipeSerializer.java b/src/main/java/llevc/ballistics/recipes/PickRecipeSerializer.java new file mode 100644 index 0000000..66e9141 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/PickRecipeSerializer.java @@ -0,0 +1,40 @@ +package llevc.ballistics.recipes; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; + +public class PickRecipeSerializer implements RecipeSerializer { + public static final PickRecipeSerializer INSTANCE = new PickRecipeSerializer(PickRecipe::new); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("ballistics","crafting_special_pick"); + + + + private final MapCodec codec; + private final StreamCodec streamCodec; + + public PickRecipeSerializer(CustomRecipe.Serializer.Factory factory) { + this.codec = RecordCodecBuilder.mapCodec( + instance -> instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)) + .apply(instance, factory::create) + ); + this.streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, factory::create); + } + + @Override + public @NotNull MapCodec codec() { + return codec; + } + + @Override + public @NotNull StreamCodec streamCodec() { + return streamCodec; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/SnortableRecipe.java b/src/main/java/llevc/ballistics/recipes/SnortableRecipe.java new file mode 100644 index 0000000..6e3e856 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/SnortableRecipe.java @@ -0,0 +1,107 @@ +package llevc.ballistics.recipes; + +import llevc.ballistics.Ballistics; +import llevc.ballistics.ModItems; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUseAnimation; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.alchemy.PotionContents; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.component.Consumable; +import net.minecraft.world.item.component.Consumables; +import net.minecraft.world.item.component.DyedItemColor; +import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect; +import net.minecraft.world.item.consume_effects.ConsumeEffect; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class SnortableRecipe extends CustomRecipe { + public SnortableRecipe(CraftingBookCategory craftingBookCategory) { + super(craftingBookCategory); + } + + public boolean matches(CraftingInput recipeInput, Level level) { + boolean potion = false; + boolean flask = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + Block block = Objects.requireNonNullElse(Block.byItem(itemStack.getItem()), Blocks.AIR); + if (block != Blocks.AIR || itemStack.is(Items.BRICK)) { + if (block != Blocks.AIR && !potion) { + potion = true; + } else if (block != Blocks.AIR && potion) { + return false; + } + if (itemStack.is(Items.BRICK) && !flask) { + flask = true; + } else if (itemStack.is(Items.BRICK) && flask) { + return false; + } + } else { + return false; + } + } + return (potion && flask && recipeInput.ingredientCount() <= 2); + } + + public ItemStack assemble(CraftingInput recipeInput, HolderLookup.Provider provider) { + ItemStack result = ItemStack.EMPTY; + Block block = Blocks.AIR; + boolean flask = false; + boolean overflow = false; + + for (int i = 0; i < recipeInput.size(); i++) { + ItemStack itemStack = recipeInput.getItem(i); + Block block1 = Objects.requireNonNullElse(Block.byItem(itemStack.getItem()), Blocks.AIR); + if (block1 != Blocks.AIR) { + if (block == Blocks.AIR) { + block = block1; + } else { + overflow = true; + } + } else if (itemStack.is(Items.BRICK)) { + + if (itemStack.is(Items.BRICK) && !flask) { + flask = true; + } else if (itemStack.is(Items.BRICK) && flask) { + overflow = true; + } + } else if (!itemStack.isEmpty()) { + overflow = true; + } + } + + if (!overflow && flask && block != Blocks.AIR) { + ItemStack yes = ModItems.createSnortable(block); + result = yes; + } + + return result; + } + + @Override + public RecipeSerializer getSerializer() { + return SnortableRecipeSerializer.INSTANCE; + } +} diff --git a/src/main/java/llevc/ballistics/recipes/SnortableRecipeSerializer.java b/src/main/java/llevc/ballistics/recipes/SnortableRecipeSerializer.java new file mode 100644 index 0000000..af1ead3 --- /dev/null +++ b/src/main/java/llevc/ballistics/recipes/SnortableRecipeSerializer.java @@ -0,0 +1,40 @@ +package llevc.ballistics.recipes; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; + +public class SnortableRecipeSerializer implements RecipeSerializer { + public static final SnortableRecipeSerializer INSTANCE = new SnortableRecipeSerializer(SnortableRecipe::new); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath("ballistics","crafting_special_snortable"); + + + + private final MapCodec codec; + private final StreamCodec streamCodec; + + public SnortableRecipeSerializer(CustomRecipe.Serializer.Factory factory) { + this.codec = RecordCodecBuilder.mapCodec( + instance -> instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)) + .apply(instance, factory::create) + ); + this.streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, factory::create); + } + + @Override + public @NotNull MapCodec codec() { + return codec; + } + + @Override + public @NotNull StreamCodec streamCodec() { + return streamCodec; + } +} diff --git a/src/main/resources/data/ballistics/recipe/cartridge.json b/src/main/resources/data/ballistics/recipe/cartridge.json new file mode 100644 index 0000000..fa24e81 --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/cartridge.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + "cac", + "aba", + "cac" + ], + "key": { + "a": "minecraft:iron_ingot", + "b": "minecraft:glass_bottle", + "c": "minecraft:paper" + }, + "result": { + "id": "ballistics:cartridge", + "count": 16 + } +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/cartridge_fill.json b/src/main/resources/data/ballistics/recipe/cartridge_fill.json new file mode 100644 index 0000000..5271035 --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/cartridge_fill.json @@ -0,0 +1,4 @@ +{ + "type": "ballistics:crafting_special_cartridge_fill", + "category": "equipment" +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/cig.json b/src/main/resources/data/ballistics/recipe/cig.json new file mode 100644 index 0000000..7019da6 --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/cig.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + "dbe", + "bab", + "cbd" + ], + "key": { + "a": "minecraft:slime_ball", + "b": "minecraft:paper", + "c": "minecraft:honey_bottle", + "d": "minecraft:iron_nugget", + "e": "minecraft:string" + }, + "result": { + "id": "ballistics:cig", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/geeked_fill.json b/src/main/resources/data/ballistics/recipe/geeked_fill.json new file mode 100644 index 0000000..c7d5ddb --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/geeked_fill.json @@ -0,0 +1,4 @@ +{ + "type": "ballistics:crafting_special_geeked", + "category": "equipment" +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/pick.json b/src/main/resources/data/ballistics/recipe/pick.json new file mode 100644 index 0000000..73be7cf --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/pick.json @@ -0,0 +1,4 @@ +{ + "type": "ballistics:crafting_special_pick", + "category": "equipment" +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/pick1.json b/src/main/resources/data/ballistics/recipe/pick1.json new file mode 100644 index 0000000..49e9c3c --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/pick1.json @@ -0,0 +1,10 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "equipment", + "ingredients": [ + "minecraft:stick" + ], + "result": { + "id": "ballistics:pick" + } +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/snortable.json b/src/main/resources/data/ballistics/recipe/snortable.json new file mode 100644 index 0000000..e23b06f --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/snortable.json @@ -0,0 +1,4 @@ +{ + "type": "ballistics:crafting_special_snortable", + "category": "misc" +} \ No newline at end of file diff --git a/src/main/resources/data/ballistics/recipe/vape.json b/src/main/resources/data/ballistics/recipe/vape.json new file mode 100644 index 0000000..c01d759 --- /dev/null +++ b/src/main/resources/data/ballistics/recipe/vape.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + "dae", + "aba", + "cad" + ], + "key": { + "a": "minecraft:iron_ingot", + "b": "minecraft:slime_block", + "c": "minecraft:honey_bottle", + "d": "minecraft:paper", + "e": "minecraft:string" + }, + "result": { + "id": "ballistics:vape" + } +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/item/enchantable/durability.json b/src/main/resources/data/minecraft/tags/item/enchantable/durability.json index 9611348..cbec1bd 100644 --- a/src/main/resources/data/minecraft/tags/item/enchantable/durability.json +++ b/src/main/resources/data/minecraft/tags/item/enchantable/durability.json @@ -2,6 +2,9 @@ "replace": false, "values": [ "ballistics:rh_glove", - "ballistics:flintlock" + "ballistics:flintlock", + "ballistics:pick", + "ballistics:cig", + "ballistics:vape" ] } \ No newline at end of file