Jump to content

Recommended Posts

Posted

So I recently removed the whole RNG of Minecraft 1.12.2,

 

but it's done in MCP.

And I don't know very much about Forge

 

What i did is just replacing the java.util.Random Import with my custom class.

But there are a few exceptions...

Here is a List:

 

Every File: 
import java.util.Random to import customrng.Random 
net.minecraft.client.audio.SoundManager: 
String s = MathHelper.getRandomUUID(ThreadLocalRandom.current()).toString(); 

to 
String s = MathHelper.getRandomUUID(new java.util.Random()).toString(); 


net.minecraft.entity.ai.attributes.AttributeModifier: 
this(MathHelper.getRandomUUID(ThreadLocalRandom.current()), nameIn, amountIn, operationIn); 

to 
this(MathHelper.getRandomUUID(new java.util.Random()), nameIn, amountIn, operationIn); 


net.minecraft.entity.Entity: 
this.entityUniqueID = MathHelper.getRandomUUID(this.rand); 

to 
this.entityUniqueID = MathHelper.getRandomUUID(new java.util.Random()); 


net.minecraft.util.math.MathHelper:
public static UUID getRandomUUID(Random rand)
    {
        long i = rand.nextLong() & -61441L | 16384L;
        long j = rand.nextLong() & 4611686018427387903L | Long.MIN_VALUE;
        return new UUID(i, j);
    }

    /**
     * Generates a random UUID using the shared random
     */
    public static UUID getRandomUUID()
    {
        return getRandomUUID(RANDOM);
    }

to 
public static UUID getRandomUUID(java.util.Random random2)
    {
        long i = random2.nextLong() & -61441L | 16384L;
        long j = random2.nextLong() & 4611686018427387903L | Long.MIN_VALUE;
        return new UUID(i, j);
    }

    /**
     * Generates a random UUID using the shared random
     */
    public static UUID getRandomUUID()
    {
        return getRandomUUID(new java.util.Random());
    }

net.minecraft.world.biome.BiomeEndDecorator: 
Collections.shuffle(list, new Random(p_load_1_.longValue())); 

to 
Collections.shuffle(list, new java.util.Random(p_load_1_.longValue()));
net.minecraft.world.end.DragonFightManager: 
Collections.shuffle(this.gateways, new Random(worldIn.getSeed()));
 to 
Collections.shuffle(this.gateways, new java.util.Random(worldIn.getSeed())); 


net.minecraft.world.gen.structure: 
Collections.shuffle(list, p_175836_1_);
 to 
Collections.shuffle(list, new java.util.Random());


net.minecraft.world.gen.structure.WoodlandMansionPieces: 
Collections.shuffle(list, this.field_191117_a);
 to 
Collections.shuffle(list, new java.util.Random()); 

