Skip to content

Commit

Permalink
fixing mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Potapenko committed Dec 28, 2022
1 parent 27bc3da commit a58182d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.nylestroke.nylemod.util.InventoryUtil;
import me.nylestroke.nylemod.util.ModTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -40,14 +41,14 @@ public ActionResult useOnBlock(ItemUsageContext context) {
boolean foundBlock = false;

for (int i = 0; i <= positionClicked.getY() + 64; i++) {
Block blockBelow = context.getWorld().getBlockState(positionClicked.down(i)).getBlock();
BlockState blockBelow = context.getWorld().getBlockState(positionClicked.down(i));

if (isValuableBlock(blockBelow)) {
outputValuableCoordinates(positionClicked.down(i), player, blockBelow);
outputValuableCoordinates(positionClicked.down(i), player, blockBelow.getBlock());
foundBlock = true;

if (InventoryUtil.hasPlayerStackInInventory(player, ModItems.DATA_TABLET)) {
addNbtToDataTable(player, positionClicked.add(0, -i, 0), blockBelow);
addNbtToDataTable(player, positionClicked.add(0, -i, 0), blockBelow.getBlock());
}

spawnFoundParticles(context, positionClicked);
Expand Down Expand Up @@ -105,8 +106,7 @@ private void outputValuableCoordinates(BlockPos blockPos, PlayerEntity player, B
"(" + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ() + ")"), false);
}

private boolean isValuableBlock(Block block) {
return Registry.BLOCK.getOrCreateEntry(Registry.BLOCK.getKey(block).get())
.isIn(ModTags.Blocks.DOWSING_ROD_DETECTABLE_BLOCKS);
private boolean isValuableBlock(BlockState state) {
return state.isIn(ModTags.Blocks.DOWSING_ROD_DETECTABLE_BLOCKS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ private boolean hasFullSuitOfArmorOn(PlayerEntity player) {
}

private boolean hasCorrectArmorOn(ArmorMaterial material, PlayerEntity player) {

for (ItemStack armorStack : player.getInventory().armor) {
if (!(armorStack.getItem() instanceof ArmorItem)) {
return false;
}
}

ArmorItem boots = ((ArmorItem)player.getInventory().getArmorStack(0).getItem());
ArmorItem leggings = ((ArmorItem)player.getInventory().getArmorStack(1).getItem());
ArmorItem chestplate = ((ArmorItem)player.getInventory().getArmorStack(2).getItem());
Expand Down

0 comments on commit a58182d

Please sign in to comment.