mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
Fix duplicated swing animations on high-ping servers
Use `InteractionResult.sidedSuccess` / `.CONSUME` where applicable instead of `.SUCCESS`. This prevents the server from sending an additional swing animation packet to the client. Normally this isn't a problem, since the client will de-duplicate swing packets if they are within the animation duration of the currently playing swing; however, when connected to a server with a high ping the packet is sent after the animation is already finished on the client, resulting in a duplicate animation.
This commit is contained in:
parent
9d394f44d3
commit
172d1824fc
@ -98,7 +98,7 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
|
||||
setLabel(currentItem.getHoverName().getString());
|
||||
currentItem.shrink(1);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
} else if (!player.isCrouching()) {
|
||||
// Regular right click to activate computer
|
||||
if (!getLevel().isClientSide && isUsable(player)) {
|
||||
@ -110,7 +110,7 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
|
||||
: ItemStack.EMPTY;
|
||||
new ComputerContainerData(computer, stack).open(player, this);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class PrintoutItem extends Item {
|
||||
new HeldItemContainerData(hand)
|
||||
.open(player, new HeldItemMenu.Factory(ModRegistry.Menus.PRINTOUT.get(), player.getItemInHand(hand), hand));
|
||||
}
|
||||
return new InteractionResultHolder<>(InteractionResult.SUCCESS, player.getItemInHand(hand));
|
||||
return new InteractionResultHolder<>(InteractionResult.sidedSuccess(world.isClientSide), player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
private ItemStack createFromTitleAndText(@Nullable String title, @Nullable String[] text, @Nullable String[] colours) {
|
||||
|
@ -193,7 +193,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public abstract class CableBlockItem extends BlockItem {
|
||||
.setValue(CONNECTIONS.get(side), existingState.getValue(CABLE));
|
||||
if (placeAt(world, pos, newState)) {
|
||||
stack.shrink(1);
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public abstract class CableBlockItem extends BlockItem {
|
||||
if (insideState.getBlock() == ModRegistry.Blocks.CABLE.get() && !insideState.getValue(CableBlock.CABLE)
|
||||
&& placeAtCorrected(world, insidePos, insideState.setValue(CableBlock.CABLE, true))) {
|
||||
stack.shrink(1);
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
|
||||
// Try to add a cable to a modem adjacent to this block
|
||||
@ -113,7 +113,7 @@ public abstract class CableBlockItem extends BlockItem {
|
||||
if (existingState.getBlock() == ModRegistry.Blocks.CABLE.get() && !existingState.getValue(CableBlock.CABLE)
|
||||
&& placeAtCorrected(world, pos, existingState.setValue(CableBlock.CABLE, true))) {
|
||||
stack.shrink(1);
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
|
||||
return super.place(context);
|
||||
|
@ -139,7 +139,7 @@ public class WiredModemFullBlockEntity extends BlockEntity {
|
||||
sendPeripheralChanges(player, "chat.computercraft.wired_modem.peripheral_connected", periphNames);
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
private static void sendPeripheralChanges(Player player, String kind, Collection<String> peripherals) {
|
||||
|
@ -110,7 +110,7 @@ public class MonitorBlock extends HorizontalDirectionalBlock implements EntityBl
|
||||
);
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(level.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +141,7 @@ public class PocketComputerItem extends Item implements IComputerItem, IMedia, I
|
||||
new ComputerContainerData(computer, stack).open(player, new PocketComputerMenuProvider(computer, stack, this, hand, isTypingOnly));
|
||||
}
|
||||
}
|
||||
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
||||
return new InteractionResultHolder<>(InteractionResult.sidedSuccess(world.isClientSide), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +104,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
}
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
} else if (currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1) {
|
||||
// Water to remove turtle colour
|
||||
if (!getLevel().isClientSide) {
|
||||
@ -116,7 +116,7 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
||||
}
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user