Skip to content

Commit

Permalink
another round of elevator adjustments
Browse files Browse the repository at this point in the history
This makes changes to hitboxes of the elevator while it is moving, to
help with some issues in high latency environments, when the server and
client have different ideas as to what blocks are colliding with the
player.
  • Loading branch information
Thutmose committed Nov 14, 2022
1 parent 88b2995 commit ddbf4a0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
13 changes: 0 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,6 @@ minecraft {
MainMods { sources sourceSets.main }
}
}
data = {
workingDirectory project.file('run')
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
properties 'mixin.env.remapRefMap': 'true'
property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg"
property 'forge.logging.console.level', 'debug'
args '--mod', 'pokecube', '--all', '--output', file('src/generated/resources/'), '--existing', sourceSets.main.resources.srcDirs[0]
mods {
pokecube {
source sourceSets.main
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void checkCollision()

var entityR = this.position().add(pos.x(), pos.y(), pos.z());

if (newVy > 0) entityR = entityR.add(0, newVy, 0);
if (newVy > 0) entityR = entityR.add(0, 0, 0);

var entityO = this.position().subtract(xo, yo, zo);
double x = entity.getX();
Expand Down
52 changes: 46 additions & 6 deletions src/main/java/thut/api/entity/blockentity/block/TempBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static TempBlock make()

private static boolean solidCheck(final BlockState state, final BlockGetter reader, final BlockPos pos)
{
BlockEntity be = reader.getBlockEntity(pos);
if (be instanceof TempTile temp && temp.getEffectiveState() != null)
return temp.getEffectiveState().isRedstoneConductor(reader, pos);
return false;
}

Expand Down Expand Up @@ -125,21 +128,37 @@ protected void createBlockStateDefinition(final StateDefinition.Builder<Block, B

@Override
public void entityInside(final BlockState state, final Level level, final BlockPos pos, final Entity entity)
{}
{
final BlockEntity be = level.getBlockEntity(pos);
if (be instanceof TempTile temp && temp.getEffectiveState() != null)
temp.getEffectiveState().entityInside(level, pos, entity);
}

@Override
public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float distance)
{
final BlockEntity te = level.getBlockEntity(pos);
if (te instanceof TempTile tile) distance = tile.onVerticalCollide(entity, distance);
if (te instanceof TempTile tile)
{
distance = tile.onVerticalCollide(entity, distance);
if (tile.getEffectiveState() != null)
{
tile.getEffectiveState().getBlock().stepOn(level, pos, state, entity);
return;
}
}
super.fallOn(level, state, pos, entity, distance);
}

@Override
public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity)
{
final BlockEntity te = level.getBlockEntity(pos);
if (te instanceof TempTile tile) tile.onVerticalCollide(entity, 0);
if (te instanceof TempTile tile)
{
tile.onVerticalCollide(entity, 0);
if (tile.getEffectiveState() != null) tile.getEffectiveState().getBlock().stepOn(level, pos, state, entity);
}
}

@Override
Expand All @@ -158,10 +177,31 @@ public VoxelShape getShape(final BlockState state, final BlockGetter worldIn, fi
final BlockEntity te = worldIn.getBlockEntity(pos);
if (te instanceof TempTile temp)
{
boolean notForcedBox = true;
// Default to true for collision, for fast moving things that have
// not collided with us yet.
boolean forCollision = true;

// Now check if it should be modified.
if (context instanceof EntityCollisionContext c && c.getEntity() != null)
notForcedBox = temp.blockEntity == null || temp.blockEntity.recentCollides.containsKey(c.getEntity());
return temp.getShape(notForcedBox);
{
boolean collider = false;

forCollision = temp.blockEntity == null
|| (collider = temp.blockEntity.recentCollides.containsKey(c.getEntity()));

// If it has already collided, we need to check if it
// intersects our bounds, if not, we are not colliding, so
// report full box for interaction purposes.
if (collider)
{
VoxelShape base = temp.getShape(false);
if (!base.isEmpty())
{
forCollision = base.bounds().intersects(c.getEntity().getBoundingBox());
}
}
}
return temp.getShape(forCollision);
}
return Shapes.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public InteractionResult use(final BlockState state, final Level world, final Bl
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
NO_INTERACT.add(eff);
}
Expand Down

0 comments on commit ddbf4a0

Please sign in to comment.