From a910cb33edf2ac68ff809ff07a718576c7bfd348 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:29:08 -0500 Subject: [PATCH 1/4] ugh --- src/main/java/net/frozenblock/lib/FrozenClient.java | 2 -- src/main/java/net/frozenblock/lib/FrozenMain.java | 12 +++--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/frozenblock/lib/FrozenClient.java b/src/main/java/net/frozenblock/lib/FrozenClient.java index ec91cf4d..55274a67 100644 --- a/src/main/java/net/frozenblock/lib/FrozenClient.java +++ b/src/main/java/net/frozenblock/lib/FrozenClient.java @@ -49,8 +49,6 @@ public final class FrozenClient implements ClientModInitializer { @Override public void onInitializeClient() { - FrozenMain.init(); - FrozenClientRegistry.initRegistry(); ModIntegrations.initializePreFreeze(); // Mod integrations must run after normal mod initialization diff --git a/src/main/java/net/frozenblock/lib/FrozenMain.java b/src/main/java/net/frozenblock/lib/FrozenMain.java index 0f3ee78c..d73e2ad9 100644 --- a/src/main/java/net/frozenblock/lib/FrozenMain.java +++ b/src/main/java/net/frozenblock/lib/FrozenMain.java @@ -70,15 +70,14 @@ import org.quiltmc.qsl.frozenblock.misc.datafixerupper.impl.ServerFreezer; public final class FrozenMain extends FrozenModInitializer { - public static boolean INITIALIZED = false; public FrozenMain() { super(FrozenSharedConstants.MOD_ID); } - public static void init() { - if (INITIALIZED) return; - INITIALIZED = true; + @Override + public void onInitialize(String modId, ModContainer container) { + if (!FabricLoader.getInstance().isModLoaded("trailiertales")) throw new AssertionError(); FrozenRegistry.initRegistry(); @@ -107,11 +106,6 @@ public static void init() { ServerCapeData.init(); FrozenMainEntrypoint.EVENT.invoker().init(); // includes dev init - } - - @Override - public void onInitialize(String modId, ModContainer container) { - init(); ArgumentTypeInfos.register( BuiltInRegistries.COMMAND_ARGUMENT_TYPE, From e46eb0e3b6ada5b3294a81f80f35cef8ddab9480 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:56:07 -0500 Subject: [PATCH 2/4] tester b*tch --- .../java/net/frozenblock/lib/FrozenMain.java | 2 - .../RegisterInGameDevTools.java | 37 -------- .../lib/ingamedevtools/item/Camera.java | 91 ------------------- .../ingamedevtools/item/LootTableWhacker.java | 78 ---------------- 4 files changed, 208 deletions(-) delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java diff --git a/src/main/java/net/frozenblock/lib/FrozenMain.java b/src/main/java/net/frozenblock/lib/FrozenMain.java index d73e2ad9..63f20dca 100644 --- a/src/main/java/net/frozenblock/lib/FrozenMain.java +++ b/src/main/java/net/frozenblock/lib/FrozenMain.java @@ -35,7 +35,6 @@ import net.frozenblock.lib.entrypoint.api.FrozenModInitializer; import net.frozenblock.lib.event.api.PlayerJoinEvents; import net.frozenblock.lib.event.api.RegistryFreezeEvents; -import net.frozenblock.lib.ingamedevtools.RegisterInGameDevTools; import net.frozenblock.lib.integration.api.ModIntegrations; import net.frozenblock.lib.networking.FrozenNetworking; import net.frozenblock.lib.particle.api.FrozenParticleTypes; @@ -101,7 +100,6 @@ public void onInitialize(String modId, ModContainer container) { Registry.register(BuiltInRegistries.MATERIAL_CONDITION, FrozenSharedConstants.id("biome_tag_condition_source"), BiomeTagConditionSource.CODEC.codec()); Registry.register(BuiltInRegistries.MATERIAL_CONDITION, FrozenSharedConstants.id("optimized_biome_tag_condition_source"), OptimizedBiomeTagConditionSource.CODEC.codec()); - RegisterInGameDevTools.init(); FrozenParticleTypes.registerParticles(); ServerCapeData.init(); diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java b/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java deleted file mode 100644 index 3111075f..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools; - -import net.frozenblock.lib.FrozenSharedConstants; -import net.frozenblock.lib.ingamedevtools.item.Camera; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.Item; - -public class RegisterInGameDevTools { - public static final Item CAMERA = Registry.register( - BuiltInRegistries.ITEM, - FrozenSharedConstants.id("camera"), - new Camera(new Item.Properties().stacksTo(1).setId(ResourceKey.create(Registries.ITEM, FrozenSharedConstants.id("camera")))) - ); - - public static void init() { - } -} diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java b/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java deleted file mode 100644 index 0e3afb16..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools.item; - -import java.io.File; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import net.frozenblock.lib.FrozenSharedConstants; -import net.minecraft.client.Minecraft; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemCooldowns; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class Camera extends Item { - - public Camera(Properties settings) { - super(settings); - } - - private boolean canGo; - - @Override - public void inventoryTick(ItemStack itemStack, Level world, Entity entity, int i, boolean bl) { - if (entity instanceof Player player) { - ItemCooldowns cooldowns = player.getCooldowns(); - if (cooldowns.isOnCooldown(itemStack) && cooldowns.getCooldownPercent(itemStack, 0) == 0.9F) { - if (world.isClientSide && canGo) { - FrozenSharedConstants.LOGGER.warn("PLAYER HAS ACCESS TO DEV CAMERA AND HAS JUST USED IT"); - Minecraft client = Minecraft.getInstance(); - File directory = getPanoramaFolderName(new File(client.gameDirectory, "panoramas")); - File directory1 = new File(directory, "screenshots"); - directory1.mkdir(); - directory1.mkdirs(); - client.grabPanoramixScreenshot(directory, 1024, 1024); - canGo = false; - } - } - } - } - - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); - - private static @NotNull File getPanoramaFolderName(File directory) { - String string = DATE_FORMAT.format(new Date()); - int i = 1; - while (true) { - File file = new File(directory, string + (i == 1 ? "" : "_" + i)); - if (!file.exists()) { - return file; - } - ++i; - } - } - - @Override - public @NotNull InteractionResult use(Level world, @NotNull Player player, InteractionHand hand) { - ItemStack itemStack = player.getItemInHand(hand); - ItemCooldowns cooldowns = player.getCooldowns(); - if (!cooldowns.isOnCooldown(itemStack)) { - cooldowns.addCooldown(itemStack, 10); - if (world.isClientSide) { - canGo = true; - } - return InteractionResult.SUCCESS; - } - return InteractionResult.PASS; - } - -} diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java b/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java deleted file mode 100644 index 05ce5c9f..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools.item; - -import net.frozenblock.lib.FrozenLogUtils; -import net.minecraft.core.BlockPos; -import net.minecraft.core.component.DataComponents; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BrushableBlockEntity; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; -import net.minecraft.world.level.storage.loot.LootTable; -import org.jetbrains.annotations.NotNull; - -public class LootTableWhacker extends Item { - - public LootTableWhacker(Properties settings) { - super(settings); - } - - private static final MutableComponent FAIL_NO_NAME = Component.translatable("frozenlib.loot_table_whacker.fail.no_name"); - - @Override - public InteractionResult useOn(@NotNull UseOnContext context) { - Level level = context.getLevel(); - BlockPos blockPos = context.getClickedPos(); - ItemStack stack = context.getItemInHand(); - Player player = context.getPlayer(); - if (player == null) { - return InteractionResult.PASS; - } - if (stack.has(DataComponents.CUSTOM_NAME)) { - String id = stack.getHoverName().getString(); - ResourceLocation location = ResourceLocation.parse(id); - ResourceKey key = ResourceKey.create(Registries.LOOT_TABLE, location); - if (!level.isClientSide) { - if (level.getBlockEntity(blockPos) instanceof RandomizableContainerBlockEntity loot) { - loot.lootTable = key; - player.displayClientMessage(Component.translatable("frozenlib.loot_table_whacker.success", location.toString()), true); - FrozenLogUtils.log(location.toString(), true); - } else if (level.getBlockEntity(blockPos) instanceof BrushableBlockEntity loot) { - loot.lootTable = key; - player.displayClientMessage(Component.translatable("frozenlib.loot_table_whacker.success", location.toString()), true); - FrozenLogUtils.log(location.toString(), true); - } - } - return InteractionResult.SUCCESS; - } else { - player.displayClientMessage(FAIL_NO_NAME, true); - } - return InteractionResult.FAIL; - } - -} From c6d3b1f562de3c9a74467d610fb411c41eb95708 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:57:26 -0500 Subject: [PATCH 3/4] remove crash --- src/main/java/net/frozenblock/lib/FrozenMain.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/net/frozenblock/lib/FrozenMain.java b/src/main/java/net/frozenblock/lib/FrozenMain.java index 63f20dca..b73ef515 100644 --- a/src/main/java/net/frozenblock/lib/FrozenMain.java +++ b/src/main/java/net/frozenblock/lib/FrozenMain.java @@ -76,8 +76,6 @@ public FrozenMain() { @Override public void onInitialize(String modId, ModContainer container) { - if (!FabricLoader.getInstance().isModLoaded("trailiertales")) throw new AssertionError(); - FrozenRegistry.initRegistry(); // QUILT INIT From 95506bba356f1ccd4255d83d5b4c4aa22f3e3bf7 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:38:40 -0500 Subject: [PATCH 4/4] trying to not cry --- CHANGELOG.md | 3 +- gradle.properties | 2 +- .../net/frozenblock/lib/FrozenClient.java | 8 +- .../java/net/frozenblock/lib/FrozenMain.java | 19 +--- .../lib/core/client/api/PanoramaCommand.java | 50 +++++++++++ .../RegisterInGameDevTools.java | 32 ------- .../lib/ingamedevtools/item/Camera.java | 88 ------------------- .../ingamedevtools/item/LootTableWhacker.java | 78 ---------------- 8 files changed, 62 insertions(+), 218 deletions(-) create mode 100644 src/main/java/net/frozenblock/lib/core/client/api/PanoramaCommand.java delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java delete mode 100644 src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b26fd7..a884ef99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,5 @@ Make sure to clear this after each release Put changelog here: ----------------- -- Restored the directional Gravity API +- Exposed the `structure_upgrade` command to players outside development environments. +- Removed the Camera item in favor of the `panorama` command. diff --git a/gradle.properties b/gradle.properties index 53b264bc..e049c6d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ min_loader_version=0.16.0 # Mod Properties - mod_version = 1.9.11 + mod_version = 1.9.12 maven_group = net.frozenblock archives_base_name = FrozenLib diff --git a/src/main/java/net/frozenblock/lib/FrozenClient.java b/src/main/java/net/frozenblock/lib/FrozenClient.java index ec91cf4d..6391e1d6 100644 --- a/src/main/java/net/frozenblock/lib/FrozenClient.java +++ b/src/main/java/net/frozenblock/lib/FrozenClient.java @@ -18,6 +18,7 @@ package net.frozenblock.lib; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; @@ -25,6 +26,7 @@ import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.frozenblock.lib.cape.client.impl.ClientCapeData; import net.frozenblock.lib.config.frozenlib_config.FrozenLibConfig; +import net.frozenblock.lib.core.client.api.PanoramaCommand; import net.frozenblock.lib.debug.client.impl.DebugRenderManager; import net.frozenblock.lib.debug.networking.StructureDebugRequestPayload; import net.frozenblock.lib.entrypoint.api.FrozenClientEntrypoint; @@ -49,8 +51,6 @@ public final class FrozenClient implements ClientModInitializer { @Override public void onInitializeClient() { - FrozenMain.init(); - FrozenClientRegistry.initRegistry(); ModIntegrations.initializePreFreeze(); // Mod integrations must run after normal mod initialization @@ -70,6 +70,10 @@ public void onInitializeClient() { Panoramas.addPanorama(ResourceLocation.withDefaultNamespace("textures/gui/title/background/panorama")); ClientCapeData.init(); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, buildContext) -> { + PanoramaCommand.register(dispatcher); + }); + var resourceLoader = ResourceManagerHelper.get(PackType.CLIENT_RESOURCES); resourceLoader.registerReloadListener(BlockSoundGroupManager.INSTANCE); diff --git a/src/main/java/net/frozenblock/lib/FrozenMain.java b/src/main/java/net/frozenblock/lib/FrozenMain.java index f586abf6..fffcfbb5 100644 --- a/src/main/java/net/frozenblock/lib/FrozenMain.java +++ b/src/main/java/net/frozenblock/lib/FrozenMain.java @@ -21,7 +21,6 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.frozenblock.lib.cape.impl.ServerCapeData; import net.frozenblock.lib.config.api.instance.Config; @@ -35,7 +34,6 @@ import net.frozenblock.lib.entrypoint.api.FrozenModInitializer; import net.frozenblock.lib.event.api.PlayerJoinEvents; import net.frozenblock.lib.event.api.RegistryFreezeEvents; -import net.frozenblock.lib.ingamedevtools.RegisterInGameDevTools; import net.frozenblock.lib.integration.api.ModIntegrations; import net.frozenblock.lib.networking.FrozenNetworking; import net.frozenblock.lib.particle.api.FrozenParticleTypes; @@ -70,16 +68,13 @@ import org.quiltmc.qsl.frozenblock.misc.datafixerupper.impl.ServerFreezer; public final class FrozenMain extends FrozenModInitializer { - public static boolean INITIALIZED = false; public FrozenMain() { super(FrozenSharedConstants.MOD_ID); } - public static void init() { - if (INITIALIZED) return; - INITIALIZED = true; - + @Override + public void onInitialize(String modId, ModContainer container) { FrozenRegistry.initRegistry(); // QUILT INIT @@ -102,16 +97,10 @@ public static void init() { Registry.register(BuiltInRegistries.MATERIAL_CONDITION, FrozenSharedConstants.id("biome_tag_condition_source"), BiomeTagConditionSource.CODEC.codec()); Registry.register(BuiltInRegistries.MATERIAL_CONDITION, FrozenSharedConstants.id("optimized_biome_tag_condition_source"), OptimizedBiomeTagConditionSource.CODEC.codec()); - RegisterInGameDevTools.register(); FrozenParticleTypes.registerParticles(); ServerCapeData.init(); FrozenMainEntrypoint.EVENT.invoker().init(); // includes dev init - } - - @Override - public void onInitialize(String modId, ModContainer container) { - init(); ArgumentTypeInfos.register( BuiltInRegistries.COMMAND_ARGUMENT_TYPE, @@ -126,9 +115,7 @@ public void onInitialize(String modId, ModContainer container) { ConfigCommand.register(dispatcher); TagListCommand.register(dispatcher); ScaleEntityCommand.register(dispatcher); - if (FabricLoader.getInstance().isDevelopmentEnvironment()) { - StructureUpgradeCommand.register(dispatcher); - } + StructureUpgradeCommand.register(dispatcher); }); ServerWorldEvents.LOAD.register((server, level) -> { diff --git a/src/main/java/net/frozenblock/lib/core/client/api/PanoramaCommand.java b/src/main/java/net/frozenblock/lib/core/client/api/PanoramaCommand.java new file mode 100644 index 00000000..ffde205a --- /dev/null +++ b/src/main/java/net/frozenblock/lib/core/client/api/PanoramaCommand.java @@ -0,0 +1,50 @@ +package net.frozenblock.lib.core.client.api; + +import com.mojang.brigadier.CommandDispatcher; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.frozenblock.lib.FrozenSharedConstants; +import net.minecraft.client.Minecraft; +import org.jetbrains.annotations.NotNull; +import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +@Environment(EnvType.CLIENT) +public class PanoramaCommand { + + public static void register(@NotNull CommandDispatcher dispatcher) { + dispatcher.register( + ClientCommandManager.literal("panorama") + .executes( + context -> { + FrozenSharedConstants.LOGGER.warn("PLAYER HAS ACCESS TO DEV CAMERA AND HAS JUST USED IT"); + Minecraft client = Minecraft.getInstance(); + File directory = getPanoramaFolderName(new File(client.gameDirectory, "panoramas")); + File directory1 = new File(directory, "screenshots"); + directory1.mkdir(); + directory1.mkdirs(); + client.grabPanoramixScreenshot(directory, 1024, 1024); + return 1; + } + ) + ); + } + + private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); + + private static @NotNull File getPanoramaFolderName(File directory) { + String string = DATE_FORMAT.format(new Date()); + int i = 1; + while (true) { + File file = new File(directory, string + (i == 1 ? "" : "_" + i)); + if (!file.exists()) { + return file; + } + ++i; + } + } +} diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java b/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java deleted file mode 100644 index 147d6a5b..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/RegisterInGameDevTools.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools; - -import net.frozenblock.lib.FrozenSharedConstants; -import net.frozenblock.lib.ingamedevtools.item.Camera; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.item.Item; - -public class RegisterInGameDevTools { - public static final Item CAMERA = new Camera(new Item.Properties().stacksTo(1)); - - public static void register() { - Registry.register(BuiltInRegistries.ITEM, FrozenSharedConstants.id("camera"), CAMERA); - } -} diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java b/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java deleted file mode 100644 index 9c00545e..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/item/Camera.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools.item; - -import java.io.File; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import net.frozenblock.lib.FrozenSharedConstants; -import net.minecraft.client.Minecraft; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class Camera extends Item { - - public Camera(Properties settings) { - super(settings); - } - - private boolean canGo; - - @Override - public void inventoryTick(ItemStack itemStack, Level world, Entity entity, int i, boolean bl) { - if (entity instanceof Player player) { - if (player.getCooldowns().isOnCooldown(this) && player.getCooldowns().getCooldownPercent(this, 0) == 0.9F) { - if (world.isClientSide && canGo) { - FrozenSharedConstants.LOGGER.warn("PLAYER HAS ACCESS TO DEV CAMERA AND HAS JUST USED IT"); - Minecraft client = Minecraft.getInstance(); - File directory = getPanoramaFolderName(new File(client.gameDirectory, "panoramas")); - File directory1 = new File(directory, "screenshots"); - directory1.mkdir(); - directory1.mkdirs(); - client.grabPanoramixScreenshot(directory, 1024, 1024); - canGo = false; - } - } - } - } - - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); - - private static File getPanoramaFolderName(File directory) { - String string = DATE_FORMAT.format(new Date()); - int i = 1; - while (true) { - File file = new File(directory, string + (i == 1 ? "" : "_" + i)); - if (!file.exists()) { - return file; - } - ++i; - } - } - - @Override - public InteractionResultHolder use(Level world, @NotNull Player user, InteractionHand hand) { - ItemStack itemStack = user.getItemInHand(hand); - if (!user.getCooldowns().isOnCooldown(this)) { - user.getCooldowns().addCooldown(this, 10); - if (world.isClientSide) { - canGo = true; - } - return InteractionResultHolder.success(itemStack); - } - return InteractionResultHolder.fail(itemStack); - } - -} diff --git a/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java b/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java deleted file mode 100644 index 05ce5c9f..00000000 --- a/src/main/java/net/frozenblock/lib/ingamedevtools/item/LootTableWhacker.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2024-2025 FrozenBlock - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.frozenblock.lib.ingamedevtools.item; - -import net.frozenblock.lib.FrozenLogUtils; -import net.minecraft.core.BlockPos; -import net.minecraft.core.component.DataComponents; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BrushableBlockEntity; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; -import net.minecraft.world.level.storage.loot.LootTable; -import org.jetbrains.annotations.NotNull; - -public class LootTableWhacker extends Item { - - public LootTableWhacker(Properties settings) { - super(settings); - } - - private static final MutableComponent FAIL_NO_NAME = Component.translatable("frozenlib.loot_table_whacker.fail.no_name"); - - @Override - public InteractionResult useOn(@NotNull UseOnContext context) { - Level level = context.getLevel(); - BlockPos blockPos = context.getClickedPos(); - ItemStack stack = context.getItemInHand(); - Player player = context.getPlayer(); - if (player == null) { - return InteractionResult.PASS; - } - if (stack.has(DataComponents.CUSTOM_NAME)) { - String id = stack.getHoverName().getString(); - ResourceLocation location = ResourceLocation.parse(id); - ResourceKey key = ResourceKey.create(Registries.LOOT_TABLE, location); - if (!level.isClientSide) { - if (level.getBlockEntity(blockPos) instanceof RandomizableContainerBlockEntity loot) { - loot.lootTable = key; - player.displayClientMessage(Component.translatable("frozenlib.loot_table_whacker.success", location.toString()), true); - FrozenLogUtils.log(location.toString(), true); - } else if (level.getBlockEntity(blockPos) instanceof BrushableBlockEntity loot) { - loot.lootTable = key; - player.displayClientMessage(Component.translatable("frozenlib.loot_table_whacker.success", location.toString()), true); - FrozenLogUtils.log(location.toString(), true); - } - } - return InteractionResult.SUCCESS; - } else { - player.displayClientMessage(FAIL_NO_NAME, true); - } - return InteractionResult.FAIL; - } - -}