Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate client side vehicle movement #4648

Merged
merged 43 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ff0fe96
WIP client side vehicles
AJ-Ferguson Jun 15, 2023
8ffcde9
Merge remote-tracking branch 'refs/remotes/upstream/master' into clie…
AJ-Ferguson May 8, 2024
72309fb
Address reviews and remove use of Optional
AJ-Ferguson May 16, 2024
4417331
Only tick active vehicle
AJ-Ferguson May 16, 2024
967d0a9
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson May 16, 2024
b250874
Track world ticks
AJ-Ferguson May 17, 2024
8d72970
Fixes for Camel dash and pose transition
AJ-Ferguson May 17, 2024
021e3bf
Remove vehicle parameter
AJ-Ferguson May 17, 2024
91574ef
Merge remote-tracking branch 'upstream/dev' into client-vehicle
AJ-Ferguson May 17, 2024
b79a12e
Start using blocks refactor
AJ-Ferguson May 17, 2024
a21ca99
Update BlockRegistryPopulator
AJ-Ferguson May 17, 2024
66bdb3b
Merge remote-tracking branch 'upstream/dev' into client-vehicle
AJ-Ferguson May 18, 2024
fa7b9fe
Update blocks
AJ-Ferguson May 18, 2024
f490af0
Support step height attribute
AJ-Ferguson May 18, 2024
8147848
Merge remote-tracking branch 'upstream/dev' into client-vehicle
AJ-Ferguson May 20, 2024
30a37fa
Use climbable block tag and TrapDoorBlock
AJ-Ferguson May 20, 2024
16d766d
Lock camel rotation if stationary
AJ-Ferguson May 20, 2024
de5b1a2
Fix boost ticking
AJ-Ferguson May 20, 2024
62822e0
Keep cache of surrounding blocks
AJ-Ferguson May 22, 2024
376b7ea
Fix bug causing BoundingBox position to change in CollisionManager
AJ-Ferguson May 22, 2024
32d587a
Merge remote-tracking branch 'upstream/dev' into client-vehicle
AJ-Ferguson May 23, 2024
818bef0
Clamp user input
AJ-Ferguson May 23, 2024
b33a023
Support weaving status effect
AJ-Ferguson May 23, 2024
d3b4ad4
Merge remote-tracking branch 'upstream/dev' into client-vehicle
AJ-Ferguson May 24, 2024
1f84b62
Support gravity attribute
AJ-Ferguson May 25, 2024
c348928
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jun 11, 2024
e1aebca
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jun 14, 2024
1a6c70f
Piston support
AJ-Ferguson Jun 15, 2024
cdbb276
Tick boost for Pig and Strider if any player is controlling
AJ-Ferguson Jun 15, 2024
77c6d5d
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jun 17, 2024
97c42d3
Submodule
AJ-Ferguson Jun 17, 2024
d49a3ec
Address some reviews
AJ-Ferguson Jun 21, 2024
9a92206
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jun 21, 2024
727604f
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jun 22, 2024
c86b41d
Support world border
AJ-Ferguson Jul 2, 2024
264b925
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jul 2, 2024
3a18ca9
Optimize world border check
AJ-Ferguson Jul 3, 2024
4c95d52
Small optimizations
AJ-Ferguson Jul 9, 2024
dae371f
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jul 9, 2024
6441514
Add comments
AJ-Ferguson Jul 17, 2024
efe8bd6
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Jul 17, 2024
02b7477
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Aug 3, 2024
fd314de
Merge remote-tracking branch 'upstream/master' into client-vehicle
AJ-Ferguson Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/dev' into client-vehicle
  • Loading branch information
