Skip to content

Commit

Permalink
Update minigame to Minecraft 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Nov 21, 2024
1 parent 8a5326a commit 838080e
Show file tree
Hide file tree
Showing 27 changed files with 123 additions and 167 deletions.
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.7.2"
id "fabric-loom" version "1.8.12"
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 @@ -39,7 +36,13 @@ processResources {
}
}

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

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

Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +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.11
minecraft_version = 1.21.3
yarn_mappings = 1.21.3+build.2
loader_version = 0.16.9
fabric_version = 0.109.0+1.21.3

plasmid_version = 0.5.102-SNAPSHOT+1.20.4
plasmid_version = 0.6.0+1.21.3
10 changes: 7 additions & 3 deletions src/main/java/io/github/haykam821/lastcard/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.util.Identifier;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.game.GameType;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;

public class Main implements ModInitializer {
public static final String MOD_ID = "lastcard";
public static final ModContainer MOD_CONTAINER = FabricLoader.getInstance().getModContainer(MOD_ID).get();

public static final GameRuleType WITHER_ROSE_WITHER_EFFECT = GameRuleType.create();

private static final Identifier LAST_CARD_ID = new Identifier(MOD_ID, "last_card");
private static final Identifier LAST_CARD_ID = Main.identifier("last_card");
public static final GameType<LastCardConfig> LAST_CARD_TYPE = GameType.register(LAST_CARD_ID, LastCardConfig.CODEC, LastCardWaitingPhase::open);

@Override
public void onInitialize() {
return;
}

public static Identifier identifier(String path) {
return Identifier.of(MOD_ID, path);
}
}
18 changes: 0 additions & 18 deletions src/main/java/io/github/haykam821/lastcard/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
import io.github.haykam821.lastcard.card.color.ColorRepresentation;
import io.github.haykam821.lastcard.card.color.ColorSelector;
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemStack.TooltipSection;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import xyz.nucleoid.plasmid.util.ItemStackBuilder;

