Skip to content

Commit

Permalink
fixed npe where lectern hasn't been selected
Browse files Browse the repository at this point in the history
  • Loading branch information
GameduJS committed Jun 11, 2023
1 parent 9992544 commit b3253e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.17
# Mod Properties
mod_version=1.2
mod_version=1.2-1.19.2
maven_group=de.gamedude
archives_base_name=EasyVillagerTrade
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void handlePlacement() {
private void handleBreak() {
World world = minecraftClient.world;
ClientPlayerEntity player = minecraftClient.player;
BlockPos blockPos = getSelectionInterface().getLecternPos();

if (world == null || player == null)
return;
Expand All @@ -108,6 +109,13 @@ private void handleBreak() {
setState(TradingState.INACTIVE);
return;
}

if(blockPos == null) {
player.sendMessage(Text.translatable("evt.logic.pos_not_set"));
setState(TradingState.INACTIVE);
return;
}

if (world.getBlockState(getSelectionInterface().getLecternPos()).getBlock() == Blocks.LECTERN) {
minecraftClient.interactionManager.updateBlockBreakingProgress(getSelectionInterface().getLecternPos(), Direction.UP);
player.swingHand(Hand.MAIN_HAND, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"evt.logic.select.fail_lectern": "§8| §cUnable to find any lecterns close to you.",
"evt.logic.select.fail_villager": "§8| §cNo appropriate villager near the lectern was found.",
"evt.logic.select.success": "§8| §aThe closest villager and lectern were selected.",
"evt.logic.pos_not_set": "§8| §cYou haven't selected the lectern yet!",

"key.custom.openscreen": "Open screen"
}

0 comments on commit b3253e9

Please sign in to comment.