Skip to content

Commit

Permalink
Fix wrong success being used
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Nov 10, 2024
1 parent c48f23f commit 264e991
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 19 deletions.
10 changes: 3 additions & 7 deletions src/main/java/xyz/nucleoid/extras/lobby/PlayerLobbyState.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,19 @@ private ActionResult collectTater(Block block, ItemStack stack, ServerPlayerEnti
if (!NEItems.canUseTaters(player) || !(block instanceof TinyPotatoBlock tater)) return ActionResult.PASS;

boolean alreadyAdded = this.collectedTaters.contains(tater);
Text message;

if (alreadyAdded) {
message = Text.translatable("text.nucleoid_extras.tater_box.already_added", block.getName()).formatted(Formatting.RED);
} else {
if (!alreadyAdded) {
this.collectedTaters.add(tater);

// Update the tooltip of tater boxes in player's inventory
PolymerUtils.reloadInventory(player);

message = Text.translatable("text.nucleoid_extras.tater_box.added", block.getName());
player.sendMessage(Text.translatable("text.nucleoid_extras.tater_box.added", block.getName()), true);
}

player.sendMessage(message, true);
triggerCollectCriterion(player, tater, this.collectedTaters.size());

return alreadyAdded ? ActionResult.FAIL : ActionResult.SUCCESS;
return alreadyAdded ? ActionResult.PASS : ActionResult.SUCCESS_SERVER;
}

private static void triggerCollectCriterion(ServerPlayerEntity player, TinyPotatoBlock tater, int count) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

if (blockEntity.isPresent()) {
blockEntity.get().openEditScreen((ServerPlayerEntity) player);
return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void onProjectileHit(World world, BlockState state, BlockHitResult hit, P
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
super.onUse(state, world, pos, player, hit);
return this.ring(world, hit, player) ? ActionResult.SUCCESS : ActionResult.PASS;
return this.ring(world, hit, player) ? ActionResult.SUCCESS_SERVER : ActionResult.PASS;
}

public boolean ring(World world, BlockHitResult hitResult, @Nullable PlayerEntity player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
model.jumpTime = 20;
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

private class Model extends ElementHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
world.playSound(null, pos, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundCategory.BLOCKS, 1, pitch);
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

private Block getDrop(ServerWorld world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
this.spawnBlockParticles(serverWorld, pos, particleEffect);
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ActionResult use(World world, PlayerEntity user, Hand hand) {
portal.requestJoin((ServerPlayerEntity) user, false);
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity
LauncherComponent launcher = stack.get(NEDataComponentTypes.LAUNCHER);

if (!user.getWorld().isClient() && LaunchPadBlock.tryLaunch(entity, user, SoundEvents.ENTITY_ENDER_DRAGON_FLAP, SoundCategory.PLAYERS, launcher)) {
return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

return ActionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
}

itemStack.decrement(1);
return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
} else {
return ActionResult.FAIL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ActionResult use(World world, PlayerEntity user, Hand hand) {
serverPlayer.networkHandler.sendPacket(new OpenWrittenBookS2CPacket(hand));
}
user.incrementStat(Stats.USED.getOrCreateStat(this));
return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ActionResult use(World world, PlayerEntity user, Hand hand) {
this.openTaterBox(world, (ServerPlayerEntity) user, stack, hand);
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ActionResult use(World world, PlayerEntity user, Hand hand) {
showGuidebook(player, taterPositionMap.positions(), stack);
}

return ActionResult.SUCCESS;
return ActionResult.SUCCESS_SERVER;
}
}

Expand Down

0 comments on commit 264e991

Please sign in to comment.