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 22, 2024
1 parent 91bf5f3 commit 7cebea2
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 126 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.5.7"
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 @@ -42,7 +39,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.109.0+1.21.3

plasmid_version = 0.5.102-SNAPSHOT+1.20.4
plasmid_version = 0.6.0+1.21.3
32 changes: 18 additions & 14 deletions src/main/java/io/github/haykam821/blocklobbers/BlockLobbers.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,41 @@
import io.github.haykam821.blocklobbers.game.lobbable.LobbableEntity;
import io.github.haykam821.blocklobbers.game.phase.BlockLobbersWaitingPhase;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
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 BlockLobbers implements ModInitializer {
public static final String MOD_ID = "blocklobbers";
private static final String MOD_ID = "blocklobbers";

private static final Identifier BLOCK_LOBBERS_ID = new Identifier(MOD_ID, "block_lobbers");
private static final Identifier BLOCK_LOBBERS_ID = BlockLobbers.identifier("block_lobbers");
public static final GameType<BlockLobbersConfig> BLOCK_LOBBERS_TYPE = GameType.register(BLOCK_LOBBERS_ID, BlockLobbersConfig.CODEC, BlockLobbersWaitingPhase::open);

private static final Identifier LOBBABLE_ID = new Identifier(MOD_ID, "lobbable");
public static final EntityType<LobbableEntity> LOBBABLE_ENTITY_TYPE = FabricEntityTypeBuilder.create()
.<LobbableEntity>entityFactory(LobbableEntity::new)
.spawnGroup(SpawnGroup.MISC)
.dimensions(EntityDimensions.changing(0.98f, 0.98f))
private static final Identifier LOBBABLE_ID = BlockLobbers.identifier("lobbable");
private static final RegistryKey<EntityType<?>> LOBBABLE_KEY = RegistryKey.of(RegistryKeys.ENTITY_TYPE, LOBBABLE_ID);

public static final EntityType<LobbableEntity> LOBBABLE_ENTITY_TYPE = EntityType.Builder.<LobbableEntity>create(LobbableEntity::new, SpawnGroup.MISC)
.dimensions(0.98f, 0.98f)
.disableSaving()
.disableSummon()
.trackRangeChunks(10)
.trackedUpdateRate(20)
.build();
.maxTrackingRange(10)
.trackingTickInterval(20)
.build(LOBBABLE_KEY);

@Override
public void onInitialize() {
Registry.register(Registries.ENTITY_TYPE, LOBBABLE_ID, LOBBABLE_ENTITY_TYPE);
Registry.register(Registries.ENTITY_TYPE, LOBBABLE_KEY, LOBBABLE_ENTITY_TYPE);
PolymerEntityUtils.registerType(LOBBABLE_ENTITY_TYPE);

LobbableBehavior.registerDefaults();
}

public static Identifier identifier(String path) {
return Identifier.of(MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package io.github.haykam821.blocklobbers.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.api.game.common.config.WaitingLobbyConfig;

public class BlockLobbersConfig {
public static final Codec<BlockLobbersConfig> CODEC = RecordCodecBuilder.create(instance -> {
public static final MapCodec<BlockLobbersConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
Identifier.CODEC.fieldOf("map").forGetter(BlockLobbersConfig::getMap),
PlayerConfig.CODEC.fieldOf("players").forGetter(BlockLobbersConfig::getPlayerConfig),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(BlockLobbersConfig::getPlayerConfig),
Codec.BOOL.optionalFieldOf("consume_lobbables", true).forGetter(BlockLobbersConfig::shouldConsumeLobbables)
).apply(instance, BlockLobbersConfig::new);
});

private final Identifier map;
private final PlayerConfig playerConfig;
private final WaitingLobbyConfig playerConfig;
private final boolean consumeLobbables;

public BlockLobbersConfig(Identifier map, PlayerConfig playerConfig, boolean consumeLobbables) {
public BlockLobbersConfig(Identifier map, WaitingLobbyConfig playerConfig, boolean consumeLobbables) {
this.map = map;
this.playerConfig = playerConfig;
this.consumeLobbables = consumeLobbables;
Expand All @@ -29,7 +30,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 @@ -3,16 +3,15 @@
import io.github.haykam821.blocklobbers.game.player.VelocityHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemStack.TooltipSection;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldEvents;
import xyz.nucleoid.plasmid.util.ItemStackBuilder;
import xyz.nucleoid.plasmid.api.util.ItemStackBuilder;

public class Lobbable {
private static final double KNOCKBACK_STRENGTH = 1.3;
Expand All @@ -36,8 +35,7 @@ public ItemStack createStack(boolean top) {
ItemStackBuilder builder = ItemStackBuilder.of(this.state.getBlock());

if (top) {
builder.addEnchantment(Enchantments.INFINITY, 1);
builder.hideFlag(TooltipSection.ENCHANTMENTS);
builder.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true);
}

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
import xyz.nucleoid.packettweaker.PacketContext;

public class LobbableEntity extends ProjectileEntity implements PolymerEntity {
private static final Vec3d ANCHOR_OFFSET = new Vec3d(-0.5d, 0, -0.5d);
Expand Down Expand Up @@ -56,6 +57,7 @@ public Vec3d getPos() {

BlockDisplayElement blockDisplay = new BlockDisplayElement(lobbable.getBlock().getDefaultState());
blockDisplay.setOffset(ANCHOR_OFFSET);
blockDisplay.ignorePositionUpdates();
this.holder.addElement(blockDisplay);

VirtualEntityUtils.addVirtualPassenger(this, blockDisplay.getEntityId());
Expand Down Expand Up @@ -94,9 +96,6 @@ protected boolean canHit(Entity entity) {
public void tick() {
super.tick();

this.checkBlockCollision();
this.updateRotation();

// Update position
Vec3d velocity = this.getVelocity();

Expand All @@ -115,6 +114,9 @@ public void tick() {

this.setVelocity(velocity);

this.updateRotation();
this.tickBlockCollision();

World world = this.getWorld();

// Handle collisions
Expand Down Expand Up @@ -144,7 +146,7 @@ public void remove(RemovalReason reason) {
}

@Override
public EntityType<?> getPolymerEntityType(ServerPlayerEntity player) {
public EntityType<?> getPolymerEntityType(PacketContext context) {
return EntityType.ARMOR_STAND;
}

Expand All @@ -165,11 +167,11 @@ public void modifyRawTrackedData(List<SerializedEntry<?>> data, ServerPlayerEnti
}

@Override
protected void initDataTracker() {
protected void initDataTracker(DataTracker.Builder builder) {
return;
}

protected float getGravity() {
return 0.05f;
protected double getGravity() {
return 0.05;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import xyz.nucleoid.map_templates.BlockBounds;
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 BlockLobbersMap {
public static final String SPAWN_KEY = "spawn";
Expand Down Expand Up @@ -71,7 +71,7 @@ private void spawn(ServerWorld world, ServerPlayerEntity player, TemplateRegion
Vec3d pos = region.getBounds().centerBottom();
float yaw = region.getData().getFloat(FACING_KEY);

player.teleport(world, pos.getX(), pos.getY(), pos.getZ(), yaw, 0);
player.teleport(world, pos.getX(), pos.getY(), pos.getZ(), Set.of(), yaw, 0, true);
}

public ChunkGenerator createGenerator(MinecraftServer server) {
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 BlockLobbersMapBuilder {
private final BlockLobbersConfig config;
Expand Down
Loading

0 comments on commit 7cebea2

Please sign in to comment.