mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
9ea22042eb
* Remove Bedrock only banner patterns from the creative inventory * Add sound for tadpole bucket * Fix lily pad and frogspawn placing on mobile/single stacks * Workaround? Fix? for bucket usage on mobile * Simplify math and update position+rotation whenever ServerboundUseItemPacket is sent * Rotate the player back after using an item and fix glass bottles * ITEM_USE actionType 1 does not need the rotation fix Increase delay for look back * Add some checks * Prevent buckets and spawn eggs from being unintentionally placed when interacting with special blocks As of 1.19 Bedrock no longer sends a PlayerActionPacket with action=BLOCK_INTERACT. Bedrock now sends action=ITEM_USE_ON_START before and action=ITEM_USE_ON_STOP after using an item on a block. However, this is not useful as it is sent for all block interactions. * Fix inventory transactions being rejected after restoreCorrectBlock The held item's netId is always 0 in the InventoryTransactionPacket. * Touch ups * Fix lookAt for different poses and sneaking + cauldron + bucket interactions Fix boat items being desynced when placing them very close to collision Fix bottles being desynced when tapping above water Resend the held item if we do encounter a desync * Avoid getting blockstate twice and fix comment * Use generated interaction data * Fix glass bottles being double filled and phantom water bottles/water buckets * Don't update the entire inventory on useItem * Use Geyser's inventory copy for check * Use ItemTranslator#getBedrockItemMapping to avoid NBT translation * mappings Co-authored-by: Camotoy <20743703+Camotoy@users.noreply.github.com>
80 lines
3.4 KiB
Java
80 lines
3.4 KiB
Java
/*
|
|
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*
|
|
* @author GeyserMC
|
|
* @link https://github.com/GeyserMC/Geyser
|
|
*/
|
|
|
|
package org.geysermc.geyser.translator.level.block.entity;
|
|
|
|
import com.nukkitx.math.vector.Vector3i;
|
|
import com.nukkitx.nbt.NbtList;
|
|
import com.nukkitx.nbt.NbtMap;
|
|
import com.nukkitx.nbt.NbtType;
|
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
|
import org.geysermc.geyser.session.GeyserSession;
|
|
|
|
/**
|
|
* Implemented only if a block is a block entity in Bedrock and not Java Edition.
|
|
*/
|
|
public interface BedrockOnlyBlockEntity extends RequiresBlockState {
|
|
/**
|
|
* Determines if block is part of class
|
|
* @param blockState BlockState to be compared
|
|
* @return true if part of the class
|
|
*/
|
|
boolean isBlock(int blockState);
|
|
|
|
/**
|
|
* Update the block on Bedrock Edition.
|
|
* @param session GeyserConnection.
|
|
* @param blockState The Java block state.
|
|
* @param position The Bedrock block position.
|
|
*/
|
|
void updateBlock(GeyserSession session, int blockState, Vector3i position);
|
|
|
|
/**
|
|
* Get the tag of the Bedrock-only block entity
|
|
* @param position Bedrock position of block.
|
|
* @param blockState Java BlockState of block.
|
|
* @return Bedrock tag, or null if not a Bedrock-only Block Entity
|
|
*/
|
|
static NbtMap getTag(GeyserSession session, Vector3i position, int blockState) {
|
|
if (FlowerPotBlockEntityTranslator.isFlowerBlock(blockState)) {
|
|
return FlowerPotBlockEntityTranslator.getTag(session, blockState, position);
|
|
} else if (PistonBlockEntityTranslator.isBlock(blockState)) {
|
|
return PistonBlockEntityTranslator.getTag(blockState, position);
|
|
} else if (BlockStateValues.isNonWaterCauldron(blockState)) {
|
|
// As of 1.18.30: this is required to make rendering not look weird on chunk load (lava and snow cauldrons look dim)
|
|
return NbtMap.builder()
|
|
.putString("id", "Cauldron")
|
|
.putByte("isMovable", (byte) 0)
|
|
.putShort("PotionId", (short) -1)
|
|
.putShort("PotionType", (short) -1)
|
|
.putList("Items", NbtType.END, NbtList.EMPTY)
|
|
.putInt("x", position.getX())
|
|
.putInt("y", position.getY())
|
|
.putInt("z", position.getZ())
|
|
.build();
|
|
}
|
|
return null;
|
|
}
|
|
}
|