Skip to content

Instantly share code, notes, and snippets.

View mattmess1221's full-sized avatar

Matthew Messinger mattmess1221

  • NetApp
  • RTP, NC
View GitHub Profile
@mattmess1221
mattmess1221 / eatItemWithDamage
Last active August 29, 2015 14:01
Method to consume item with damage in Minecraft.
private void eatItemWithDamage(InventoryPlayer inventory, Item item, int damage){
for(int i = 0;i<inventory.getSizeInventory(); i++){
ItemStack itemstack = inventory.mainInventory[i];
if(itemstack == null)
continue;
if(itemstack.getItem() == item && itemstack.getItemDamage() == damage){
itemstack.stackSize--;
if(itemstack.stackSize <=0)
inventory.setInventorySlotContents(i, null);
return;
@mattmess1221
mattmess1221 / Builder.java
Created September 11, 2014 19:25
Text Message Builder for Sponge
package org.spongepowered.api.util;
/**
* Base interface for creating a Builder.
*
* @param B The builder
* @param T The type this builder is building
*/
public interface Builder<B extends Builder<?, T>, T> {
@mattmess1221
mattmess1221 / ConfigText.java
Last active August 29, 2015 14:06
Usage for config system.
package mnm.plugins.test;
import org.spongepowered.api.plugin.config.*;
public class ConfigTest {
public void loadConfig(Configuration config) {
// loads any changes
config.load();
@mattmess1221
mattmess1221 / ServerConfig.java
Created September 16, 2014 18:23
Server config class
package org.spongepowered.mod.configuration;
import java.io.File;
public class ServerConfig extends PluginConfig {
private static ServerConfig instance;
private ServerConfig() {
super(new File("server.cfg"));
@mattmess1221
mattmess1221 / README.md
Last active August 29, 2015 14:10
ServerInfo

Server Info for Bungee Cord

Server info is meant to help client mods which use per-server settings to differentiate between different servers on a bungee cord proxy. The mod needs to know about and listen to this plugin in order to benefit from it.

Server Admins

Install the plugin by dropping the jar into the plugins folder of your bungee environment. This is not made to work using bukkit. If you wish to allow the

@mattmess1221
mattmess1221 / PacketIOTransformer.java
Last active August 29, 2015 14:10
Packet IO Transformer
package mnm.mods.protocol4.asm;
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.transformers.ClassTransformer;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodInsnNode;
@mattmess1221
mattmess1221 / build.gradle
Last active December 2, 2015 22:23
Example build script for liteloader 1.8 mods. Put the mcpnames jar in the libs folder.
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
@mattmess1221
mattmess1221 / decompile.sh
Last active August 29, 2015 14:16
Decompile minecraft 1.8
java -cp "asm-all-5.0.3.jar;guava-18.0.jar;jopt-simple-4.7.jar;SpecialSource-1.7.3.jar" net.md_5.specialsource.SpecialSource -i 1.8.3.jar -o 1.8.3-remapped.jar -m minecraft.srg
java -jar FernFlower.jar -rsy=1 -dgs=1 -asc=1 -ind=" " -log=ERROR 1.8.3-remapped.jar 1.8.3
rm -r 1.8.3/src/*
"C:/Program Files/7-zip/7z" x -o1.8.3\\src 1.8.3/1.8.3-remapped.jar net/minecraft/**
sed 's/☃/p/g' 1.8.3/src/net/minecraft/**/*.java -i
@mattmess1221
mattmess1221 / BasePlugin.groovy
Created May 24, 2015 22:14
Groovy port of ForgeGradle's BasePlugin
package net.minecraftforge.groodle.common
import static net.minecraftforge.gradle.common.Constants.*
import java.lang.reflect.ParameterizedType
import net.minecraftforge.gradle.common.BaseExtension
import net.minecraftforge.gradle.common.Constants
import net.minecraftforge.gradle.tasks.CrowdinDownload
import net.minecraftforge.gradle.tasks.Download
private void loadUtils() {
ModContainer thisCont = FMLCommonHandler.instance().findContainerFor(this);
String str = Color.class.getProtectionDomain().getCodeSource().getLocation().toString();
str = str.replace("/" + Color.class.getCanonicalName().replace('.', '/').concat(".class"), "");
str = str.replace('\\', '/');
System.out.println(str);
if (str.endsWith("!")) {
str = str.substring(0, str.length() - 1);
}