Skip to content

Commit

Permalink
Fixed the Fish Mounts could be placed on floors and ceilings
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Dec 18, 2022
1 parent 3dd5e86 commit e12b758
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
Expand Down Expand Up @@ -72,7 +73,7 @@ protected void defineSynchedData() {
}

@Override
protected void setDirection(Direction direction) {
public void setDirection(@Nonnull Direction direction) {
Validate.notNull(direction);
this.direction = direction;
if (direction.getAxis().isHorizontal()) {
Expand Down Expand Up @@ -324,6 +325,12 @@ public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}

@Override
public void recreateFromPacket(@Nonnull ClientboundAddEntityPacket packet) {
super.recreateFromPacket(packet);
this.setDirection(Direction.from3DDataValue(packet.getData()));
}

@Override
public ItemStack getPickedResult(HitResult target) {
return !this.getDisplayedItem().isEmpty() ? this.getDisplayedItem() : new ItemStack(this.getItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public InteractionResult useOn(UseOnContext context) {

@Override
protected boolean mayPlace(@Nonnull Player player, @Nonnull Direction direction, @Nonnull ItemStack stack, @Nonnull BlockPos pos) {
return !player.level.isOutsideBuildHeight(pos) && player.mayUseItemAt(pos, direction, stack);
return !player.level.isOutsideBuildHeight(pos) && player.mayUseItemAt(pos, direction, stack) && (direction != Direction.UP && direction != Direction.DOWN);
}
}

0 comments on commit e12b758

Please sign in to comment.