-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a427a07
commit 9cf1571
Showing
20 changed files
with
271 additions
and
54 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
content/src/main/java/com/fqf/mario_qua_mario/characters/Luigi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.fqf.mario_qua_mario.characters; | ||
|
||
import com.fqf.mario_qua_mario.MarioQuaMarioContent; | ||
import com.fqf.mario_qua_mario.definitions.states.CharacterDefinition; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioAuthoritativeData; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioClientData; | ||
import net.minecraft.util.Identifier; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Set; | ||
|
||
import static com.fqf.mario_qua_mario.util.StatCategory.*; | ||
|
||
public class Luigi extends Mario implements CharacterDefinition { | ||
@Override public @NotNull Identifier getID() { | ||
return MarioQuaMarioContent.makeID("luigi"); | ||
} | ||
|
||
@Override public Set<StatModifier> getStatModifiers() { | ||
return Set.of( | ||
// Luigi walks and runs faster | ||
new StatModifier(Set.of(FORWARD, WALKING, SPEED), 1.45), | ||
new StatModifier(Set.of(FORWARD, RUNNING, SPEED), 1.2), | ||
new StatModifier(Set.of(FORWARD, P_RUNNING, SPEED), 1.2), | ||
new StatModifier(Set.of(FORWARD, RUNNING, ACCELERATION), 1.2), | ||
|
||
// Luigi jumps higher | ||
new StatModifier(Set.of(JUMPING_GRAVITY), 0.94), | ||
new StatModifier(Set.of(JUMP_VELOCITY), 1.05), | ||
|
||
// Luigi is slipperier | ||
new StatModifier(Set.of(FRICTION), 0.4), | ||
new StatModifier(Set.of(DRAG), 0.4) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
mod/src/client/java/com/fqf/mario_qua_mario/mixin/client/ExampleClientMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
mod/src/main/java/com/fqf/mario_qua_mario/mixin/ExampleMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
mod/src/main/java/com/fqf/mario_qua_mario/mixin/ServerPlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.fqf.mario_qua_mario.mixin; | ||
|
||
import com.fqf.mario_qua_mario.MarioQuaMario; | ||
import com.fqf.mario_qua_mario.mariodata.MarioPlayerData; | ||
import com.fqf.mario_qua_mario.mariodata.MarioServerPlayerData; | ||
import com.fqf.mario_qua_mario.mariodata.injections.MarioServerDataHolder; | ||
import com.fqf.mario_qua_mario.registries.ParsedMarioThing; | ||
import com.fqf.mario_qua_mario.registries.RegistryManager; | ||
import com.fqf.mario_qua_mario.registries.actions.AbstractParsedAction; | ||
import com.fqf.mario_qua_mario.registries.power_granting.ParsedCharacter; | ||
import com.fqf.mario_qua_mario.registries.power_granting.ParsedPowerUp; | ||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.nbt.NbtElement; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import java.util.Objects; | ||
|
||
@Mixin(ServerPlayerEntity.class) | ||
public abstract class ServerPlayerEntityMixin extends PlayerEntity implements MarioServerDataHolder { | ||
@Shadow public ServerPlayNetworkHandler networkHandler; | ||
|
||
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) { | ||
super(world, pos, yaw, gameProfile); | ||
} | ||
|
||
@Override | ||
public void readCustomDataFromNbt(NbtCompound nbt) { | ||
super.readCustomDataFromNbt(nbt); | ||
|
||
if(nbt.contains(MarioQuaMario.MOD_DATA_KEY, NbtElement.COMPOUND_TYPE)) { | ||
NbtCompound persistentData = nbt.getCompound(MarioQuaMario.MOD_DATA_KEY); | ||
|
||
MarioQuaMario.LOGGER.info("Reading player NBT:\nEnabled: {}\nPower-up: {}\nCharacter: {}", | ||
persistentData.getBoolean("Enabled"), | ||
persistentData.getString("PowerUp"), | ||
persistentData.getString("Character")); | ||
|
||
MarioServerPlayerData data = mqm$getMarioData(); | ||
if(networkHandler == null) { | ||
data.setEnabledInternal(persistentData.getBoolean("Enabled")); | ||
data.setPowerUpTransitionless(getPowerUp(nbt)); | ||
data.setCharacter(getCharacter(nbt)); | ||
} | ||
else { | ||
data.setEnabled(persistentData.getBoolean("Enabled")); | ||
data.assignPowerUp(getPowerUp(nbt).ID); | ||
data.assignCharacter(getCharacter(nbt).ID); | ||
} | ||
} | ||
} | ||
|
||
@Unique | ||
private static ParsedCharacter getCharacter(NbtCompound nbt) { | ||
return getDataFromNbt(nbt.getString("Characters"), MarioQuaMario.makeID("mario"), RegistryManager.CHARACTERS); | ||
} | ||
@Unique | ||
private static ParsedPowerUp getPowerUp(NbtCompound nbt) { | ||
return getDataFromNbt(nbt.getString("PowerUp"), getCharacter(nbt).INITIAL_POWER_UP.ID, RegistryManager.POWER_UPS); | ||
} | ||
|
||
@Unique | ||
private static @NotNull <T extends ParsedMarioThing> T getDataFromNbt(String ID, Identifier defaultID, Registry<T> registry) { | ||
@Nullable T attempted = registry.get(Identifier.of(ID)); | ||
return attempted == null ? Objects.requireNonNull(registry.get(defaultID)) : attempted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.