Skip to content

Commit

Permalink
Finalize DoubleRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugman76 committed Nov 17, 2024
1 parent 8502476 commit 22d63f9
Show file tree
Hide file tree
Showing 44 changed files with 819 additions and 172 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ loader_version=0.16.9
fabric_version=0.108.0+1.21.3

# check this on https://nucleoid.xyz/use/
plasmid_version=0.6.0-SNAPSHOT+1.21.3
plasmid_version=0.6.0+1.21.3
1 change: 1 addition & 0 deletions src/main/java/com/hugman/uhc/config/UHCConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public List<Modifier> getModifiers() {
}

public <V extends Modifier> List<V> getModifiers(ModifierType<V> type) {
//TODO: cache modules so it's quicker to sort by type
List<V> modifiers = new ArrayList<>();
for (var moduleEntry : modules) {
for (Modifier modifier : moduleEntry.value().modifiers()) {
Expand Down
36 changes: 20 additions & 16 deletions src/main/java/com/hugman/uhc/game/phase/UHCActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket;
import net.minecraft.network.packet.s2c.play.WorldBorderInitializeS2CPacket;
import net.minecraft.network.packet.s2c.play.WorldBorderInterpolateSizeS2CPacket;
import net.minecraft.scoreboard.AbstractTeam;
Expand Down Expand Up @@ -46,6 +47,7 @@
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.block.BlockBreakEvent;
import xyz.nucleoid.stimuli.event.block.BlockDropItemsEvent;
import xyz.nucleoid.stimuli.event.entity.EntityDamageEvent;
import xyz.nucleoid.stimuli.event.entity.EntityDropItemsEvent;
import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent;
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;
Expand Down Expand Up @@ -304,20 +306,6 @@ private void playerLeave(ServerPlayerEntity player) {
}
}

private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
if (participants.containsKey(player)) {
if (!getParticipant(player).isEliminated()) {
PlayerSet players = this.gameSpace.getPlayers();
players.sendMessage(Text.literal("\n☠ ").append(source.getDeathMessage(player).copy()).append("!\n").formatted(Formatting.DARK_RED));
players.playSound(SoundEvents.ENTITY_WITHER_SPAWN);
this.eliminateParticipant(player);
return EventResult.DENY;
}
}
this.spawnLogic.spawnPlayerAtCenter(player);
return EventResult.DENY;
}

private void eliminateParticipant(ServerPlayerEntity player) {
ItemScatterer.spawn(player.getWorld(), player.getBlockPos(), player.getInventory());
player.changeGameMode(GameMode.SPECTATOR);
Expand Down Expand Up @@ -345,8 +333,9 @@ public void clearPlayer(ServerPlayerEntity player) {

public void refreshPlayerAttributes(ServerPlayerEntity player) {
for (PlayerAttributeModifier piece : this.config.getModifiers(ModifierType.PLAYER_ATTRIBUTE)) {
piece.setAttribute(player);
piece.refreshAttribute(player);
}
player.networkHandler.sendPacket(new EntityAttributesS2CPacket(player.getId(), player.getAttributes().getTracked()));
}

public void applyPlayerEffects(ServerPlayerEntity player) {
Expand Down Expand Up @@ -393,6 +382,7 @@ private void checkForWinner() {
private void setInvulnerable(boolean b) {
this.invulnerable = b;
this.activity.setRule(GameRuleType.HUNGER, b ? EventResult.DENY : EventResult.ALLOW);
//TODO check modules
this.activity.setRule(GameRuleType.FALL_DAMAGE, b ? EventResult.DENY : EventResult.ALLOW);
}

Expand Down Expand Up @@ -461,7 +451,7 @@ private void sendWarning(String s, Object... args) {
public void sendModuleListToChat() {
var moduleEntries = this.config.modules();
if (moduleEntries.size() > 0) {
MutableText text = Text.literal("\n").append(Text.translatable("text.uhc.modules_enabled").formatted(Formatting.GOLD));
MutableText text = Text.literal("\n").append(Text.translatable("text.uhc.enabled_modules").formatted(Formatting.GOLD));
moduleEntries.forEach(moduleEntry -> {
var module = moduleEntry.value();
Style style = Style.EMPTY;
Expand All @@ -486,6 +476,20 @@ private EventResult onPlayerDamage(ServerPlayerEntity entity, DamageSource damag
}
}

private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
if (participants.containsKey(player)) {
if (!getParticipant(player).isEliminated()) {
PlayerSet players = this.gameSpace.getPlayers();
players.sendMessage(Text.literal("\n☠ ").append(source.getDeathMessage(player).copy()).append("!\n").formatted(Formatting.DARK_RED));
players.playSound(SoundEvents.ENTITY_WITHER_SPAWN);
this.eliminateParticipant(player);
return EventResult.DENY;
}
}
this.spawnLogic.spawnPlayerAtCenter(player);
return EventResult.DENY;
}

private EventResult onBlockBroken(ServerPlayerEntity playerEntity, ServerWorld world, BlockPos pos) {
for (TraversalBreakModifier piece : this.config.getModifiers(ModifierType.TRAVERSAL_BREAK)) {
piece.breakBlock(this.world, playerEntity, pos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
package com.hugman.uhc.modifier;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.network.ServerPlayerEntity;

public record PlayerAttributeModifier(RegistryEntry<EntityAttribute> attribute, double value) implements Modifier {
public record PlayerAttributeModifier(
RegistryEntry<EntityAttribute> attribute,
EntityAttributeModifier modifier
) implements Modifier {
public static final MapCodec<PlayerAttributeModifier> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
EntityAttribute.CODEC.fieldOf("attribute").forGetter(PlayerAttributeModifier::attribute),
Codec.doubleRange(0.0F, Double.MAX_VALUE).fieldOf("value").forGetter(PlayerAttributeModifier::value)
EntityAttributeModifier.MAP_CODEC.forGetter(PlayerAttributeModifier::modifier)
).apply(instance, PlayerAttributeModifier::new));

@Override
public ModifierType<?> getType() {
return ModifierType.PLAYER_ATTRIBUTE;
}

public void setAttribute(ServerPlayerEntity player) {
public void refreshAttribute(ServerPlayerEntity player) {
EntityAttributeInstance instance = player.getAttributes().getCustomInstance(this.attribute);
if (instance != null) {
instance.setBaseValue(value);
player.networkHandler.sendPacket(new EntityAttributesS2CPacket(player.getId(), player.getAttributes().getTracked()));
instance.removeModifier(modifier);
instance.addPersistentModifier(modifier);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": {
"translate": "game.doublerunner"
},
"icon": "minecraft:golden_apple",
"icon": "minecraft:enchanted_golden_apple",
"entries": [
{
"type": "plasmid:game",
Expand Down
19 changes: 18 additions & 1 deletion src/main/resources/data/doublerunner/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{
"game.doublerunner": "DoubleRunner"
"game.doublerunner": "DoubleRunner",

"module.doublerunner.blasted_ores_plus": "Blasted Ores+",
"module.doublerunner.dasher_plus": "Dasher+",
"module.doublerunner.dasher_plus.description": "Permanent haste and speed, and no fall damage",
"module.doublerunner.faster_resources_plus": "Faster Resources+",
"module.doublerunner.guaranteed_golden_apples": "Guaranteed Golden Apples",
"module.doublerunner.guaranteed_golden_apples.description": "All leaves only drop golden apples",
"module.doublerunner.ore_boost_plus": "Ore Boost+",
"module.doublerunner.potion_drops": "Potion Drops",
"module.doublerunner.potion_drops.description": "Some entities drop potions",
"module.doublerunner.timberman.description": "Trees get cut instantly and drop oak planks",

"module_description.doublerunner.zombies_drop_strength_potions": "Zombies drops potions of Strength",
"module_description.doublerunner.spiders_drop_poison_potions": "Spiders drops potions of Poison",
"module_description.doublerunner.sugar_cane_drops_swiftness_potions": "Sugar cane drops potions of Swiftness",
"module_description.doublerunner.rabbits_drop_leaping_potions": "Rabbits drops potions of Leaping",
"module_description.doublerunner.bats_drop_night_vision_potions": "Bats drops potions of Night Vision"
}
46 changes: 0 additions & 46 deletions src/main/resources/data/doublerunner/plasmid/game/test.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"replace": false,
"values": [
"uhcrun:timberman",
"doublerunner:guaranteed_gapples",
"doublerunner:guaranteed_golden_apples",
"doublerunner:dasher_plus",
"doublerunner:ore_boost_plus",
"doublerunner:blasted_ores_plus",
"uhcrun:faster_resources",
"doublerunner:potion_drops",
"doublerunner:faster_resources_plus",
"uhcrun:animal_cooked_food",
"uhcrun:mob_cooked_food",
"uhcrun:creeper_tnt",
"uhcrun:chicken_arrows"
"uhcrun:mob_cooked_food"
]
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": {
"translate": "module.uhcrun.blasted_ores_plus"
"translate": "module.doublerunner.blasted_ores_plus"
},
"description": {
"translate": "module.uhcrun.blasted_ores_plus.description"
"translate": "module.uhcrun.blasted_ores.description"
},
"icon": "minecraft:iron_ingot",
"icon": "minecraft:gold_ingot",
"modifiers": [
{
"type": "uhc:block_loot",
Expand Down
18 changes: 15 additions & 3 deletions src/main/resources/data/doublerunner/uhc/module/dasher_plus.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@
{
"type": "uhc:player_attribute",
"attribute": "minecraft:movement_speed",
"value": 0.22
"id": "doublerunner:dasher_movement",
"amount": 0.5,
"operation": "add_multiplied_total"
},
{
"type": "uhc:permanent_effect",
"effect": "minecraft:haste"
"type": "uhc:player_attribute",
"attribute": "minecraft:block_break_speed",
"id": "doublerunner:dasher_break_speed",
"amount": 0.4,
"operation": "add_multiplied_total"
},
{
"type": "uhc:player_attribute",
"attribute": "minecraft:safe_fall_distance",
"id": "doublerunner:dasher_safe_fall_distance",
"amount": 1024,
"operation": "add_value"
}
]
}
Loading

0 comments on commit 22d63f9

Please sign in to comment.