Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.bullshit.procedures;
- import net.minecraftforge.common.ForgeHooks;
- import net.minecraft.world.level.LevelAccessor;
- import net.minecraft.world.level.Level;
- import net.minecraft.world.item.crafting.RecipeType;
- import net.minecraft.world.item.ItemStack;
- import net.minecraft.world.inventory.Slot;
- import net.minecraft.world.entity.player.Player;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.SimpleContainer;
- import java.util.function.Supplier;
- import java.util.Map;
- public class FurnaceBlockOnTickUpdateProcedure {
- public static void execute(LevelAccessor world, Entity entity) {
- if (entity == null)
- return;
- if (entity.getPersistentData().getBoolean("Cooking") == false) {
- if (world instanceof Level _level2 && _level2.getRecipeManager()
- .getRecipeFor(RecipeType.SMELTING,
- new SimpleContainer((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY)), _level2)
- .isPresent()) {
- if (ForgeHooks.getBurnTime((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(1)).getItem() : ItemStack.EMPTY), null) > 0) {
- if (new Object() {
- public int getAmount(int sltid) {
- if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
- ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
- if (stack != null)
- return stack.getCount();
- }
- return 0;
- }
- }.getAmount(2) <= 62
- && ((world instanceof Level _lvlSmeltResult
- ? _lvlSmeltResult.getRecipeManager()
- .getRecipeFor(RecipeType.SMELTING,
- new SimpleContainer(
- (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY)),
- _lvlSmeltResult)
- .map(recipe -> recipe.getResultItem(_lvlSmeltResult.registryAccess()).copy()).orElse(ItemStack.EMPTY)
- : ItemStack.EMPTY)
- .getItem() == (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(2)).getItem() : ItemStack.EMPTY).getItem()
- || (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(2)).getItem() : ItemStack.EMPTY).getItem() == ItemStack.EMPTY
- .getItem())) {
- if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
- ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(1)).getItem() : ItemStack.EMPTY).copy();
- _setstack.setCount((int) (new Object() {
- public int getAmount(int sltid) {
- if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
- ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
- if (stack != null)
- return stack.getCount();
- }
- return 0;
- }
- }.getAmount(1) - 1));
- ((Slot) _slots.get(1)).set(_setstack);
- _player.containerMenu.broadcastChanges();
- }
- entity.getPersistentData().putBoolean("Cooking", true);
- entity.getPersistentData().putDouble("Timer", 200);
- entity.getPersistentData().putDouble("Burning",
- (ForgeHooks.getBurnTime((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(1)).getItem() : ItemStack.EMPTY), null)));
- }
- }
- }
- } else {
- if (!((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY).getItem() == ItemStack.EMPTY.getItem())) {
- entity.getPersistentData().putDouble("Timer", (entity.getPersistentData().getDouble("Timer") - 1));
- if (entity.getPersistentData().getDouble("Timer") == 0) {
- entity.getPersistentData().putBoolean("Cooking", false);
- }
- if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
- ItemStack _setstack = (world instanceof Level _lvlSmeltResult
- ? _lvlSmeltResult.getRecipeManager()
- .getRecipeFor(RecipeType.SMELTING,
- new SimpleContainer((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY)),
- _lvlSmeltResult)
- .map(recipe -> recipe.getResultItem(_lvlSmeltResult.registryAccess()).copy()).orElse(ItemStack.EMPTY)
- : ItemStack.EMPTY).copy();
- _setstack.setCount((int) (new Object() {
- public int getAmount(int sltid) {
- if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
- ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
- if (stack != null)
- return stack.getCount();
- }
- return 0;
- }
- }.getAmount(2) + 2));
- ((Slot) _slots.get(2)).set(_setstack);
- _player.containerMenu.broadcastChanges();
- }
- } else {
- entity.getPersistentData().putBoolean("Cooking", false);
- entity.getPersistentData().putDouble("Timer", 0);
- }
- }
- if (entity.getPersistentData().getDouble("Burning") > 0 && entity.getPersistentData().getDouble("Burning") <= 0) {
- entity.getPersistentData().putDouble("Burning", (entity.getPersistentData().getDouble("Burning") - 1));
- }
- }
- }
Add Comment
Please, Sign In to add comment