net.minecraft.world.storage.loot:
```java
private void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand)
    {
        List<ItemStack> list = Lists.<ItemStack>newArrayList();
        Iterator<ItemStack> iterator = stacks.iterator();

        while (iterator.hasNext())
        {
            ItemStack itemstack = iterator.next();

            if (itemstack.func_190926_b())
            {
                iterator.remove();
            }
            else if (itemstack.func_190916_E() > 1)
            {
                list.add(itemstack);
                iterator.remove();
            }
        }

        p_186463_2_ = p_186463_2_ - stacks.size();

        while (p_186463_2_ > 0 && !list.isEmpty())
        {
            ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
            int i = MathHelper.getInt(rand, 1, itemstack2.func_190916_E() / 2);
            ItemStack itemstack1 = itemstack2.splitStack(i);

            if (itemstack2.func_190916_E() > 1 && rand.nextBoolean())
            {
                list.add(itemstack2);
            }
            else
            {
                stacks.add(itemstack2);
            }

            if (itemstack1.func_190916_E() > 1 && rand.nextBoolean())
            {
                list.add(itemstack1);
            }
            else
            {
                stacks.add(itemstack1);
            }
        }

        stacks.addAll(list);
        Collections.shuffle(stacks, rand);
    }

    private List<Integer> getEmptySlotsRandomized(IInventory inventory, Random rand)
    {
        List<Integer> list = Lists.<Integer>newArrayList();

        for (int i = 0; i < inventory.getSizeInventory(); ++i)
        {
            if (inventory.getStackInSlot(i).func_190926_b())
            {
                list.add(Integer.valueOf(i));
            }
        }

        Collections.shuffle(list, rand);
        return list;
    }
```
to ```java
private void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand)
    {
        List<ItemStack> list = Lists.<ItemStack>newArrayList();
        Iterator<ItemStack> iterator = stacks.iterator();

        while (iterator.hasNext())
        {
            ItemStack itemstack = iterator.next();

            if (itemstack.func_190926_b())
            {
                iterator.remove();
            }
            else if (itemstack.func_190916_E() > 1)
            {
                list.add(itemstack);
                iterator.remove();
            }
        }

        p_186463_2_ = p_186463_2_ - stacks.size();

        while (p_186463_2_ > 0 && !list.isEmpty())
        {
            ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
            int i = MathHelper.getInt(rand, 1, itemstack2.func_190916_E() / 2);
            ItemStack itemstack1 = itemstack2.splitStack(i);

            if (itemstack2.func_190916_E() > 1 && rand.nextBoolean())
            {
                list.add(itemstack2);
            }
            else
            {
                stacks.add(itemstack2);
            }

            if (itemstack1.func_190916_E() > 1 && rand.nextBoolean())
            {
                list.add(itemstack1);
            }
            else
            {
                stacks.add(itemstack1);
            }
        }

        stacks.addAll(list);
        Collections.shuffle(stacks, new java.util.Random());
    }

    private List<Integer> getEmptySlotsRandomized(IInventory inventory, Random rand)
    {
        List<Integer> list = Lists.<Integer>newArrayList();

        for (int i = 0; i < inventory.getSizeInventory(); ++i)
        {
            if (inventory.getStackInSlot(i).func_190926_b())
            {
                list.add(Integer.valueOf(i));
            }
        }

        Collections.shuffle(list, new java.util.Random());
        return list;
    }
```

That's it!

 

Well i don't know if that is possible or not. (i think not)

If anybody can help me with that ty.

 

So: I need to transform every Random import with my Class which has to be injected in the Code of Minecraft.

And i need to change a few lines in the code.

 

Ty 4 your help :D

 

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • So i have a forge modded aternos server that worked just fine for a month untill today it suddenly crashes most of the time giving errors and idk which mod is causing the error or its smth else here is the crash log link https://mclo.gs/gGkzGKT
    • Struggling to decipher a crash report I'm getting in a custom modpack I'm tinkering with. The crash happens on startup, but weirdly, only some of the time. It seems to be related to Steves Carts, but weirdly it only started happening recently, and I can't identify if another mod is conflicting, or why it is only happening some of the time:   java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.player.Player.m_20202_()" because "player" is null at vswe.stevescarts.events.OverlayEventHandler.onRenderTick(OverlayEventHandler.java:24) ~[stevescarts-1.20.1-1.1.14.jar%23527!/:1.20.1-1.1.14] {re:classloading} at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:260) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:252) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(ForgeEventFactory.java:919) ~[forge-1.20.1-47.1.106-universal.jar%23581!/:?] {re:mixin,re:classloading,pl:mixin:APP:modernfix-forge.mixins.json:perf.potential_spawns_alloc.ForgeEventFactoryMixin,pl:mixin:A} at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1148) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:218) ~[minecraft-1.20.1-client.jar:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:flywheel.mixins.json:ClientMainMixin,pl:mixin:A,pl:runtimedistcleaner:A}     Including some extra info in case any of it is relevant^. Appreciate any ideas/advice!    
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.