Skip to content

Instantly share code, notes, and snippets.

@CatDany
CatDany / gist:4d5ce4c39acdf9288cf0
Last active August 29, 2015 14:20
EE3 Custom EMC table
------ NEW ------
Track = 36
Dragon Egg = 32768
Certus Quartz Crystal = 512
Charged Certus Quartz Crystal = 768
Singularity = 256000
Yellorium Ingot = 4096
Monochromium Ingot = 256
Wool (any) = 48
Barley Seeds = 16
Цель: обе стороны должны иметь одно и то же значение - секрет. Это может быть что угодно (обычно массив байтов)
Условие:
Существует способ асимметрической криптографии (публичный ключ используется для зашифровки, секретный ключ используется для расшифровки). Используя этот способ никто не может узнать второй ключ, зная один из пары.
Решение:
1. Сервер создает случайную пару ключей.
2. Сервер передает публичный ключ клиенту (третья сторона имеет доступ к публичному ключу)
3. Клиент получает публичный ключ.
4. Клиент создает секрет.
@CatDany
CatDany / explanation.txt
Last active April 20, 2023 23:14
Minecraft Authentification UUID System Explained (How does Minecraft UUID system work?)
> Since 1.7 came out, there's a "GameProfile" assigned to every player now. You can get GameProfile of a player by using EntityPlayer.getGameProfile(). Yeah, with that said, you probably still wonder how does Minecraft UUID system work. Let me start explaining that.
>>>>>>>>>>>>>>>>>>>>>>>> DISCLAIMER! <<<<<<<<<<<<<<<<<<<<<<<<
>> 1. English is not my main language, I could make mistakes
>> 2. I could be wrong.
1. UUID in Java
> There's a concept of Universally Unique Identifier. If you're not familiar with it, try reading that*. If you have no time (too lazy) to read it, I'm going to cut a long story short here. UUID is an ID made out of 128 bits (16 bytes, 2 longs). It's called "unique" because the random number generator used when doing UUID.randomUUID() is very strong. According to wikipedia "only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%", so yeah, pretty strong. UUIDs can be converted to hexadecimal string and
package dany.test3;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import sun.awt.OSInfo;
import sun.awt.OSInfo.OSType;
@CatDany
CatDany / ModClass.java
Last active June 28, 2022 21:56
Packets are Easy (by Dany)
@EventHandler
public static void init(FMLInitializationEvent e)
{
// this should be in initialization
PacketHandler.initPackets();
}
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("message.redeem." + (result == EnumResult.SUCCESS ? "success" : "fail")).setChatStyle(new ChatStyle().setColor(result == EnumResult.SUCCESS ? EnumChatFormatting.GREEN : EnumChatFormatting.RED)));
@CatDany
CatDany / gist:9dc33b0eecc259ce5760
Created July 8, 2014 21:03
Such Network, Very Packet, Much Handler For So 1.7.2 / 1.7.10
/// PacketHandler.java ///
public class PacketHandler
{
public static PacketHandler instance;
public final SimpleNetworkWrapper net;
public static void init()
{
instance = new PacketHandler();
instance.net = NetworkRegistry.INSTANCE.newSimpleChannel("CHANNEL_NAME_USE_YOUR_MODID");