Fix super glue behavior. Fix super glue can stay between two unmovable blocks

This commit is contained in:
Snownee 2020-05-14 23:00:43 +08:00
parent 8d4e6895bc
commit 463bf0b641
2 changed files with 12 additions and 7 deletions

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllEntities;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.modules.contraptions.components.contraptions.BlockMovementTraits;
import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement; import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement;
import com.simibubi.create.modules.schematics.ItemRequirement; import com.simibubi.create.modules.schematics.ItemRequirement;
import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType;
@ -157,11 +158,20 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite()); BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite());
if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0)) if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0))
return true; return true;
if (world.isAirBlock(pos) && world.isAirBlock(pos2)) if (!isValidFace(world, pos2, getFacingDirection()) && !isValidFace(world, pos, getFacingDirection().getOpposite()))
return false; return false;
return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity).isEmpty(); return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity).isEmpty();
} }
public static boolean isValidFace(World world, BlockPos pos, Direction direction) {
if (!BlockMovementTraits.movementNecessary(world, pos))
return false;
if (BlockMovementTraits.notSupportive(world.getBlockState(pos), direction)) {
return false;
}
return true;
}
@Override @Override
public boolean canBeCollidedWith() { public boolean canBeCollidedWith() {
return true; return true;
@ -236,11 +246,6 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
return Math.max(light, light2); return Math.max(light, light2);
} }
@Override
public void applyEntityCollision(Entity entityIn) {
super.applyEntityCollision(entityIn);
}
@Override @Override
public boolean processInitialInteract(PlayerEntity player, Hand hand) { public boolean processInitialInteract(PlayerEntity player, Hand hand) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {

View file

@ -83,7 +83,7 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
return false; return false;
BlockPos pos = entity.hangingPosition; BlockPos pos = entity.hangingPosition;
BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite()); BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite());
return entity.world.isAirBlock(pos) != entity.world.isAirBlock(pos2); return !SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) || !SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite());
} }
private void initQuads() { private void initQuads() {