Skip to content

Commit

Permalink
Initial port to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
PoeticRainbow committed Nov 19, 2024
1 parent 08ab614 commit 51ecc78
Show file tree
Hide file tree
Showing 29 changed files with 356 additions and 380 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ bin/
build/

.classpath
.DS_Store
.DS_Store
/src - Copy/
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id "fabric-loom" version "1.8.12"
id 'maven-publish'
}

Expand Down Expand Up @@ -45,7 +45,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation 'xyz.nucleoid:plasmid:0.5.102-SNAPSHOT+1.20.4'
modImplementation "xyz.nucleoid:plasmid:${project.plasmid_version}"

}

Expand Down
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=1.0.2
mod_version=1.1.0
maven_group=poeticrainbow.lavasurvival
archives_base_name=lavasurvival

# Dependencies
fabric_version=0.97.1+1.20.4
fabric_version=0.108.0+1.21.3
plasmid_version=0.6.0+1.21.3
49 changes: 36 additions & 13 deletions src/main/java/poeticrainbow/lavasurvival/LavaSurvival.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package poeticrainbow.lavasurvival;

import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import eu.pb4.polymer.rsm.api.RegistrySyncUtils;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -19,22 +23,36 @@
import poeticrainbow.lavasurvival.game.LavaSurvivalConfig;
import poeticrainbow.lavasurvival.game.phases.LavaSurvivalWaitingPhase;
import poeticrainbow.lavasurvival.item.BlockMenuItem;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;

public class LavaSurvival implements ModInitializer {
public static final String ID = "lavasurvival";
public static final String MOD_ID = "lavasurvival";
public static final Logger LOGGER = LoggerFactory.getLogger("lavasurvival");

public static final Block INFINITE_LAVA = new InfiniteLavaBlock(AbstractBlock.Settings.create().nonOpaque().solid());
public static final Block INFINITE_LAVA_STILL = new InfiniteLavaBlockStill(AbstractBlock.Settings.create().nonOpaque().solid());
public static final Block BURNING_BLOCK = new BurningBlock(AbstractBlock.Settings.create().solid().ticksRandomly());
public static final RegistryKey<Block> INFINITE_LAVA_KEY = RegistryKey.of(RegistryKeys.BLOCK, id("infinite_lava"));
public static final Block INFINITE_LAVA = register(
new InfiniteLavaBlock(AbstractBlock.Settings.create().nonOpaque().solid().registryKey(INFINITE_LAVA_KEY)),
INFINITE_LAVA_KEY);

public static final Item BLOCK_MENU_ITEM = new BlockMenuItem(new Item.Settings());
public static final RegistryKey<Block> INFINITE_LAVA_STILL_KEY = RegistryKey.of(RegistryKeys.BLOCK, id("infinite_lava_still"));
public static final Block INFINITE_LAVA_STILL = register(new InfiniteLavaBlockStill(
AbstractBlock.Settings.create().nonOpaque().solid().registryKey(INFINITE_LAVA_STILL_KEY)),
INFINITE_LAVA_STILL_KEY);

public static final RegistryKey<Block> BURNING_BLOCK_KEY = RegistryKey.of(RegistryKeys.BLOCK, id("burning_block"));
public static final Block BURNING_BLOCK = register(
new BurningBlock(AbstractBlock.Settings.create().solid().ticksRandomly().registryKey(BURNING_BLOCK_KEY)),
BURNING_BLOCK_KEY);

public static final RegistryKey<Item> BLOCK_MENU_ITEM_KEY = RegistryKey.of(RegistryKeys.ITEM, id("block_menu"));
public static final Item BLOCK_MENU_ITEM = register(
new BlockMenuItem(new Item.Settings().registryKey(BLOCK_MENU_ITEM_KEY)),
BLOCK_MENU_ITEM_KEY);

public static final BlockEntityType<InfiniteLavaBlockEntity> INFINITE_LAVA_BLOCK_ENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
id("infinite_lava_entity"),
BlockEntityType.Builder.create(InfiniteLavaBlockEntity::new, LavaSurvival.INFINITE_LAVA).build(null)
FabricBlockEntityTypeBuilder.create(InfiniteLavaBlockEntity::new, LavaSurvival.INFINITE_LAVA).build(null)
);

