Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
cache: gradle
distribution: microsoft
java-version: 21
java-version: 25
- name: Build with Gradle
run: gradle build
- name: Upload Artifacts
Expand Down
20 changes: 11 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
plugins {
id "fabric-loom" version "1.10.5"
id "net.fabricmc.fabric-loom" version "1.15+"
id "maven-publish"
}

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
maven {
name = "Fabric"
Expand All @@ -21,14 +24,13 @@ repositories {
dependencies {
// Main
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
implementation("net.fabricmc:fabric-loader:${project.loader_version}")

// Fabric API
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
implementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

// Plasmid
modImplementation("xyz.nucleoid:plasmid:${project.plasmid_version}")
implementation("xyz.nucleoid:plasmid:${project.plasmid_version}")
}

processResources {
Expand All @@ -40,12 +42,12 @@ processResources {
}

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

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

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

# Versions
minecraft_version = 1.21.4
yarn_mappings = 1.21.4+build.8
loader_version = 0.16.14
fabric_version = 0.119.2+1.21.4
minecraft_version = 26.2
loader_version = 0.19.2
fabric_version = 0.145.2+26.2

plasmid_version = 0.6.3+1.21.4
plasmid_version = 0.7.2-SNAPSHOT+26.2
7 changes: 4 additions & 3 deletions src/main/java/io/github/haykam821/anvildrop/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
import io.github.haykam821.anvildrop.game.AnvilDropConfig;
import io.github.haykam821.anvildrop.game.phase.AnvilDropWaitingPhase;
import net.fabricmc.api.ModInitializer;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import xyz.nucleoid.plasmid.api.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameTypes;

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

private static final Identifier ANVIL_DROP_ID = Main.identifier("anvil_drop");
public static final GameType<AnvilDropConfig> ANVIL_DROP_TYPE = GameType.register(ANVIL_DROP_ID, AnvilDropConfig.CODEC, AnvilDropWaitingPhase::open);
public static final GameType<AnvilDropConfig> ANVIL_DROP_TYPE = GameTypes.register(ANVIL_DROP_ID, AnvilDropConfig.CODEC, AnvilDropWaitingPhase::open);

@Override
public void onInitialize() {
return;
}

public static Identifier identifier(String path) {
return Identifier.of(MOD_ID, path);
return Identifier.fromNamespaceAndPath(MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

import io.github.haykam821.anvildrop.game.map.AnvilDropMapConfig;
import net.minecraft.SharedConstants;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.IntProvider;
import net.minecraft.util.valueproviders.ConstantInt;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.util.valueproviders.IntProviders;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public class AnvilDropConfig {
public static final MapCodec<AnvilDropConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
AnvilDropMapConfig.CODEC.fieldOf("map").forGetter(AnvilDropConfig::getMapConfig),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(AnvilDropConfig::getPlayerConfig),
IntProvider.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantIntProvider.create(SharedConstants.TICKS_PER_SECOND * 5)).forGetter(AnvilDropConfig::getTicksUntilClose),
IntProviders.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantInt.of(SharedConstants.TICKS_PER_SECOND * 5)).forGetter(AnvilDropConfig::getTicksUntilClose),
Codec.INT.optionalFieldOf("delay", 20 * 2).forGetter(AnvilDropConfig::getDelay),
Codec.DOUBLE.optionalFieldOf("chance", 0.4).forGetter(AnvilDropConfig::getChance),
Codec.INT.optionalFieldOf("drop_height", 15).forGetter(AnvilDropConfig::getDropHeight),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
import java.util.Iterator;

import io.github.haykam821.anvildrop.game.AnvilDropConfig;
import net.minecraft.block.AnvilBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.world.level.block.AnvilBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.core.Direction;
import net.minecraft.world.level.chunk.ChunkGenerator;
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.map_templates.MapTemplate;
import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator;
import xyz.nucleoid.plasmid.api.game.level.generator.TemplateChunkGenerator;

public class AnvilDropMap {
private static final BlockState CLEAR_STATE = Blocks.AIR.getDefaultState();
private static final BlockState ANVIL_STATE = Blocks.ANVIL.getDefaultState();
private static final BlockState ALTERNATE_ANVIL_STATE = Blocks.ANVIL.getDefaultState().with(AnvilBlock.FACING, Direction.EAST);
private static final BlockState CLEAR_STATE = Blocks.AIR.defaultBlockState();
private static final BlockState ANVIL_STATE = Blocks.ANVIL.defaultBlockState();
private static final BlockState ALTERNATE_ANVIL_STATE = Blocks.ANVIL.defaultBlockState().setValue(AnvilBlock.FACING, Direction.EAST);

private final MapTemplate template;
private final AnvilDropConfig config;
private final BlockBounds platformBounds;
private final Box box;
private final AABB box;
private final BlockBounds clearBounds;
private final BlockBounds dropBounds;

Expand All @@ -33,7 +33,7 @@ public AnvilDropMap(MapTemplate template, AnvilDropConfig config, BlockBounds pl
this.config = config;

this.platformBounds = platformBounds;
this.box = this.platformBounds.asBox().expand(-1, -0.5, -1);
this.box = this.platformBounds.asBox().inflate(-1, -0.5, -1);

this.clearBounds = clearBounds;
this.dropBounds = dropBounds;
Expand All @@ -43,28 +43,28 @@ public BlockBounds getPlatformBounds() {
return this.platformBounds;
}

public Box getBox() {
public AABB getBox() {
return this.box;
}

public void clearAnvils(ServerWorld world) {
public void clearAnvils(ServerLevel level) {
Iterator<BlockPos> iterator = this.clearBounds.iterator();
while (iterator.hasNext()) {
BlockPos pos = iterator.next();
if (this.config.isBreaking() && !world.isAir(pos)) {
world.breakBlock(pos.withY(0), false);
if (this.config.isBreaking() && !level.isEmptyBlock(pos)) {
level.destroyBlock(pos.atY(0), false);
}
world.setBlockState(pos, CLEAR_STATE);
level.setBlockAndUpdate(pos, CLEAR_STATE);
}
}

public void dropAnvils(ServerWorld world) {
public void dropAnvils(ServerLevel level) {
Iterator<BlockPos> iterator = this.dropBounds.iterator();
while (iterator.hasNext()) {
BlockPos pos = iterator.next();
if (world.getRandom().nextDouble() < this.config.getChance()) {
BlockState state = world.getRandom().nextBoolean() ? ANVIL_STATE : ALTERNATE_ANVIL_STATE;
world.setBlockState(pos, state, 0);
if (level.getRandom().nextDouble() < this.config.getChance()) {
BlockState state = level.getRandom().nextBoolean() ? ANVIL_STATE : ALTERNATE_ANVIL_STATE;
level.setBlock(pos, state, 0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import java.util.Iterator;

import io.github.haykam821.anvildrop.game.AnvilDropConfig;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.map_templates.MapTemplate;

public class AnvilDropMapBuilder {
private static final BlockState FLOOR = Blocks.SMOOTH_STONE.getDefaultState();
private static final BlockState FLOOR_OUTLINE = Blocks.NETHERITE_BLOCK.getDefaultState();
private static final BlockState WALL = Blocks.END_STONE_BRICK_WALL.getDefaultState();
private static final BlockState WALL_TOP = Blocks.BIRCH_SLAB.getDefaultState();
private static final BlockState BARRIER = Blocks.BARRIER.getDefaultState();
private static final BlockState FLOOR = Blocks.SMOOTH_STONE.defaultBlockState();
private static final BlockState FLOOR_OUTLINE = Blocks.NETHERITE_BLOCK.defaultBlockState();
private static final BlockState WALL = Blocks.END_STONE_BRICK_WALL.defaultBlockState();
private static final BlockState WALL_TOP = Blocks.BIRCH_SLAB.defaultBlockState();
private static final BlockState BARRIER = Blocks.BARRIER.defaultBlockState();

private final AnvilDropConfig config;

Expand All @@ -26,7 +26,7 @@ public AnvilDropMap create() {
MapTemplate template = MapTemplate.createEmpty();
AnvilDropMapConfig mapConfig = this.config.getMapConfig();

BlockBounds bounds = BlockBounds.of(BlockPos.ORIGIN, new BlockPos(mapConfig.getX() + 1, this.config.getStackHeight() + 3, mapConfig.getZ() + 1));
BlockBounds bounds = BlockBounds.of(BlockPos.ZERO, new BlockPos(mapConfig.getX() + 1, this.config.getStackHeight() + 3, mapConfig.getZ() + 1));
this.build(bounds, template, mapConfig);

BlockBounds clearBounds = createInnerBounds(mapConfig, this.config.getStackHeight() + 1);
Expand Down
Loading
Loading