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

Clean Up Codebase and Start Boulders #1

Open
wants to merge 5 commits into
base: testing
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {

// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.
// Quilted Fabric API will automatically pull in the correct QSL version.
modImplementation libs.qsl
modImplementation libs.quilted.fabric.api
// modImplementation libs.bundles.quilted.fabric.api // If you wish to use Fabric API's deprecated modules, you can replace the above line with this one
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 1.0.0+1.19
version = 1.0.0+1.19.1
maven_group = io.github.debuggyteam
archives_base_name = wonders

Expand Down
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[versions]
# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.19"
quilt_mappings = "1.19+build.1"
quilt_loader = "0.17.1-beta.6"
minecraft = "1.19.1"
quilt_mappings = "1.19.1+build.2"
quilt_loader = "0.17.2-beta.2"

quilted_fabric_api = "2.0.0-beta.8+0.57.0-1.19"
qsl = "3.0.0-beta.3+1.19.1"
quilted_fabric_api = "4.0.0-beta.1+0.58.5-1.19.1"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand All @@ -13,6 +14,7 @@ quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loade

quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" }
quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" }
qsl = { module = "org.quiltmc:qsl", version.ref = "qsl"}

# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
Expand Down
33 changes: 5 additions & 28 deletions src/main/java/io/github/debuggyteam/wonders/Wonders.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@

import io.github.debuggyteam.wonders.block.WondersBlocks;
import io.github.debuggyteam.wonders.item.WondersItems;
import io.github.debuggyteam.wonders.util.WondersUtils;
import io.github.debuggyteam.wonders.world.biomes.WondersBiomes;
import io.github.debuggyteam.wonders.world.gen.feature.custom.CustomBoulder;
import net.minecraft.block.Blocks;
import io.github.debuggyteam.wonders.world.gen.feature.WondersFeatures;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Holder;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.Heightmap;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;
import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.item.group.api.QuiltItemGroup;
Expand All @@ -35,30 +24,18 @@ public class Wonders implements ModInitializer {
Made by Joost
*/
private static final String MOD_ID = "wonders";
public static final ItemGroup GROUP = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build();

public static Identifier ID(String name) {
return new Identifier(MOD_ID, name);
}

public static final ItemGroup itemGroup = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build();

private static final Feature<CustomBoulder.BoulderConfig> BOULDER = new CustomBoulder(CustomBoulder.BoulderConfig.CODEC);
public static final ConfiguredFeature<?, ?> ROCK = BOULDER.configure(new CustomBoulder.BoulderConfig(ConstantIntProvider.create(15),
new SimpleBlockStateProvider(Blocks.STONE.getDefaultState())))
.decorate(Decorator.HEIGHTMAP.configure(new HeightmapDecoratorConfig(Heightmap.Type.OCEAN_FLOOR_WG)))
.spreadHorizontally()
.applyChance(5);



@Override
public void onInitialize(ModContainer mod) {

Registry.register(Registry.FEATURE, new Identifier("wonders", "rock"), ROCK);
WondersItems.init();
WondersBlocks.init();
WondersBiomes.registerWondersBiomes();
WondersItems.init();

WondersUtils.registerUtils();
WondersBiomes.init();

LOGGER.info("Everything loaded from: {}!", mod.metadata().name());
}
Expand Down
117 changes: 78 additions & 39 deletions src/main/java/io/github/debuggyteam/wonders/block/WondersBlocks.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,100 @@
package io.github.debuggyteam.wonders.block;

import io.github.debuggyteam.wonders.util.WondersRegistry;
import io.github.debuggyteam.wonders.Wonders;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.registry.Registry;
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;

import java.util.HashMap;
import java.util.Map;

public class WondersBlocks {
/**
* Used to hold Blocks (type {@code Block}) and their names (type {@code String})
* </br></br>
* Used by both {@code WondersBlocks} and {@code WondersItems} to allow for automatic creation of block items per-block.
* @see io.github.debuggyteam.wonders.item.WondersItems#init
*/
public static final Map<String, Block> BLOCKS = new HashMap<>();
/*
Made by Joost
*/
public static final Block TEST_BLOCK = WondersRegistry.registerBlock("test_block", createBlock(Material.WOOD, 2.0f));

// Palm tree logs
public static final Block PALM_LOG = WondersRegistry.registerBlock("palm_log", new PillarBlock(
QuiltBlockSettings.copy(Blocks.OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
public static final Block TEST_BLOCK = blockWithSettingsOf(Material.WOOD, 2.0f);

public static final Block PALM_WOOD = WondersRegistry.registerBlock("palm_wood", new PillarBlock(
QuiltBlockSettings.copy(Blocks.OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
// Palm wood and crew
public static final Block PALM_LOG = new PillarBlock(QuiltBlockSettings.copy(Blocks.OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final Block PALM_WOOD = new PillarBlock(QuiltBlockSettings.copy(Blocks.OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final Block STRIPPED_PALM_LOG = new PillarBlock(QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final Block STRIPPED_PALM_WOOD = new PillarBlock(QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final Block PALM_PLANKS = new Block(QuiltBlockSettings.copy(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final StairsBlock PALM_STAIRS = new StairsBlock(Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_STAIRS).sounds(BlockSoundGroup.WOOD).strength(2.0f));
//TODO: add a Palm Fence Gate
public static final FenceBlock PALM_FENCE = new FenceBlock(QuiltBlockSettings.copy(Blocks.OAK_FENCE).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final SlabBlock PALM_SLAB = new SlabBlock(QuiltBlockSettings.copy(Blocks.OAK_SLAB).sounds(BlockSoundGroup.WOOD).strength(2.0f));
public static final TrapdoorBlock PALM_TRAPDOOR = new TrapdoorBlock(QuiltBlockSettings.copy(Blocks.OAK_TRAPDOOR).sounds(BlockSoundGroup.WOOD).strength(2.0f));

public static final Block STRIPPED_PALM_LOG = WondersRegistry.registerBlock("stripped_palm_log", new PillarBlock(
QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
static {
BLOCKS.put("test_block", TEST_BLOCK);
BLOCKS.put("palm_log", PALM_LOG);
BLOCKS.put("palm_wood", PALM_WOOD);
BLOCKS.put("stripped_palm_log", STRIPPED_PALM_LOG);
BLOCKS.put("stripped_palm_wood", STRIPPED_PALM_WOOD);
BLOCKS.put("palm_planks", PALM_PLANKS);
BLOCKS.put("palm_stairs", PALM_STAIRS);
BLOCKS.put("palm_fence", PALM_FENCE);
BLOCKS.put("palm_slab", PALM_SLAB);
BLOCKS.put("palm_trapdoor", PALM_TRAPDOOR);
}
//TODO: palm sign?
//public static final SignBlock PALM_SIGN = WondersRegistry.registerBlock("palm_sign", new SignBlock(
// Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_SIGN).sounds(BlockSoundGroup.WOOD).strength(2.0f)
//));

public static final Block STRIPPED_PALM_WOOD = WondersRegistry.registerBlock("stripped_palm_wood", new PillarBlock(
QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
/**
* To be used for creating a block with just the settings of a {@code Material}
* @param material - the material to use for the block
* @param strength - float value of strength
* @see QuiltBlockSettings#of
* @see Material
*/
private static Block blockWithSettingsOf(Material material, Float strength){
return new Block(QuiltBlockSettings.of(material).strength(strength));
}

// Palm tree planks
public static final Block PALM_PLANKS = WondersRegistry.registerBlock("palm_planks", new Block(
QuiltBlockSettings.copy(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
public static void init(){
//simple, innit?
BLOCKS.forEach((String name, Block block) -> Registry.register(Registry.BLOCK, Wonders.ID(name), block));

public static final StairsBlock PALM_STAIRS = (StairsBlock) WondersRegistry.registerBlock("palm_stairs", new StairsBlock(
Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_STAIRS).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
//TODO this has got to go soon. Use Tags and REAs.
registerStrippableBlocks();
registerFlammables();
registerFuels();
}

public static final FenceBlock PALM_FENCE = (FenceBlock) WondersRegistry.registerBlock("palm_fence", new FenceBlock(
QuiltBlockSettings.copy(Blocks.OAK_FENCE).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
private static void registerStrippableBlocks(){
StrippableBlockRegistry.register(PALM_LOG, STRIPPED_PALM_LOG);
StrippableBlockRegistry.register(PALM_WOOD, STRIPPED_PALM_WOOD);
}

public static final SlabBlock PALM_SLAB = (SlabBlock) WondersRegistry.registerBlock("palm_slab", new SlabBlock(
QuiltBlockSettings.copy(Blocks.OAK_SLAB).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
private static void registerFuels() {
FuelRegistry registry = FuelRegistry.INSTANCE;

public static final TrapdoorBlock PALM_TRAPDOOR = (TrapdoorBlock) WondersRegistry.registerBlock("palm_trapdoor", new TrapdoorBlock(
QuiltBlockSettings.copy(Blocks.OAK_TRAPDOOR).sounds(BlockSoundGroup.WOOD).strength(2.0f)
));
registry.add(PALM_LOG, 300);
registry.add(PALM_WOOD, 300);
registry.add(STRIPPED_PALM_LOG, 300);
registry.add(STRIPPED_PALM_WOOD, 300);
}

//public static final SignBlock PALM_SIGN = WondersRegistry.registerBlock("palm_sign", new SignBlock(
// Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_SIGN).sounds(BlockSoundGroup.WOOD).strength(2.0f)
//));
private static void registerFlammables() {
FlammableBlockRegistry flammableBocks = FlammableBlockRegistry.getDefaultInstance();

private static Block createBlock(Material material, Float strength){
return new Block(QuiltBlockSettings.of(material).strength(strength));
flammableBocks.add(PALM_LOG, 5, 5);
flammableBocks.add(PALM_WOOD, 5, 5);
flammableBocks.add(STRIPPED_PALM_LOG, 5, 5);
flammableBocks.add(STRIPPED_PALM_WOOD, 5, 5);
}

public static void init(){}
}
31 changes: 14 additions & 17 deletions src/main/java/io/github/debuggyteam/wonders/item/WondersItems.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package io.github.debuggyteam.wonders.item;

import io.github.debuggyteam.wonders.Wonders;
import io.github.debuggyteam.wonders.block.WondersBlocks;
import io.github.debuggyteam.wonders.util.WondersRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.registry.Registry;


public class WondersItems {
// registering items
public static Item TEST = WondersRegistry.registerItem("test");
public static Item TEST = new Item(new Item.Settings().group(Wonders.GROUP));

// registering block items
public static Item TEST_BLOCK = WondersRegistry.registerBlockItem("test_block", WondersBlocks.TEST_BLOCK);
public static void init(){
//dynamically register a new block item for every block.
WondersBlocks.BLOCKS.forEach((String name, Block block) -> register(new BlockItem(block, new Item.Settings().group(Wonders.GROUP)), name));

// Palm logs
public static Item PALM_LOG = WondersRegistry.registerBlockItem("palm_log", WondersBlocks.PALM_LOG);
public static Item PALM_WOOD = WondersRegistry.registerBlockItem("palm_wood", WondersBlocks.PALM_WOOD);
public static Item STRIPPED_PALM_LOG = WondersRegistry.registerBlockItem("stripped_palm_log", WondersBlocks.STRIPPED_PALM_LOG);
public static Item STRIPPED_PALM_WOOD = WondersRegistry.registerBlockItem("stripped_palm_wood", WondersBlocks.STRIPPED_PALM_WOOD);
//regular Items
register(TEST, "test_item");
}

// Palm planks
public static Item PALM_PLANKS = WondersRegistry.registerBlockItem("palm_planks", WondersBlocks.PALM_PLANKS);
public static Item PALM_STAIRS = WondersRegistry.registerBlockItem("palm_stairs", WondersBlocks.PALM_STAIRS);
public static Item PALM_FENCE = WondersRegistry.registerBlockItem("palm_fence", WondersBlocks.PALM_FENCE);
public static Item PALM_SLAB = WondersRegistry.registerBlockItem("palm_slab", WondersBlocks.PALM_SLAB);
public static Item PALM_TRAPDOOR = WondersRegistry.registerBlockItem("palm_trapdoor", WondersBlocks.PALM_TRAPDOOR);

public static void init(){}
private static <T extends Item> void register(T item, String name) {
Registry.register(Registry.ITEM, Wonders.ID(name), item);
}
}

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
package io.github.debuggyteam.wonders.util;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this file still exists?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking the stuff that used to exist in the utils file got moved or will have a different implementation. Currently this is what exists in the main repo: https://github.com/DebuggyTeam/wonders/blob/1.19/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, however in that case shouldn't it just be yeeted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, I'll ask snooze about it on the dev chat since snooze was the one who made the PR.


import io.github.debuggyteam.wonders.block.WondersBlocks;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;

public class WondersUtils {

public static void registerUtils() {
registerFuels();
registerStrippableBlocks();
registerFlammables();
}

private static void registerFuels() {
FuelRegistry registry = FuelRegistry.INSTANCE;

registry.add(WondersBlocks.PALM_LOG, 300);
registry.add(WondersBlocks.PALM_WOOD, 300);
registry.add(WondersBlocks.STRIPPED_PALM_LOG, 300);
registry.add(WondersBlocks.STRIPPED_PALM_WOOD, 300);
}

private static void registerStrippableBlocks(){
StrippableBlockRegistry.register(WondersBlocks.PALM_LOG, WondersBlocks.STRIPPED_PALM_LOG);
StrippableBlockRegistry.register(WondersBlocks.PALM_WOOD, WondersBlocks.STRIPPED_PALM_WOOD);
}

private static void registerFlammables() {
FlammableBlockRegistry flammableBocks = FlammableBlockRegistry.getDefaultInstance();

flammableBocks.add(WondersBlocks.PALM_LOG, 5, 5);
flammableBocks.add(WondersBlocks.PALM_WOOD, 5, 5);
flammableBocks.add(WondersBlocks.STRIPPED_PALM_LOG, 5, 5);
flammableBocks.add(WondersBlocks.STRIPPED_PALM_WOOD, 5, 5);
}
}
Loading