public static final GameType<LavaSurvivalConfig> LAVASURVIVAL = GameType.register(
Expand All @@ -43,18 +61,23 @@ public class LavaSurvival implements ModInitializer {
LavaSurvivalWaitingPhase::open);

public static Identifier id(String path) {
return new Identifier(LavaSurvival.ID, path);
return Identifier.of(MOD_ID, path);
}

@Override
public void onInitialize() {
Registry.register(Registries.BLOCK, id("infinite_lava"), INFINITE_LAVA);
Registry.register(Registries.BLOCK, id("infinite_lava_still"), INFINITE_LAVA_STILL);
Registry.register(Registries.BLOCK, id("burning_block"), BURNING_BLOCK);
RegistrySyncUtils.setServerEntry(Registries.BLOCK_ENTITY_TYPE, INFINITE_LAVA_BLOCK_ENTITY);

Registry.register(Registries.ITEM, id("block_menu"), BLOCK_MENU_ITEM);
PolymerBlockUtils.registerBlockEntity(INFINITE_LAVA_BLOCK_ENTITY);
}

RegistrySyncUtils.setServerEntry(Registries.BLOCK_ENTITY_TYPE, INFINITE_LAVA_BLOCK_ENTITY);
public static Block register(Block block, RegistryKey<Block> key) {
Registry.register(Registries.BLOCK, key, block);
return block;
}

public static Item register(Item item, RegistryKey<Item> key) {
Registry.register(Registries.ITEM, key, item);
return item;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

public class LavaSurvivalDataGenerator implements DataGeneratorEntrypoint {
public static class ModBlockTagGenerator extends FabricTagProvider.BlockTagProvider {
public static final TagKey<Block> ONE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, new Identifier("lavasurvival:one_point_blocks"));
public static final TagKey<Block> THREE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, new Identifier("lavasurvival:three_point_blocks"));
public static final TagKey<Block> FIVE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, new Identifier("lavasurvival:five_point_blocks"));
public static final TagKey<Block> ONE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, Identifier.of("lavasurvival:one_point_blocks"));
public static final TagKey<Block> THREE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, Identifier.of("lavasurvival:three_point_blocks"));
public static final TagKey<Block> FIVE_POINT_BLOCKS = TagKey.of(RegistryKeys.BLOCK, Identifier.of("lavasurvival:five_point_blocks"));

public ModBlockTagGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
super(output, completableFuture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import poeticrainbow.lavasurvival.LavaSurvival;
import xyz.nucleoid.packettweaker.PacketContext;

public class BurningBlock extends Block implements PolymerBlock {
public BurningBlock(Settings settings) {
Expand All @@ -21,7 +22,7 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
}

@Override
public Block getPolymerBlock(BlockState state) {
return Blocks.MAGMA_BLOCK;
public BlockState getPolymerBlockState(BlockState blockState, PacketContext packetContext) {
return Blocks.MAGMA_BLOCK.getDefaultState();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import poeticrainbow.lavasurvival.LavaSurvival;
import xyz.nucleoid.packettweaker.PacketContext;

public class InfiniteLavaBlock extends BlockWithEntity implements PolymerBlock {
public InfiniteLavaBlock(Settings settings) {
Expand All @@ -24,11 +26,6 @@ protected MapCodec<? extends BlockWithEntity> getCodec() {
return null;
}

@Override
public Block getPolymerBlock(BlockState state) {
return Blocks.LAVA;
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
Expand All @@ -45,10 +42,15 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, Block
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (entity instanceof ServerPlayerEntity player) {
player.damage(world.getDamageSources().lava(), 4.0f);
player.damage((ServerWorld) world, world.getDamageSources().lava(), 4.0f);
}
if (entity instanceof ItemEntity item) {
item.kill();
item.kill((ServerWorld) world);
}
}

@Override
public BlockState getPolymerBlockState(BlockState blockState, PacketContext packetContext) {
return Blocks.LAVA.getDefaultState();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.world.World;
import poeticrainbow.lavasurvival.LavaSurvival;
import poeticrainbow.lavasurvival.util.LavaSurvivalUtil;
import xyz.nucleoid.plasmid.game.manager.GameSpaceManager;
import xyz.nucleoid.plasmid.api.game.GameSpaceManager;

public class InfiniteLavaBlockEntity extends BlockEntity {
private static int spreadTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.block.WireOrientation;
import org.jetbrains.annotations.Nullable;
import poeticrainbow.lavasurvival.LavaSurvival;
import xyz.nucleoid.packettweaker.PacketContext;

public class InfiniteLavaBlockStill extends Block implements PolymerBlock {
public InfiniteLavaBlockStill(Settings settings) {
super(settings);
}

@Override
public Block getPolymerBlock(BlockState state) {
return Blocks.LAVA;
public BlockState getPolymerBlockState(BlockState blockState, PacketContext packetContext) {
return Blocks.LAVA.getDefaultState();
}

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (entity instanceof ServerPlayerEntity player) {
player.damage(world.getDamageSources().lava(), 4.0f);
player.damage((ServerWorld) world, world.getDamageSources().lava(), 4.0f);
}
}

@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
super.neighborUpdate(state, world, pos, sourceBlock, sourcePos, notify);
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, @Nullable WireOrientation wireOrientation, boolean notify) {
super.neighborUpdate(state, world, pos, sourceBlock, null, notify);
if (sourceBlock != LavaSurvival.INFINITE_LAVA && sourceBlock != LavaSurvival.INFINITE_LAVA_STILL) {
world.setBlockState(pos, LavaSurvival.INFINITE_LAVA.getDefaultState());
}
Expand Down
Loading

0 comments on commit 51ecc78

Please sign in to comment.