### Manage Mod Configuration - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt Handles mod configuration options, including recipe difficulty and visual settings. Supports in-game configuration changes by reading and writing to a configuration file. ```java public class Config { public static Configuration configuration; public static Boolean overPoweredRecipe = true; public static Boolean hidePotionEffects = true; public static void synchronizeConfiguration(File configFile) { configuration = new Configuration(configFile); ConfigCategory category = configuration.getCategory(Configuration.CATEGORY_GENERAL); category.setLanguageKey("config.category." + Configuration.CATEGORY_GENERAL); synchronizeConfiguration(); } public static void synchronizeConfiguration() { overPoweredRecipe = configuration.getBoolean( "OverPoweredRecipe", Configuration.CATEGORY_GENERAL, overPoweredRecipe, "Is the recipe for timecrystal extremely OP?", "config.property.OverPoweredRecipe"); hidePotionEffects = configuration.getBoolean( "HidePotionEffects", Configuration.CATEGORY_GENERAL, hidePotionEffects, "Hide potion effects?", "config.property.HidePotionEffects"); if (configuration.hasChanged()) { configuration.save(); } } } ``` -------------------------------- ### Register Mod GUIs - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt Handles the registration and creation of GUI elements for both the client and server sides of the mod. It implements the IGuiHandler interface to provide the correct container and GUI instances based on the requested ID and world context. ```java // ModGuiHandler.java - GUI registration and creation public class ModGuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == 0) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityBaseTimeCrystal t) { return new ContainerTimeCrystal(t); } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == 0) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityBaseTimeCrystal t) { return new GuiTimeCrystal(t, new ContainerTimeCrystal(t)); } } return null; } } ``` -------------------------------- ### Define Crafting Recipes for Time Crystal Tiers (Java) Source: https://context7.com/kuolemax/time-crystal/llms.txt This Java code defines the crafting recipes for different tiers of time crystals. It includes logic to adjust recipe difficulty based on configuration and defines recipes for basic, compressed, and double compressed time crystals. Dependencies include Config, GameRegistry, ItemStack, ModBlocks, and various Items/Blocks. ```java public final class Recipes { public static void init() { // Basic Time Crystal recipe (configurable difficulty) if (Config.overPoweredRecipe) { // Easy recipe: Clocks + Nether Star GameRegistry.addRecipe( new ItemStack(ModBlocks.timeCrystal), "XCX", "CTC", "XCX", 'C', Items.clock, 'T', Items.nether_star); } else { // Hard recipe: Clocks + Diamond Blocks + Nether Star GameRegistry.addRecipe( new ItemStack(ModBlocks.timeCrystal), "SCS", "CTC", "SCS", 'C', Items.clock, 'S', Blocks.diamond_block, 'T', Items.nether_star); } // Compressed: 9x Time Crystal GameRegistry.addRecipe( new ItemStack(ModBlocks.compressedTimeCrystal), "XXX", "XXX", "XXX", 'X', ModBlocks.timeCrystal); // Double Compressed: 9x Compressed Time Crystal GameRegistry.addRecipe( new ItemStack(ModBlocks.doubleCompressedTimeCrystal), "XXX", "XXX", "XXX", 'X', ModBlocks.compressedTimeCrystal); } } ``` -------------------------------- ### Initialize Time Crystal Mod - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt The main mod class for Time Crystal, responsible for initialization, event handling, and mod lifecycle management using Forge annotations. It sets up the mod ID, version, and client/server proxies. ```Java import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import cn.kuolemax.timecrystal.init.ClientProxy; import cn.kuolemax.timecrystal.init.CommonProxy; import cn.kuolemax.timecrystal.gui.ConfigGuiFactory; @Mod( modid = TimeCrystal.MODID, version = Tags.VERSION, name = "Time Crystal", acceptedMinecraftVersions = "[1.7.10]", guiFactory = "cn.kuolemax.timecrystal.gui.ConfigGuiFactory") public class TimeCrystal { public static final String MODID = "timecrystal"; public static final Logger LOG = LogManager.getLogger(MODID); public static boolean hasGregTech = false; private static TimeCrystal instance; @Mod.InstanceFactory public static TimeCrystal instance() { if (TimeCrystal.instance == null) TimeCrystal.instance = new TimeCrystal(); return TimeCrystal.instance; } @SidedProxy( clientSide = "cn.kuolemax.timecrystal.init.ClientProxy", serverSide = "cn.kuolemax.timecrystal.init.CommonProxy") public static CommonProxy proxy; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); FMLCommonHandler.instance().bus().register(new ConfigHandler()); } } ``` -------------------------------- ### Configure Time Crystal GUI - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt The in-game graphical user interface for adjusting the speed and range settings of the Time Crystal. It allows players to select different speed multipliers and area-of-effect ranges for the crystal. This GUI interacts with a TileEntity to apply the chosen settings. ```java // GuiTimeCrystal.java - Configuration GUI public class GuiTimeCrystal extends GuiContainer { private final TileEntityBaseTimeCrystal tile; private final GuiButton[] speedButtons = new GuiButton[5]; // OFF + 4 levels private final GuiButton[] rangeButtons = new GuiButton[4]; // 3x3 to 9x9 @Override public void initGui() { super.initGui(); // Create speed buttons (OFF, 1x, 2x, 3x, 4x multiplied by factor) int[] speeds = tile.getSpeeds(); for (int i = 0; i < speedButtons.length; i++) { String label = speeds[i] == 0 ? "OFF" : String.format("x%s", speeds[i]); speedButtons[i] = new GuiButton(i, guiLeft + 10 + (i * 35), guiTop + 40, 30, 20, label); speedButtons[i].enabled = (i != tile.getSpeedIndex()); buttonList.add(speedButtons[i]); } // Create range buttons (3x3, 5x5, 7x7, 9x9) String[] rangeLabels = { "3x3", "5x5", "7x7", "9x9" }; for (int i = 0; i < rangeButtons.length; i++) { rangeButtons[i] = new GuiButton(i + 10, guiLeft + 10 + (i * 45), guiTop + 80, 40, 20, rangeLabels[i]); rangeButtons[i].enabled = (i + 1 != tile.getRange()); buttonList.add(rangeButtons[i]); } } @Override protected void actionPerformed(GuiButton button) { if (button.id >= 0 && button.id <= 4) { // Speed button clicked - send update to server tile.setSpeedWithIndex(button.id); PacketHandler.INSTANCE.sendToServer( new PacketUpdateTile(tile.xCoord, tile.yCoord, tile.zCoord, button.id, 0)); } else if (button.id >= 10 && button.id <= 13) { // Range button clicked - send update to server int rangeValue = button.id - 9; tile.setRange(rangeValue); PacketHandler.INSTANCE.sendToServer( new PacketUpdateTile(tile.xCoord, tile.yCoord, tile.zCoord, rangeValue, 1)); } } } ``` -------------------------------- ### Implement Network Packet System for Tile Entity Updates (Java) Source: https://context7.com/kuolemax/time-crystal/llms.txt This Java code implements a network packet system for handling client-server communication, specifically for updating tile entity properties like speed and range. It includes packet registration and handling logic for updating a Time Crystal tile entity. Dependencies include SimpleNetworkWrapper, NetworkRegistry, IMessage, IMessageHandler, MessageContext, World, TileEntity, and TileEntityBaseTimeCrystal. ```java // PacketHandler.java - Network channel registration public class PacketHandler { public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(TimeCrystal.MODID); public static void init() { INSTANCE.registerMessage(PacketUpdateTile.Handler.class, PacketUpdateTile.class, 0, Side.SERVER); } } // PacketUpdateTile.java - Tile entity update packet public class PacketUpdateTile implements IMessage { private int x, y, z; private int value; private int type; // 0 = speed, 1 = range public PacketUpdateTile(int x, int y, int z, int value, int type) { this.x = x; this.y = y; this.z = z; this.value = value; this.type = type; } @Override public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeInt(value); buf.writeByte(type); } public static class Handler implements IMessageHandler { @Override public IMessage onMessage(PacketUpdateTile message, MessageContext ctx) { World world = ctx.getServerHandler().playerEntity.worldObj; TileEntity te = world.getTileEntity(message.x, message.y, message.z); if (te instanceof TileEntityBaseTimeCrystal crystal) { if (message.type == 0) { crystal.setSpeedWithIndex(message.value); } else { crystal.setRange(message.value); } crystal.markDirty(); world.markBlockForUpdate(message.x, message.y, message.z); } return null; } } } ``` -------------------------------- ### Crystal Tier Implementations - Time Crystal Variants Source: https://context7.com/kuolemax/time-crystal/llms.txt Provides specific implementations for different tiers of Time Crystals, each overriding the getFactor() method to return a unique acceleration multiplier. These classes extend TileEntityBaseTimeCrystal and define the 1x, 9x, and 81x acceleration factors. ```java // TileEntityTimeCrystal.java - Basic tier (1x factor) public class TileEntityTimeCrystal extends TileEntityBaseTimeCrystal { @Override public int getFactor() { return 1; // Speeds: 0, 1, 2, 3, 4 } } ``` ```java // TileEntityCompressedTimeCrystal.java - Compressed tier (9x factor) public class TileEntityCompressedTimeCrystal extends TileEntityBaseTimeTimeCrystal { @Override public int getFactor() { return 9; // Speeds: 0, 9, 18, 27, 36 } } ``` ```java // TileEntityDoubleCompressedTimeCrystal.java - Double compressed tier (81x factor) public class TileEntityDoubleCompressedTimeCrystal extends TileEntityBaseTimeTimeCrystal { @Override public int getFactor() { return 9 * 9; // Speeds: 0, 81, 162, 243, 324 } } ``` -------------------------------- ### Implement Time Crystal Block - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt Provides the base implementation for the Time Crystal block, including custom rendering, collision handling, and GUI integration. It overrides standard block methods to enable unique functionalities. ```java public class BlockTimeCrystal extends BlockContainer { public BlockTimeCrystal() { super(Material.circuits); this.setBlockName("timecrystal.time_crystal"); this.setBlockTextureName("timecrystal:time_crystal"); this.setLightLevel(1f); this.setCreativeTab(CreativeTabs.tabTools); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { // Open the configuration GUI when player right-clicks the block player.openGui(TimeCrystal.instance(), 0, world, x, y, z); } return true; } @Override public TileEntity createNewTileEntity(final World world, final int i) { return new TileEntityTimeCrystal(); } @Override public boolean isOpaqueCube() { return false; // Crystal is transparent } @Override public int getRenderType() { return -1; // Custom rendering via TileEntitySpecialRenderer } } ``` -------------------------------- ### Time Acceleration Logic - TileEntityBaseTimeCrystal Source: https://context7.com/kuolemax/time-crystal/llms.txt Implements the core time acceleration mechanism by iterating through blocks and tile entities within range and calling their update methods. It includes a blacklist for blocks that should not be accelerated and handles different acceleration factors based on crystal tier. Dependencies include standard Java utilities and Minecraft's TileEntity and Block classes. ```java public abstract class TileEntityBaseTimeCrystal extends TileEntity { // Blocks that should not be accelerated private static final ImmutableSet blacklist = ImmutableSet.of( Blocks.air, Blocks.bedrock, Blocks.obsidian, Blocks.stone, ModBlocks.timeCrystal, ModBlocks.compressedTimeCrystal, ModBlocks.doubleCompressedTimeCrystal); private int speedIndex = 0; private int range = 1; private final int[] baseSpeedArr = new int[] { 0, 1, 2, 3, 4 }; // Abstract method - each tier returns different multiplier public abstract int getFactor(); // 1x, 9x, or 81x public int[] getSpeeds() { return Arrays.stream(baseSpeedArr) .map(it -> it * this.getFactor()) .toArray(); } @Override public void updateEntity() { if (worldObj.isRemote || this.getSpeed() == 0) return; // Iterate through all blocks in range for (int x = xCoord - range; x <= xCoord + range; x++) { for (int y = yCoord - 1; y <= yCoord + 1; y++) { for (int z = zCoord - range; z <= zCoord + range; z++) { Block block = worldObj.getBlock(x, y, z); if (block == null || blacklist.contains(block)) continue; // Accelerate random tick blocks (crops, etc.) if (block.getTickRandomly()) { for (int i = 0; i < getSpeed(); i++) block.updateTick(worldObj, x, y, z, rand); continue; } // Accelerate tile entities (furnaces, machines, etc.) TileEntity tileEntity = worldObj.getTileEntity(x, y, z); if (tileEntity != null && tileEntity.canUpdate()) { // Special GregTech handling if (TimeCrystal.hasGregTech && tileEntity instanceof BaseMetaTileEntity) { // Directly increment progress timer for GT machines // ... GregTech-specific acceleration code } else { for (int i = 0; i < getSpeed(); i++) { tileEntity.updateEntity(); } } } } } } } public void setSpeedWithIndex(int speedIndex) { this.speedIndex = speedIndex; } public void setRange(int range) { this.range = range; } } ``` -------------------------------- ### Register Time Crystal Blocks - Java Source: https://context7.com/kuolemax/time-crystal/llms.txt Handles the registration of all time crystal block variants and their associated tile entities with the Minecraft game registry. This ensures the blocks are recognized and can be placed in the world. ```Java import net.minecraft.block.Block; import net.minecraftforge.fml.common.registry.GameRegistry; import cn.kuolemax.timecrystal.blocks.BlockCompressedTimeCrystal; import cn.kuolemax.timecrystal.blocks.BlockDoubleCompressedTimeCrystal; import cn.kuolemax.timecrystal.blocks.BlockTimeCrystal; import cn.kuolemax.timecrystal.tileentities.TileEntityCompressedTimeCrystal; import cn.kuolemax.timecrystal.tileentities.TileEntityDoubleCompressedTimeCrystal; import cn.kuolemax.timecrystal.tileentities.TileEntityTimeCrystal; public final class ModBlocks { public static BlockTimeCrystal timeCrystal; public static BlockCompressedTimeCrystal compressedTimeCrystal; public static BlockDoubleCompressedTimeCrystal doubleCompressedTimeCrystal; public static void init() { // Initialize block instances ModBlocks.timeCrystal = new BlockTimeCrystal(); ModBlocks.compressedTimeCrystal = new BlockCompressedTimeCrystal(); ModBlocks.doubleCompressedTimeCrystal = new BlockDoubleCompressedTimeCrystal(); // Register blocks with GameRegistry GameRegistry.registerBlock(ModBlocks.timeCrystal, ModBlocks.timeCrystal.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityTimeCrystal.class, "tile_time_crystal"); GameRegistry.registerBlock(ModBlocks.compressedTimeCrystal, ModBlocks.compressedTimeCrystal.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityCompressedTimeCrystal.class, "tile_compressed_time_crystal"); GameRegistry.registerBlock(ModBlocks.doubleCompressedTimeCrystal, ModBlocks.doubleCompressedTimeCrystal.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityDoubleCompressedTimeCrystal.class, "tile_double_compressed_time_crystal"); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.