Skip to content

Commit

Permalink
Fix invisible question block
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Jan 5, 2025
1 parent 5a9eb43 commit 60b3796
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,24 @@
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ParticleRegistry;
import com.wenxin2.marioverse.init.TagRegistry;
import com.wenxin2.marioverse.items.BasePowerUpItem;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorStandItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BoatItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.DebugStickItem;
import net.minecraft.world.item.EggItem;
import net.minecraft.world.item.ExperienceBottleItem;
import net.minecraft.world.item.FireChargeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.LingeringPotionItem;
import net.minecraft.world.item.MinecartItem;
import net.minecraft.world.item.PotionItem;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.WindChargeItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
Expand Down Expand Up @@ -165,6 +153,10 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
&& !state.getValue(EMPTY)) {
ItemStack storedItem = questionBlockEntity.getItems().getFirst();

// Keep above "if (!storedItem.isEmpty())"
if (state.getValue(InvisibleQuestionBlock.INVISIBLE))
world.setBlock(pos, state.setValue(INVISIBLE, Boolean.FALSE), 3);

if (!storedItem.isEmpty()) {
if (!world.isClientSide)
this.spawnFromQuestionBlock(world, pos, storedItem, null, Boolean.FALSE, Boolean.TRUE);
Expand All @@ -174,13 +166,9 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
questionBlockEntity.setChanged();
}

if (storedItem.isEmpty()) {
if (storedItem.isEmpty())
world.setBlock(pos, state.setValue(QuestionBlock.EMPTY, Boolean.TRUE), 3);
}

if (state.getValue(InvisibleQuestionBlock.INVISIBLE)) {
world.setBlock(pos, state.setValue(INVISIBLE, Boolean.FALSE), 3);
}
return ItemInteractionResult.SUCCESS;
} else return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
questionBlockEntity.setChanged();
}

if (storedItem.isEmpty()) {
if (storedItem.isEmpty())
world.setBlock(pos, state.setValue(QuestionBlock.EMPTY, Boolean.TRUE), 3);
}

return ItemInteractionResult.SUCCESS;
} else return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
Expand Down

0 comments on commit 60b3796

Please sign in to comment.