diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index ffee079ab..4c76c7c96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -1,18 +1,15 @@ package ru.dbotthepony.mc.otm.item import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap -import net.minecraft.ChatFormatting -import net.minecraft.network.chat.Component +import net.minecraft.core.component.DataComponents import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult -import net.minecraft.world.entity.vehicle.AbstractMinecart import net.minecraft.world.entity.vehicle.MinecartChest import net.minecraft.world.item.* import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.UseOnContext -import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.LevelEvent import net.minecraft.world.level.block.entity.BarrelBlockEntity @@ -20,14 +17,11 @@ import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.gameevent.GameEvent import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParams -import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.registry.MEntityTypes @@ -143,15 +137,16 @@ class ChestUpgraderItem : MatteryItem(Properties().stacksTo(1)) { newCart.xRot = cart.xRot newCart.yRot = cart.yRot newCart.deltaMovement = delta - newCart.customName = if (stack.hasCustomHoverName()) stack.hoverName else cart.customName + newCart.customName = stack[DataComponents.CUSTOM_NAME] ?: cart.customName val contents = Int2ObjectArrayMap(cart.containerSize) - for (i in 0 until cart.containerSize) { + + for (i in 0 until cart.containerSize) contents.put(i, cart.getItem(i)) - } + cart.clearContent() - (cart as AbstractMinecart).destroy(cart.damageSources().genericKill()) + cart.destroy(cart.damageSources().genericKill()) level.addFreshEntity(newCart) level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below())))