Skip to content

Commit

Permalink
Update to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 8, 2024
1 parent a793150 commit 16fd78d
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -33,7 +33,7 @@ jobs:
run: ./gradlew build

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.1.+'
id 'fabric-loom' version '1.7.+'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -28,7 +28,7 @@ dependencies {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9

# Dependencies
fabric_version=0.83.1+1.20.1
plasmid_version=0.5+1.20.1-SNAPSHOT
fabric_version=0.110.2+1.21.4
plasmid_version=0.6.2+1.21.4

# Mod Properties
mod_version=1.1.3
mod_version=1.1.4
maven_group=xyz.nucleoid
archives_base_name=farmy-feud
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/java/xyz/nucleoid/farmyfeud/FarmyFeud.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.apache.logging.log4j.Logger;
import xyz.nucleoid.farmyfeud.game.FfConfig;
import xyz.nucleoid.farmyfeud.game.FfWaiting;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;

public final class FarmyFeud implements ModInitializer {
public static final String ID = "farmy_feud";
Expand All @@ -15,7 +15,7 @@ public final class FarmyFeud implements ModInitializer {
@Override
public void onInitialize() {
GameType.register(
new Identifier(FarmyFeud.ID, "farmy_feud"),
Identifier.of(FarmyFeud.ID, "farmy_feud"),
FfConfig.CODEC,
FfWaiting::open
);
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/xyz/nucleoid/farmyfeud/entity/FarmSheepEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.joml.Vector3f;
import xyz.nucleoid.farmyfeud.game.active.FfActive;
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.plasmid.game.common.team.GameTeamKey;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeamKey;

import java.util.EnumSet;

Expand Down Expand Up @@ -81,8 +81,8 @@ public boolean tryPickUp(long time, GameTeamKey team) {

public void teleportWithPoof(double x, double y, double z) {
if (this.getWorld() instanceof ServerWorld world) {
var colorComponents = this.getColor().getColorComponents();
var particle = new DustParticleEffect(new Vector3f(colorComponents), 2f);
var colorComponents = this.getColor().getEntityColor();
var particle = new DustParticleEffect(colorComponents, 2f);

for (int i = 0; i < 20; i++) {
double deltaX = this.random.nextGaussian() * 0.02;
Expand All @@ -93,7 +93,7 @@ public void teleportWithPoof(double x, double y, double z) {
}
}

this.teleport(x, y, z);
this.teleport(x, y, z, false);
}

@Nullable
Expand All @@ -120,7 +120,7 @@ protected void initGoals() {
}

@Override
protected void mobTick() {
protected void mobTick(ServerWorld world) {
this.game.tickSheep(this);

if (this.home != null) {
Expand All @@ -137,13 +137,13 @@ protected void mobTick() {
}

@Override
public boolean damage(DamageSource source, float amount) {
public boolean damage(ServerWorld world, DamageSource source, float amount) {
Entity vehicle = this.getVehicle();
if (vehicle != null && source.getSource() != null) {
return vehicle.damage(source, amount);
return vehicle.damage(world, source, amount);
}

return super.damage(source, amount);
return super.damage(world, source, amount);
}

@Override
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/xyz/nucleoid/farmyfeud/game/FfConfig.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package xyz.nucleoid.farmyfeud.game;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeamList;

import java.util.List;

public record FfConfig(Identifier map, PlayerConfig players,
List<GameTeam> teams, long gameDuration,
public record FfConfig(Identifier map, WaitingLobbyConfig players,
GameTeamList teams, long gameDuration,
long spawnInterval, int maxArrows, long arrowInterval) {
public static final Codec<FfConfig> CODEC = RecordCodecBuilder.create(instance -> {
public static final MapCodec<FfConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
Identifier.CODEC.fieldOf("map").forGetter(config -> config.map),
PlayerConfig.CODEC.fieldOf("players").forGetter(config -> config.players),
GameTeam.CODEC.listOf().fieldOf("teams").forGetter(config -> config.teams),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(config -> config.players),
GameTeamList.CODEC.fieldOf("teams").forGetter(config -> config.teams),
Codec.LONG.optionalFieldOf("game_duration", 60L * 8 * 20).forGetter(config -> config.gameDuration),
Codec.LONG.optionalFieldOf("spawn_interval", 30L * 30).forGetter(config -> config.spawnInterval),
Codec.INT.optionalFieldOf("max_arrows", 3).forGetter(config -> config.maxArrows),
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/xyz/nucleoid/farmyfeud/game/FfSpawnLogic.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package xyz.nucleoid.farmyfeud.game;

import net.minecraft.command.argument.EntityAnchorArgumentType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import xyz.nucleoid.farmyfeud.game.map.FfMap;
import xyz.nucleoid.map_templates.BlockBounds;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameMode;
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.game.common.team.GameTeamKey;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeamKey;

import java.util.Set;

public record FfSpawnLogic(ServerWorld world, FfMap map) {

Expand All @@ -25,9 +30,9 @@ public void resetPlayer(ServerPlayerEntity player, GameMode gameMode) {
public void spawnPlayerAtCenter(ServerPlayerEntity player) {
BlockBounds centerSpawn = this.map.getCenterSpawn();
if (centerSpawn != null) {
this.spawnAt(player, BlockPos.ofFloored(centerSpawn.center()));
this.spawnAt(player, BlockPos.ofFloored(centerSpawn.center()), 0);
} else {
this.spawnAt(player, BlockPos.ORIGIN);
this.spawnAt(player, BlockPos.ORIGIN, 0);
}
}

Expand All @@ -40,11 +45,20 @@ public void spawnPlayerAtTeam(ServerPlayerEntity player, GameTeamKey team) {
BlockBounds teamSpawn = teamRegions.spawn();
if (teamSpawn != null) {
BlockPos spawnPos = BlockPos.ofFloored(teamSpawn.center());
this.spawnAt(player, spawnPos);
BlockPos center;
var centerSpawn = this.map.getCenterSpawn();
if (centerSpawn != null) {
center = BlockPos.ofFloored(centerSpawn.center());
} else {
center = BlockPos.ORIGIN;
}

this.spawnAt(player, spawnPos, 0);
player.lookAt(EntityAnchorArgumentType.EntityAnchor.FEET, Vec3d.ofCenter(center.withY(spawnPos.getY())));
}
}

private void spawnAt(ServerPlayerEntity player, BlockPos spawnPos) {
player.teleport(this.world, spawnPos.getX() + 0.5, spawnPos.getY() + 0.5, spawnPos.getZ() + 0.5, 0.0F, 0.0F);
private void spawnAt(ServerPlayerEntity player, BlockPos spawnPos, float yaw) {
player.teleport(this.world, spawnPos.getX() + 0.5, spawnPos.getY() + 0.5, spawnPos.getZ() + 0.5, Set.of(), yaw, 0.0F, false);
}
}
36 changes: 21 additions & 15 deletions src/main/java/xyz/nucleoid/farmyfeud/game/FfWaiting.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import xyz.nucleoid.farmyfeud.game.active.FfActive;
import xyz.nucleoid.farmyfeud.game.map.FfMap;
import xyz.nucleoid.farmyfeud.game.map.FfMapBuilder;
import xyz.nucleoid.plasmid.game.GameOpenContext;
import xyz.nucleoid.plasmid.game.GameOpenProcedure;
import xyz.nucleoid.plasmid.game.GameResult;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.game.common.GameWaitingLobby;
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.api.game.GameOpenContext;
import xyz.nucleoid.plasmid.api.game.GameOpenProcedure;
import xyz.nucleoid.plasmid.api.game.GameResult;
import xyz.nucleoid.plasmid.api.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.common.GameWaitingLobby;
import xyz.nucleoid.plasmid.api.game.common.team.TeamSelectionLobby;
import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.api.game.player.JoinOffer;
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;

public final class FfWaiting {
Expand All @@ -26,12 +28,14 @@ public final class FfWaiting {
private final FfConfig config;

private final FfSpawnLogic spawnLogic;
private final TeamSelectionLobby teamSelection;

private FfWaiting(GameSpace gameSpace, ServerWorld world, FfMap map, FfConfig config) {
private FfWaiting(GameSpace gameSpace, ServerWorld world, FfMap map, FfConfig config, TeamSelectionLobby teamSelection) {
this.world = world;
this.gameSpace = gameSpace;
this.map = map;
this.config = config;
this.teamSelection = teamSelection;

this.spawnLogic = new FfSpawnLogic(this.world, map);
}
Expand All @@ -45,28 +49,30 @@ public static GameOpenProcedure open(GameOpenContext<FfConfig> context) {
.setGenerator(map.createGenerator(context.server()));

return context.openWithWorld(worldConfig, (game, world) -> {
FfWaiting waiting = new FfWaiting(game.getGameSpace(), world, map, config);

var teamSelection = TeamSelectionLobby.addTo(game, config.teams());
GameWaitingLobby.addTo(game, config.players());
game.listen(GamePlayerEvents.OFFER, player -> player.accept(world, map.getCenterSpawn() != null ? map.getCenterSpawn().center() : new Vec3d(0, 256, 0)));
FfWaiting waiting = new FfWaiting(game.getGameSpace(), world, map, config, teamSelection);

game.listen(GamePlayerEvents.OFFER, JoinOffer::accept);
game.listen(GamePlayerEvents.ACCEPT, player -> player.teleport(world, map.getCenterSpawn() != null ? map.getCenterSpawn().center() : new Vec3d(0, 256, 0)));
game.listen(GameActivityEvents.REQUEST_START, waiting::requestStart);
game.listen(GamePlayerEvents.ADD, waiting::addPlayer);
game.listen(PlayerDeathEvent.EVENT, waiting::onPlayerDeath);
});
}

private GameResult requestStart() {
FfActive.open(this.gameSpace, this.world, this.map, this.config);
FfActive.open(this.gameSpace, this.world, this.map, this.config, this.teamSelection);
return GameResult.ok();
}

private void addPlayer(ServerPlayerEntity player) {
this.spawnPlayer(player);
}

private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
this.spawnPlayer(player);
return ActionResult.FAIL;
return EventResult.DENY;
}

private void spawnPlayer(ServerPlayerEntity player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import xyz.nucleoid.farmyfeud.FarmyFeud;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

public final class EntityCarryStack<T extends Entity> {
private static final UUID SLOW_MODIFIER_ID = UUID.fromString("19462f6a-7346-4e27-846f-68864be3ddcb");
private static final Identifier SLOW_MODIFIER_ID = Identifier.of(FarmyFeud.ID, "stack_slowness");

private final int maximumHeight;
private final List<T> stack = new ArrayList<>();
Expand Down Expand Up @@ -64,7 +66,7 @@ public List<T> dropAll(ServerPlayerEntity player) {
private void onStackChange(ServerPlayerEntity player) {
player.networkHandler.sendPacket(new EntityPassengersSetS2CPacket(player));

EntityAttributeInstance attribute = player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
EntityAttributeInstance attribute = player.getAttributeInstance(EntityAttributes.MOVEMENT_SPEED);
if (attribute == null) {
return;
}
Expand All @@ -76,8 +78,8 @@ private void onStackChange(ServerPlayerEntity player) {
double targetValue = baseValue / (this.stack.size() * 0.3 + 1);

EntityAttributeModifier modifier = new EntityAttributeModifier(
SLOW_MODIFIER_ID, "carry slow",
targetValue - baseValue, EntityAttributeModifier.Operation.ADDITION
SLOW_MODIFIER_ID,
targetValue - baseValue, EntityAttributeModifier.Operation.ADD_VALUE
);

attribute.addTemporaryModifier(modifier);
Expand Down
Loading

0 comments on commit 16fd78d

Please sign in to comment.