public abstract class Card {
private final ColorSelector selector;
Expand All @@ -24,20 +20,6 @@ public Card(ColorSelector selector) {
this.selector = Objects.requireNonNull(selector);
}

public final ItemStack createStack(AbstractPlayerEntry player) {
ItemStackBuilder builder = ItemStackBuilder.of(this.selector.getItem());
builder.setName(this.getFullName());

if (this.canPlay(player)) {
builder.addEnchantment(Enchantments.POWER, 1);
}

ItemStack stack = builder.build();
stack.getNbt().putInt("HideFlags", TooltipSection.ENCHANTMENTS.getFlag());

return stack;
}

public abstract Text getName();

public final Text getFullName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.haykam821.lastcard.card.color;

import org.joml.Vector3f;

import eu.pb4.mapcanvas.api.core.CanvasColor;
import eu.pb4.mapcanvas.api.core.DrawableCanvas;
import io.github.haykam821.lastcard.card.display.CardTemplates;
Expand All @@ -13,7 +11,6 @@
import net.minecraft.particle.ParticleEffect;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Vec3d;

public enum CardColor implements ColorRepresentation {
RED("red", Items.RED_WOOL, Formatting.RED, BossBar.Color.RED, CardTemplates.RED_FRONT, CanvasColor.RED_NORMAL),
Expand Down Expand Up @@ -90,7 +87,6 @@ private static ParticleEffect createParticleEffect(CanvasColor canvasColor) {
}

public static ParticleEffect createParticleEffect(int rgb) {
Vector3f color = Vec3d.unpackRgb(rgb).toVector3f();
return new DustColorTransitionParticleEffect(color, TurnManager.BLACK_PARTICLE_COLOR, TurnManager.PARTICLE_SIZE);
return new DustColorTransitionParticleEffect(rgb, TurnManager.BLACK_PARTICLE_COLOR, TurnManager.PARTICLE_SIZE);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.haykam821.lastcard.game;

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

import io.github.haykam821.lastcard.game.player.VirtualPlayerConfig;
Expand All @@ -10,13 +10,13 @@
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.IntProvider;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public class LastCardConfig {
public static final Codec<LastCardConfig> CODEC = RecordCodecBuilder.create(instance -> {
public static final MapCodec<LastCardConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
Identifier.CODEC.fieldOf("map").forGetter(LastCardConfig::getMap),
PlayerConfig.CODEC.fieldOf("players").forGetter(LastCardConfig::getPlayerConfig),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(LastCardConfig::getPlayerConfig),
VirtualPlayerConfig.CODEC.optionalFieldOf("virtual_players", VirtualPlayerConfig.DEFAULT).forGetter(LastCardConfig::getVirtualPlayers),
IntProvider.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantIntProvider.create(SharedConstants.TICKS_PER_SECOND * 5)).forGetter(LastCardConfig::getTicksUntilClose),
IntProvider.POSITIVE_CODEC.optionalFieldOf("initial_hand_count", ConstantIntProvider.create(7)).forGetter(LastCardConfig::getInitialHandCount),
Expand All @@ -26,14 +26,14 @@ public class LastCardConfig {
});

private final Identifier map;
private final PlayerConfig playerConfig;
private final WaitingLobbyConfig playerConfig;
private final VirtualPlayerConfig virtualPlayers;
private final IntProvider ticksUntilClose;
private final IntProvider initialHandCount;
private final IntProvider timeOfDay;
private final BlockStateProvider chairBlock;

public LastCardConfig(Identifier map, PlayerConfig playerConfig, VirtualPlayerConfig virtualPlayers, IntProvider ticksUntilClose, IntProvider initialHandCount, IntProvider timeOfDay, BlockStateProvider chairBlock) {
public LastCardConfig(Identifier map, WaitingLobbyConfig playerConfig, VirtualPlayerConfig virtualPlayers, IntProvider ticksUntilClose, IntProvider initialHandCount, IntProvider timeOfDay, BlockStateProvider chairBlock) {
this.map = map;
this.playerConfig = playerConfig;
this.virtualPlayers = virtualPlayers;
Expand All @@ -47,7 +47,7 @@ public Identifier getMap() {
return this.map;
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraft.entity.boss.BossBar;
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 LastPlayedBar {
private static final BossBar.Style STYLE = BossBar.Style.PROGRESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.block.StairsBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.decoration.InteractionEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void teleport(ServerPlayerEntity player) {
}

private Entity createMount(ServerWorld world) {
InteractionEntity mount = EntityType.INTERACTION.create(world);
InteractionEntity mount = EntityType.INTERACTION.create(world, SpawnReason.STRUCTURE);
InteractionEntityAccessor accessor = (InteractionEntityAccessor) mount;

accessor.lastcard$setInteractionWidth(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Util;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import xyz.nucleoid.map_templates.MapTemplate;
import xyz.nucleoid.map_templates.TemplateRegion;
import xyz.nucleoid.plasmid.game.world.generator.TemplateChunkGenerator;
import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator;

public class LastCardMap {
private static final Random RANDOM = Random.createLocal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.text.Text;
import xyz.nucleoid.map_templates.MapTemplate;
import xyz.nucleoid.map_templates.MapTemplateSerializer;
import xyz.nucleoid.plasmid.game.GameOpenException;
import xyz.nucleoid.plasmid.api.game.GameOpenException;

public class LastCardMapBuilder {
private final LastCardConfig config;
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/io/github/haykam821/lastcard/game/map/Spawn.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.github.haykam821.lastcard.game.map;

import java.util.Set;

import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import xyz.nucleoid.map_templates.TemplateRegion;
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult.Accept;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptor;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptorResult;

public class Spawn {
public final Vec3d pos;
Expand All @@ -18,13 +20,13 @@ public Spawn(TemplateRegion region) {
}

public void teleport(ServerPlayerEntity player) {
player.teleport(player.getServerWorld(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), this.rotation, 0);
player.teleport(player.getServerWorld(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), Set.of(), this.rotation, 0, true);
}

public Accept acceptOffer(PlayerOffer offer, ServerWorld world, GameMode gameMode) {
return offer.accept(world, this.pos).and(() -> {
offer.player().changeGameMode(gameMode);
offer.player().setYaw(this.rotation);
public JoinAcceptorResult.Teleport acceptPlayers(JoinAcceptor acceptor, ServerWorld world, GameMode gameMode) {
return acceptor.teleport(world, this.pos).thenRunForEach(player -> {
player.changeGameMode(gameMode);
player.setYaw(this.rotation);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
import eu.pb4.polymer.virtualentity.api.elements.TextDisplayElement;
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.entity.decoration.DisplayEntity.BillboardMode;
import net.minecraft.item.ModelTransformationMode;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
Expand Down
Loading

0 comments on commit 838080e

Please sign in to comment.