AJ-Ferguson committed May 23, 2024
commit 32d587a65a12f4e55cb6285571c918e6fa7974ff
Original file line number Diff line number Diff line change
Expand Up @@ -36,99 +36,8 @@
* Used for block entities if the Java block state contains Bedrock block information.
*/
public final class BlockStateValues {
private static final IntSet HORIZONTAL_FACING_JIGSAWS = new IntOpenHashSet();
private static final IntSet STICKY_PISTONS = new IntOpenHashSet();
private static final Object2IntMap<Direction> PISTON_HEADS = new Object2IntOpenHashMap<>();
private static final Int2ObjectMap<Direction> PISTON_ORIENTATION = new Int2ObjectOpenHashMap<>();
private static final IntSet ALL_PISTON_HEADS = new IntOpenHashSet();
private static final Int2IntMap WATER_LEVEL = new Int2IntOpenHashMap();
private static final Int2IntMap LAVA_LEVEL = new Int2IntOpenHashMap();

public static int JAVA_WATER_ID;

public static final int NUM_FLUID_LEVELS = 9;

/**
* Determines if the block state contains Bedrock block information
*
* @param javaId The Java Identifier of the block
* @param javaBlockState the Java Block State of the block
*/
public static void storeBlockStateValues(String javaId, int javaBlockState) {
if (javaId.contains("piston[")) { // minecraft:moving_piston, minecraft:sticky_piston, minecraft:piston
if (javaId.contains("sticky")) {
STICKY_PISTONS.add(javaBlockState);
}
PISTON_ORIENTATION.put(javaBlockState, getBlockDirection(javaId));
return;
} else if (javaId.startsWith("minecraft:piston_head")) {
ALL_PISTON_HEADS.add(javaBlockState);
if (javaId.contains("short=false")) {
PISTON_HEADS.put(getBlockDirection(javaId), javaBlockState);
}
return;
}

if (javaId.startsWith("minecraft:water") && !javaId.contains("cauldron")) {
String strLevel = javaId.substring(javaId.lastIndexOf("level=") + 6, javaId.length() - 1);
int level = Integer.parseInt(strLevel);
WATER_LEVEL.put(javaBlockState, level);
return;
}

if (javaId.startsWith("minecraft:lava") && !javaId.contains("cauldron")) {
String strLevel = javaId.substring(javaId.lastIndexOf("level=") + 6, javaId.length() - 1);
int level = Integer.parseInt(strLevel);
LAVA_LEVEL.put(javaBlockState, level);
return;
}

if (javaId.startsWith("minecraft:jigsaw[orientation=")) {
String blockStateData = javaId.substring(javaId.indexOf("orientation=") + "orientation=".length(), javaId.lastIndexOf('_'));
Direction direction = Direction.valueOf(blockStateData.toUpperCase(Locale.ROOT));
if (direction.isHorizontal()) {
HORIZONTAL_FACING_JIGSAWS.add(javaBlockState);
}
}
}

/**
* @return a set of all forward-facing jigsaws, to use as a fallback if NBT is missing.
*/
public static IntSet getHorizontalFacingJigsaws() {
return HORIZONTAL_FACING_JIGSAWS;
}

public static boolean isStickyPiston(int blockState) {
return STICKY_PISTONS.contains(blockState);
}

public static boolean isPistonHead(int state) {
return ALL_PISTON_HEADS.contains(state);
}

/**
* Get the Java Block State for a piston head for a specific direction
* This is used in PistonBlockEntity to get the BlockCollision for the piston head.
*
* @param direction Direction the piston head points in
* @return Block state for the piston head
*/
public static int getPistonHead(Direction direction) {
return PISTON_HEADS.getOrDefault(direction, Block.JAVA_AIR_ID);
}

/**
* This is used in GeyserPistonEvents.java and accepts minecraft:piston,
* minecraft:sticky_piston, and minecraft:moving_piston.
*
* @param state The block state of the piston base
* @return The direction in which the piston faces
*/
public static Direction getPistonOrientation(int state) {
return PISTON_ORIENTATION.get(state);
}

/**
* Checks if a block sticks to other blocks
* (Slime and honey blocks)
Expand Down Expand Up @@ -197,11 +106,12 @@ public static boolean canPistonMoveBlock(BlockState state, boolean isPushing) {
* @return The type of fluid
*/
public static Fluid getFluid(int state) {
if (WATER_LEVEL.containsKey(state) || BlockRegistries.WATERLOGGED.get().get(state)) {
BlockState blockState = BlockState.of(state);
onebeastchris marked this conversation as resolved.
Show resolved Hide resolved
if (blockState.is(Blocks.WATER) || BlockRegistries.WATERLOGGED.get().get(state)) {
return Fluid.WATER;
}

if (LAVA_LEVEL.containsKey(state)) {
if (blockState.is(Blocks.LAVA)) {
return Fluid.LAVA;
}

Expand Down Expand Up @@ -253,7 +163,11 @@ public static double getWaterHeight(int state) {
* @return The lava level or -1 if the block isn't lava
*/
public static int getLavaLevel(int state) {
return LAVA_LEVEL.getOrDefault(state, -1);
BlockState blockState = BlockState.of(state);
if (!blockState.is(Blocks.LAVA)) {
return -1;
}
return blockState.getValue(Properties.LEVEL);
}

/**
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.