Skip to content

Instantly share code, notes, and snippets.

@witchica
Created December 5, 2014 19:42
Show Gist options
  • Save witchica/b487a75fce9a34ab1760 to your computer and use it in GitHub Desktop.
Save witchica/b487a75fce9a34ab1760 to your computer and use it in GitHub Desktop.
A simple example of PistonExtendEvent and PistonRetractEvent
package net.minecraftforge.test;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.PistonEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod(modid = "pistonTest")
public class PistonTest
{
@EventHandler
public void preInit(FMLPreInitializationEvent pre)
{
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void pistonRetract(PistonEvent.PistonRetractEvent event)
{
event.setCanceled(true); /* The piston won't retract */
}
@SubscribeEvent
public void pistonExtend(PistonEvent.PistonExtendEvent event)
{
event.setCanceled(true); /* The piston won't extend */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment