Skip to content

Instantly share code, notes, and snippets.

View Tzeentchful's full-sized avatar

Antonio Tzeentchful

View GitHub Profile
package main
import "regexp"
func main() {
}
func regex(name string) bool {
ok, _ := regexp.MatchString("^[a-zA-Z0-9_]+$", name)
void ClothPoint::TimeStep(float _dt)
{
if (m_Moveable)
{
D3DXVECTOR3 temp = m_Pos;
m_Pos += DAMPING * (m_Pos - m_PrevPos) + (m_Acceleration * _dt);
m_PrevPos = temp;
m_Acceleration = D3DXVECTOR3(0, 0, 0);
}
}
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err = tinyobj::LoadObj(shapes, materials, m_Filename.c_str(), "../Res/Models/");
if (!err.empty())
{
// fail
}
void Push2dArrayToLUA(lua_State* _Env, int _array[9][9])
{
lua_createtable(_Env, 9, 0);
for (int t = 1; t < 10; ++t)
{
// Puts key of the first child table on-top of Lua stack
lua_pushnumber(_Env, t);
// Creates child table
@Tzeentchful
Tzeentchful / NetServerAnnouncer.java
Last active August 29, 2015 14:04
Send a message to all servers on a Lilypad cluster
public class NetServerAnnouncer {
private Connect connect;
public NetServerAnnouncer(Connect connect) {
this.connect = connect;
}
public void sendMessage() {
try {
@Tzeentchful
Tzeentchful / gist:52ac00935fece5e084d7
Last active May 15, 2016 06:00
Get online players lilypad
public class OnlineGUIItem implements GUIItem, Runnable {
private int playerCount = 0;
public OnlineGUIItem() {
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), this, 80L, 80L);
}
@Override
public void processUpdate(Core plugin, Player player, Objective obj) {
@Tzeentchful
Tzeentchful / gist:a0bcc48cda65df73eac1
Created May 16, 2014 03:44
Minecraft map rendering
public void a(World world, Entity entity, WorldMap worldmap) {
if (world.worldProvider.dimension == worldmap.map && entity instanceof EntityHuman) {
int scale = 1 << worldmap.scale;
int centerX = worldmap.centerX;
int centerZ = worldmap.centerZ;
int relX = MathHelper.floor(entity.locX - (double) centerX) / scale + 64;
int relZ = MathHelper.floor(entity.locZ - (double) centerZ) / scale + 64;
int blocksPP = 128 / scale; // blocks per pixel
if (world.worldProvider.g) { // if nether
public static <T> List<T>[] splitList(List<T> list, int nLists) {
@SuppressWarnings("unchecked")
List<T>[] res = (ArrayList<T>[]) new ArrayList[nLists];
Collections.shuffle(list);
for (int i = 0; i < list.size(); i++) {
res[i % nLists].add(list.get(i));
}
return res;
}
@Tzeentchful
Tzeentchful / ScoreboardManager.java
Last active December 15, 2015 03:29
A manager to help with setting up of scoreboards in bukkit.
public class ScoreboardManager {
/**
* Here be dragons! I have done some testing, need to do more.
*
* No comments for you. This was hard to code so it will be hard to read.
* :P i'll add comments when i get time.
*
*/