Skip to content

Commit

Permalink
update and move back to Forge 1.20.2-48.0.23 (from NeoForge) until it…
Browse files Browse the repository at this point in the history
… is stable

- Temporary deactivation of The One Probe support until it is ported to 1.20.2
- deactivate game tests, because they are not working yet
  • Loading branch information
cech12 committed Oct 26, 2023
1 parent 517fdba commit 1a8d8f7
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 88 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/cicd-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ jobs:
uses: cech12/MinecraftModActions/.github/workflows/build.yml@main
with:
java-version: 17
gametest:
needs: build
name: Game Test
uses: cech12/MinecraftModActions/.github/workflows/gametest.yml@main
with:
java-version: 17
# gametest:
# needs: build
# name: Game Test
# uses: cech12/MinecraftModActions/.github/workflows/gametest.yml@main
# with:
# java-version: 17
codeql:
needs: build
name: CodeQL
uses: cech12/MinecraftModActions/.github/workflows/codeql-analysis.yml@main
with:
java-version: 17
publish-github:
needs: [ gametest, codeql ]
# needs: [ gametest, codeql ]
needs: codeql
if: startsWith(github.ref, 'refs/tags/')
name: Publish Github
uses: cech12/MinecraftModActions/.github/workflows/publish-github.yml@main
Expand All @@ -48,10 +49,9 @@ jobs:
java-version: 17
curseforge-id: 436874
game-versions: |
1.20.1
1.20.2
release-type: release
loaders: |
neoforge
forge
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -65,10 +65,9 @@ jobs:
java-version: 17
modrinth-id: IsSapAeq
game-versions: |
1.20.1
1.20.2
release-type: release
loaders: |
neoforge
forge
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ 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.2-2.2.0.0] - 2023-10-26
### Changed
- update and move back to Forge 1.20.2-48.0.23 (from NeoForge) until it is stable
- Temporary deactivation of The One Probe support until it is ported to 1.20.2
- deactivate game tests, because they are not working yet

## [1.20.1-2.1.0.0] - 2023-08-09
### Changed
- Changed Forge to NeoForge 1.20.1-47.1.54 (compatible with Forge 47.1.0)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0,6.2)'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

version = "${minecraft_version}-${mod_version}"
Expand Down Expand Up @@ -106,15 +106,15 @@ repositories {
}

dependencies {
minecraft "net.neoforged:forge:${project.minecraft_version}-${project.forge_version}"
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"

// compile against the JEI API but do not include it at runtime
compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-common-api:${project.jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-forge:${project.jei_version}")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}-forge:${project.jei_version}")

implementation fg.deobf("mcjty.theoneprobe:theoneprobe:$top_version") {transitive = false}
//implementation fg.deobf("mcjty.theoneprobe:theoneprobe:$top_version") {transitive = false}
}

tasks.named('processResources', ProcessResources).configure {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

## Environment Properties
minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)
forge_version=47.1.54
forge_version_range=[47.1.0,)
loader_version_range=[47,)
minecraft_version=1.20.2
minecraft_version_range=[1.20.2,1.21)
forge_version=48.0.23
forge_version_range=[48.0.23,)
loader_version_range=[48,)

mod_id=solarcooker
mod_version=2.1.0.0
mod_version=2.2.0.0
mod_group_id=cech12.solarcooker
mod_name=Solar Cooker
mod_authors=Cech12
Expand All @@ -21,8 +21,8 @@ mod_issue_tracker=https://github.com/cech12/SolarCooker/issues
mod_description=A mod which adds a Solar Cooker.

# jei
jei_version=15.2.0.23
jei_version_range=[15.2.0.23,)
jei_version=16.0.0.28
jei_version_range=[16.0.0.28,)

