Skip to content

Instantly share code, notes, and snippets.

@Cadiboo
Cadiboo / Collisions.java
Last active July 10, 2021 10:23
Minecraft's collisions are hard to wrap my head around
public class Entity {
//...
// AKA 'adjustMovementForCollisions'
public static Vector3d collideBoundingBoxHeuristically(@Nullable Entity entity, Vector3d motion, AxisAlignedBB aabb, World world, ISelectionContext ctx, ReuseableStream<VoxelShape> nonBlockShapes) {
// 'nonBlockShapes' may include the shapes of other entities and the world border
boolean xStatic = motion.x == 0.0D;
boolean yStatic = motion.y == 0.0D;
boolean zStatic = motion.z == 0.0D;
boolean xOrYMoving = !xStatic || !yStatic;
[03:00:53] [main/INFO] [GradleStart]: Extra: []
[03:00:53] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, /Users/Cadiboo/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[03:00:53] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[03:00:53] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[03:00:53] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[03:00:53] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[03:00:53] [main/DEBUG] [FML]: Injecting tracing printstreams for STDOUT/STDERR.
[03:00:53] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2795 for Minecraft 1.12.2 loadi
> Configure project :
New Dep: net.minecraftforge:forge:1.16.1-32.0.106_mapped_snapshot_20200723-1.16.1_at_b8ece74492c7bf6fe378357d1b29a80593acc080
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'NoCubes'.
> Invalid patcher dependency: net.minecraftforge:forge:1.16.1-32.0.106:userdev
Test: get
5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0,
8, 9, 7, 10, 6,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
3, 4, 2, 5, 1, 6, 0, 7, 8, 9, 10,
7, 8, 6, 9, 5, 10, 4, 11, 3, 12, 2, 13, 1, 14, 0, 15, 16, 17, 18, 19, 20,
15, 16, 14, 17, 13, 18, 12, 19, 11, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
Test: get2
5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0,
@Cadiboo
Cadiboo / FieldDebug.java
Created January 6, 2020 12:10
Rendering Debugging helper
public class FieldDebug {
/**
* Call this code from a debugger evaluation from some working code and some code that
* doesn't work then compare the two dumps. Comparing the two will allow you to see the
* differences and change your code to eliminate the differences by invoking methods on
* the RenderSystem.
*/
public static void printGlStateManager() throws IllegalAccessException {
final StringBuilder stringBuilder = new StringBuilder();
@Cadiboo
Cadiboo / ModDimensionTeleporter.java
Created January 6, 2020 11:19
How to get to your Dimension in 1.14 (and probably in 1.13 and 1.15 too)
// By Commoble#9251
// https://discordapp.com/channels/176780432371744769/179315645005955072/661244291833790494 on the MMD Discord (https://discord.mcmoddev.com/)
// How to get to your Dimension in 1.14 (and probably in 1.13 and 1.15 too)
public static void teleportPlayerToDimension(ServerPlayerEntity player, DimensionType destinationType, BlockPos destinationPos) {
ServerWorld nextWorld = player.getServer().getWorld(destinationType);
nextWorld.getChunk(destinationPos); // Make sure the chunk is loaded
player.teleport(nextWorld, destinationPos.getX(), destinationPos.getY(), destinationPos.getZ(), player.rotationYaw, player.rotationPitch);
}
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
package io.github.cadiboo.testrender.render;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;
import static io.github.cadiboo.testrender.main.Main.handleException;
import static org.lwjgl.glfw.GLFW.GLFW_FALSE;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
package net.minecraft.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
package me.asuramagica.blocks.tileentity;
import me.asuramagica.block.inventory.ManaStoneContainer;
import me.asuramagica.list.BlockList;
import me.asuramagica.list.ItemList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FireBlock;
import net.minecraft.entity.player.PlayerEntity;