Skip to content

Commit

Permalink
Starting on block-bumping functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
floral-qua-floral committed Nov 11, 2024
1 parent 81b9a6c commit 7442574
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 172 deletions.
32 changes: 32 additions & 0 deletions src/main/java/com/floralquafloral/BlockBumping.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.floralquafloral;

import com.floralquafloral.mariodata.MarioData;
import com.floralquafloral.mariodata.moveable.MarioMainClientData;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;

import java.util.HashMap;
import java.util.Map;

public abstract class BlockBumping {
public static final Map<BlockPos, BumpedBlockData> BUMPED_BLOCKS = new HashMap<>();

public static void registerPackets() {

}
public static void registerPacketsClient() {

}

public static void attempt(MarioMainClientData data, Vec3d movement) {

}

public static void bumpBlock(MarioData data, BlockPos position, boolean isCeiling, int strength) {
MarioQuaMario.LOGGER.info("{} bumped block {}", data.getMario(), position);
}

public static class BumpedBlockData {

}
}
7 changes: 3 additions & 4 deletions src/main/java/com/floralquafloral/MarioPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static void registerCommon() {
SyncUseCharacterStatsS2CPayload.register();
MarioDataPackets.registerCommon();
StompHandler.registerPackets();
// VoiceLine.registerPackets();
JumpSoundPlayer.registerPackets();
BlockBumping.registerPackets();


ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
MarioQuaMario.LOGGER.info("");
Expand All @@ -35,8 +35,7 @@ public static void registerClient() {
SyncUseCharacterStatsS2CPayload.registerReceiver();
MarioDataPackets.registerClient();
StompHandler.registerPacketsClient();
// VoiceLine.registerPacketsClient();
JumpSoundPlayer.registerPacketsClient();
BlockBumping.registerPacketsClient();
}

public static PlayerEntity getPlayerFromInt(ClientPlayNetworking.Context context, int playerID) {
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/com/floralquafloral/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.floralquafloral.mixin;

import com.floralquafloral.BlockBumping;
import com.floralquafloral.MarioQuaMario;
import com.floralquafloral.mariodata.MarioData;
import com.floralquafloral.mariodata.MarioDataManager;
import com.floralquafloral.mariodata.MarioPlayerData;
import com.floralquafloral.mariodata.moveable.MarioMainClientData;
import com.floralquafloral.mariodata.moveable.MarioMoveableData;
import com.floralquafloral.mariodata.moveable.MarioServerData;
import com.floralquafloral.registries.RegistryManager;
import com.floralquafloral.registries.states.action.ParsedAction;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityPose;
Expand All @@ -16,6 +21,7 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -68,8 +74,8 @@ private void preventStepSounds(BlockPos pos, BlockState state, CallbackInfo ci)

@Inject(method = "move", at = @At("HEAD"), cancellable = true)
private void executeStompsOnServer(MovementType movementType, Vec3d movement, CallbackInfo ci) {
if((Entity) (Object) this instanceof ServerPlayerEntity player && shouldStompHook) {
MarioData data = MarioDataManager.getMarioData(player);
if((Entity) (Object) this instanceof ServerPlayerEntity mario && shouldStompHook) {
MarioData data = MarioDataManager.getMarioData(mario);
if(data.useMarioPhysics()) {
ParsedAction action = data.getAction();
if(action.STOMP != null) {
Expand All @@ -81,6 +87,13 @@ private void executeStompsOnServer(MovementType movementType, Vec3d movement, Ca
}
}

@WrapOperation(method = "checkBlockCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;onEntityCollision(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/Entity;)V"))
private void executeBumpsOnClient(BlockState instance, World world, BlockPos blockPos, Entity entity, Operation<Void> original) {
if(entity instanceof ServerPlayerEntity mario) {
// world.breakBlock(blockPos, true, mario);
}
}

@Inject(method = "startRiding(Lnet/minecraft/entity/Entity;Z)Z", at = @At("HEAD"))
private void setMountedAction(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
if((Entity) (Object) this instanceof PlayerEntity mario) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public interface MarioMajorStateDefinition extends MarioStateDefinition {
void populateStatModifiers(Map<Set<StatCategory>, Double> modifiers);

int getBumpStrengthModifier();
float getWidthFactor();
float getHeightFactor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import java.util.Set;

public abstract class ParsedMajorMarioState extends ParsedMarioState {
public final int BUMP_STRENGTH_MODIFIER;
public final float WIDTH_FACTOR;
public final float HEIGHT_FACTOR;
public final Map<Set<StatCategory>, Double> STAT_MODIFIERS;

protected ParsedMajorMarioState(MarioMajorStateDefinition definition) {
super(definition);

this.BUMP_STRENGTH_MODIFIER = definition.getBumpStrengthModifier();
this.WIDTH_FACTOR = definition.getWidthFactor();
this.HEIGHT_FACTOR = definition.getHeightFactor();
this.STAT_MODIFIERS = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ public boolean doSpeedScaling() {
return this.DO_FADING;
}
}
enum BumpType {
NONE(0, 0),
HIT_CEILINGS(2, 0),
GROUND_POUND(0, 2),
SPIN_JUMP(2, 1);

public final int HIT_CEILING_STRENGTH;
public final int HIT_FLOOR_STRENGTH;
BumpType(int hitCeilingStrength, int hitFloorStrength) {
this.HIT_CEILING_STRENGTH = hitCeilingStrength;
this.HIT_FLOOR_STRENGTH = hitFloorStrength;
}
}

class ActionTransitionDefinition {
@FunctionalInterface public interface TransitionEvaluator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import com.floralquafloral.mariodata.moveable.MarioTravelData;
import com.floralquafloral.stats.CharaStat;
import com.floralquafloral.stats.StatCategory;
import com.floralquafloral.util.AsymmetricalEasing;
import com.floralquafloral.util.Easings;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import static com.floralquafloral.util.AsymmetricalEasing.*;
import static com.floralquafloral.util.MixedEasing.*;

public class Backflip extends Jump {
@Override public @NotNull Identifier getID() {
Expand All @@ -25,7 +23,7 @@ public class Backflip extends Jump {
return new CameraAnimationSet(
new CameraAnimation(
false, 1.0F,
(progress, offsets) -> offsets[1] = asymmetricEase(progress, easeInOutSine, easeInOutCubic) * -360
(progress, offsets) -> offsets[1] = mixedEase(progress, SINE, CUBIC) * -360
),
null,
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public void populateStatModifiers(Map<Set<StatCategory>, Double> modifiers) {
modifiers.put(Set.of(DRAG), 0.4);
}

@Override
public float getWidthFactor() {
@Override public int getBumpStrengthModifier() {
return 0;
}
@Override public float getWidthFactor() {
return 1.0F;
}

@Override
public float getHeightFactor() {
@Override public float getHeightFactor() {
return 1.0F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public void populateStatModifiers(Map<Set<StatCategory>, Double> modifiers) {

}

@Override
public float getWidthFactor() {
@Override public int getBumpStrengthModifier() {
return 0;
}
@Override public float getWidthFactor() {
return 1.0F;
}

@Override
public float getHeightFactor() {
@Override public float getHeightFactor() {
return 1.0F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public void populateStatModifiers(Map<Set<StatCategory>, Double> modifiers) {

}

@Override
public float getWidthFactor() {
@Override public int getBumpStrengthModifier() {
return 0;
}
@Override public float getWidthFactor() {
return 1.0F;
}

@Override
public float getHeightFactor() {
@Override public float getHeightFactor() {
return 1.0F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public void serverTick(MarioServerData data) {

}

@Override public int getBumpStrengthModifier() {
return -1;
}
@Override public float getWidthFactor() {
return 1.0F;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public void serverTick(MarioServerData data) {

}

@Override public int getBumpStrengthModifier() {
return 0;
}
@Override public float getWidthFactor() {
return 1.0F;
}
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/com/floralquafloral/util/AsymmetricalEasing.java

This file was deleted.

47 changes: 0 additions & 47 deletions src/main/java/com/floralquafloral/util/ClientSoundPlayer.java

This file was deleted.

Loading

0 comments on commit 7442574

Please sign in to comment.