Skip to content

Instantly share code, notes, and snippets.

@t81lal
t81lal / blockget.java
Last active August 29, 2015 14:14
Minecraft Block Retrieving
ExtendedBlockStorage blockStorage = storageArrays[pos.getY() >> 4];
if (blockStorage != null) {
int x = pos.getX() & 15;
int y = pos.getY() & 15;
int z = pos.getZ() & 15;
return blockStorage.get(x, y, z);
}
}
@t81lal
t81lal / setblockdata.java
Created January 29, 2015 16:54
MineNet block set
@Override
public void setBlockData(int data, BlockLocation loc) {
int x = loc.getX(), y = loc.getY(), z = loc.getZ();
int chunkX = x >> 4, chunkY = y >> 4, chunkZ = z >> 4;
int chunkBaseX = chunkX << 4, chunkBaseY = chunkY << 4, chunkBaseZ = chunkZ << 4;
Chunk chunk = getChunkAt(new ChunkLocation(chunkX, chunkY, chunkZ));
chunk.getBlocks().set(x - chunkBaseX, y - chunkBaseY, z - chunkBaseZ, data);
}
@t81lal
t81lal / spawn packets.java
Last active August 29, 2015 14:14
Object and Living entity spawn packets
case 0x0E: { // PacketPS0ESpawnObject
PacketPS0ESpawnObject pso = (PacketPS0ESpawnObject) p;
DefaultMinecraftWorld world = context.getWorld();
ObjectEntity objectEntity = world.getObjectEntityFactory().create(pso.getTypeId(), world, pso.getEntityId());
objectEntity.setLocation(pso.getX(), pso.getY(), pso.getZ());
objectEntity.setPitch(pso.getPitch());
objectEntity.setYaw(pso.getYaw());
objectEntity.setMotion(pso.getMotX(), pso.getMotY(), pso.getMotZ());
world.spawnEntity(objectEntity);
bus.dispatch(new ObjectEntitySpawnEvent(objectEntity));
public static void linearSearch(String[] strings, String finding) {
for (int i = 0; i < strings.length; i++) {
String s = strings[i];
if (s.equals(finding)) {
System.out.println("checked " + i + " words.");
System.out.println("Found it at index " + i);
}
}
}
import java.util.Scanner;
public class SearchMain {
public static void main(String args[]) {
String[] array = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec",
"Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-Ray", "Yankee", "Zulu" };
Scanner scanner = new Scanner(System.in);
String word = "";
char again;
package org.topdank.cfide.io.gson;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
@t81lal
t81lal / getPackages.java
Last active August 29, 2015 14:18
getPackages
public static String[] getPackages(String name) {
int len = packageLength(name);
if (len == 0)
return new String[] {};
String[] arr = new String[len];
int k = 0;
char[] chars = name.toCharArray();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
package org.nullbool.api.obfuscation.refactor;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@t81lal
t81lal / ArithmeticFixer.java
Last active August 29, 2015 14:22
ArithmeticFixer.java
package org.nullbool.api.obfuscation;
import java.util.HashSet;
import java.util.Set;
import org.nullbool.api.util.InstructionUtil;
import org.objectweb.asm.commons.cfg.tree.NodeVisitor;
import org.objectweb.asm.commons.cfg.tree.node.AbstractNode;
import org.objectweb.asm.commons.cfg.tree.node.ArithmeticNode;
import org.objectweb.asm.commons.cfg.tree.node.NumberNode;
@t81lal
t81lal / bfs.java
Created May 29, 2015 19:14
Breadth first
private NumberNode firstNumber(AbstractNode node) {
if(node == null || node.children() == 0)
return null;
for(AbstractNode n : node) {
if(n instanceof NumberNode)
return (NumberNode) n;
}
for(AbstractNode n : node) {