use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class ItemDevData method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
if (stack.getItemDamage() == 0) {
player.addChatComponentMessage(new ChatComponentText("Block: " + block));
player.addChatComponentMessage(new ChatComponentText(" Extended: " + ExtendedBlockDataManager.SERVER.getValue(world, x, y, z)));
player.addChatComponentMessage(new ChatComponentText(" Meta: " + meta));
player.addChatComponentMessage(new ChatComponentText(" Class: " + block.getClass()));
if (tile != null) {
player.addChatComponentMessage(new ChatComponentText(" Tile: " + tile));
player.addChatComponentMessage(new ChatComponentText(" Class: " + tile.getClass()));
}
} else //Super tile data mode
if (stack.getItemDamage() == 1) {
try {
if (tile != null) {
int i = 0;
for (Field field : ReflectionUtility.getAllFields(tile.getClass())) {
if (!Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true);
Object obj = field.get(tile);
if (!(obj instanceof Collection)) {
player.addChatComponentMessage(new ChatComponentText("Field[" + (i++) + ", " + field.getName() + "] = " + obj));
if (i % 5 == 0) {
player.addChatComponentMessage(new ChatComponentText(""));
}
}
}
}
} else {
player.addChatComponentMessage(new ChatComponentText("No tile to pull data from"));
}
} catch (Exception e) {
player.addChatComponentMessage(new ChatComponentText("Failed to reflect data! see log for details! " + e.getMessage()));
e.printStackTrace();
}
}
}
return false;
}
use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class ItemDevData method hitEntity.
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase hit, EntityLivingBase player) {
if (hit != null && player != null) {
if (player instanceof EntityPlayer && !player.worldObj.isRemote) {
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Entity: " + hit));
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("ID: " + hit.getEntityId()));
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Name: " + hit.getCommandSenderName()));
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Class: " + hit.getClass()));
}
return true;
}
return false;
}
use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class TileInfInv method onPlayerRightClick.
@Override
protected boolean onPlayerRightClick(EntityPlayer player, int side, Pos hit) {
if (isServer()) {
if (player.getHeldItem() != null) {
if (player.capabilities.isCreativeMode) {
if (player.isSneaking() && player.getHeldItem().getItem() == Items.stick) {
slotStack = null;
player.addChatComponentMessage(new ChatComponentText("SlotStack = " + slotStack));
} else {
setInventorySlotContents(0, player.getHeldItem());
}
}
} else {
player.addChatComponentMessage(new ChatComponentText("SlotStack = " + slotStack));
}
}
return true;
}
use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandDebugItem method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
if (args[0].equals("dump") || args[0].equals("dumpsubs")) {
sender.addChatMessage(new ChatComponentText("See console for data"));
FMLControlledNamespacedRegistry<Item> registry = (FMLControlledNamespacedRegistry<Item>) Item.itemRegistry;
Set set = registry.getKeys();
for (Object obj : set) {
String name = (String) obj;
Item item = registry.getObject(name);
System.out.println("" + name + " " + item);
if (item != null) {
if (args[0].equals("dumpsubs")) {
List list = new ArrayList();
item.getSubItems(item, item.getCreativeTab(), list);
for (Object o : list) {
System.out.println("\t" + o);
if (o instanceof ItemStack) {
ItemStack stack = (ItemStack) o;
System.out.println("\t\tName: " + stack.getUnlocalizedName());
int[] oreIDs = OreDictionary.getOreIDs(stack);
if (oreIDs != null && oreIDs.length > 0) {
for (int i : oreIDs) {
String oreName = OreDictionary.getOreName(i);
System.out.println("\t\t" + oreName);
}
}
}
}
}
}
}
return true;
}
} else {
return handleHelp(sender, args);
}
return false;
}
use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class GSCUser method handle.
@Override
public boolean handle(ICommandSender sender, AccessGroup group, String user, String[] args) {
if (!remove) {
if (group.addMember(user)) {
sender.addChatMessage(new ChatComponentText("User added to group"));
} else if (group.getMember(user) != null) {
sender.addChatMessage(new ChatComponentText("Error: User already added"));
} else {
sender.addChatMessage(new ChatComponentText("Error adding user to group"));
}
} else {
if (group.getMember(user) != null) {
group.removeMember(user);
sender.addChatMessage(new ChatComponentText("User removed from group"));
} else {
sender.addChatMessage(new ChatComponentText("Group does not contain that user"));
}
}
return true;
}
Aggregations