Skip to content

Instantly share code, notes, and snippets.

package net.cazzar.corelib.asm.transformers;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
import java.io.File;
import java.io.FileNotFoundException;
@Cazzar
Cazzar / javap
Last active August 29, 2015 14:12
Compiled from "test.java"
class test {
public java.util.List<java.lang.String> strings;
test();
}
#include <stdio.h>
int main()
{
int ae1 = 0xDEADBEEF;
printf("%d", ae1);
*(&ae1) = NULL;
printf("%d", ae1);
return 0;
}
package net.cazzar.mods.jukeboxreloaded
import io.netty.buffer.ByteBuf
import net.minecraft.block.Block
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.{BlockPos, ChatComponentText}
import net.minecraft.world.World
import net.minecraftforge.fml.common.network.ByteBufUtils
implicit class RichByteBuf(buf: ByteBuf) {
def writeString(str: String) = ByteBufUtils.writeUTF8String(buf, String)
def readString() = ByteBufUtils.readUTF8String(buf)
def writeItemStack(is: ItemStack) = ByteBufUtils.writeItemStack(buf, is)
def readItemStack() = ByteBufUtils.readItemStack(buf)
def writePos(pos: BlockPos): Unit = {
buf.writeInt(pos.getX)
buf.writeInt(pos.getY)
package net.cazzar.mods.jukeboxreloaded.network.message
import io.netty.buffer.ByteBuf
import net.cazzar.mods.jukeboxreloaded.JukeboxReloaded
import net.cazzar.mods.jukeboxreloaded.Util._
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.util.BlockPos
import net.minecraftforge.fml.common.network.simpleimpl.{MessageContext, IMessageHandler, IMessage}
class ClientPlayMessage(var item: Item, var pos: BlockPos) extends IMessage {
scala> import net.minecraft.tileentity.TileEntity
import net.minecraft.util.BlockPos
import net.minecraft.world.IBlockAccess
def getTile[T <: TileEntity](world: IBlockAccess, pos: BlockPos): T = world.getTileEntity(pos) match {
case t: T => t
case _ => null
}
import net.minecraft.tileentity.TileEntity
@Cazzar
Cazzar / scratch
Last active August 29, 2015 14:11
import com.google.common.base.Predicate
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.block.properties.PropertyDirection
import net.minecraft.block.state.{BlockState, IBlockState}
import net.minecraft.util.EnumFacing
object BlockExample extends {
val FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL.asInstanceOf[Predicate[EnumFacing]])
} with Block(Material.wood) {
public void missingMappings(FMLMissingMappingsEvent e) {
for (FMLMissingMappingsEvent.MissingMapping mapping : e.getAll()) {
if ("ukeboxreloaded:blockJukebox".equals(mapping.name)) { //You know, because FML has a small mapping issue.
mapping.remap(proxy.jukeBox);
}
}
}
@Cazzar
Cazzar / example_block.json
Last active August 29, 2015 14:11
goes into /assets/domain/models/block/ 2nd in /assets/domain/models/item
{
"parent": "block/cube_all",
"textures": {
"all": "domain:blocks/texture"
}
}