use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onServerChatEvent.
@SubscribeEvent
public void onServerChatEvent(ServerChatEvent event) {
SCIRCBot bot = mod_SecurityCraft.instance.getIrcBot(event.getPlayer().getName());
if (bot != null && bot.getMessageMode()) {
event.setCanceled(true);
bot.sendMessage("> " + event.getMessage());
bot.sendMessageToPlayer(TextFormatting.GRAY + "<" + event.getPlayer().getName() + " --> IRC> " + event.getMessage(), event.getPlayer());
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onPlayerLoggedIn.
@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
mod_SecurityCraft.instance.createIrcBot(event.player.getName());
String tipKey = getRandomTip();
ITextComponent TextComponentString;
if (tipsWithLink.containsKey(tipKey.split("\\.")[2])) {
TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
} else {
TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey));
}
if (mod_SecurityCraft.configHandler.sayThanksMessage) {
event.player.addChatComponentMessage(TextComponentString);
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onBlockBroken.
@SubscribeEvent
public void onBlockBroken(BreakEvent event) {
if (!event.getWorld().isRemote) {
if (event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE) {
CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());
for (int i = 0; i < te.getNumberOfCustomizableOptions(); i++) {
if (te.itemStacks[i] != null) {
ItemStack stack = te.itemStacks[i];
EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
event.getWorld().spawnEntityInWorld(item);
te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[] { stack, ((ItemModule) stack.getItem()).getModule() }, te);
}
}
}
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onPlayerTick.
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.side.isClient() && event.phase == Phase.START && event.player != null && event.player == ClientUtils.mc().getRenderViewEntity()) {
skyhookGrabableConnections.clear();
EntityPlayer player = event.player;
ItemStack stack = player.getActiveItemStack();
if (stack != null && stack.getItem() instanceof ItemSkyhook) {
TileEntity connector = null;
double lastDist = 0;
Connection line = null;
double py = player.posY + player.getEyeHeight();
BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
for (int xx = -2; xx <= 2; xx++) for (int zz = -2; zz <= 2; zz++) for (int yy = 0; yy <= 3; yy++) {
TileEntity tile = player.worldObj.getTileEntity(pos.add(xx, yy, zz));
if (tile != null) {
Connection con = SkylineHelper.getTargetConnection(player.worldObj, pos.add(xx, yy, zz), player, null);
if (con != null) {
double d = tile.getDistanceSq(player.posX, py, player.posZ);
if (connector == null || d < lastDist) {
connector = tile;
lastDist = d;
line = con;
}
}
}
}
if (line != null && connector != null)
skyhookGrabableConnections.add(line);
}
}
// if(event.side.isClient() && event.phase == Phase.END && event.player!=null)
// {
// EntityPlayer player = event.player;
// ItemStack stack = player.getActiveItemStack();
// boolean twohanded = stack!=null && (stack.getItem() instanceof ItemDrill);
// if(twohanded && (player!=ClientUtils.mc().getRenderViewEntity()||ClientUtils.mc().gameSettings.thirdPersonView!=0))
// {
// if(player.getItemInUseCount() <= 0)
// {
// player.stopActiveHand();
// player.setActiveHand(EnumHand.MAIN_HAND);
// }
// }
//
// }
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project AgriCraft by AgriCraft.
the class GrassDropHandler method interceptGrassDrop.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void interceptGrassDrop(BlockEvent.HarvestDropsEvent event) {
// Skip silk touch.
if (event.isSilkTouching()) {
return;
}
// Fetch the blockstate.
final IBlockState state = event.getState();
// Skip Air or Error
if (state == null || state.getBlock() == null) {
return;
}
// Fetch the world random.
final Random rand = event.getWorld().rand;
// Add grass drops if grass block.
if (state.getBlock() instanceof BlockTallGrass) {
// Wipe other drops, if needed.
if (AgriCraftConfig.wipeGrassDrops) {
event.getDrops().clear();
}
// Log
// Commenented out to prevent spam.
// AgriCore.getLogger("agricraft").debug("Inserting Drops!");
// Add the drops.
addGrassDrops(event.getDrops(), rand);
}
}
Aggregations