Skip to content

Commit

Permalink
add Fabric & Quilt support
Browse files Browse the repository at this point in the history
  • Loading branch information
cech12 committed Apr 27, 2024
1 parent f98511b commit ed31c4b
Show file tree
Hide file tree
Showing 63 changed files with 1,097 additions and 80 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ body:
- Fabric
- Forge
- NeoForge
- Quilt
validations:
required: true
- type: input
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/cicd-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,41 @@ jobs:
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
publish-fabric-on-curseforge:
needs: publish-github
if: startsWith(github.ref, 'refs/tags/')
name: Publish Fabric on Curseforge
uses: cech12/MinecraftModActions/.github/workflows/publish-curseforge.yml@main
with:
java-version: 17
subproject: fabric
title-prefix: fabric-
curseforge-id: 436874
game-versions: |
1.20.4
release-type: release
loaders: |
fabric
quilt
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
publish-fabric-on-modrinth:
needs: publish-github
if: startsWith(github.ref, 'refs/tags/')
name: Publish Fabric on Modrinth
uses: cech12/MinecraftModActions/.github/workflows/publish-modrinth.yml@main
with:
java-version: 17
subproject: fabric
title-prefix: fabric-
modrinth-id: IsSapAeq
game-versions: |
1.20.4
release-type: release
loaders: |
fabric
quilt
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/).

## [1.20.4-3.1.0.0] - 2024-04-27
### Added
- add Fabric (>=0.96.11+1.20.4) support (Fabric, Quilt)