#the one probe
top_version=1.20.1-10.0.1-3
Expand Down
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'NeoForge'
url = 'https://maven.neoforged.net'
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cech12/solarcooker/SolarCookerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cech12.solarcooker.client.SolarCookerBlockEntityRenderer;
import cech12.solarcooker.client.SolarCookerScreen;
import cech12.solarcooker.compat.TOPCompat;
//import cech12.solarcooker.compat.TOPCompat;
import cech12.solarcooker.config.ServerConfig;
import cech12.solarcooker.init.ModBlockEntityTypes;
import cech12.solarcooker.init.ModBlocks;
Expand Down Expand Up @@ -49,7 +49,7 @@ public SolarCookerMod() {
ServerConfig.loadConfig(ServerConfig.SERVER_CONFIG, FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath()).resolve(MOD_ID + "-server.toml"));
//The One Probe registration.
if (ModList.get().isLoaded("theoneprobe")) {
TOPCompat.register();
//TOPCompat.register();
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/cech12/solarcooker/block/SolarCookerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.annotation.Nullable;

import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.network.NetworkHooks;

public class SolarCookerBlock extends AbstractSolarCookerBlock {

Expand Down Expand Up @@ -50,7 +49,7 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@Nonnull Level lev
protected void interactWith(Level worldIn, @Nonnull BlockPos pos, @Nonnull Player player) {
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof SolarCookerBlockEntity && player instanceof ServerPlayer) {
NetworkHooks.openScreen((ServerPlayer) player, (SolarCookerBlockEntity) blockEntity, pos);
player.openMenu((SolarCookerBlockEntity) blockEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.inventory.RecipeCraftingHolder;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.LidBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.StackedContentsCompatible;
import net.minecraft.world.inventory.RecipeHolder;
import net.minecraft.world.WorldlyContainer;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -47,7 +49,11 @@
import javax.annotation.Nullable;
import java.util.List;

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

public static final int CONTAINER_IS_SUNLIT = 0;
public static final int CONTAINER_COOK_TIME = 1;
public static final int CONTAINER_COOK_TIME_TOTAL = 2;

private static final int[] SLOTS = new int[]{0, 1};
private static final int[] SLOTS_UP = new int[]{};
Expand Down Expand Up @@ -77,9 +83,35 @@ public AbstractSolarCookerBlockEntity(BlockEntityType<?> tileTypeIn, BlockPos po
this.specificRecipeType = specificRecipeTypeIn;
}

protected AbstractCookingRecipe curRecipe;
protected RecipeHolder<? extends AbstractCookingRecipe> curRecipe;
protected ItemStack failedMatch = ItemStack.EMPTY;

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;
default -> 0;
};
}

public void set(int index, int value) {
switch (index) {
//case CONTAINER_IS_SUNLIT: break; //do nothing
case CONTAINER_COOK_TIME:
AbstractSolarCookerBlockEntity.this.cookTime = value;
break;
case CONTAINER_COOK_TIME_TOTAL:
AbstractSolarCookerBlockEntity.this.cookTimeTotal = value;
}
}

public int getCount() {
return 3;
}
};

private boolean hasShiningBlockAbove() {
if (this.level != null && !this.level.isClientSide) {
BlockPos checkPos = this.worldPosition.above();
Expand Down Expand Up @@ -163,7 +195,7 @@ public static void tick(Level level, BlockPos pos, BlockState state, AbstractSol
entity.calculateLidAngle();
boolean isSunlit = entity.isSunlit();
if (isSunlit && !entity.items.get(INPUT).isEmpty()) {
AbstractCookingRecipe recipe = entity.getRecipe();
RecipeHolder<? extends AbstractCookingRecipe> recipe = entity.getRecipe();
if (entity.canSmelt(recipe)) {
entity.cookTime++;
if (entity.cookTime == entity.cookTimeTotal) {
Expand Down Expand Up @@ -280,9 +312,9 @@ private void playSound(SoundEvent soundIn) {
}
}

protected boolean canSmelt(@Nullable Recipe<?> recipe) {
protected boolean canSmelt(@Nullable RecipeHolder<?> recipe) {
if (!this.items.get(INPUT).isEmpty() && recipe != null) {
ItemStack recipeOutput = ((Recipe<WorldlyContainer>) recipe).assemble(this, this.getLevel().registryAccess());
ItemStack recipeOutput = ((Recipe<WorldlyContainer>) recipe.value()).assemble(this, this.getLevel().registryAccess());
if (!recipeOutput.isEmpty()) {
ItemStack output = this.items.get(OUTPUT);
if (output.isEmpty()) return true;
Expand All @@ -293,10 +325,10 @@ protected boolean canSmelt(@Nullable Recipe<?> recipe) {
return false;
}

private void smeltItem(@Nullable Recipe<?> recipe) {
private void smeltItem(@Nullable RecipeHolder<?> recipe) {
if (recipe != null && this.canSmelt(recipe)) {
ItemStack itemstack = this.items.get(INPUT);
ItemStack itemstack1 = ((Recipe<WorldlyContainer>) recipe).assemble(this, this.getLevel().registryAccess());
ItemStack itemstack1 = ((Recipe<WorldlyContainer>) recipe.value()).assemble(this, this.getLevel().registryAccess());
ItemStack itemstack2 = this.items.get(OUTPUT);
if (itemstack2.isEmpty()) {
this.items.set(1, itemstack1.copy());
Expand All @@ -313,33 +345,33 @@ private void smeltItem(@Nullable Recipe<?> recipe) {
}

protected int getRecipeCookTime() {
AbstractCookingRecipe rec = getRecipe();
RecipeHolder<? extends AbstractCookingRecipe> rec = getRecipe();
if (rec == null) {
return 200;
}
this.checkForReflectors();
double reflectorFactor = (this.reflectorCount > 0) ? 1 - ((1 - ServerConfig.MAX_REFLECTOR_TIME_FACTOR.get()) / 4.0D) * this.reflectorCount : 1;
if (this.specificRecipeType.getClass().isInstance(rec.getType())) {
return (int) (rec.getCookingTime() * reflectorFactor);
if (this.specificRecipeType.getClass().isInstance(rec.value().getType())) {
return (int) (rec.value().getCookingTime() * reflectorFactor);
}
return (int) (rec.getCookingTime() * (ServerConfig.COOK_TIME_FACTOR.get() * reflectorFactor));
return (int) (rec.value().getCookingTime() * (ServerConfig.COOK_TIME_FACTOR.get() * reflectorFactor));
}

@SuppressWarnings("unchecked")
protected AbstractCookingRecipe getRecipe() {
protected RecipeHolder<? extends AbstractCookingRecipe> getRecipe() {
ItemStack input = this.getItem(INPUT);
if (input.isEmpty() || input == failedMatch) {
return null;
}
if (this.level != null && curRecipe != null && curRecipe.matches(this, level)) {
if (this.level != null && curRecipe != null && curRecipe.value().matches(this, level)) {
return curRecipe;
} else {
AbstractCookingRecipe rec = null;
RecipeHolder<? extends AbstractCookingRecipe> rec = null;
if (this.level != null) {
rec = this.level.getRecipeManager().getRecipeFor((RecipeType<AbstractCookingRecipe>) this.specificRecipeType, this, this.level).orElse(null);
if (rec == null && ServerConfig.VANILLA_RECIPES_ENABLED.get()) {
rec = this.level.getRecipeManager().getRecipesFor((RecipeType<AbstractCookingRecipe>) ServerConfig.getRecipeType(), this, this.level)
.stream().filter(abstractCookingRecipe -> ServerConfig.isRecipeNotBlacklisted(abstractCookingRecipe.getId())).findFirst().orElse(null);
.stream().filter(abstractCookingRecipe -> ServerConfig.isRecipeNotBlacklisted(abstractCookingRecipe.id())).findFirst().orElse(null);
}
}
if (rec == null) {
Expand Down Expand Up @@ -493,31 +525,31 @@ public void clearContent() {
}

@Override
public void setRecipeUsed(@Nullable Recipe<?> recipe) {
public void setRecipeUsed(@Nullable RecipeHolder<?> recipe) {
if (recipe != null) {
this.usedRecipes.addTo(recipe.getId(), 1);
this.usedRecipes.addTo(recipe.id(), 1);
}
}

@Override
@Nullable
public Recipe<?> getRecipeUsed() {
public RecipeHolder<?> getRecipeUsed() {
return null;
}

public void awardUsedRecipesAndPopExperience(Player p_235645_1_) {
List<Recipe<?>> list = this.getRecipesToAwardAndPopExperience(p_235645_1_.level(), p_235645_1_.position());
List<RecipeHolder<?>> list = this.getRecipesToAwardAndPopExperience(p_235645_1_.level(), p_235645_1_.position());
p_235645_1_.awardRecipes(list);
this.usedRecipes.clear();
}

public List<Recipe<?>> getRecipesToAwardAndPopExperience(Level p_235640_1_, Vec3 p_235640_2_) {
List<Recipe<?>> list = Lists.newArrayList();
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(Level p_235640_1_, Vec3 p_235640_2_) {
List<RecipeHolder<?>> list = Lists.newArrayList();

for(Object2IntMap.Entry<ResourceLocation> entry : this.usedRecipes.object2IntEntrySet()) {
p_235640_1_.getRecipeManager().byKey(entry.getKey()).ifPresent((p_235642_4_) -> {
list.add(p_235642_4_);
createExperience(p_235640_1_, p_235640_2_, entry.getIntValue(), ((AbstractCookingRecipe)p_235642_4_).getExperience());
p_235640_1_.getRecipeManager().byKey(entry.getKey()).ifPresent((recipeHolder) -> {
list.add(recipeHolder);
createExperience(p_235640_1_, p_235640_2_, entry.getIntValue(), ((AbstractCookingRecipe)recipeHolder.value()).getExperience());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected Component getDefaultName() {
@Override
@Nonnull
protected AbstractContainerMenu createMenu(int id, @Nonnull Inventory player) {
return new SolarCookerContainer(ModRecipeTypes.SOLAR_COOKING.get(), id, player, this);
return new SolarCookerContainer(ModRecipeTypes.SOLAR_COOKING.get(), id, player, this, this.dataAccess);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public void init() {
}

@Override
public void render(@Nonnull GuiGraphics guiGraphics, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
this.renderBackground(guiGraphics);
super.render(guiGraphics, p_230430_2_, p_230430_3_, p_230430_4_);
this.renderTooltip(guiGraphics, p_230430_2_, p_230430_3_);
public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
this.renderTooltip(guiGraphics, mouseX, mouseY);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cech12/solarcooker/compat/TOPCompat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cech12.solarcooker.compat;

/*
import cech12.solarcooker.SolarCookerMod;
import cech12.solarcooker.blockentity.AbstractSolarCookerBlockEntity;
import mcjty.theoneprobe.api.ElementAlignment;
Expand Down Expand Up @@ -60,3 +60,4 @@ public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player play
}
}
}
*/
Loading

0 comments on commit 1a8d8f7

Please sign in to comment.