Skip to content

Commit

Permalink
enabling some underwater mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Nov 18, 2024
1 parent 34bcd33 commit e8f699a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ protected float getEngineReactionSpeed() {
return 20.0f;
}

public boolean worksUnderWater() {
return false;
}

@Override
protected void defineSynchedData() {
super.defineSynchedData();
Expand All @@ -104,7 +108,7 @@ public void tick() {
enginePower.setSteps(getEngineReactionSpeed() / getProperties().get(VehicleStat.ACCELERATION));

// spin up the engine
enginePower.update(getEngineTarget() * (wasTouchingWater ? 0.1f : 1.0f));
enginePower.update(getEngineTarget() * (isInWater() && !worksUnderWater() ? 0.1f : 1.0f));

// simulate spin up
engineSpinUpStrength = Math.max(0.0f, engineSpinUpStrength + enginePower.getDiff() - 0.01f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ public interface VehicleConstructor {
}

private final VehicleConstructor constructor;
private final boolean onWater;

public VehicleItem(Properties settings, VehicleConstructor constructor) {
this(settings, constructor, true);
}

public VehicleItem(Properties settings, VehicleConstructor constructor, boolean onWater) {
super(settings);

this.constructor = constructor;
this.onWater = onWater;
}

@Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
ItemStack itemStack = user.getItemInHand(hand);
BlockHitResult hitResult = getPlayerPOVHitResult(world, user, ClipContext.Fluid.ANY);
BlockHitResult hitResult = getPlayerPOVHitResult(world, user, onWater ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE);
if (((HitResult) hitResult).getType() == HitResult.Type.MISS) {
error(user, "immersive_aircraft.tooltip.no_target");
return InteractionResultHolder.pass(itemStack);
Expand Down

0 comments on commit e8f699a

Please sign in to comment.