## [1.20.4-3.0.0.0] - 2024-04-08
### Changed
- updated to Minecraft 1.20.4 (Forge 49.0.38, Neoforge 20.4.225)
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
[![License](https://img.shields.io/github/license/cech12/SolarCooker)](http://opensource.org/licenses/MIT)
[![](https://img.shields.io/discord/752506676719910963.svg?style=flat&color=informational&logo=discord&label=Discord)](https://discord.gg/gRUFH5t)

This is a **Minecraft Forge** mod and adds a **Solar Cooker** to the game.
This is a Minecraft mod that adds a **Solar Cooker** to the game. (Forge, NeoForge, Fabric, Quilt)

The Fabric / Quilt version needs the following mods:

- Fabric API ([Github](https://github.com/FabricMC/fabric), [Curseforge](https://www.curseforge.com/minecraft/mc-mods/fabric-api), [Modrinth](https://modrinth.com/mod/fabric-api))
- Cloth Config API ([Github](https://github.com/shedaniel/cloth-config), [Curseforge](https://www.curseforge.com/minecraft/mc-mods/cloth-config), [Modrinth](https://modrinth.com/mod/cloth-config))

![All Furnaces](material/logo.png)

Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ subprojects {
"forge_version": forge_version,
"forge_version_range": forge_version_range,
"forge_loader_version_range": forge_loader_version_range,
//"fabric_version": fabric_version,
//"fabric_loader_version": fabric_loader_version,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"cloth_config_version": cloth_config_version,
"mod_menu_version": mod_menu_version,
"neoforge_version": neoforge_version,
"neoforge_version_range": neoforge_version_range,
"neoforge_loader_version_range": neoforge_loader_version_range,
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/de/cech12/solarcooker/CommonLoader.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.cech12.solarcooker;

import de.cech12.solarcooker.platform.Services;
import net.minecraft.resources.ResourceLocation;

/**
* A static class for all loaders which initializes everything which is used by all loaders.
Expand All @@ -14,6 +15,10 @@ public static void init() {
Services.CONFIG.init();
}

public static ResourceLocation id(String name) {
return new ResourceLocation(Constants.MOD_ID, name);
}

private CommonLoader() {}

}
8 changes: 4 additions & 4 deletions common/src/main/java/de/cech12/solarcooker/Constants.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.cech12.solarcooker;

import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import de.cech12.solarcooker.crafting.SolarCookingRecipe;
import net.minecraft.world.inventory.AbstractContainerMenu;
import de.cech12.solarcooker.inventory.SolarCookerContainer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.RecipeType;
Expand Down Expand Up @@ -37,15 +37,15 @@ public class Constants {
public static Supplier<Block> REFLECTOR_BLOCK;
public static Supplier<Block> SHINING_DIAMOND_BLOCK_BLOCK;

public static Supplier<BlockEntityType<? extends AbstractSolarCookerBlockEntity>> SOLAR_COOKER_ENTITY_TYPE;
public static Supplier<BlockEntityType<? extends SolarCookerBlockEntity>> SOLAR_COOKER_ENTITY_TYPE;

public static Supplier<Item> SOLAR_COOKER_ITEM;
public static Supplier<Item> REFLECTOR_ITEM;
public static Supplier<Item> SHINING_DIAMOND_BLOCK_ITEM;

public static Supplier<RecipeType<SolarCookingRecipe>> SOLAR_COOKING_RECIPE_TYPE;

public static Supplier<MenuType<? extends AbstractContainerMenu>> SOLAR_COOKER_MENU_TYPE;
public static Supplier<MenuType<SolarCookerContainer>> SOLAR_COOKER_MENU_TYPE;

private Constants() {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.cech12.solarcooker.block;

import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
Expand Down Expand Up @@ -73,8 +73,8 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
public void setPlacedBy(@Nonnull Level worldIn, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, ItemStack stack) {
if (stack.hasCustomHoverName()) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof AbstractSolarCookerBlockEntity) {
((AbstractSolarCookerBlockEntity)tileentity).setCustomName(stack.getHoverName());
if (tileentity instanceof SolarCookerBlockEntity) {
((SolarCookerBlockEntity)tileentity).setCustomName(stack.getHoverName());
}
}

Expand All @@ -85,9 +85,9 @@ public void setPlacedBy(@Nonnull Level worldIn, @Nonnull BlockPos pos, @Nonnull
public void onRemove(BlockState state, @Nonnull Level worldIn, @Nonnull BlockPos pos, BlockState newState, boolean isMoving) {
if (!state.is(newState.getBlock())) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof AbstractSolarCookerBlockEntity) {
Containers.dropContents(worldIn, pos, (AbstractSolarCookerBlockEntity)tileentity);
((AbstractSolarCookerBlockEntity)tileentity).getRecipesToAwardAndPopExperience(worldIn, Vec3.atLowerCornerOf(pos));
if (tileentity instanceof SolarCookerBlockEntity) {
Containers.dropContents(worldIn, pos, (SolarCookerBlockEntity)tileentity);
((SolarCookerBlockEntity)tileentity).getRecipesToAwardAndPopExperience(worldIn, Vec3.atLowerCornerOf(pos));
worldIn.updateNeighbourForOutputSignal(pos, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.serialization.MapCodec;
import de.cech12.solarcooker.Constants;
import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import de.cech12.solarcooker.platform.Services;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.BaseEntityBlock;
Expand Down Expand Up @@ -46,7 +46,7 @@ public BlockEntity newBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState sta
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level level, @Nonnull BlockState state, @Nonnull BlockEntityType<T> entityType) {
return createTickerHelper(entityType, Constants.SOLAR_COOKER_ENTITY_TYPE.get(), AbstractSolarCookerBlockEntity::tick);
return createTickerHelper(entityType, Constants.SOLAR_COOKER_ENTITY_TYPE.get(), SolarCookerBlockEntity::tick);
}

/**
Expand All @@ -56,8 +56,8 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level lev
@Override
protected void interactWith(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) {
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof AbstractSolarCookerBlockEntity && player instanceof ServerPlayer) {
player.openMenu((AbstractSolarCookerBlockEntity) blockEntity);
if (blockEntity instanceof SolarCookerBlockEntity && player instanceof ServerPlayer) {
player.openMenu((SolarCookerBlockEntity) blockEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import javax.annotation.Nullable;
import java.util.List;

public abstract class AbstractSolarCookerBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible, LidBlockEntity {
public class SolarCookerBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible, LidBlockEntity {

public static final int CONTAINER_IS_SUNLIT = 0;
public static final int CONTAINER_COOK_TIME = 1;
Expand Down Expand Up @@ -77,13 +77,13 @@ public abstract class AbstractSolarCookerBlockEntity extends BaseContainerBlockE
protected final RecipeType<? extends AbstractCookingRecipe> specificRecipeType;
private final Object2IntOpenHashMap<ResourceLocation> usedRecipes = new Object2IntOpenHashMap<>();

public AbstractSolarCookerBlockEntity(BlockEntityType<?> tileTypeIn, BlockPos pos, BlockState state,
RecipeType<? extends AbstractCookingRecipe> specificRecipeTypeIn) {
public SolarCookerBlockEntity(BlockEntityType<?> tileTypeIn, BlockPos pos, BlockState state,
RecipeType<? extends AbstractCookingRecipe> specificRecipeTypeIn) {
super(tileTypeIn, pos, state);
this.specificRecipeType = specificRecipeTypeIn;
}

public AbstractSolarCookerBlockEntity(BlockPos pos, BlockState state) {
public SolarCookerBlockEntity(BlockPos pos, BlockState state) {
this(Constants.SOLAR_COOKER_ENTITY_TYPE.get(), pos, state, Constants.SOLAR_COOKING_RECIPE_TYPE.get());
}

Expand All @@ -93,9 +93,9 @@ public AbstractSolarCookerBlockEntity(BlockPos pos, BlockState state) {
protected final ContainerData dataAccess = new ContainerData() {
public int get(int index) {
return switch (index) {
case CONTAINER_IS_SUNLIT -> AbstractSolarCookerBlockEntity.this.isSunlit() ? 1 : 0;
case CONTAINER_COOK_TIME -> AbstractSolarCookerBlockEntity.this.cookTime;
case CONTAINER_COOK_TIME_TOTAL -> AbstractSolarCookerBlockEntity.this.cookTimeTotal;
case CONTAINER_IS_SUNLIT -> SolarCookerBlockEntity.this.isSunlit() ? 1 : 0;
case CONTAINER_COOK_TIME -> SolarCookerBlockEntity.this.cookTime;
case CONTAINER_COOK_TIME_TOTAL -> SolarCookerBlockEntity.this.cookTimeTotal;
default -> 0;
};
}
Expand All @@ -104,10 +104,10 @@ public void set(int index, int value) {
switch (index) {
//case CONTAINER_IS_SUNLIT: break; //do nothing
case CONTAINER_COOK_TIME:
AbstractSolarCookerBlockEntity.this.cookTime = value;
SolarCookerBlockEntity.this.cookTime = value;
break;
case CONTAINER_COOK_TIME_TOTAL:
AbstractSolarCookerBlockEntity.this.cookTimeTotal = value;
SolarCookerBlockEntity.this.cookTimeTotal = value;
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public boolean isSunlit() {
&& this.level.canSeeSky(this.worldPosition.above()));
} else {
//world.isDaytime() returns always true on client side
return AbstractSolarCookerBlockEntity.this.getBlockState().getValue(SolarCookerBlock.SUNLIT);
return SolarCookerBlockEntity.this.getBlockState().getValue(SolarCookerBlock.SUNLIT);
}
}
return false;
Expand Down Expand Up @@ -205,7 +205,7 @@ public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
this.load(pkt.getTag());
}

public static void tick(Level level, BlockPos pos, BlockState state, AbstractSolarCookerBlockEntity entity) {
public static void tick(Level level, BlockPos pos, BlockState state, SolarCookerBlockEntity entity) {
if (level != null) {
boolean dirty = false;
entity.calculateLidAngle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.cech12.solarcooker.Constants;
import de.cech12.solarcooker.block.AbstractSolarCookerBlock;
import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
Expand All @@ -29,7 +29,7 @@

import javax.annotation.Nonnull;

public class SolarCookerBlockEntityRenderer implements BlockEntityRenderer<AbstractSolarCookerBlockEntity> {
public class SolarCookerBlockEntityRenderer implements BlockEntityRenderer<SolarCookerBlockEntity> {

public static final ResourceLocation TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/entity/solar_cooker.png");

Expand All @@ -56,7 +56,7 @@ public SolarCookerBlockEntityRenderer(BlockEntityRendererProvider.Context render
}

@Override
public void render(AbstractSolarCookerBlockEntity blockEntity, float partialTicks, @Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
public void render(SolarCookerBlockEntity blockEntity, float partialTicks, @Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
Level world = blockEntity.getLevel();
boolean isInWorld = world != null;
BlockState blockstate = isInWorld ? blockEntity.getBlockState() : Constants.SOLAR_COOKER_BLOCK.get().defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.cech12.solarcooker.inventory;

import de.cech12.solarcooker.Constants;
import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import de.cech12.solarcooker.platform.Services;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -134,16 +134,16 @@ public void removed(@Nonnull Player playerIn) {
}

public int getCookProgressionScaled() {
int i = this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME);
int j = this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME_TOTAL);
int i = this.data.get(SolarCookerBlockEntity.CONTAINER_COOK_TIME);
int j = this.data.get(SolarCookerBlockEntity.CONTAINER_COOK_TIME_TOTAL);
return j != 0 && i != 0 ? i * 24 / j : 0;
}

public boolean isBurning() {
return this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_COOK_TIME) > 0;
return this.data.get(SolarCookerBlockEntity.CONTAINER_COOK_TIME) > 0;
}

public boolean isSunlit() {
return this.data.get(AbstractSolarCookerBlockEntity.CONTAINER_IS_SUNLIT) > 0;
return this.data.get(SolarCookerBlockEntity.CONTAINER_IS_SUNLIT) > 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.cech12.solarcooker.inventory;

import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.FurnaceResultSlot;
Expand All @@ -19,8 +19,8 @@ public SolarCookerResultSlot(Player player, Container inventoryIn, int slotIndex
@Override
protected void checkTakeAchievements(@Nonnull ItemStack stack) {
super.checkTakeAchievements(stack);
if (!this.player.level().isClientSide && this.container instanceof AbstractSolarCookerBlockEntity) {
((AbstractSolarCookerBlockEntity)this.container).awardUsedRecipesAndPopExperience(this.player);
if (!this.player.level().isClientSide && this.container instanceof SolarCookerBlockEntity) {
((SolarCookerBlockEntity)this.container).awardUsedRecipesAndPopExperience(this.player);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface IConfigHelper {
/** Default value of the recipe blocked list option */
String RECIPE_BLOCKED_LIST_DEFAULT = "";
/** Config description of the recipe blocked list option */
String RECIPE_BLOCKED_LIST_DESCRIPTION = "A comma separated list of all vanilla recipes that should not be used by the brick furnaces. Example: \"baked_potato,baked_potato_from_smoking,othermod:other_baked_food\"";
String RECIPE_BLOCKED_LIST_DESCRIPTION = "A comma separated list of all vanilla recipes that should not be used by the solar cooker. Example: \"baked_potato,baked_potato_from_smoking,othermod:other_baked_food\"";

/**
* Initialization method for the Service implementations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.cech12.solarcooker.platform.services;

import de.cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import de.cech12.solarcooker.blockentity.SolarCookerBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;

Expand All @@ -11,6 +11,6 @@
*/
public interface IRegistryHelper {

AbstractSolarCookerBlockEntity getNewBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state);
SolarCookerBlockEntity getNewBlockEntity(@Nonnull BlockPos pos, @Nonnull BlockState state);

}
Loading

0 comments on commit ed31c4b

Please sign in to comment.