Skip to content

Commit

Permalink
1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Voxxin committed Jan 7, 2025
1 parent 0893d23 commit 45bc3e5
Show file tree
Hide file tree
Showing 24 changed files with 256 additions and 190 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

version = project.mod_version
group = project.maven_group

loom {
accessWidenerPath = file("src/main/resources/blockhunt.accesswidener")
}

repositories {
maven { url = "https://maven.nucleoid.xyz/" }
maven { url = "https://maven.gegy.dev/" }
Expand Down Expand Up @@ -34,7 +38,7 @@ processResources {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.6
fabric_version=0.91.1+1.20.4
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9
fabric_version=0.91.1+1.21.4

# check this on https://nucleoid.xyz/use/
plasmid_version=0.5.102-SNAPSHOT+1.20.4
plasmid_version=0.6.3-SNAPSHOT+1.21.4
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jan 06 20:48:19 EST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 3 additions & 4 deletions src/main/java/com/github/voxxin/blockhunt/BlockHunt.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import com.github.voxxin.blockhunt.game.BlockHuntConfig;
import com.github.voxxin.blockhunt.game.BlockHuntWaiting;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,7 +17,7 @@ public class BlockHunt implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger(ID);

public static final GameType<BlockHuntConfig> TYPE = GameType.register(
new Identifier(ID, "blockhunt"),
Identifier.of(ID, "blockhunt"),
BlockHuntConfig.CODEC,
BlockHuntWaiting::open
);
Expand All @@ -27,7 +26,7 @@ public void onInitialize() {
}

public static Identifier id(String value) {
return new Identifier(ID, value);
return Identifier.of(ID, value);
}
public static List<Integer> deniedIDs = new ArrayList<>();
}
67 changes: 34 additions & 33 deletions src/main/java/com/github/voxxin/blockhunt/game/BlockHuntActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.GameMode;
import xyz.nucleoid.plasmid.game.GameCloseReason;
import xyz.nucleoid.plasmid.game.GameLifecycle;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.game.player.PlayerSet;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.util.PlayerRef;
import xyz.nucleoid.plasmid.api.game.GameCloseReason;
import xyz.nucleoid.plasmid.api.game.GameLifecycle;
import xyz.nucleoid.plasmid.api.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.api.game.player.JoinIntent;
import xyz.nucleoid.plasmid.api.game.player.JoinOffer;
import xyz.nucleoid.plasmid.api.game.player.JoinOfferResult;
import xyz.nucleoid.plasmid.api.game.player.PlayerSet;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.util.PlayerRef;
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.block.BlockPunchEvent;
import xyz.nucleoid.stimuli.event.block.BlockUseEvent;
import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent;
Expand Down Expand Up @@ -64,10 +68,6 @@ public class BlockHuntActive {
private static Team hidersTeam = null;
private static Team spectatorTeam = null;

private int lastHiddenReset = 20;

private ArrayList<BlockHuntBossBar> bossBars = new ArrayList<>();

private static final ArrayList<Block> deniedBlockInteractions = new ArrayList<>();

private static final ArrayList<Block> allowedMapDisguises = new ArrayList<>();
Expand Down Expand Up @@ -135,22 +135,23 @@ public static void open(GameSpace gameSpace, ServerWorld world, BlockHuntMap map


// Game Rules
game.setRule(GameRuleType.FALL_DAMAGE, ActionResult.FAIL);
game.setRule(GameRuleType.PICKUP_ITEMS, ActionResult.FAIL);
game.setRule(GameRuleType.THROW_ITEMS, ActionResult.FAIL);
game.setRule(GameRuleType.CRAFTING, ActionResult.FAIL);
game.setRule(GameRuleType.FIRE_TICK, ActionResult.FAIL);
game.setRule(GameRuleType.FLUID_FLOW, ActionResult.FAIL);
game.setRule(GameRuleType.HUNGER, ActionResult.FAIL);
game.setRule(GameRuleType.MODIFY_ARMOR, ActionResult.FAIL);
//game.setRule(GameRuleType.PLACE_BLOCKS, ActionResult.FAIL);
game.setRule(GameRuleType.FALL_DAMAGE, EventResult.DENY);
game.setRule(GameRuleType.PICKUP_ITEMS, EventResult.DENY);
game.setRule(GameRuleType.THROW_ITEMS, EventResult.DENY);
game.setRule(GameRuleType.CRAFTING, EventResult.DENY);
game.setRule(GameRuleType.FIRE_TICK, EventResult.DENY);
game.setRule(GameRuleType.FLUID_FLOW, EventResult.DENY);
game.setRule(GameRuleType.HUNGER, EventResult.DENY);
game.setRule(GameRuleType.MODIFY_ARMOR, EventResult.DENY);
//game.setRule(GameRuleType.PLACE_BLOCKS, EventResult.DENY);


// Unique Gamerules

game.listen(GameActivityEvents.ENABLE, active::onOpen);

game.listen(GamePlayerEvents.OFFER, (offer) -> offer.accept(world, Vec3d.ZERO));
game.listen(GamePlayerEvents.OFFER, JoinOffer::accept);
game.listen(GamePlayerEvents.ACCEPT, (offer) -> offer.teleport(world, Vec3d.ZERO));
game.listen(GamePlayerEvents.ADD, active::addPlayer);
game.listen(GamePlayerEvents.REMOVE, active::removePlayer);

Expand All @@ -172,8 +173,8 @@ private void onOpen() {
seekerAnimation.settings.tick();
if (seekerAnimation.settings.startTime == 0) {
BlockHunt.LOGGER.info("No start time set for seeker released animation. Defaulting to 1 minute.");
int mins = 1;
this.stageManager.onOpen(this.world.getTime(), this.config, (mins * 60) * 20);
int mins = 1200;
this.stageManager.onOpen(this.world.getTime(), this.config, mins);
} else this.stageManager.onOpen(this.world.getTime(), this.config, (long) seekerAnimation.settings.startTime);
} else {
BlockHunt.LOGGER.fatal("No seeker released animation found. Please add one to your map.");
Expand Down Expand Up @@ -251,7 +252,7 @@ private ActionResult allowInteraction(ServerPlayerEntity serverPlayerEntity, Han
return ActionResult.PASS;
}

private ActionResult blockAttack(ServerPlayerEntity serverPlayerEntity, Direction direction, BlockPos blockPos) {
private EventResult blockAttack(ServerPlayerEntity serverPlayerEntity, Direction direction, BlockPos blockPos) {
BlockPos blockPosHit = ((BlockHitResult) serverPlayerEntity.raycast(5, 0, false)).getBlockPos();
BlockHuntPlayer player = this.participants.get(PlayerRef.of(serverPlayerEntity));

Expand All @@ -264,7 +265,7 @@ private ActionResult blockAttack(ServerPlayerEntity serverPlayerEntity, Directio
}
});

return ActionResult.FAIL;
return EventResult.DENY;
}

private void addPlayer(ServerPlayerEntity player) {
Expand All @@ -290,8 +291,8 @@ private void removePlayer(ServerPlayerEntity player) {
}
}

private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
if (source.getSource() == null) return ActionResult.FAIL;
private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
if (source.getSource() == null) return EventResult.DENY;

if (source.getSource().isPlayer()) {
if (!player.isTeammate(source.getAttacker())) {
Expand All @@ -301,14 +302,14 @@ private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource sour
thisPlayer.updateTimeBar(true);
thisPlayer.setHidden(false);
}
return ActionResult.SUCCESS;
return EventResult.ALLOW;
}
}

return ActionResult.FAIL;
return EventResult.DENY;
}

private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
if (source.getSource().isPlayer()) {
BlockHuntPlayer thisPlayer = this.participants.get(PlayerRef.of(player));
BlockHuntPlayer thisAttacker = this.participants.get(PlayerRef.of((ServerPlayerEntity) source.getAttacker()));
Expand Down Expand Up @@ -355,7 +356,7 @@ private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource sourc
}
}

