Skip to content

Commit

Permalink
Merge pull request #35 from banna12345bob/1.20.1/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr authored Apr 13, 2024
2 parents 75b15f5 + cf7e45e commit 0dc7e5f
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ithundxr.createnumismatics.content.bank.blaze_banker;

import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import dev.ithundxr.createnumismatics.registry.NumismaticsBlocks;
import net.minecraft.core.BlockPos;
Expand All @@ -10,6 +11,7 @@
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.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;

Expand All @@ -22,15 +24,17 @@ public BankingGuideItem(Properties properties) {
public @NotNull InteractionResult useOn(UseOnContext context) {
BlockPos clickedPos = context.getClickedPos();
Level level = context.getLevel();
Block block = level.getBlockState(clickedPos).getBlock();
if (block == AllBlocks.BLAZE_BURNER.get() || block == AllBlocks.LIT_BLAZE_BURNER.get()) {
BlockState state = NumismaticsBlocks.BLAZE_BANKER.getDefaultState();
if (level.setBlockAndUpdate(clickedPos, state)) {
state.getBlock().setPlacedBy(level, clickedPos, state, context.getPlayer(), context.getItemInHand());
BlockEntity blockEntity = level.getBlockEntity(clickedPos);
if (blockEntity != null) {
if (AllBlockEntityTypes.HEATER.is(blockEntity)) {
BlockState state = NumismaticsBlocks.BLAZE_BANKER.getDefaultState();
if (level.setBlockAndUpdate(clickedPos, state)) {
state.getBlock().setPlacedBy(level, clickedPos, state, context.getPlayer(), context.getItemInHand());
}
context.getItemInHand().shrink(1);
level.playSound(null, clickedPos, SoundEvents.ARROW_HIT_PLAYER, SoundSource.BLOCKS, 0.5f, 1.0f);
return InteractionResult.SUCCESS;
}
context.getItemInHand().shrink(1);
level.playSound(null, clickedPos, SoundEvents.ARROW_HIT_PLAYER, SoundSource.BLOCKS, 0.5f, 1.0f);
return InteractionResult.SUCCESS;
}
return super.useOn(context);
}
Expand Down

0 comments on commit 0dc7e5f

Please sign in to comment.