Fix screwdrivered block stacking, tweak sound

This commit is contained in:
Shadowfacts 2021-03-03 22:29:19 -05:00
parent 170e50755a
commit 868b0d42f9
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,12 @@
package net.shadowfacts.phycon.item package net.shadowfacts.phycon.item
import net.minecraft.block.Blocks
import net.minecraft.entity.ItemEntity import net.minecraft.entity.ItemEntity
import net.minecraft.item.Item import net.minecraft.item.Item
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.item.ItemUsageContext import net.minecraft.item.ItemUsageContext
import net.minecraft.sound.SoundCategory
import net.minecraft.sound.SoundEvents
import net.minecraft.util.ActionResult import net.minecraft.util.ActionResult
import net.minecraft.util.Identifier import net.minecraft.util.Identifier
import net.shadowfacts.phycon.PhysicalConnectivity import net.shadowfacts.phycon.PhysicalConnectivity
@ -26,18 +29,20 @@ class ScrewdriverItem: Item(Settings()) {
val stack = ItemStack(block) val stack = ItemStack(block)
val beTag = stack.getOrCreateSubTag("BlockEntityTag") val beTag = stack.getOrCreateSubTag("BlockEntityTag")
be.toTag(beTag)
// remove x, y, z entries for stacking purposes // remove x, y, z entries for stacking purposes
beTag.remove("x") beTag.remove("x")
beTag.remove("y") beTag.remove("y")
beTag.remove("z") beTag.remove("z")
be.toTag(beTag)
val entity = ItemEntity(context.world, context.blockPos.x.toDouble(), context.blockPos.y.toDouble(), context.blockPos.z.toDouble(), stack) val entity = ItemEntity(context.world, context.blockPos.x.toDouble(), context.blockPos.y.toDouble(), context.blockPos.z.toDouble(), stack)
context.world.spawnEntity(entity) context.world.spawnEntity(entity)
context.world.breakBlock(context.blockPos, false) context.world.setBlockState(context.blockPos, Blocks.AIR.defaultState, 3, 512)
} }
context.world.playSound(context.player, context.blockPos, SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 0.8f, 0.65f)
return ActionResult.SUCCESS return ActionResult.SUCCESS
} else { } else {
return ActionResult.PASS return ActionResult.PASS