Skip to content
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
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -39,6 +39,7 @@ sourceSets {
}

repositories {
mavenCentral()
maven {
name = 'TerraformersMC'
url = 'https://maven.terraformersmc.com/'
Expand All @@ -59,12 +60,12 @@ dependencies {

// Dependancies
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
include(modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
include "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}"
modImplementation "maven.modrinth:panorama-screens:${project.panoramascreens_version}"
include "maven.modrinth:panorama-screens:${project.panoramascreens_version}"
})

include(annotationProcessor(modApi("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}")))
include(modImplementation("maven.modrinth:panorama-screens:${project.panoramascreens_version}"))

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
modCompileOnly("squeek.appleskin:appleskin-fabric:${project.apple_skin}:api") {
Expand Down Expand Up @@ -103,8 +104,9 @@ tasks.withType(JavaCompile).configureEach {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
tasks.register("sourcesJar", Jar) {
dependsOn classes
archiveClassifier = "sources"
from sourceSets.main.allSource
}

Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ org.gradle.jvmargs=-Xmx2048m
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.22
loader_version=0.14.24

# Mod Properties
mod_version = 1.9.1
maven_group = me.juancarloscp52
archives_base_name = bedrockify

# Dependencies
fabric_version=0.89.3+1.20.2
fabric_version=0.91.0+1.20.2
modmenu_version=8.0.0
cloth_config_version=12.0.109
cloth_config_version=12.0.111
mixin_extras_version=0.2.1
panoramascreens_version=1.0+fabric+mc1.20.2
apple_skin=mc1.20.2-2.5.1
iris_version=1.6.9+1.20.2
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sat Jul 18 15:09:59 CEST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.juancarloscp52.bedrockify.client.features.heldItemTooltips;

import com.google.common.collect.Lists;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
import me.juancarloscp52.bedrockify.client.BedrockifyClientSettings;
import me.juancarloscp52.bedrockify.client.features.heldItemTooltips.tooltip.ContainerTooltip;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class HeldItemTooltips {

private final int tooltipSize = 6;

public int drawItemWithCustomTooltips(DrawContext drawContext, TextRenderer fontRenderer, Text text, float x, float y, int color, ItemStack currentStack) {
public int drawItemWithCustomTooltips(DrawContext drawContext, TextRenderer fontRenderer, Text text, float x, float y, int color, ItemStack currentStack, Operation<Integer> original) {
final BedrockifyClientSettings settings = BedrockifyClient.getInstance().settings;
final int screenBorder = settings.getScreenSafeArea();
int tooltipOffset = 0;
Expand Down Expand Up @@ -88,7 +89,7 @@ public int drawItemWithCustomTooltips(DrawContext drawContext, TextRenderer font
}

// Render the item name.
return drawContext.drawTextWithShadow(fontRenderer, text, (int)x, (int)(y - tooltipOffset - screenBorder), color);
return original.call(drawContext, fontRenderer, text, (int) x, (int) y - tooltipOffset - screenBorder, color);
}

/**
Expand All @@ -99,7 +100,7 @@ public int drawItemWithCustomTooltips(DrawContext drawContext, TextRenderer font
public List<Tooltip> getTooltips(ItemStack currentStack) {
final Item item = currentStack.getItem();
final List<Tooltip> result = Lists.newArrayList();
//If the item is a enchanted book, retrieve the enchantments.
//If the item is an enchanted book, retrieve the enchantments.
if (item == Items.ENCHANTED_BOOK || currentStack.hasEnchantments()) {
generateTooltipsFromEnchantMap(EnchantmentHelper.get(currentStack), result);
//If the item has a potion effects, retrieve them.
Expand All @@ -113,10 +114,8 @@ public List<Tooltip> getTooltips(ItemStack currentStack) {
if(compoundTag != null && compoundTag.contains("Items", 9)){
generateTooltipsFromShulkerBox(compoundTag, result);
}
} else if(item instanceof BundleItem){
if(currentStack.getTooltipData().isPresent() && currentStack.isOf(Items.BUNDLE)){
} else if(item instanceof BundleItem && currentStack.getTooltipData().isPresent() && currentStack.isOf(Items.BUNDLE)){
generateTooltipsFromContainer(((BundleTooltipData)currentStack.getTooltipData().get()).getInventory(), result);
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import net.minecraft.item.ShieldItem;
import net.minecraft.util.Hand;

public class SneakingShield {
public final class SneakingShield {
private SneakingShield() {}

public static void tryActivation(boolean sneaking){
PlayerEntity player = MinecraftClient.getInstance().player;
if(BedrockifyClient.getInstance().settings.isSneakingShieldEnabled() && sneaking && player !=null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public Screen getConfigScreen(Screen parent, boolean isTransparent){
*
*/
mixins.addEntry(entryBuilder.startTextDescription(Text.translatable("bedrockify.options.mixins.description")).build());
for(Map.Entry<String, Boolean> elem : MixinFeatureManager.features.entrySet()){
mixins.addEntry(entryBuilder.startBooleanToggle(Text.translatable(elem.getKey()), elem.getValue()).setDefaultValue(true).setSaveConsumer(newValue -> MixinFeatureManager.features.put(elem.getKey(),newValue)).build());
for(Map.Entry<String, Boolean> elem : MixinFeatureManager.FEATURES.entrySet()){
mixins.addEntry(entryBuilder.startBooleanToggle(Text.translatable(elem.getKey()), elem.getValue()).setDefaultValue(true).setSaveConsumer(newValue -> MixinFeatureManager.FEATURES.put(elem.getKey(),newValue)).build());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, Ca

if (this.getLoadedChunkCount() == 0 && this.getBuiltChunkCount() == 0) {
LoadingScreenWidget.getInstance().render(new DrawContext(client,client.getBufferBuilders().getEntityVertexConsumers()),client.getWindow().getScaledWidth() / 2, client.getWindow().getScaledHeight() / 2, Text.translatable("fastload.buildingTerrain.starting"), null, -1);
}else{
} else {
Text content = screenTemplate.copyContentOnly().append("\n").append(this.preparingChunks.getString() + ": " + loadedChunksString).append("\n").append(this.buildingChunks.getString() + ": " + builtChunksString);
int progress = (int)Math.ceil((this.getBuiltChunkCount()/this.loadingAreaGoal)*100);
int progress = this.getBuiltChunkCount() / this.loadingAreaGoal * 100;
LoadingScreenWidget.getInstance().render(new DrawContext(client,client.getBufferBuilders().getEntityVertexConsumers()), client.getWindow().getScaledWidth() / 2, client.getWindow().getScaledHeight() / 2, this.screenName, content, progress);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package me.juancarloscp52.bedrockify.mixin.client.core.bedrockIfyButton;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
import me.juancarloscp52.bedrockify.client.BedrockifyClientSettings;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.EmptyWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand All @@ -39,37 +39,36 @@ public void addBedrockIfyButton(CallbackInfo ci, GridWidget gridWidget, GridWidg
}
}

@Redirect(method = "init", at = @At(value = "INVOKE",target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;I)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 0))
public <T extends Widget> T addBedrockIfyButton(GridWidget.Adder adder, T widget, int occupiedColumns){
@WrapOperation(method = "init", at = @At(value = "INVOKE",target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;I)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 0))
public <T extends Widget> T addBedrockIfyButton(GridWidget.Adder adder, T widget, int occupiedColumns, Operation<T> original){
BedrockifyClientSettings settings = BedrockifyClient.getInstance().settings;
if(settings.bedrockIfyButtonPosition == BedrockifyClientSettings.ButtonPosition.BELOW_SLIDERS)
return (T) adder.add(ButtonWidget.builder(Text.translatable("bedrockify.options.settings"),button -> this.client.setScreen(BedrockifyClient.getInstance().settingsGUI.getConfigScreen(this,this.client.world != null))).width(310).build(), occupiedColumns);
return (T) adder.add(EmptyWidget.ofHeight(26), 2);
return original.call(adder, widget, occupiedColumns);
}

@Inject(method = "init", at = @At("RETURN"))
public void addBedrockIfyButton(CallbackInfo ci){
BedrockifyClientSettings settings = BedrockifyClient.getInstance().settings;
ButtonWidget.Builder bedrockIfyButton = ButtonWidget.builder(Text.translatable("bedrockify.options.settings"), button -> this.client.setScreen(BedrockifyClient.getInstance().settingsGUI.getConfigScreen(this,this.client.world != null))).width(150);
switch (settings.bedrockIfyButtonPosition){
case DISABLED:
case IN_GRID:
case BELOW_SLIDERS: break;
case TOP_LEFT:
switch (settings.bedrockIfyButtonPosition) {
case DISABLED, IN_GRID, BELOW_SLIDERS -> {}
case TOP_LEFT -> {
bedrockIfyButton.position(0,0);
this.addDrawableChild(bedrockIfyButton.build());
break;
case TOP_RIGHT:
}
case TOP_RIGHT -> {
bedrockIfyButton.position(this.width-150,0);
this.addDrawableChild(bedrockIfyButton.build());
break;
case BOTTOM_LEFT:
}
case BOTTOM_LEFT -> {
bedrockIfyButton.position(0,this.height-20);
this.addDrawableChild(bedrockIfyButton.build());
break;
case BOTTOM_RIGHT:
}
case BOTTOM_RIGHT -> {
bedrockIfyButton.position(this.width-150,this.height-20);
this.addDrawableChild(bedrockIfyButton.build());
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -13,7 +14,9 @@
public class MinecraftClientMixin {

@Shadow public Screen currentScreen;
long newTime=0;
@Unique
private long newTime =0;

@Inject(method = "render", at=@At("HEAD"))
private void computeDeltaTime(boolean tick, CallbackInfo ci){
long oldTime = newTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.juancarloscp52.bedrockify.mixin.client.features.bedrockShading.lightBlock;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
import net.fabricmc.fabric.impl.client.indigo.renderer.render.AbstractBlockRenderContext;
import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo;
Expand All @@ -9,7 +11,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

/**
* @author Shaddatic
*/
Expand All @@ -18,13 +20,13 @@ public class AbstractQuadRendererMixin {

@Shadow @Final protected BlockRenderInfo blockInfo;

@Redirect(method = "shadeFlatQuad", at=@At(value = "INVOKE",target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getBlockShade(BlockRenderView blockRenderView, Direction direction, boolean shaded){
@WrapOperation(method = "shadeFlatQuad", at=@At(value = "INVOKE",target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getBlockShade(BlockRenderView instance, Direction direction, boolean shaded, Operation<Float> original){

if(blockInfo.blockState.getLuminance()>2 && shaded && BedrockifyClient.getInstance().settings.bedrockShading)
return BedrockifyClient.getInstance().bedrockBlockShading.getBlockShade(direction);
else
return blockRenderView.getBrightness(direction, shaded);
return original.call(instance,direction,shaded);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.juancarloscp52.bedrockify.mixin.client.features.bedrockShading.lightBlock;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.VertexConsumer;
Expand All @@ -10,9 +12,9 @@
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.BitSet;
Expand All @@ -22,17 +24,19 @@
*/
@Mixin(BlockModelRenderer.class)
public class BlockModelRendererMixin {
@Unique
private boolean luminant = false;

@Inject(method = "renderQuadsFlat",at=@At(value = "INVOKE",target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F",ordinal = 0))
private void getLuminant(BlockRenderView world, BlockState state, BlockPos pos, int light, int overlay, boolean useWorldLight, MatrixStack matrices, VertexConsumer vertexConsumer, List<BakedQuad> quads, BitSet flags, CallbackInfo ci){
this.luminant = state.getLuminance() > 2;
}

@Redirect(method = "renderQuadsFlat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getBlockShade(BlockRenderView blockRenderView, Direction direction, boolean shaded){
@WrapOperation(method = "renderQuadsFlat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getBlockShade(BlockRenderView instance, Direction direction, boolean shaded, Operation<Float> original) {
if(luminant && shaded && BedrockifyClient.getInstance().settings.bedrockShading)
return BedrockifyClient.getInstance().bedrockBlockShading.getBlockShade(direction);
else
return blockRenderView.getBrightness(direction, shaded);
return original.call(instance, direction, shaded);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.juancarloscp52.bedrockify.mixin.client.features.bedrockShading.lightBlock;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.VertexConsumer;
Expand All @@ -11,7 +13,6 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* @author Shaddatic
Expand All @@ -25,10 +26,10 @@ private void getFluidType(BlockRenderView world, BlockPos pos, VertexConsumer ve
this.isLuminous = 0 < world.getLuminance(pos); //state.isIn(FluidTags.LAVA);
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getLavaShade(BlockRenderView blockRenderView, Direction direction, boolean shaded) {
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/BlockRenderView;getBrightness(Lnet/minecraft/util/math/Direction;Z)F"))
private float getLavaShade(BlockRenderView instance, Direction direction, boolean shaded, Operation<Float> original) {
if(!BedrockifyClient.getInstance().settings.bedrockShading)
return blockRenderView.getBrightness(direction,shaded);
return original.call(instance, direction, shaded);

return BedrockifyClient.getInstance().bedrockBlockShading.getLiquidShade(direction,isLuminous);
}
Expand Down
Loading