Skip to content

Commit

Permalink
Added unlockAllRecipes gamerule.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Feb 24, 2024
1 parent 40ebae7 commit 82e9ffc
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 57 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bta_version=7.1-pre1a
loader_version=0.14.19-babric.3-bta

# Mod
mod_version=3.4.4
mod_version=3.4.5
mod_group=turniplabs
mod_name=halplibe

4 changes: 4 additions & 0 deletions src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.core.block.Block;
import net.minecraft.core.block.BlockLanternFirefly;
import net.minecraft.core.block.tag.BlockTags;
import net.minecraft.core.data.gamerule.GameRuleBoolean;
import net.minecraft.core.data.gamerule.GameRules;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemPlaceable;
import net.minecraft.core.item.ItemStack;
Expand Down Expand Up @@ -111,6 +113,8 @@ public void onInitialize() {
public static FireflyColor fireflyBlue;
public static FireflyColor fireflyRed;

public static GameRuleBoolean UNLOCK_ALL_RECIPES = (GameRuleBoolean) GameRules.register(new GameRuleBoolean("unlockAllRecipes", false));

@Override
public void onPreLaunch() {
// Initializes halp statics first
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package turniplabs.halplibe.mixin.mixins;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiRenderItem;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.player.inventory.slot.Slot;
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.callback.CallbackInfo;
import turniplabs.halplibe.HalpLibe;

@Mixin(
value = GuiRenderItem.class,
remap = false
)
public class GuiRenderItemMixin extends Gui {

@Shadow
Minecraft mc;

@Inject(method = "render(Lnet/minecraft/core/item/ItemStack;IIZLnet/minecraft/core/player/inventory/slot/Slot;)V", at = @At("HEAD"))
public void render(ItemStack itemStack, int x, int y, boolean isSelected, Slot slot, CallbackInfo ci) {
if(mc.theWorld.getGameRule(HalpLibe.UNLOCK_ALL_RECIPES)){
slot.discovered = true;
}
}
}
36 changes: 36 additions & 0 deletions src/main/java/turniplabs/halplibe/mixin/mixins/MobPageMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package turniplabs.halplibe.mixin.mixins;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.guidebook.GuidebookSection;
import net.minecraft.client.gui.guidebook.mobs.MobInfoRegistry;
import net.minecraft.client.gui.guidebook.mobs.MobPage;
import net.minecraft.client.render.FontRenderer;
import net.minecraft.client.render.RenderEngine;
import org.spongepowered.asm.mixin.Final;
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.callback.CallbackInfo;
import turniplabs.halplibe.HalpLibe;

@Mixin(value = MobPage.class, remap = false)
public class MobPageMixin {
@Shadow private boolean discovered;

@Shadow @Final private static Minecraft mc;

@Inject(method = "<init>", at = @At("RETURN"))
private void onMobPageInit(GuidebookSection section, Class<?> mobClass, MobInfoRegistry.MobInfo mobInfo, CallbackInfo ci) {
if(mc.theWorld.getGameRule(HalpLibe.UNLOCK_ALL_RECIPES)){
discovered = true;
}
}

@Inject(method = "renderForeground", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/guidebook/mobs/MobPage;discovered:Z", ordinal = 0, shift = At.Shift.AFTER))
public void setDiscovered(RenderEngine re, FontRenderer fr, int x, int y, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
if(mc.theWorld.getGameRule(HalpLibe.UNLOCK_ALL_RECIPES)){
discovered = true;
}
}
}
114 changes: 58 additions & 56 deletions src/main/resources/halplibe.mixins.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
{
"required": true,
"minVersion": "0.8",
"package": "turniplabs.halplibe.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"accessors.BlockFireAccessor",
"accessors.EntityFireflyFXAccessor",
"accessors.EntityFXAccessor",
"accessors.EntityListAccessor",
"accessors.LanguageAccessor",
"accessors.TileEntityAccessor",
"accessors.WeightedRandomBagAccessor",
"accessors.WeightedRandomBagEntryAccessor",
"mixins.ArmorMaterialMixin",
"mixins.BlockFireMixin",
"mixins.BlockLanternFireflyMixin",
"mixins.BlockMixin",
"mixins.BlockSoundDispatcherMixin",
"mixins.ContainerPlayerCreativeMixin",
"mixins.EntityFireflyClusterMixin",
"mixins.EntityFireflyFXMixin",
"mixins.I18nMixin",
"mixins.ItemJarMixin",
"mixins.ItemStackJsonAdapterMixin",
"mixins.RegistryMixin",
"mixins.TileEntityBlastFurnaceMixin",
"mixins.TileEntityFurnaceMixin",
"mixins.commands.CommandsCoreMixin",
"mixins.network.PacketMixin",
"mixins.registry.BlockMixin",
"mixins.registry.ItemMixin",
"mixins.version.NetHandlerMixin"
],
"client": [
"accessors.RenderManagerAccessor",
"accessors.TileEntityRendererAccessor",
"mixins.EntityClientPlayerMPMixin",
"mixins.GuiIngameMenuMixin",
"mixins.MinecraftMixin",
"mixins.PlayerRendererMixin",
"mixins.RenderEngineMixin",
"mixins.RenderGlobalMixin",
"mixins.commands.CommandsClientMixin",
"mixins.network.MinecraftMixin",
"mixins.registry.MinecraftMixin",
"mixins.version.NetClientHandlerMixin"
],
"server": [
"mixins.MinecraftServerMixin",
"mixins.commands.CommandsServerMixin",
"mixins.network.MinecraftServerMixin",
"mixins.registry.MinecraftServerMixin",
"mixins.version.NetLoginHandlerMixin"
],
"injectors": {
"defaultRequire": 1
"required": true,
"minVersion": "0.8",
"package": "turniplabs.halplibe.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"accessors.BlockFireAccessor",
"accessors.EntityFireflyFXAccessor",
"accessors.EntityFXAccessor",
"accessors.EntityListAccessor",
"accessors.LanguageAccessor",
"accessors.TileEntityAccessor",
"accessors.WeightedRandomBagAccessor",
"accessors.WeightedRandomBagEntryAccessor",
"mixins.ArmorMaterialMixin",
"mixins.BlockFireMixin",
"mixins.BlockLanternFireflyMixin",
"mixins.BlockMixin",
"mixins.BlockSoundDispatcherMixin",
"mixins.ContainerPlayerCreativeMixin",
"mixins.EntityFireflyClusterMixin",
"mixins.EntityFireflyFXMixin",
"mixins.I18nMixin",
"mixins.ItemJarMixin",
"mixins.ItemStackJsonAdapterMixin",
"mixins.RegistryMixin",
"mixins.TileEntityBlastFurnaceMixin",
"mixins.TileEntityFurnaceMixin",
"mixins.commands.CommandsCoreMixin",
"mixins.network.PacketMixin",
"mixins.registry.BlockMixin",
"mixins.registry.ItemMixin",
"mixins.version.NetHandlerMixin"
],
"client": [
"accessors.RenderManagerAccessor",
"accessors.TileEntityRendererAccessor",
"mixins.EntityClientPlayerMPMixin",
"mixins.GuiIngameMenuMixin",
"mixins.MinecraftMixin",
"mixins.PlayerRendererMixin",
"mixins.RenderEngineMixin",
"mixins.RenderGlobalMixin",
"mixins.commands.CommandsClientMixin",
"mixins.network.MinecraftMixin",
"mixins.registry.MinecraftMixin",
"mixins.version.NetClientHandlerMixin",
"mixins.MobPageMixin",
"mixins.GuiRenderItemMixin"
],
"server": [
"mixins.MinecraftServerMixin",
"mixins.commands.CommandsServerMixin",
"mixins.network.MinecraftServerMixin",
"mixins.registry.MinecraftServerMixin",
"mixins.version.NetLoginHandlerMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 82e9ffc

Please sign in to comment.