Skip to content

Commit

Permalink
port to 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Jun 16, 2023
1 parent bf0be9b commit a260981
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 62 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "fabric-loom" version "1.1.10"
id "io.github.juuxel.loom-quiltflower" version "1.7.3"
id "fabric-loom" version "1.2.4"
id "io.github.juuxel.loom-quiltflower" version "1.10.0"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "java-library"
id "maven-publish"
Expand Down Expand Up @@ -34,7 +34,7 @@ dependencies {
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")

// emi - recipe viewer
modImplementation("dev.emi:emi:${emi_version}") { transitive = false }
modImplementation("dev.emi:emi-fabric:${emi_version}") { transitive = false }

// dependencies for config
shadow("com.electronwill.night-config:core:${project.night_config_version}")
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx1G

# fabric properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.4
quilt_mappings=3
loader_version=0.14.14
minecraft_version=1.20.1
quilt_mappings=1
loader_version=0.14.21

# mod properties
java_version = 17
mod_version = 2.1.1+mc1.19.4
mod_version = 2.1.1+mc1.20.1
maven_group = io.ix0rai.bodacious_berries
archives_base_name = bodacious_berries

# mod dependencies
fabric_api_version=0.76.0+1.19.4
emi_version=0.7.0+1.19.3
spruceui_version=4.2.0+1.19.4
mod_menu_version=6.1.0-rc.1
fabric_api_version=0.83.1+1.20.1
emi_version=1.0.3+1.20
spruceui_version=5.0.0+1.20
mod_menu_version=7.0.0

# other dependencies
night_config_version=3.6.6
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 4 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.ix0rai.bodacious_berries.block.entity;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand All @@ -15,20 +15,19 @@ public BerryHarvesterScreen(BerryHarvesterScreenHandler handler, PlayerInventory
}

@Override
protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) {
protected void drawBackground(GuiGraphics graphics, float delta, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE);
int x = (width - backgroundWidth) / 2;
int y = (height - backgroundHeight) / 2;
drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight);
graphics.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight);
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
drawMouseoverTooltip(matrices, mouseX, mouseY);
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
renderBackground(graphics);
super.render(graphics, mouseX, mouseY, delta);
drawMouseoverTooltip(graphics, mouseX, mouseY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.ix0rai.bodacious_berries.block.entity;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;
Expand All @@ -18,8 +18,8 @@ protected BodaciousScreen(T screenHandler, PlayerInventory playerInventory, Text
}

@Override
protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
this.textRenderer.draw(matrices, Language.getInstance().get(this.title.getString()), this.playerInventoryTitleX, this.titleY, 4210752);
this.textRenderer.draw(matrices, this.playerInventoryTitle, this.playerInventoryTitleX, this.playerInventoryTitleY, 4210752);
protected void drawForeground(GuiGraphics graphics, int mouseX, int mouseY) {
graphics.drawText(this.textRenderer, Language.getInstance().get(this.title.getString()), this.titleX, this.titleY, 4210752, false);
graphics.drawText(this.textRenderer, this.playerInventoryTitle, this.playerInventoryTitleX, this.playerInventoryTitleY, 4210752, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.mojang.blaze3d.systems.RenderSystem;
import io.ix0rai.bodacious_berries.BodaciousBerries;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand All @@ -27,26 +27,25 @@ public JuicerScreen(JuicerScreenHandler handler, PlayerInventory inventory, Text
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
this.drawMouseoverTooltip(matrices, mouseX, mouseY);
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
this.renderBackground(graphics);
super.render(graphics, mouseX, mouseY, delta);
this.drawMouseoverTooltip(graphics, mouseX, mouseY);
}

@Override
protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) {
protected void drawBackground(GuiGraphics graphics, float delta, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE);

// draw background
int x = (this.width - this.backgroundWidth) / 2;
int y = (this.height - this.backgroundHeight) / 2;
drawTexture(matrices, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
this.drawProgress(matrices);
graphics.drawTexture(TEXTURE, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
this.drawProgress(graphics);
}

private void drawProgress(MatrixStack matrices) {
private void drawProgress(GuiGraphics graphics) {
final int brewTime = this.handler.getBrewTime();
final boolean dubious = this.handler.brewingDubiously();
final boolean blend = this.handler.brewingBlend();
Expand All @@ -55,14 +54,14 @@ private void drawProgress(MatrixStack matrices) {
// draw progress bar
int progress = Math.round(28.0F * (1.0F - brewTime / (float) JuicerBlockEntity.TOTAL_BREW_TIME));
if (progress > 0) {
drawTexture(matrices, x + 73, y + 35, dubious ? DUBIOUS_PROGRESS_BAR_UV_X : PROGRESS_BAR_UV_X, blend ? BLEND_PROGRESS_BAR_UV_Y : PROGRESS_BAR_UV_Y, 28, progress);
graphics.drawTexture(TEXTURE, x + 73, y + 35, dubious ? DUBIOUS_PROGRESS_BAR_UV_X : PROGRESS_BAR_UV_X, blend ? BLEND_PROGRESS_BAR_UV_Y : PROGRESS_BAR_UV_Y, 28, progress);
}

// draw bubbles
progress = BUBBLE_PROGRESS[brewTime / 2 % 7];
if (progress > 0) {
for (int i = 0; i < 2; i++) {
drawTexture(matrices, x + (i == 0 ? LEFT_BUBBLE_X : RIGHT_BUBBLE_X), y + 63 - progress, dubious ? DUBIOUS_BUBBLE_UV_X : BUBBLE_UV_X, (blend ? BLEND_BUBBLE_UV_Y : BUBBLE_UV_Y) - progress, 12, progress);
graphics.drawTexture(TEXTURE, x + (i == 0 ? LEFT_BUBBLE_X : RIGHT_BUBBLE_X), y + 63 - progress, dubious ? DUBIOUS_BUBBLE_UV_X : BUBBLE_UV_X, (blend ? BLEND_BUBBLE_UV_Y : BUBBLE_UV_Y) - progress, 12, progress);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.ix0rai.bodacious_berries.compat;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.WidgetHolder;
import io.ix0rai.bodacious_berries.BodaciousBerries;
import io.ix0rai.bodacious_berries.block.entity.JuicerRecipe;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;

Expand Down Expand Up @@ -66,21 +64,20 @@ public int getDisplayHeight() {
@Override
public void addWidgets(WidgetHolder widgets) {
// juicer background and animated textures
widgets.addDrawable(-19, 3, 64, 59, (matrices, mouseX, mouseY, delta) -> {
widgets.addDrawable(-19, 3, 64, 59, (graphics, mouseX, mouseY, delta) -> {
// add juicer background
RenderSystem.setShaderTexture(0, JuicerEmiPlugin.JUICER_TEXTURE);
DrawableHelper.drawTexture(matrices, 20, 0, 55, 17, 64, 59, 256, 256);
graphics.drawTexture(JuicerEmiPlugin.JUICER_TEXTURE, 20, 0, 55, 17, 64, 59, 256, 256);

// add progress bar
final double time = System.currentTimeMillis() / 250d;

int progress = MathHelper.floor(time % 16);
DrawableHelper.drawTexture(matrices, 38, 24, 187, 0, 28, progress, 256, 256);
graphics.drawTexture(JuicerEmiPlugin.JUICER_TEXTURE, 38, 24, 187, 0, 28, progress, 256, 256);

// add animated bubbles
int height = MathHelper.floor(time % 9);
DrawableHelper.drawTexture(matrices, 24, 24 + height, 176, height, 11, 9 - height, 256, 256);
DrawableHelper.drawTexture(matrices, 70, 24 + height, 176, height, 11, 9 - height, 256, 256);
graphics.drawTexture(JuicerEmiPlugin.JUICER_TEXTURE, 24, 24 + height, 176, height, 11, 9 - height, 256, 256);
graphics.drawTexture(JuicerEmiPlugin.JUICER_TEXTURE, 70, 24 + height, 176, height, 11, 9 - height, 256, 256);
});

// input and output slots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected void init() {
}

@Override
public void renderTitle(MatrixStack matrices, int mouseX, int mouseY, float delta) {
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
public void renderTitle(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
graphics.drawCenteredShadowedText(this.textRenderer, this.title, this.width / 2, 8, 16777215);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ private static boolean hasSupportingBlock(StructureWorldAccess access, BlockPos
// block must not be surrounded by air or a non-solid blocks
// we only return true if it has a supporting solid block
return east != Blocks.AIR || west != Blocks.AIR || north != Blocks.AIR || south != Blocks.AIR
&& (east.canMobSpawnInside() || west.canMobSpawnInside() || north.canMobSpawnInside() || south.canMobSpawnInside());
&& (east.canMobSpawnInside(east.getDefaultState()) || west.canMobSpawnInside(west.getDefaultState()) || north.canMobSpawnInside(north.getDefaultState()) || south.canMobSpawnInside(south.getDefaultState()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.feature_flags.FeatureFlags;
import net.minecraft.item.BlockItem;
Expand All @@ -21,17 +20,19 @@
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;

public class BodaciousBlocks {
public static final Identifier BERRY_HARVESTER = BodaciousBerries.id("berry_harvester");
public static final BerryHarvesterBlock BERRY_HARVESTER_BLOCK = new BerryHarvesterBlock(FabricBlockSettings.of(Material.METAL).strength(4.0f));
public static final BerryHarvesterBlock BERRY_HARVESTER_BLOCK = new BerryHarvesterBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.COPPER).strength(4.0f));
public static final BlockEntityType<BerryHarvesterBlockEntity> BERRY_HARVESTER_ENTITY = FabricBlockEntityTypeBuilder.create(BerryHarvesterBlockEntity::new, BERRY_HARVESTER_BLOCK).build(null);
public static final ScreenHandlerType<BerryHarvesterScreenHandler> BERRY_HARVESTER_SCREEN_HANDLER = new ScreenHandlerType<>(BerryHarvesterScreenHandler::new, FeatureFlags.DEFAULT_SET);

public static final Identifier JUICER = BodaciousBerries.id("juicer");
public static final JuicerBlock JUICER_BLOCK = new JuicerBlock(FabricBlockSettings.of(Material.METAL).strength(4.0f));
public static final JuicerBlock JUICER_BLOCK = new JuicerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.COPPER).strength(4.0f));
public static final BlockEntityType<JuicerBlockEntity> JUICER_ENTITY = FabricBlockEntityTypeBuilder.create(JuicerBlockEntity::new, JUICER_BLOCK).build(null);
public static final ScreenHandlerType<JuicerScreenHandler> JUICER_SCREEN_HANDLER = new ScreenHandlerType<>(JuicerScreenHandler::new, FeatureFlags.DEFAULT_SET);

Expand All @@ -42,7 +43,7 @@ public static void register() {
BodaciousBushes.register();
}

private static void register(Identifier id, Block block, BlockEntityType<?> entity, ScreenHandlerType<?> handler, ItemGroup group) {
private static void register(Identifier id, Block block, BlockEntityType<?> entity, ScreenHandlerType<?> handler, RegistryKey<ItemGroup> group) {
Registry.register(Registries.BLOCK, id, block);
Registry.register(Registries.SCREEN_HANDLER_TYPE, id, handler);
Registry.register(Registries.BLOCK_ENTITY_TYPE, BodaciousBerries.id(id.getPath() + "_entity"), entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import io.ix0rai.bodacious_berries.block.SpikedBerryBush;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
Expand Down Expand Up @@ -42,7 +41,7 @@ public class BodaciousBushes {
private static final VoxelShape LARGE_RASPBERRY = Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 13.0D, 15.0D);
private static final VoxelShape LARGE_CLOUDBERRY = Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 15.0D, 13.0D);

public static final AbstractBlock.Settings BERRY_BUSH_SETTINGS = AbstractBlock.Settings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH).nonOpaque();
public static final AbstractBlock.Settings BERRY_BUSH_SETTINGS = AbstractBlock.Settings.create().ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH).nonOpaque();

public static final ChorusBerryBush CHORUS_BERRY_BUSH = new ChorusBerryBush(Berry.CHORUS_BERRIES,
SMALL_LINGONBERRY, LARGE_LINGONBERRY, 2);
Expand Down
9 changes: 4 additions & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@

"depends": {
"fabricloader": ">=0.14.14",
"fabric-api": ">=0.69.0",
"minecraft": ">=1.19.4",
"java": ">=17"
"fabric-api": ">=0.83.0",
"minecraft": ">=1.20"
},

"suggests": {
"emi": ">=0.7.0",
"modmenu": ">=6.0.0"
"emi": ">=1.0.0",
"modmenu": ">=7.0.0"
},

"custom": {
Expand Down

0 comments on commit a260981

Please sign in to comment.