Skip to content

Instantly share code, notes, and snippets.

@Commoble
Commoble / ObservationsOnEntitySpawnTicksInMinecraftForge115.txt
Last active January 16, 2021 19:15
Observations on entity spawn ticks in minecraft forge 1.15
the world attempts to spawn monsters every tick
the world attempts to spawn animals every 400 ticks
entities classified as MISC are not spawned in world-chunk ticks
int mobCap = nominal cap * tracked chunks / 289D // 289 == 17^2
nominal cap is 70 for monsters, 10 for animals
tracked chunks is the number of chunks tracked by any player (the range appears to be 8)
I'm not sure if this is a square or a circle, but if it's a square, then we have 289 chunks tracked per player (minus overlaps)
if (total Explicitly Persistant Loaded Mobs < mobCap)
@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 / 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 / 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 / VoxelShapeGetters.java
Last active December 10, 2023 22:31
What's the difference between the different VoxelShape getters in forge for minecraft 1.16.4?
/**
AbstractBlock::getShape(BlockState, IBlockReader, BlockPos, ISelectionContext)
The primary shape for "selection" raytraces, like clicking a block.
Defaults to a full cube. Delegated to by AbstractBlockState::getShape(IBlockReader, BlockPos, ISelectionContext)
Most of the other shape getters either default to this or default to empty,
so just overriding this shape getter is sufficient if finer variations aren't needed.
AbstractBlock::getCollisionShape(BlockState, IBlockReader, BlockPos, ISelectionContext)
The primary shape for collision raytraces.
Delegated to by AbstractBlockState::getCollisionShape(IBlockReader, BlockPos, ISelectionContext)
@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
@Commoble
Commoble / SyncingTileEntitiesInMinecraftForgeOnePointFifteen.java
Last active October 29, 2021 11:07
Syncing Tile Entities in Minecraft Forge 1.15
/** TLDR
* Update Tag -> sent when client loads the chunk the TE is in
* Update Packet -> sent when you call world.notifyBlockUpdate
**/
public class YourTileEntity extends TileEntity
{
public YourTileEntity()
@Commoble
Commoble / EffectsOfTaggingAFluidAsWaterInVanillaMinecraftPlusForgeCode
Last active October 10, 2020 20:15
EFFECTS OF TAGGING A FLUID AS WATER IN VANILLA MINECRAFT + FORGE CODE (1.15?)
```
EFFECTS OF TAGGING A FLUID AS WATER IN VANILLA MINECRAFT + FORGE CODE
This list is not intended to be exhaustive, up-to-date, or accurate
- Sponges can absorb WATER
- Walking while fully submerged in WATER is exhausting and counts as walking underwater for stats-tracking
- Allows things to pathfind through it if necessary (things won't pathfind through any fluid that isn't WATER)
- Decrements your air supply
- Allows the worldcarver to carve through the floor beneath WATER
- Affects reactions between your fluid and LAVA
- Prevents other WATER from displacing your fluid
@Commoble
Commoble / ThisIsHowYouMakeDimensionsInForgeForMinecraft14.java
Last active February 25, 2022 21:42
Custom Dimensions and How You Go In Them in Minecraft Forge 1.14 and 1.15
/**
WHAT ARE WE WORKING WITH
--Dimension, DimensionType, ServerWorld
-- There exists a 1:1:1 relationship between each of these, e.g. there will be one DimensionType instance
and one Dimension instance for a given ServerWorld, and those DimensionType and Dimension instances will only be
used on that worldserver
--ServerWorld
-- The server-specific version of the World, which holds all the block and chunk data, entities, tile entities, etc.\
for a given dimension. You won't be making these yourself or extending the class, but you'll need to find and use the
ServerWorld for your Dimension to teleport the player there.
@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;