Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minigame to Minecraft 1.21.3 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
key: gradle-${{hashFiles('**/*.gradle*')}}
restore-keys: gradle-
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 17
cache: gradle
distribution: microsoft
java-version: 21
- name: Build with Gradle
run: gradle build
- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
plugins {
id "fabric-loom" version "1.5.7"
id "fabric-loom" version "1.9.2"
id "maven-publish"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
Expand Down Expand Up @@ -46,7 +43,13 @@ processResources {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

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

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ mod_version = 1.0.0
org.gradle.jvmargs = -Xmx1G

# Versions
minecraft_version = 1.20.4
yarn_mappings = 1.20.4+build.3
loader_version = 0.15.6
fabric_version = 0.96.0+1.20.4
minecraft_version = 1.21.3
yarn_mappings = 1.21.3+build.2
loader_version = 0.16.9
fabric_version = 0.110.0+1.21.3

plasmid_version = 0.5.102-SNAPSHOT+1.20.4
plasmid_version = 0.6.1+1.21.3
20 changes: 13 additions & 7 deletions src/main/java/io/github/haykam821/deathswap/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@
import io.github.haykam821.deathswap.game.DeathSwapConfig;
import io.github.haykam821.deathswap.game.phase.DeathSwapWaitingPhase;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;

public class Main implements ModInitializer {
public static final String MOD_ID = "deathswap";
private static final String MOD_ID = "deathswap";

private static final Identifier BARRIER_AIR_ID = new Identifier(MOD_ID, "barrier_air");
public static final Block BARRIER_AIR = new BarrierAirBlock(FabricBlockSettings.copyOf(Blocks.AIR).strength(-1, 3600000));
private static final Identifier BARRIER_AIR_ID = Main.identifier("barrier_air");
private static final RegistryKey<Block> BARRIER_AIR_KEY = RegistryKey.of(RegistryKeys.BLOCK, BARRIER_AIR_ID);
public static final Block BARRIER_AIR = new BarrierAirBlock(Block.Settings.copy(Blocks.AIR).strength(-1, 3600000).registryKey(BARRIER_AIR_KEY));

private static final Identifier DEATH_SWAP_ID = new Identifier(MOD_ID, "death_swap");
private static final Identifier DEATH_SWAP_ID = Main.identifier("death_swap");
public static final GameType<DeathSwapConfig> DEATH_SWAP_TYPE = GameType.register(DEATH_SWAP_ID, DeathSwapConfig.CODEC, DeathSwapWaitingPhase::open);

@Override
public void onInitialize() {
Registry.register(Registries.BLOCK, BARRIER_AIR_ID, BARRIER_AIR);
Registry.register(Registries.BLOCK, BARRIER_AIR_KEY, BARRIER_AIR);
}

public static Identifier identifier(String path) {
return Identifier.of(MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import xyz.nucleoid.packettweaker.PacketContext;

public class BarrierAirBlock extends AirBlock implements PolymerBlock {
public static final MapCodec<AirBlock> CODEC = Block.createCodec(BarrierAirBlock::new);
Expand All @@ -21,7 +22,7 @@ public MapCodec<AirBlock> getCodec() {
}

@Override
public Block getPolymerBlock(BlockState state) {
return Blocks.BARRIER;
public BlockState getPolymerBlockState(BlockState state, PacketContext context) {
return Blocks.BARRIER.getDefaultState();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package io.github.haykam821.deathswap.game;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import io.github.haykam821.deathswap.game.map.DeathSwapMapConfig;
import net.minecraft.SharedConstants;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.IntProvider;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public class DeathSwapConfig {
public static final Codec<DeathSwapConfig> CODEC = RecordCodecBuilder.create(instance -> {
public static final MapCodec<DeathSwapConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
PlayerConfig.CODEC.fieldOf("players").forGetter(DeathSwapConfig::getPlayerConfig),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(DeathSwapConfig::getPlayerConfig),
DeathSwapMapConfig.CODEC.fieldOf("map").forGetter(DeathSwapConfig::getMapConfig),
IntProvider.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantIntProvider.create(SharedConstants.TICKS_PER_SECOND * 10)).forGetter(DeathSwapConfig::getTicksUntilClose),
Codec.INT.optionalFieldOf("initial_swap_ticks", SharedConstants.TICKS_PER_MINUTE * 5).forGetter(DeathSwapConfig::getInitialSwapTicks),
Expand All @@ -22,15 +23,15 @@ public class DeathSwapConfig {
).apply(instance, DeathSwapConfig::new);
});

private final PlayerConfig playerConfig;
private final WaitingLobbyConfig playerConfig;
private final DeathSwapMapConfig mapConfig;
private final IntProvider ticksUntilClose;
private final int initialSwapTicks;
private final int swapTicks;
private final int swapWarningTicks;
private final int swapEliminationCollectionTicks;

public DeathSwapConfig(PlayerConfig playerConfig, DeathSwapMapConfig mapConfig, IntProvider ticksUntilClose, int initialSwapTicks, int swapTicks, int swapWarningTicks, int swapEliminationCollectionTicks) {
public DeathSwapConfig(WaitingLobbyConfig playerConfig, DeathSwapMapConfig mapConfig, IntProvider ticksUntilClose, int initialSwapTicks, int swapTicks, int swapWarningTicks, int swapEliminationCollectionTicks) {
this.playerConfig = playerConfig;
this.mapConfig = mapConfig;
this.ticksUntilClose = ticksUntilClose;
Expand All @@ -40,7 +41,7 @@ public DeathSwapConfig(PlayerConfig playerConfig, DeathSwapMapConfig mapConfig,
this.swapEliminationCollectionTicks = swapEliminationCollectionTicks;
}

public PlayerConfig getPlayerConfig() {
public WaitingLobbyConfig getPlayerConfig() {
return this.playerConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.common.widget.BossBarWidget;
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.api.game.common.widget.BossBarWidget;

public class DeathSwapTimer {
private static final BossBar.Style STYLE = BossBar.Style.PROGRESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import xyz.nucleoid.plasmid.game.player.PlayerIterable;
import xyz.nucleoid.plasmid.util.PlayerRef;
import xyz.nucleoid.plasmid.api.game.player.PlayerIterable;
import xyz.nucleoid.plasmid.api.util.PlayerRef;

public class EliminationCollector {
private static final int FADE_IN_TICKS = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Vec3d;

public record SwapData(Vec3d pos, Entity vehicle, List<Entity> passengers) {
public record SwapData(ServerWorld world, Vec3d pos, Entity vehicle, List<Entity> passengers) {
public void apply(ServerPlayerEntity player) {
player.stopRiding();
player.teleport(this.pos.getX(), this.pos.getY(), this.pos.getZ());
player.teleport(world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), PositionFlag.ROT, 0, 0, false);

if (this.vehicle != null) {
player.startRiding(this.vehicle, true);
Expand All @@ -21,6 +23,6 @@ public void apply(ServerPlayerEntity player) {
}

public static SwapData from(ServerPlayerEntity player) {
return new SwapData(player.getPos(), player.getVehicle(), player.getPassengerList());
return new SwapData(player.getServerWorld(), player.getPos(), player.getVehicle(), player.getPassengerList());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.haykam821.deathswap.game.map;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import net.minecraft.block.BlockState;
import net.minecraft.server.MinecraftServer;
Expand All @@ -15,7 +14,6 @@
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.GenerationStep.Carver;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.gen.chunk.ChunkGenerator;
Expand All @@ -24,7 +22,7 @@
import net.minecraft.world.gen.chunk.VerticalBlockSample;
import net.minecraft.world.gen.noise.NoiseConfig;
import xyz.nucleoid.fantasy.util.ChunkGeneratorSettingsProvider;
import xyz.nucleoid.plasmid.game.world.generator.GameChunkGenerator;
import xyz.nucleoid.plasmid.api.game.world.generator.GameChunkGenerator;

public final class DeathSwapChunkGenerator extends GameChunkGenerator implements ChunkGeneratorSettingsProvider {
private final DeathSwapMapConfig mapConfig;
Expand Down Expand Up @@ -55,11 +53,11 @@ private boolean isChunkWithinArea(Chunk chunk) {
}

@Override
public CompletableFuture<Chunk> populateBiomes(Executor executor, NoiseConfig noiseConfig, Blender blender, StructureAccessor structures, Chunk chunk) {
public CompletableFuture<Chunk> populateBiomes(NoiseConfig noiseConfig, Blender blender, StructureAccessor structures, Chunk chunk) {
if (this.isChunkWithinArea(chunk)) {
return this.chunkGenerator.populateBiomes(executor, noiseConfig, blender, structures, chunk);
return this.chunkGenerator.populateBiomes(noiseConfig, blender, structures, chunk);
} else {
return super.populateBiomes(executor, noiseConfig, blender, structures, chunk);
return super.populateBiomes(noiseConfig, blender, structures, chunk);
}
}

Expand All @@ -77,11 +75,11 @@ public void populateEntities(ChunkRegion region) {
}

@Override
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig, StructureAccessor structures, Chunk chunk) {
public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noiseConfig, StructureAccessor structures, Chunk chunk) {
if (this.isChunkWithinArea(chunk)) {
return this.chunkGenerator.populateNoise(executor, blender, noiseConfig, structures, chunk);
return this.chunkGenerator.populateNoise(blender, noiseConfig, structures, chunk);
}
return super.populateNoise(executor, blender, noiseConfig, structures, chunk);
return super.populateNoise(blender, noiseConfig, structures, chunk);
}

@Override
Expand Down Expand Up @@ -117,7 +115,7 @@ private void generateWalls(int chunkX, int chunkZ, BlockPos originPos, Chunk chu
BlockPos.Mutable pos = new BlockPos.Mutable();

int bottomY = chunk.getBottomY();
int topY = chunk.getTopY() - 1;
int topY = chunk.getTopYInclusive();

// Top
for (int x = 0; x < 16; x++) {
Expand Down Expand Up @@ -177,9 +175,9 @@ private BlockState getBarrierState(Random random, BlockPos pos) {
}

@Override
public void carve(ChunkRegion region, long seed, NoiseConfig noiseConfig, BiomeAccess access, StructureAccessor structures, Chunk chunk, Carver carver) {
public void carve(ChunkRegion region, long seed, NoiseConfig noiseConfig, BiomeAccess access, StructureAccessor structures, Chunk chunk) {
if (this.isChunkWithinArea(chunk)) {
this.chunkGenerator.carve(region, seed, noiseConfig, access, structures, chunk, carver);
this.chunkGenerator.carve(region, seed, noiseConfig, access, structures, chunk);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BlockBox getBox() {

public int getSurfaceY(ServerWorld world, int x, int z) {
int bottomY = world.getBottomY();
int maxY = Math.min(world.getTopY(), bottomY + world.getLogicalHeight()) - 1;
int maxY = Math.min(world.getTopYInclusive(), bottomY + world.getLogicalHeight() - 1);

BlockPos.Mutable pos = new BlockPos.Mutable(x, maxY, z);
Chunk chunk = world.getChunk(pos);
Expand Down
Loading
Loading