Skip to content

Instantly share code, notes, and snippets.

@TheGreyGhost
TheGreyGhost / gist:96983a0cd47c8c2f294d
Created August 22, 2015 01:56
Rendering to a FrameBuffer
package speedytools.clientside.selections;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
@TheGreyGhost
TheGreyGhost / gist:db79ee859f15a9c238c3
Created August 14, 2015 23:13
RayTraceServer - which block is player pointing at
package info.ata4.minecraft.dragon.server.util;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
try {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// just white
@TheGreyGhost
TheGreyGhost / gist:d3e89af8f4121bd63acc
Created August 8, 2015 13:57
Utility class for rotating and/or flipping blocks in 1.8
package speedytools.common.utilities;
import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import java.util.HashMap;
import java.util.Map;
@TheGreyGhost
TheGreyGhost / gist:b5ea2acd1c651a2d6350
Last active April 28, 2021 13:22
EntityBodyHelper (1.8) deobfuscated
/**
*
* @author Nico Bergemann <barracuda415 at yahoo.de>
*/
public class DragonBodyHelper extends EntityBodyHelper
{
private EntityTameableDragon dragon;
private int turnTicks;
private int turnTicksLimit = 20;
private float lastRotationYawHead;
@TheGreyGhost
TheGreyGhost / gist:f8964ede43732fd1016e
Created May 31, 2015 10:39
Workaround for Race condition inSimpleNetworkWrapper
This code works properly (separate copy of each msg)
int dimension = sendingPlayer.dimension;
MinecraftServer minecraftServer = sendingPlayer.mcServer;
for (EntityPlayerMP player : (List<EntityPlayerMP>)minecraftServer.getConfigurationManager().playerEntityList) {
MessageToClient msg = new MessageToClient(nextID); // generate a fresh message for every player
if (dimension == player.dimension) {
simpleNetworkWrapper.sendTo(msg, player);
}
}
@TheGreyGhost
TheGreyGhost / gist:62d3d37fcef29700eb9a
Last active August 29, 2015 14:22
Race condition in SimpleNetworkWrapper; error locations
Breakpoint on IndexOutOfBoundsException
AbstractByteBuf::
@Override
public ByteBuf readerIndex(int readerIndex) {
if (readerIndex < 0 || readerIndex > writerIndex) {
throw new IndexOutOfBoundsException(String.format(
"readerIndex: %d (expected: 0 <= readerIndex <= writerIndex(%d))", readerIndex, writerIndex));
}
this.readerIndex = readerIndex;
return this;
@TheGreyGhost
TheGreyGhost / gist:0e7b5e1d0a868ce311a0
Created May 31, 2015 08:24
Race condition in SimpleNetworkWrapper
package racecheck;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Vec3;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
@TheGreyGhost
TheGreyGhost / gist:7613416
Last active January 21, 2018 14:47
A basic framework for understanding how Forge starts up your code. See http://greyminecraftcoder.blogspot.com/2013/11/how-forge-starts-up-your-code.html
---TestFrameworkMod.Java---------------------------------------------
package testframework;
/**
* This class is just used to pass control to the appropriate "Proxy" class depending on whether the mod has been installed in a normal Minecraft Client or a Dedicated Server.
*/
@Mod(modid="testframeworkmod", name="Forge Test Framework Mod", version="0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class TestFrameworkMod {
@TheGreyGhost
TheGreyGhost / KeyBindingInterceptor.java
Last active May 20, 2024 02:16
KeyBindingInterceptor (for Minecraft Forge mods). The purpose of this class is to intercept key presses (especially left and right mouse button clicks) before they are passed to the vanilla code. This gives the mod code greater flexibility in responding to them. For example- a staff which, when held: (1) left click performs an immediate attack (…
package speedytools.client;
/**
* The purpose of this class is to intercept key presses (especially left and right mouse button clicks) and allow
* greater flexibility in responding to them.
* The class replaces KeyBindings in GameSettings. When interception is on:
* .isPressed() is overridden to return false so that the vanilla code never receives the clicks.
* .pressed is always false.
* The true .isPressed() and .pressed are available using .retrieveClick() and .isKeyDown()
* Usage: