Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Starexify committed Oct 31, 2024
1 parent 19d7803 commit 3c54b5f
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "nmt:crafting_special_obsidiantippedarrow",
"category": "misc"
}
1 change: 1 addition & 0 deletions src/main/java/net/nova/nmt/NoMoreThings.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public NoMoreThings(IEventBus bus) {
NMTMenuType.MENUS.register(bus);
NMTFeature.FEATURES.register(bus);
NMTEntityType.ENTITY_TYPES.register(bus);
NMTRecipeSerializers.RECIPE_SERIALIZERS.register(bus);

bus.addListener(DataGenerators::gatherData);
bus.addListener(this::onRegisterComplete);
Expand Down

This file was deleted.

33 changes: 20 additions & 13 deletions src/main/java/net/nova/nmt/data/recipe/CraftingRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.SpecialRecipeBuilder;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.TippedArrowRecipe;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.neoforge.common.Tags;
import net.nova.nmt.NoMoreThings;
import net.nova.nmt.init.NMTBlocks;
import net.nova.nmt.init.NMTItems;
import net.nova.nmt.recipe.ObsidianTippedArrowRecipe;

import java.util.concurrent.CompletableFuture;

Expand All @@ -23,6 +27,20 @@ public CraftingRecipes(PackOutput output, CompletableFuture<HolderLookup.Provide
}

public void build() {
// Ender Wart
threeByThreePacker(recipeOutput, RecipeCategory.BUILDING_BLOCKS, NMTBlocks.ENDER_WART_BLOCK, NMTItems.ENDER_WART);

// Brewing Stand
ShapedRecipeBuilder.shaped(RecipeCategory.BREWING, NMTBlocks.ENDER_BREWING_STAND)
.define('B', Items.END_ROD)
.define('S', Items.BREWING_STAND)
.define('#', Items.OBSIDIAN)
.pattern(" B ")
.pattern(" S ")
.pattern("###")
.unlockedBy("has_" + getItemName(Items.BREWING_STAND), has(Items.BREWING_STAND))
.save(recipeOutput);

// Obsidian Glass
ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, NMTBlocks.OBSIDIAN_GLASS)
.group(getItemName(NMTBlocks.OBSIDIAN_GLASS))
Expand All @@ -36,17 +54,6 @@ public void build() {

stainedGlassPaneFromStainedGlass(recipeOutput, NMTBlocks.OBSIDIAN_GLASS_PANE, NMTBlocks.OBSIDIAN_GLASS);

// Brewing Stand
ShapedRecipeBuilder.shaped(RecipeCategory.BREWING, NMTBlocks.ENDER_BREWING_STAND)
.define('B', Items.END_ROD)
.define('S', Items.BREWING_STAND)
.define('#', Items.OBSIDIAN)
.pattern(" B ")
.pattern(" S ")
.pattern("###")
.unlockedBy("has_" + getItemName(Items.BREWING_STAND), has(Items.BREWING_STAND))
.save(recipeOutput);

// Obsidian Bottle
ShapedRecipeBuilder.shaped(RecipeCategory.BREWING, NMTItems.OBSIDIAN_GLASS_BOTTLE, 3)
.define('#', NMTBlocks.OBSIDIAN_GLASS)
Expand All @@ -55,7 +62,7 @@ public void build() {
.unlockedBy("has_" + getItemName(NMTBlocks.OBSIDIAN_GLASS), has(NMTBlocks.OBSIDIAN_GLASS))
.save(recipeOutput);

// Ender Wart
threeByThreePacker(recipeOutput, RecipeCategory.BUILDING_BLOCKS, NMTBlocks.ENDER_WART_BLOCK, NMTItems.ENDER_WART);
// Tipped Arrows
SpecialRecipeBuilder.special(ObsidianTippedArrowRecipe::new).save(recipeOutput, NoMoreThings.rl("obsidian_tipped_arrow"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ protected void onHit(HitResult result) {
this.level().levelEvent(i, this.blockPosition(), potioncontents.getColor());
this.discard();
}

if (potioncontents.is(NMTPotions.AWFULLY)) {
this.applySplash(
potioncontents.getAllEffects(), result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) result).getEntity() : null
);
int i = potioncontents.potion().isPresent() && potioncontents.potion().get().value().hasInstantEffects() ? 2007 : 2002;
this.level().levelEvent(i, this.blockPosition(), potioncontents.getColor());
this.discard();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/nova/nmt/init/NMTItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemNameBlockItem;
import net.minecraft.world.item.TippedArrowItem;
import net.minecraft.world.item.alchemy.PotionContents;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
Expand All @@ -22,6 +23,5 @@ public class NMTItems {
public static final DeferredItem<Item> OBSIDIAN_POTION = ITEMS.register("obsidian_potion", () -> new ObsidianPotionItem(new Item.Properties().stacksTo(1).component(DataComponents.POTION_CONTENTS, new PotionContents(NMTPotions.LAVA)).fireResistant()));
public static final DeferredItem<Item> SPLASH_OBSIDIAN_POTION = ITEMS.register("splash_obsidian_potion", () -> new SplashObsidianPotionItem(new Item.Properties().stacksTo(1).component(DataComponents.POTION_CONTENTS, new PotionContents(NMTPotions.LAVA)).fireResistant()));
public static final DeferredItem<Item> LINGERING_OBSIDIAN_POTION = ITEMS.register("lingering_obsidian_potion", () -> new LingeringObsidianPotionItem(new Item.Properties().stacksTo(1).component(DataComponents.POTION_CONTENTS, new PotionContents(NMTPotions.LAVA)).fireResistant()));
public static final DeferredItem<Item> OBSIDIAN_TIPPED_ARROW = ITEMS.register("obsidian_tipped_arrow", () -> new ObsidianTippedArrowItem(new Item.Properties().component(DataComponents.POTION_CONTENTS, new PotionContents(NMTPotions.LAVA))));

public static final DeferredItem<Item> OBSIDIAN_TIPPED_ARROW = ITEMS.register("obsidian_tipped_arrow", () -> new TippedArrowItem(new Item.Properties().component(DataComponents.POTION_CONTENTS, new PotionContents(NMTPotions.LAVA))));
}
18 changes: 18 additions & 0 deletions src/main/java/net/nova/nmt/init/NMTRecipeSerializers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.nova.nmt.init;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer;
import net.minecraft.world.item.crafting.TippedArrowRecipe;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.nova.nmt.recipe.ObsidianTippedArrowRecipe;

import java.util.function.Supplier;

import static net.nova.nmt.NoMoreThings.MODID;

public class NMTRecipeSerializers {
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(Registries.RECIPE_SERIALIZER, MODID);

public static final Supplier<RecipeSerializer<ObsidianTippedArrowRecipe>> OBSIDIAN_TIPPED_ARROW = RECIPE_SERIALIZERS.register("crafting_special_obsidiantippedarrow", () -> new SimpleCraftingRecipeSerializer<>(ObsidianTippedArrowRecipe::new));
}
39 changes: 0 additions & 39 deletions src/main/java/net/nova/nmt/item/ObsidianTippedArrowItem.java

This file was deleted.

65 changes: 65 additions & 0 deletions src/main/java/net/nova/nmt/recipe/ObsidianTippedArrowRecipe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package net.nova.nmt.recipe;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
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.nova.nmt.init.NMTItems;
import net.nova.nmt.init.NMTRecipeSerializers;

public class ObsidianTippedArrowRecipe extends CustomRecipe {
public ObsidianTippedArrowRecipe(CraftingBookCategory category) {
super(category);
}

public boolean matches(CraftingInput input, Level level) {
if (input.width() == 3 && input.height() == 3) {
for (int i = 0; i < input.height(); i++) {
for (int j = 0; j < input.width(); j++) {
ItemStack itemstack = input.getItem(j, i);
if (itemstack.isEmpty()) {
return false;
}

if (j == 1 && i == 1) {
if (!itemstack.is(NMTItems.LINGERING_OBSIDIAN_POTION)) {
return false;
}
} else if (!itemstack.is(Items.ARROW)) {
return false;
}
}
}

return true;
} else {
return false;
}
}

public ItemStack assemble(CraftingInput input, HolderLookup.Provider registries) {
ItemStack itemstack = input.getItem(1, 1);
if (!itemstack.is(NMTItems.LINGERING_OBSIDIAN_POTION)) {
return ItemStack.EMPTY;
} else {
ItemStack itemstack1 = new ItemStack(NMTItems.OBSIDIAN_TIPPED_ARROW.get(), 8);
itemstack1.set(DataComponents.POTION_CONTENTS, itemstack.get(DataComponents.POTION_CONTENTS));
return itemstack1;
}
}

@Override
public boolean canCraftInDimensions(int width, int height) {
return width >= 3 && height >= 3;
}

@Override
public RecipeSerializer<?> getSerializer() {
return NMTRecipeSerializers.OBSIDIAN_TIPPED_ARROW.get();
}
}

0 comments on commit 3c54b5f

Please sign in to comment.