Skip to content

Instantly share code, notes, and snippets.

@Commoble
Commoble / areagrid.py
Created August 29, 2019 04:25
Python script to generate permutations of a 3x3 grid divided into rectangles
import string
primes = []
first100primes = []
START_VALS = range(0,3)
SIZE_VALS = range(1,4)
class XY:
def __init__(self, x, y):
self.x = x
@Commoble
Commoble / Registration.java
Last active September 17, 2019 17:17
This Is How Commoble Registers Things in Forge for Minecraft
/**
* Helper class that we use to register things
*/
public class Registrator<T extends IForgeRegistryEntry<T>>
{
public IForgeRegistry<T> registry;
public Registrator(IForgeRegistry<T> registry)
{
this.registry = registry;
@Commoble
Commoble / SummaryOfMinecraftForgeAbstractFurnaceTileEntityTickLogic.txt
Last active June 19, 2020 18:40
Summary of minecraft forge AbstractFurnaceTileEntity tick logic
how does furnace logic flow?
if burning, decrement burn time
rest of tick is on server worlds only
if burning, or if can start burning fuel and has a smeltable input
if not burning but can start cooking
set burn time based on fuel input
@Commoble
Commoble / DirectionTransformer.java
Last active June 29, 2020 17:36
Direction Rotation Table
public static final Direction D = Direction.DOWN;
public static final Direction U = Direction.UP;
public static final Direction N = Direction.NORTH;
public static final Direction S = Direction.SOUTH;
public static final Direction W = Direction.WEST;
public static final Direction E = Direction.EAST;
public static final Direction[] SAMES ={D,U,N,S,W,E};
public static final Direction[] OPPOSITES = {U,D,S,N,E,W};
public static final Direction[] ROTATE_X_DNUS = {N,S,U,D,W,E};
@Commoble
Commoble / RandomPermutation.java
Last active June 30, 2020 15:39
Random Permutation Generator
/**
* Returns an array of numbers [a0, a1, a2 ... a(n-1)]
* Where each number aX is unique,
* n is given by permutationSize,
* and the different possible numbers returnable are in the range [0, possibilities).
*
* Implements the algorithms given here
* https://stackoverflow.com/questions/158716/how-do-you-efficiently-generate-a-list-of-k-non-repeating-integers-between-0-and-n
* https://www.geeksforgeeks.org/generate-a-random-permutation-of-1-to-n/
*
@Commoble
Commoble / Fluids.java
Created August 29, 2020 04:03
Flowing Fluid Registry Helper for Minecraft Forge 1.16
public class FluidTest
{
public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(ForgeRegistries.FLUIDS, "modid");
public static final Pair<RegistryObject<ForgeFlowingFluid.Source>, RegistryObject<ForgeFlowingFluid.Flowing>> TEST_FLUIDS =
registerFluid("test_fluid", "flowing_test_fluid",
ForgeFlowingFluid.Source::new,
ForgeFlowingFluid.Flowing::new,
FluidAttributes.builder(new ResourceLocation("modid:block/test_fluid_still"), new ResourceLocation("modid:block/test_fluid_flowing")));
@Commoble
Commoble / CodecJsonDataManager.java
Last active October 3, 2020 18:28
Codec-based Json Data Loader for Minecraft Forge 1.16.3
/*
The MIT License (MIT)
Copyright (c) 2020 Joseph Bettendorff a.k.a. "Commoble"
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@Commoble
Commoble / IdleTimeAndMobDespawningInMinecraftForge.txt
Created October 9, 2020 23:19
Idle Time and Mob Despawning in Minecraft Forge
idletime has these interactions:
is reset to 0 when:
when attacked
in the despawn check, when:
when the despawn fails due to persistance flag set or preventDespawn returning true
when the forge event is denied
when the nearest player is closer than the random despawn distance
when piglin or raider uses a ranged attack
when raider starts targeting a home
@Commoble
Commoble / waterSlowdown.txt
Created October 10, 2020 20:13
Water Slowdown Mechanics in Minecraft Forge 1.16.3
water slowdown mechanics
assume an entity is in water
let moveSpeed = movement speed attribute
defaults to 0.7 for players?
let swimSpeed = swim speed modifier attribute
defaults to 1.0
let depthStriderEnchantment be 0F, 1F, 2F, or 3F (depends on enchantment tier, hard capped at 3) if on ground, or half that if treading water
let depthStriderFactor = depthStriderEnchantment / 3F (results in a number in the range [0,1])
@Commoble
Commoble / EngineeringNotation.java
Created April 7, 2020 16:39
Engineering Notation Util for Minecraft+Forge 1.15
/**
The MIT License (MIT)
Copyright (c) Joseph "Commoble" Bettendorff 2020
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is