Advertisement
Brickfix

TotemBlockLogic.java

Mar 10th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. package com.brickfix.totemmod;
  2.  
  3. import net.minecraft.command.ICommandSender;
  4. import net.minecraft.command.CommandResultStats.Type;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.server.MinecraftServer;
  7. import net.minecraft.util.BlockPos;
  8. import net.minecraft.util.IChatComponent;
  9. import net.minecraft.world.World;
  10.  
  11. public abstract class TotemBlockLogic implements ICommandSender
  12. {
  13.  
  14.     public int trigger(World worldIn)
  15.     {
  16.         MinecraftServer minecraftserver = MinecraftServer.getServer();
  17.         int i = 0;
  18.        
  19.         if (minecraftserver != null && minecraftserver.func_175578_N())
  20.         {
  21.        
  22.             try
  23.             {
  24.                 i = minecraftserver.getCommandManager().executeCommand(this, getCommand());
  25.                 //System.out.println(getCommand());
  26.                 return i;
  27.             }
  28.             catch(Throwable t)
  29.             {
  30.                 System.out.println("could not execute command");
  31.                 return 0;
  32.             }
  33.         }
  34.         return i;
  35.        
  36.     }
  37.    
  38.     public abstract String getCommand();
  39.    
  40.     @Override
  41.     public void addChatMessage(IChatComponent message)
  42.     {
  43.         //We do not want to see a chat message
  44.     }
  45.    
  46.     @Override
  47.     public String getName()
  48.     {
  49.         // TODO Auto-generated method stub
  50.         return "totem";
  51.     }
  52.    
  53.     @Override
  54.     public Entity getCommandSenderEntity()
  55.     {
  56.         // This is no entity and not important
  57.         return null;
  58.     }
  59.    
  60.     @Override
  61.     public boolean sendCommandFeedback()
  62.     {
  63.         //We do not need this
  64.         return false;
  65.     }
  66.  
  67.     @Override
  68.     public void setCommandStat(Type type, int amount)
  69.     {
  70.         // We do not need this     
  71.     }
  72.    
  73.     @Override
  74.     public IChatComponent getDisplayName()
  75.     {
  76.         return null;
  77.     }
  78.  
  79.     @Override
  80.     public boolean canUseCommand(int permLevel, String commandName)
  81.     {
  82.         return true;
  83.     }
  84.    
  85.    
  86.    
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement