Skip to content

Commit

Permalink
update to 1.20.1 except this isn't publish-ready
Browse files Browse the repository at this point in the history
  • Loading branch information
woodiertexas committed Aug 31, 2023
1 parent f1454a1 commit 50fa57e
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 130 deletions.
17 changes: 13 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}

// All the dependencies are declared at gradle/libs.version.toml and referenced with "libs.<id>"
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies {
minecraft libs.minecraft
mappings loom.layered {
addLayer quiltMappings.mappings("org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:v2")
// officialMojangMappings() // Uncomment if you want to use Mojang mappings as your primary mappings, falling back on QM for parameters and Javadocs
}
mappings variantOf(libs.quilt.mappings) { classifier 'intermediary-v2' }
modImplementation libs.quilt.loader

// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.
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 = 2.0.1+1.19
version = 2.1.0+1.19
maven_group = io.github.woodiertexas
archives_base_name = chocolate_bar

Expand Down
16 changes: 5 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
[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.1"

quilted_fabric_api = "2.0.0-alpha.3+0.55.3-1.19"
minecraft = "1.20.1"
quilt_mappings = "1.20.1+build.23"
quilt_loader = "0.20.1"
quilted_fabric_api = "7.1.2+0.87.0-1.20.1"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" }
quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" }

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" }

# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
quilted_fabric_api = ["quilted_fabric_api", "quilted_fabric_api_deprecated"]

[plugins]
quilt_loom = { id = "org.quiltmc.loom", version = "0.12.+" }
quilt_loom = { id = "org.quiltmc.loom", version = "1.0.+" }
minotaur = { id = "com.modrinth.minotaur", version = "2.+" }
111 changes: 69 additions & 42 deletions src/main/java/io/github/woodiertexas/chocolate_bar/ChocolateBar.java
Original file line number Diff line number Diff line change
@@ -1,71 +1,98 @@
package io.github.woodiertexas.chocolate_bar;

import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.item.BucketItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
import net.minecraft.util.registry.Registry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.loader.api.QuiltLoader;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;
import org.quiltmc.qsl.recipe.api.RecipeManagerHelper;
import org.quiltmc.qsl.recipe.api.builder.VanillaRecipeBuilders;

public class ChocolateBar implements ModInitializer {
//Making a logger
public static final Logger LOGGER = LogManager.getLogger("ExampleMod");
public static final Logger LOGGER = LogManager.getLogger("Chocolate Bar");
public static final String MODID = "chocolate_bar";

/*
Creating items/blocks/etc and defining their properties
*/
public static final Item QUILTY_WRAPPING_PAPER = new Item(new QuiltItemSettings().group(ItemGroup.MISC).rarity(Rarity.UNCOMMON));
public static final Item TOOLCHAIN_WRAPPING_PAPER = new Item(new QuiltItemSettings().group(ItemGroup.MISC).rarity(Rarity.UNCOMMON));
public static Block CHOCOLATE;
public static FlowableFluid STILL_CHOCOLATE;
public static FlowableFluid FLOWING_CHOCOLATE;
public static Item CHOCOLATE_BUCKET;

//This code for a food item is so big it had to be put on multiple lines.
public static final ChocolateBarItem CHOCOLATE_BAR = new ChocolateBarItem(
new QuiltItemSettings()
.group(ItemGroup.FOOD).food(
new FoodComponent.Builder()
.hunger(1)
.saturationModifier(0)
.alwaysEdible()
.snack()
.statusEffect(
new StatusEffectInstance(StatusEffects.JUMP_BOOST, 600), 0.15f).build()
)
);
// Creating items/blocks/etc and defining their properties
public static final ChocolateBarItem CHOCOLATE_BAR = new ChocolateBarItem(
new QuiltItemSettings().food(
new FoodComponent.Builder()
.hunger(1)
.saturationModifier(0)
.alwaysEdible()
.snack()
.statusEffect(
new StatusEffectInstance(StatusEffects.JUMP_BOOST, 600, 1), 0.15f).build()
)
);

public static final ChocolateBarItem CHOCOLATE_BAR_ZOOMIES = new ChocolateBarItem(
new QuiltItemSettings().food(
new FoodComponent.Builder()
.hunger(1)
.saturationModifier(0)
.alwaysEdible()
.snack()
.statusEffect(
new StatusEffectInstance(StatusEffects.SPEED, 600, 4), 0.15f).build()
)
);

@Override
public void onInitialize(ModContainer mod) {
LOGGER.info( "Chocolate Bar is ready to go on v{}!", mod.metadata().version().raw() );

/*
Every block, item, entity, and biome must sign their registration papers.
All registration papers must be turned into the ModInitializer in the @Override Building
In all seriousness, the following code registers any item, block, entity, or biome added by the mod.
*/
//Registry.register(Registries.ITEM, new Identifier("chocolate_bar", "quilty_wrapping_paper"), QUILTY_WRAPPING_PAPER);
//Registry.register(Registries.ITEM, new Identifier("chocolate_bar", "toolchain_wrapping_paper"), TOOLCHAIN_WRAPPING_PAPER);

Registry.register(Registry.ITEM, new Identifier("chocolate_bar", "chocolate_bar"), CHOCOLATE_BAR);
Registry.register(Registry.ITEM, new Identifier("chocolate_bar", "quilty_wrapping_paper"), QUILTY_WRAPPING_PAPER);
Registry.register(Registry.ITEM, new Identifier("chocolate_bar", "toolchain_wrapping_paper"), TOOLCHAIN_WRAPPING_PAPER);
Registry.register(Registries.ITEM, new Identifier(MODID, "chocolate_bar"), CHOCOLATE_BAR);
Registry.register(Registries.ITEM, new Identifier(MODID, "chocolate_bar_zoomies"), CHOCOLATE_BAR_ZOOMIES);

/*
This automatically loads up a datapack.
In this case it's a modified chocolate bar recipe if Create is present.
*/
STILL_CHOCOLATE = Registry.register(Registries.FLUID, new Identifier(MODID, "still_chocolate"), new ChocolateFluid.Still());
FLOWING_CHOCOLATE = Registry.register(Registries.FLUID, new Identifier(MODID, "flowing_chocolate"), new ChocolateFluid.Flowing());
CHOCOLATE_BUCKET = Registry.register(Registries.ITEM, new Identifier(MODID, "chocolate_bucket"),
new BucketItem(STILL_CHOCOLATE, new Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1)));

CHOCOLATE = Registry.register(Registries.BLOCK, new Identifier(MODID, "chocolate"), new FluidBlock(STILL_CHOCOLATE, QuiltBlockSettings.copy(Blocks.WATER)){});

ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINKS).register(entries -> entries.addItem(CHOCOLATE_BAR));
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINKS).register(entries -> entries.addItem(CHOCOLATE_BAR_ZOOMIES));
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINKS).register(entries -> entries.addItem(CHOCOLATE_BUCKET));

if (QuiltLoader.isModLoaded("create")); {
ResourceLoader.registerBuiltinResourcePack(
new Identifier("chocolate_bar", "create_compat"),
QuiltLoader.getModContainer("chocolate_bar").get(),
org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType.DEFAULT_ENABLED
);
}
// Registers the recipe for Chocolate Bar
RecipeManagerHelper.registerStaticRecipe(
VanillaRecipeBuilders.shapedRecipe("CMS")
.output(new ItemStack(CHOCOLATE_BAR))
.ingredient('C', Items.COCOA_BEANS)
.ingredient('M', Items.MILK_BUCKET)
.ingredient('S', Items.SUGAR)
.build(new Identifier(MODID, "chocolate_bar"), "")
);
LOGGER.info("Recipes are done generating. Have fun with Chocolate Bar! :)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public ChocolateBarItem(Settings settings) {
*/
@Override
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext options) {
//in '.styled()'; style is lamba'd to the 'style.withColor()' method to color the toolip.
// in '.styled()'; style is lamba'd to the 'style.withColor()' method to color the toolip.
MutableText lore = Text.literal("Potato chocolate?").styled(style -> style.withColor(0xB79268));

//This just finalizes the tooltip adding. That's quite literally all this does.
// This just finalizes the tooltip adding. That's quite literally all this does.
tooltip.add(lore);
}

Expand Down
114 changes: 114 additions & 0 deletions src/main/java/io/github/woodiertexas/chocolate_bar/ChocolateFluid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package io.github.woodiertexas.chocolate_bar;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.Item;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

import static io.github.woodiertexas.chocolate_bar.ChocolateBar.CHOCOLATE;

public abstract class ChocolateFluid extends FlowableFluid {
@Override
public Fluid getFlowing() {
return ChocolateBar.FLOWING_CHOCOLATE;
}

@Override
public Fluid getStill() {
return ChocolateBar.STILL_CHOCOLATE;
}

@Override
public Item getBucketItem() {
return ChocolateBar.CHOCOLATE_BUCKET;
}

@Override
protected boolean isInfinite(World world) {
return false;
}

@Override
protected void beforeBreakingBlock(WorldAccess world, BlockPos pos, BlockState state) {
final BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
Block.dropStacks(state, world, pos, blockEntity);
}

@Override
protected int getFlowSpeed(WorldView world) {
return 3;
}

@Override
protected int getLevelDecreasePerBlock(WorldView world) {
return 2;
}

@Override
protected boolean canBeReplacedWith(FluidState state, BlockView world, BlockPos pos, Fluid fluid, Direction direction) {
return false;
}

@Override
public int getTickRate(WorldView world) {
return 5;
}

@Override
protected float getBlastResistance() {
return 100f;
}

@Override
public boolean isSource(FluidState state) {
return false;
}

@Override
public int getLevel(FluidState state) {
return 8;
}

public BlockState toBlockState(FluidState state) {
return CHOCOLATE.getDefaultState().with(Properties.LEVEL_15, getBlockStateLevel(state));
}

public static class Flowing extends ChocolateFluid {
@Override
protected void appendProperties(StateManager.Builder<Fluid, FluidState> builder) {
super.appendProperties(builder);
builder.add(LEVEL);
}

@Override
public int getLevel(FluidState fluidState) {
return fluidState.get(LEVEL);
}

public boolean isStill(FluidState fluidState) {
return false;
}
}

public static class Still extends ChocolateFluid {
@Override
public int getLevel(FluidState fluidState) {
return 8;
}

public boolean isStill(FluidState fluidState) {
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "chocolate_bar:block/chocolate"
}
}
}
19 changes: 0 additions & 19 deletions src/main/resources/data/chocolate_bar/recipes/chocolate_bar.json

This file was deleted.

This file was deleted.

Loading

0 comments on commit 50fa57e

Please sign in to comment.