Skip to content

Commit

Permalink
Fix rotation not being set in Player Simulator
Browse files Browse the repository at this point in the history
This caused issues with items that consider player rotation, such as
buckets.

Closes CyclopsMC/IntegratedDynamics#1357
  • Loading branch information
rubensworks committed Jul 21, 2024
1 parent befc81e commit b472f14
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.cyclops.integratedtunnels.core;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.FakePlayer;

import java.util.Map;
Expand All @@ -29,13 +29,12 @@ public static FakePlayer getFakePlayer(ServerLevel world) {

public static void setPlayerState(Player player, InteractionHand hand, BlockPos pos,
double offsetX, double offsetY, double offsetZ, Direction side, boolean sneaking) {
offsetY = side == Direction.DOWN ? -offsetY : offsetY;
player.setPos(pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ);
player.xo = player.getX();
player.yo = player.getY();
player.zo = player.getZ();
player.yRotO = side.getOpposite().toYRot();
player.xRotO = side == Direction.UP ? 90F : (side == Direction.DOWN ? -90F : 0F);
player.setYRot(side.getOpposite().toYRot());
player.setXRot(side == Direction.UP ? 90F : (side == Direction.DOWN ? -90F : 0F));
player.eyeHeight = 0F;
player.setShiftKeyDown(sneaking);
setHeldItemSilent(player, hand, ItemStack.EMPTY);
Expand Down

0 comments on commit b472f14

Please sign in to comment.