Skip to content

Commit

Permalink
Half way done
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Nov 9, 2023
1 parent 74e180c commit f020737
Show file tree
Hide file tree
Showing 50 changed files with 200 additions and 199 deletions.
2 changes: 1 addition & 1 deletion neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ println(
.trimIndent()
)

//minecraft.accessTransformers.file(rootProject.file("src/main/resources/META-INF/accesstransformer.cfg"))
accessTransformers.file("src/main/resources/META-INF/accesstransformer.cfg")

runs {
configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,25 @@
import net.minecraft.world.entity.player.StackedContents;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.inventory.RecipeHolder;
import net.minecraft.world.inventory.RecipeCraftingHolder;
import net.minecraft.world.inventory.StackedContentsCompatible;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.*;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import var;

/**
* @see AbstractFurnaceBlockEntity
*/
public class IngotFusionTollEnhancerBlockEntity extends BaseContainerBlockEntity
implements WorldlyContainer, RecipeHolder, StackedContentsCompatible {
implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible {

@Getter
private final RecipeManager.CachedCheck<Container, IngotFusionTollEnhancerRecipe> quickCheck;
Expand Down Expand Up @@ -337,9 +333,9 @@ private void createItem(Level level) {
} else if (!this.level.isClientSide) {
Containers.dropItemStack(
this.level,
(double) blockPos.getX(),
(double) blockPos.getY(),
(double) blockPos.getZ(),
blockPos.getX(),
blockPos.getY(),
blockPos.getZ(),
ingredient2Remaining);
}
} else {
Expand Down Expand Up @@ -374,13 +370,13 @@ private void createItem(Level level) {

private boolean hasRecipe(ItemStack ingredient) {
return level.getRecipeManager().getAllRecipesFor(type).stream()
.anyMatch(recipe -> recipe.isIngredient(ingredient));
.anyMatch(recipe -> recipe.value().isIngredient(ingredient));
}

private ItemStack getOutput(
Level level, ItemStack ingredient1, ItemStack ingredient2, ItemStack ingredient3) {
return level.getRecipeManager().getAllRecipesFor(type).stream()
.map(recipe -> recipe.getResult(ingredient1, ingredient2, ingredient3))
.map(recipe -> recipe.value().getResult(ingredient1, ingredient2, ingredient3))
.filter(itemStack -> !itemStack.isEmpty())
.findFirst()
.orElse(ItemStack.EMPTY);
Expand Down Expand Up @@ -438,16 +434,15 @@ public boolean canTakeItemThroughFace(int pIndex, ItemStack pStack, Direction pD
}

@Override
public void setRecipeUsed(@Nullable Recipe<?> pRecipe) {
if (pRecipe != null) {
ResourceLocation resourcelocation = pRecipe.getId();
this.recipesUsed.addTo(resourcelocation, 1);
public void setRecipeUsed(@Nullable RecipeHolder<?> recipe) {
if (recipe != null) {
ResourceLocation resourcelocation = recipe.id();
this.recipesUsed.addTo(resourcelocation, 1);
}
}

@Nullable
@Override
public Recipe<?> getRecipeUsed() {
public RecipeHolder<?> getRecipeUsed() {
return null;
}

Expand All @@ -461,11 +456,11 @@ public void fillStackedContents(StackedContents pContents) {
public void awardUsedRecipes(Player pPlayer, List<ItemStack> pItems) {}

public void awardUsedRecipesAndPopExperience(ServerPlayer pPlayer) {
List<Recipe<?>> list =
List<RecipeHolder<?>> list =
this.getRecipesToAwardAndPopExperience(pPlayer.serverLevel(), pPlayer.position());
pPlayer.awardRecipes(list);

for (Recipe<?> recipe : list) {
for (RecipeHolder<?> recipe : list) {
if (recipe != null) {
pPlayer.triggerRecipeCrafted(recipe, this.items);
}
Expand All @@ -474,8 +469,8 @@ public void awardUsedRecipesAndPopExperience(ServerPlayer pPlayer) {
this.recipesUsed.clear();
}

public List<Recipe<?>> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec3 pPopVec) {
List<Recipe<?>> list = Lists.newArrayList();
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec3 pPopVec) {
List<RecipeHolder<?>> list = Lists.newArrayList();

for (Object2IntMap.Entry<ResourceLocation> entry : this.recipesUsed.object2IntEntrySet()) {
pLevel
Expand All @@ -488,7 +483,7 @@ public List<Recipe<?>> getRecipesToAwardAndPopExperience(ServerLevel pLevel, Vec
pLevel,
pPopVec,
entry.getIntValue(),
((AbstractCookingRecipe) p_155023_).getExperience());
((AbstractCookingRecipe) p_155023_.value()).getExperience());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import net.minecraft.world.entity.player.StackedContents
import net.minecraft.world.inventory.*
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Recipe
import net.minecraft.world.item.crafting.RecipeHolder
import net.minecraft.world.level.Level

/** @see CraftingMenu */
Expand Down Expand Up @@ -88,7 +89,7 @@ class CustomArmourCraftingTableMenu(
if (optional.isPresent) {
val craftingrecipe = optional.get()
if (pResult.setRecipeUsed(pLevel, serverplayer, craftingrecipe)) {
val itemstack1 = craftingrecipe.assemble(pContainer, pLevel.registryAccess())
val itemstack1 = craftingrecipe.value.assemble(pContainer, pLevel.registryAccess())
if (itemstack1.isItemEnabled(pLevel.enabledFeatures())) {
itemstack = itemstack1
}
Expand Down Expand Up @@ -119,8 +120,8 @@ class CustomArmourCraftingTableMenu(
resultSlots.clearContent()
}

override fun recipeMatches(pRecipe: Recipe<in CustomArmourCraftingTableContainer>): Boolean {
return pRecipe.matches(craftSlots, player.level())
override fun recipeMatches(recipeHolder: RecipeHolder<out Recipe<CustomArmourCraftingTableContainer>>): Boolean {
return recipeHolder.value.matches(craftSlots, player.level())
}

/** Called when the container is closed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ package io.github.realyusufismail.armourandtoolsmod.blocks.armour
import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeTypeInit
import net.minecraft.world.Container
import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.RecipeHolder
import net.minecraft.world.inventory.RecipeCraftingHolder
import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack
import net.minecraftforge.common.ForgeHooks
import net.minecraftforge.event.ForgeEventFactory
import net.minecraft.world.item.crafting.RecipeHolder
import net.neoforged.neoforge.common.CommonHooks
import net.neoforged.neoforge.event.EventHooks

/** @see net.minecraft.world.inventory.ResultSlot */
class CustomArmourCraftingTableResultSlot(
Expand Down Expand Up @@ -74,24 +75,26 @@ class CustomArmourCraftingTableResultSlot(
override fun checkTakeAchievements(pStack: ItemStack) {
if (this.removeCount > 0) {
pStack.onCraftedBy(this.player.level(), this.player, this.removeCount)
ForgeEventFactory.firePlayerCraftingEvent(this.player, pStack, this.craftSlots)
EventHooks.firePlayerCraftingEvent(this.player, pStack, this.craftSlots)
}
if (container is RecipeHolder) {
(container as RecipeHolder).awardUsedRecipes(this.player, listOf(pStack))

if (container is RecipeCraftingHolder) {
(container as RecipeCraftingHolder).awardUsedRecipes(this.player, listOf(pStack))
}

this.removeCount = 0
}

override fun onTake(pPlayer: Player, pStack: ItemStack) {
checkTakeAchievements(pStack)
ForgeHooks.setCraftingPlayer(pPlayer)
CommonHooks.setCraftingPlayer(pPlayer)
val nonnulllist =
pPlayer
.level()
.recipeManager
.getRemainingItemsFor(
RecipeTypeInit.ARMOUR_CRAFTING.get(), this.craftSlots, pPlayer.level())
ForgeHooks.setCraftingPlayer(null)
CommonHooks.setCraftingPlayer(null)
for (i in nonnulllist.indices) {
var itemstack: ItemStack = this.craftSlots.getItem(i)
val itemstack1 = nonnulllist[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package io.github.realyusufismail.armourandtoolsmod.blocks.infusion.book

import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTollEnhancerBlockEntity
import net.minecraft.client.gui.components.WidgetSprites
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent
import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.Item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTo
import io.github.realyusufismail.armourandtoolsmod.blocks.infusion.IngotFusionTollEnhancerMenu
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraftforge.items.IItemHandler
import net.minecraftforge.items.SlotItemHandler
import net.neoforged.neoforge.items.IItemHandler
import net.neoforged.neoforge.items.SlotItemHandler

class InfusionFuelSlot(itemHandler: IItemHandler, private val menu: IngotFusionTollEnhancerMenu) :
SlotItemHandler(itemHandler, IngotFusionTollEnhancerBlockEntity.FUEL_SLOT, 102, 65) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import kotlin.math.min
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraftforge.event.ForgeEventFactory
import net.minecraftforge.items.IItemHandler
import net.minecraftforge.items.SlotItemHandler
import net.neoforged.neoforge.event.EventHooks
import net.neoforged.neoforge.items.IItemHandler
import net.neoforged.neoforge.items.SlotItemHandler

class OutputSlotItemHandler(itemHandler: IItemHandler, val player: Player) :
SlotItemHandler(itemHandler, IngotFusionTollEnhancerBlockEntity.RESULT_SLOT, 138, 40) {
Expand Down Expand Up @@ -57,6 +57,6 @@ class OutputSlotItemHandler(itemHandler: IItemHandler, val player: Player) :
player)
}
removeCount = 0
ForgeEventFactory.firePlayerSmeltedEvent(this.player, pStack)
EventHooks.firePlayerSmeltedEvent(this.player, pStack)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import net.minecraft.world.entity.player.StackedContents
import net.minecraft.world.inventory.*
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Recipe
import net.minecraft.world.item.crafting.RecipeHolder
import net.minecraft.world.level.Level

/** @see CraftingMenu */
Expand Down Expand Up @@ -88,7 +89,7 @@ class CustomToolCraftingTableMenu(
if (optional.isPresent) {
val craftingrecipe = optional.get()
if (pResult.setRecipeUsed(pLevel, serverplayer, craftingrecipe)) {
val itemstack1 = craftingrecipe.assemble(pContainer, pLevel.registryAccess())
val itemstack1 = craftingrecipe.value.assemble(pContainer, pLevel.registryAccess())
if (itemstack1.isItemEnabled(pLevel.enabledFeatures())) {
itemstack = itemstack1
}
Expand Down Expand Up @@ -119,8 +120,8 @@ class CustomToolCraftingTableMenu(
resultSlots.clearContent()
}

override fun recipeMatches(pRecipe: Recipe<in CustomToolCraftingTableContainer>): Boolean {
return pRecipe.matches(craftSlots, player.level())
override fun recipeMatches(p_301144_: RecipeHolder<out Recipe<CustomToolCraftingTableContainer>>): Boolean {
return p_301144_.value().matches(craftSlots, player.level())
}

/** Called when the container is closed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ package io.github.realyusufismail.armourandtoolsmod.blocks.tool
import io.github.realyusufismail.armourandtoolsmod.core.init.RecipeTypeInit
import net.minecraft.world.Container
import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.RecipeHolder
import net.minecraft.world.inventory.RecipeCraftingHolder
import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack
import net.minecraftforge.common.ForgeHooks
import net.minecraftforge.event.ForgeEventFactory
import net.minecraft.world.item.crafting.RecipeHolder
import net.neoforged.neoforge.common.CommonHooks
import net.neoforged.neoforge.event.EventHooks

/** @see net.minecraft.world.inventory.ResultSlot */
class CustomToolCraftingTableResultSlot(
Expand Down Expand Up @@ -74,24 +75,24 @@ class CustomToolCraftingTableResultSlot(
override fun checkTakeAchievements(pStack: ItemStack) {
if (this.removeCount > 0) {
pStack.onCraftedBy(this.player.level(), this.player, this.removeCount)
ForgeEventFactory.firePlayerCraftingEvent(this.player, pStack, this.craftSlots)
EventHooks.firePlayerCraftingEvent(this.player, pStack, this.craftSlots)
}
if (container is RecipeHolder) {
(container as RecipeHolder).awardUsedRecipes(this.player, listOf(pStack))
if (container is RecipeCraftingHolder) {
(container as RecipeCraftingHolder).awardUsedRecipes(this.player, listOf(pStack))
}
this.removeCount = 0
}

override fun onTake(pPlayer: Player, pStack: ItemStack) {
checkTakeAchievements(pStack)
ForgeHooks.setCraftingPlayer(pPlayer)
CommonHooks.setCraftingPlayer(pPlayer)
val nonnulllist =
pPlayer
.level()
.recipeManager
.getRemainingItemsFor(
RecipeTypeInit.TOOL_CRAFTING.get(), this.craftSlots, pPlayer.level())
ForgeHooks.setCraftingPlayer(null)
CommonHooks.setCraftingPlayer(null)
for (i in nonnulllist.indices) {
var itemstack: ItemStack = this.craftSlots.getItem(i)
val itemstack1 = nonnulllist[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.item.ItemStack
import net.minecraft.world.phys.Vec3
import net.minecraftforge.client.event.EntityRenderersEvent
import net.minecraftforge.client.event.InputEvent
import net.minecraftforge.client.event.RegisterKeyMappingsEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
import net.neoforged.neoforge.client.event.EntityRenderersEvent
import net.neoforged.neoforge.client.event.InputEvent
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent

object ClientEvents {
val MjolnirLayer = ModelLayerLocation(ArmourAndToolsMod.getModIdAndName("mjolnir"), "mjolnir")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper
import net.minecraft.world.level.Level
import net.minecraft.world.phys.EntityHitResult
import net.minecraft.world.phys.Vec3
import net.minecraftforge.network.NetworkHooks
import net.neoforged.neoforge.network.NetworkHooks

/** @see ThrownTrident */
abstract class ArmourToolsModTridentEntity : AbstractArrow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import net.minecraft.world.item.Item
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import net.neoforged.neoforge.registries.DeferredRegister
import net.neoforged.neoforge.registries.ForgeRegistries
import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate
import thedarkcolour.kotlinforforge.forge.registerObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import net.minecraft.world.item.CreativeModeTab
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.block.Block
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.RegistryObject
import net.neoforged.neoforge.registries.DeferredRegister
import net.neoforged.neoforge.registries.RegistryObject

object CreativeModeTabInit {
val CREATIVE_MODE_TAB: DeferredRegister<CreativeModeTab> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import io.github.realyusufismail.armourandtoolsmod.items.hammer.util.HammerLevel
import io.github.realyusufismail.armourandtoolsmod.items.shield.ArmourToolsModShieldItem
import io.github.realyusufismail.armourandtoolsmod.items.trident.AqumarineTridentItem
import net.minecraft.world.item.*
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import net.minecraftforge.registries.RegistryObject
import net.neoforged.neoforge.registries.DeferredRegister
import net.neoforged.neoforge.registries.ForgeRegistries
import net.neoforged.neoforge.registries.RegistryObject
import thedarkcolour.kotlinforforge.forge.ObjectHolderDelegate
import thedarkcolour.kotlinforforge.forge.registerObject

Expand Down
Loading

0 comments on commit f020737

Please sign in to comment.