return ActionResult.FAIL;
return EventResult.DENY;
}

private void spawnParticipant(ServerPlayerEntity player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.github.voxxin.blockhunt.game.map.BlockHuntMapConfig;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public record BlockHuntConfig(BlockHuntMapConfig mapConfig) {
public static final Codec<BlockHuntConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
public static final MapCodec<BlockHuntConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
BlockHuntMapConfig.CODEC.fieldOf("map").forGetter(BlockHuntConfig::mapConfig)
).apply(instance, BlockHuntConfig::new));
}
}
41 changes: 26 additions & 15 deletions src/main/java/com/github/voxxin/blockhunt/game/BlockHuntPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
import com.github.voxxin.blockhunt.game.util.BlockHuntBossBar;
import com.github.voxxin.blockhunt.game.util.BlockHuntTitle;
import net.minecraft.block.Block;
import net.minecraft.component.ComponentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.UnbreakableComponent;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.util.PlayerRef;
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.api.util.PlayerRef;

public class BlockHuntPlayer {
private final ServerWorld world;
Expand Down Expand Up @@ -68,7 +73,7 @@ public void setDisguise(BlockHuntBlock disguise, Block block) {
}

public void resetDisguise() {
if (this.disguise[0] != null) ((BlockHuntBlock) this.disguise[0]).kill();
if (this.disguise[0] != null) ((BlockHuntBlock) this.disguise[0]).kill(world);
this.disguise = new Object[]{null, null};
}

Expand Down Expand Up @@ -127,10 +132,10 @@ public void loadPlayerInventory() {

this.player.getInventory().clear();
this.player.getInventory().setStack(0, new ItemStack(Items.IRON_SWORD));
this.player.getInventory().armor.set(0, new ItemStack(Items.CHAINMAIL_BOOTS).setCustomName(Text.of("§f§lHeavy Boots")));
this.player.getInventory().armor.set(1, new ItemStack(Items.CHAINMAIL_LEGGINGS).setCustomName(Text.of("§f§lHeavy Pants")));
this.player.getInventory().armor.set(2, new ItemStack(Items.CHAINMAIL_CHESTPLATE).setCustomName(Text.of("§f§lHeavy Chestplate")));
this.player.getInventory().armor.set(3, new ItemStack(Items.CHAINMAIL_HELMET).setCustomName(Text.of("§f§lHeavy Helmet")));
this.player.getInventory().armor.set(0, itemWName(Items.CHAINMAIL_BOOTS, Text.of("§f§lHeavy Boots")));
this.player.getInventory().armor.set(1, itemWName(Items.CHAINMAIL_LEGGINGS, Text.of("§f§lHeavy Pants")));
this.player.getInventory().armor.set(2, itemWName(Items.CHAINMAIL_CHESTPLATE, Text.of("§f§lHeavy Chestplate")));
this.player.getInventory().armor.set(3, itemWName(Items.CHAINMAIL_HELMET, Text.of("§f§lHeavy Helmet")));
}
case "hiders" -> {
this.player.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, StatusEffectInstance.INFINITE, 2, false, false));
Expand All @@ -139,24 +144,30 @@ public void loadPlayerInventory() {

this.player.getInventory().clear();
this.player.getInventory().setStack(0, new ItemStack(Items.STONE_SWORD));
this.player.getInventory().armor.set(0, new ItemStack(Items.LEATHER_BOOTS).setCustomName(Text.of("§f§lSneaky Boots")));
this.player.getInventory().armor.set(1, new ItemStack(Items.LEATHER_LEGGINGS).setCustomName(Text.of("§f§lSneaky Pants")));
this.player.getInventory().armor.set(2, new ItemStack(Items.LEATHER_CHESTPLATE).setCustomName(Text.of("§f§lSneaky Chestplate")));
this.player.getInventory().armor.set(3, new ItemStack(Items.LEATHER_HELMET).setCustomName(Text.of("§f§lSneaky Helmet")));
this.player.getInventory().armor.set(0, itemWName(Items.LEATHER_BOOTS, Text.of("§f§lSneaky Boots")));
this.player.getInventory().armor.set(1, itemWName(Items.LEATHER_LEGGINGS, Text.of("§f§lSneaky Pants")));
this.player.getInventory().armor.set(2, itemWName(Items.LEATHER_CHESTPLATE, Text.of("§f§lSneaky Chestplate")));
this.player.getInventory().armor.set(3, itemWName(Items.LEATHER_HELMET, Text.of("§f§lSneaky Helmet")));
}
}

for (ItemStack item : this.player.getInventory().main) {
item.getOrCreateNbt().putBoolean("Unbreakable", true);
item.addHideFlag(ItemStack.TooltipSection.UNBREAKABLE);
item.set(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true));
item.set(DataComponentTypes.HIDE_TOOLTIP, Unit.INSTANCE);
}

for (ItemStack item : this.player.getInventory().armor) {
item.getOrCreateNbt().putBoolean("Unbreakable", true);
item.addHideFlag(ItemStack.TooltipSection.UNBREAKABLE);
item.set(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true));
item.set(DataComponentTypes.HIDE_TOOLTIP, Unit.INSTANCE);
}
}

private ItemStack itemWName(Item stack, Text text) {
ItemStack itemStack = new ItemStack(stack);
itemStack.set(DataComponentTypes.ITEM_NAME, text);
return itemStack;
}

public void playerDeath() {
BlockHuntTitle.sendTitle(this.player,
Text.literal("")
Expand Down
Loading

0 comments on commit 45bc3e5

Please sign in to comment.