From 4e93171437b7e76f065b0524aabcacb9fef2c7b9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 22 Jul 2024 01:15:38 +0300 Subject: [PATCH] Fullbright --- README.md | 2 +- gradle.properties | 12 +-- .../lumijiez/cacheduper/CacheDupeCommand.java | 75 ------------------- .../com/lumijiez/cacheduper/CacheDuper.java | 14 ---- .../java/com/lumijiez/cacheduper/Tags.java | 12 --- .../java/com/lumijiez/cacheduper/Utils.java | 62 --------------- .../com/lumijiez/luminous/HelloCommand.java | 33 ++++++++ .../java/com/lumijiez/luminous/Luminous.java | 42 +++++++++++ src/main/java/com/lumijiez/luminous/Tags.java | 9 +++ src/main/resources/mcmod.info | 14 ++-- 10 files changed, 98 insertions(+), 177 deletions(-) delete mode 100644 src/main/java/com/lumijiez/cacheduper/CacheDupeCommand.java delete mode 100644 src/main/java/com/lumijiez/cacheduper/CacheDuper.java delete mode 100644 src/main/java/com/lumijiez/cacheduper/Tags.java delete mode 100644 src/main/java/com/lumijiez/cacheduper/Utils.java create mode 100644 src/main/java/com/lumijiez/luminous/HelloCommand.java create mode 100644 src/main/java/com/lumijiez/luminous/Luminous.java create mode 100644 src/main/java/com/lumijiez/luminous/Tags.java diff --git a/README.md b/README.md index 12df9ee..9bd5064 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ __Warning:__ Access Transformers are bugged and will deny you any sources for th Mixins are usually used to modify vanilla or mod/library in runtime without having to change source code. For example, redirect a call, change visibility or make class implement your interface. It's an advanced topic and most mods don't need to do that. You can activate Mixin in 'gradle.properties'. In that case a mixin configuration (usually named `mixins.mymodid.json`) will be generated automatically, and you only have to write the mixins itself. Dependencies are handled as well. -Take a look at the examples in [`com.lumijiez.cacheduper.mixinplugin.*`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins/src/main/java/com/myname/mymodid/mixinplugin) and [`com.lumijiez.cacheduper.mixins.*`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins/src/main/java/com/myname/mymodid/mixins). +Take a look at the examples in [`com.lumijiez.luminous.mixinplugin.*`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins/src/main/java/com/myname/mymodid/mixinplugin) and [`com.lumijiez.luminous.mixins.*`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins/src/main/java/com/myname/mymodid/mixins). Check out the [`example-mixins`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins) brach for a working example! diff --git a/gradle.properties b/gradle.properties index 6935f51..28f08ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -modName = CacheDuper +modName = Luminous # This is a case-sensitive string to identify your mod. Convention is to use lower case. -modId = cacheduper +modId = luminous -modGroup = com.lumijiez.cacheduper +modGroup = com.lumijiez.luminous # WHY is there no version field? # The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the @@ -15,7 +15,7 @@ autoUpdateBuildScript = false minecraftVersion = 1.7.10 forgeVersion = 10.13.4.1614 -# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you # restart Minecraft in development. Choose this dependent on your mod: # Do you need consistent player progressing (for example Thaumcraft)? -> Select a name # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty @@ -34,7 +34,7 @@ gradleTokenGroupName = GRADLETOKEN_GROUPNAME # In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can # leave this property empty. -# Example value: apiPackage = api + modGroup = com.lumijiez.cacheduper -> com.lumijiez.cacheduper.api +# Example value: apiPackage = api + modGroup = com.lumijiez.luminous -> com.lumijiez.luminous.api apiPackage = # Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ @@ -49,7 +49,7 @@ mixinPlugin = mixinsPackage = # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! # This parameter is for legacy compatibility only -# Example value: coreModClass = asm.FMLPlugin + modGroup = com.lumijiez.cacheduper -> com.lumijiez.cacheduper.asm.FMLPlugin +# Example value: coreModClass = asm.FMLPlugin + modGroup = com.lumijiez.luminous -> com.lumijiez.luminous.asm.FMLPlugin coreModClass = # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class # that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! diff --git a/src/main/java/com/lumijiez/cacheduper/CacheDupeCommand.java b/src/main/java/com/lumijiez/cacheduper/CacheDupeCommand.java deleted file mode 100644 index 7fc41fb..0000000 --- a/src/main/java/com/lumijiez/cacheduper/CacheDupeCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.lumijiez.cacheduper; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import java.util.UUID; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; - -public class CacheDupeCommand extends CommandBase { - - @Override - public String getCommandName() { - return "cachedp"; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "/cachedp "; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (args.length != 2) { - sender.addChatMessage(new ChatComponentText("Invalid arguments. Usage: " + getCommandUsage(sender))); - return; - } - - String itemId = args[0]; - int number; - - try { - number = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { - sender.addChatMessage(new ChatComponentText("The number parameter must be an integer.")); - return; - } - - Utils utils = new Utils(); - - ItemStack stack = Utils.getItemStackFromId(itemId, number); - - TileEntity checkTile = utils.tile(); - - try { - if (Class.forName("cofh.thermalexpansion.block.cache.TileCache").isInstance(checkTile)) { - Object packet = Class.forName("cofh.core.network.PacketTile").getConstructor(TileEntity.class).newInstance(checkTile); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addString", String.class).invoke(packet, ""); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addByte", byte.class).invoke(packet, (byte) 0); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addUUID", UUID.class).invoke(packet, UUID.randomUUID()); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addString", String.class).invoke(packet, ""); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addBool", boolean.class).invoke(packet, true); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addByte", byte.class).invoke(packet, (byte) 0); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addBool", boolean.class).invoke(packet, true); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addInt", int.class).invoke(packet, 0); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addByteArray", byte[].class).invoke(packet, new byte[6]); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addByte", byte.class).invoke(packet, (byte) 0); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addBool", boolean.class).invoke(packet, false); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addItemStack", ItemStack.class).invoke(packet, stack); - Class.forName("cofh.core.network.PacketCoFHBase").getMethod("addInt", int.class).invoke(packet, number); - Class.forName("cofh.core.network.PacketHandler").getMethod("sendToServer", Class.forName("cofh.core.network.PacketBase")).invoke(null, packet); - } - } catch(Exception ignored) {} - } -} diff --git a/src/main/java/com/lumijiez/cacheduper/CacheDuper.java b/src/main/java/com/lumijiez/cacheduper/CacheDuper.java deleted file mode 100644 index 3a49cdb..0000000 --- a/src/main/java/com/lumijiez/cacheduper/CacheDuper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lumijiez.cacheduper; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLServerStartingEvent; - -@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]") -public class CacheDuper { - - @Mod.EventHandler - public void onServerStarting(FMLServerStartingEvent event) { - event.registerServerCommand(new CacheDupeCommand()); - } - -} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/cacheduper/Tags.java b/src/main/java/com/lumijiez/cacheduper/Tags.java deleted file mode 100644 index 613c3ea..0000000 --- a/src/main/java/com/lumijiez/cacheduper/Tags.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lumijiez.cacheduper; - -// Use this class for Strings only. Do not import any classes here. It will lead to issues with Mixins if in use! - -public class Tags { - - // GRADLETOKEN_* will be replaced by your configuration values at build time - public static final String MODID = "GRADLETOKEN_MODID"; - public static final String MODNAME = "GRADLETOKEN_MODNAME"; - public static final String VERSION = "GRADLETOKEN_VERSION"; - public static final String GROUPNAME = "GRADLETOKEN_GROUPNAME"; -} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/cacheduper/Utils.java b/src/main/java/com/lumijiez/cacheduper/Utils.java deleted file mode 100644 index 26269be..0000000 --- a/src/main/java/com/lumijiez/cacheduper/Utils.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.lumijiez.cacheduper; - -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.entity.Entity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MovingObjectPosition; - -public class Utils { - - public Minecraft mc() { - return Minecraft.getMinecraft(); - } - - public int[] mop() { - MovingObjectPosition mop = mc().renderViewEntity.rayTrace(200, 1.0F); - Entity ent = pointedEntity(); - return new int[] { mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, (ent != null) ? ent.getEntityId() : -1 }; - } - - public static ItemStack getItemStackFromId(String itemId, int quantity) { - String[] parts = itemId.split(":"); - if (parts.length != 2) { - System.out.println("Invalid item ID format. Expected modid:itemname"); - return null; - } - - String modId = parts[0]; - String itemName = parts[1]; - - Item item = GameRegistry.findItem(modId, itemName); - if (item == null) { - System.out.println("Item not found: " + itemId); - return null; - } - - return new ItemStack(item, quantity); - } - - public WorldClient world() { - return mc().theWorld; - } - - public TileEntity tile() { - return tile(mop()); - } - - public TileEntity tile(int[] mop) { - return tile(mop[0], mop[1], mop[2]); - } - - public TileEntity tile(int x, int y, int z) { - return world().getTileEntity(x, y, z); - } - - public Entity pointedEntity() { - return mc().objectMouseOver.entityHit; - } -} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/luminous/HelloCommand.java b/src/main/java/com/lumijiez/luminous/HelloCommand.java new file mode 100644 index 0000000..9e0c484 --- /dev/null +++ b/src/main/java/com/lumijiez/luminous/HelloCommand.java @@ -0,0 +1,33 @@ +package com.lumijiez.luminous; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class HelloCommand extends CommandBase { + + @Override + public String getCommandName() { + return "hello"; + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/hello"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + sender.addChatMessage(new ChatComponentText("Hello!")); + } +} diff --git a/src/main/java/com/lumijiez/luminous/Luminous.java b/src/main/java/com/lumijiez/luminous/Luminous.java new file mode 100644 index 0000000..274a3cd --- /dev/null +++ b/src/main/java/com/lumijiez/luminous/Luminous.java @@ -0,0 +1,42 @@ +package com.lumijiez.luminous; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderWorldEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.common.MinecraftForge; + +import java.util.Arrays; +import java.util.logging.Logger; + +@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]") +public class Luminous { + + private static final Logger logger = Logger.getLogger(Tags.MODID); + + @SubscribeEvent + public void onRender(RenderWorldLastEvent event) { + if (Minecraft.getMinecraft().theWorld != null) { + float[] bTable = Minecraft.getMinecraft().theWorld.provider.lightBrightnessTable; + if (bTable != null) { + Arrays.fill(bTable, 1.0f); + } + } + } + + @Mod.EventHandler + public void onServerStarting(FMLServerStartingEvent event) { + event.registerServerCommand(new HelloCommand()); + } + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + MinecraftForge.EVENT_BUS.register(this); + logger.info("Luminous mod initialized."); + } +} diff --git a/src/main/java/com/lumijiez/luminous/Tags.java b/src/main/java/com/lumijiez/luminous/Tags.java new file mode 100644 index 0000000..e081026 --- /dev/null +++ b/src/main/java/com/lumijiez/luminous/Tags.java @@ -0,0 +1,9 @@ +package com.lumijiez.luminous; + + +public class Tags { + public static final String MODID = "GRADLETOKEN_MODID"; + public static final String MODNAME = "GRADLETOKEN_MODNAME"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + public static final String ROUPNAME = "GRADLETOKEN_GROUPNAME"; +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index c226201..2293eba 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,13 +1,13 @@ [ { - "modid": "${modId}", - "name": "${modName}", - "description": "An example mod for Minecraft 1.7.10 with Forge focussed on a stable setup.", - "version": "${modVersion}", - "mcversion": "${minecraftVersion}", - "url": "https://github.com/SinTh0r4s/MyMod", + "modid": "luminous", + "name": "Luminous", + "description": "Simple, fast fullbright mod for 1.7.10", + "version": "1.0.0", + "mcversion": "1.7.10", + "url": "https://github.com/lumijiez/forge-luminous", "updateUrl": "", - "authorList": ["SinTho0r4s"], + "authorList": ["Lumijiez"], "credits": "", "logoFile": "", "screenshots": [],