xwerswoodx
Forge Modder-
Posts
80 -
Joined
-
Last visited
Converted
-
Gender
Male
-
Location
London, United Kingdom
- MSN Messenger
-
Personal Text
Apprentice Forge Modder
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
xwerswoodx's Achievements
Stone Miner (3/8)
8
Reputation
-
[1.11] Adding a potion effect to a player
xwerswoodx replied to MSpace-Dev's topic in Modder Support
I know MobEffects initialization. But he asked about "I've seen around the internet that they go Potion.getPotionByID(), or was it PotionEffect.getPotionByID()? Either way, it doesn't seem to be supported here." So I answered him same way. Sorry bro but knowing "MobEffects" init doesn't make you good or bad modder. Anyway here is the code with "MobEffects" for "GOOD" mooders... player.addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 0)); -
[1.11] Adding a potion effect to a player
xwerswoodx replied to MSpace-Dev's topic in Modder Support
player.addPotionEffect(new PotionEffect(Potion.getPotionById(19), 100, 0)); Here is the example. 19 is id of potion which is equals to Poison, 100 is duration of potion 20ticks per second, so 100 is equals to 5 seconds. and 0 is a level of potion. (zero-based) so if you type 2 for level, it equals level 3 potion effect. You can get ids from net.minecraft.potion.Potion.java. -
player.sendMessage(new TextComponentString("This is sendmessage example string."));
-
Here is my basic ConfigHandler class, maybe help you. package net.xwerswoodx.vrenchant; import java.io.File; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; public class ConfigHandler { public static Configuration config; private static String file = "config/modID.cfg"; public static void init() { config = new Configuration(new File(file)); try { config.load(); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } /* * Removes specific category from configuration file. */ public static void removeConfig(String category) { config = new Configuration(new File(file)); try { config.load(); if (config.hasCategory(category)) config.removeCategory(new ConfigCategory(category)); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } /* * Removes specific key in specific category from configuration file. */ public static void removeConfig(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) config.getCategory(category).remove(key); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static int getInt(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return config.get(category, key, 0).getInt(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return 0; } public static double getDouble(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return config.get(category, key, 0D).getDouble(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return 0D; } public static float getFloat(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return (float)config.get(category, key, 0D).getDouble(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return 0f; } public static String getString(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return config.get(category, key, "").getString(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return ""; } public static long getLong(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return config.get(category, key, 0L).getLong(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return 0L; } public static short getShort(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return (short)config.get(category, key, (short)0).getInt(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return (short)0; } public static byte getByte(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) { return (byte)config.get(category, key, (byte)0).getInt(); } } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return (byte)0; } public static boolean getBoolean(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (config.getCategory(category).containsKey(key)) return config.get(category, key, false).getBoolean(); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return false; } public static void writeConfig(String category, String key, String value) { config = new Configuration(new File(file)); try { config.load(); String set = config.get(category, key, value).getString(); config.getCategory(category).get(key).set(value); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, int value) { config = new Configuration(new File(file)); try { config.load(); int set = config.get(category, key, value).getInt(); config.getCategory(category).get(key).set(value); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, boolean value) { config = new Configuration(new File(file)); try { config.load(); boolean set = config.get(category, key, value).getBoolean(); config.getCategory(category).get(key).set(value); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, long value) { config = new Configuration(new File(file)); try { config.load(); long set = config.get(category, key, value).getLong(); config.getCategory(category).get(key).set(value); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, double value) { config = new Configuration(new File(file)); try { config.load(); double set = config.get(category, key, value).getDouble(); config.getCategory(category).get(key).set(value); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, short value) { config = new Configuration(new File(file)); try { config.load(); int set = config.get(category, key, value).getInt(); config.getCategory(category).get(key).set(Integer.valueOf(value)); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, byte value) { config = new Configuration(new File(file)); try { config.load(); int set = config.get(category, key, value).getInt(); config.getCategory(category).get(key).set(Integer.valueOf(value)); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static void writeConfig(String category, String key, float value) { config = new Configuration(new File(file)); try { config.load(); double set = config.get(category, key, value).getDouble(); config.getCategory(category).get(key).set(Double.valueOf(value)); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } } public static boolean hasCategory(String category) { config = new Configuration(new File(file)); try { config.load(); return config.hasCategory(category); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return false; } public static boolean hasKey(String category, String key) { config = new Configuration(new File(file)); try { config.load(); if (!config.hasCategory(category)) return false; return config.getCategory(category).containsKey(key); } catch (Exception e) { System.out.println("Cannot load configuration file!"); } finally { config.save(); } return false; } public static void setFile(String filename) { file = "config/" + filename; } public static String getFile() { return file; } } Just put this code to ConfigHandler.java (Or you can give another name) and you can write, remove or get values like; writeConfig(category[String], key[String], value[String, int, long, short, byte, boolean, double, float]); ConfigHandler.writeConfig("My Category", "Name", "Hamit"); //Write string ("Hamit") to config. ConfigHandler.writeConfig("My Category", "isPlayer", true); //Write boolean ("true") to config. setFile(fileName[String]); ConfigHandler.setFile("Hamit.cfg"); //Changes default file (which is set at the beginning of ConfigHandler class) getString(category[String], key[String]); //You can use getInt, getLong, getShort etc. ConfigHandler.getString("My Category", "Name"); //Get string value of "Name" from the category - named "My Category". out.println("isPlayer " + ConfigHandler.getString("My Category", "isPlayer").toString() + " boolean value has written in file: " + ConfigHandler.getFile()); @EventHandler public void onInitialization(FMLInitializationEvent event) { ConfigHandler.writeConfig("My Category", "Name", "Hamit"); System.out.println("Name " + ConfigHandler.getString("My Category", "Name") + " string value has written in file: " + ConfigHandler.getFile()); ConfigHandler.setFile("Mehmet.cfg"); ConfigHandler.writeConfig("My Category", "Age", 22); System.out.println("Name " + String.valueOf(ConfigHandler.getInt("My Category", "Age")) + " integer value has written in file: " + ConfigHandler.getFile()); ConfigHandler.setFile("Batuhan.cfg"); ConfigHandler.writeConfig("My Category", "isPlayer", false); System.out.println("isPlayer " + ConfigHandler.getBoolean("My Category", "isPlayer").toString() + " boolean value has written in file: " + ConfigHandler.getFile()); }
-
Get UUID from name for offline player
xwerswoodx replied to DaComputerNerd's topic in Modder Support
I don't know if it's possible to get from UUID from offline player (I haven't tried it before) but you can save player uuid to configuration file when he logged in server first time, and you can check his nickname from configuration file. If I remember correct, playerLoginEvent or LoggedIn event could be suitable for this. -
[1.8] [UNSOLVED] Creating wearable armor?
xwerswoodx replied to TheDogePwner's topic in Modder Support
public class EmeraldArmor extends ItemArmor { public addarmor(String name, int index, int type) { super(yourmainclass.ArmorMaterial_EMERALD, index, type); this.setCreativeTab(CreativeTabs.tabCombat); this.setUnlocalizedName(name); GameRegistry.registerItem(this, name); } @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { if (slot == 2) { return yourmodid + ":textures/models/armor/emerald_layer_2.png"; } else { return yourmodid + ":textures/models/armor/emerald_layer_1.png"; } } } To the main code: public static ArmorMaterial ArmorMaterial_EMERALD = EnumHelper.addArmorMaterial("EMERALD", "emerald", 44, new int[] {4, 10, 8, 4}, 15); [/size]When you register; emeraldHelmet = new EmeraldArmor("emeraldhelmet", 4, 0); emeraldChestplate = new EmeraldArmor("emeraldchestplate", 4, 1); emeraldLeggings = new EmeraldArmor("emeraldleggings", 4, 2); emeraldBoots = new EmeraldArmor("emeraldboots", 4, 3); Put your emerald models to; \src\main\resources\assets\your modid\textures\models\armor You need to register item textures with modelregistry. -
[1.8] Broken build.gradle not loading resources? [Unsolved]
xwerswoodx replied to TheDogePwner's topic in Modder Support
if you didn't change your mod Id was examplemod I remember, you need to check public Static MODID from your main class, because it works for me -
[1.8] Broken build.gradle not loading resources? [Unsolved]
xwerswoodx replied to TheDogePwner's topic in Modder Support
You need to change this sections; version = "1.8-11.14.1.1334" group= "net.extend.mod" archivesBaseName = "extend" group should be same with your main class folder and extend should be your modid. -
[1.8] Manipulate villager trades on custom villagers.
xwerswoodx replied to 61352151511's topic in Modder Support
I am waiting for this too, but it hasn't fixed yet or maybe I didn't see. -
This is helpful for me thanks for this, I remove sideonly, but it still not working. //I solved it, I can delete topic but maybe someone will make same mistake so I can explain, I used EntityPlayer for onUpdate but have to use Entity. So I change my code; public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (player.inventory.hasItem(stack.getItem())) { Minecraft mc = FMLClientHandler.instance().getClient(); update(mc); } } }
-
I am trying to tick item. But onUpdate never works, how is it work? I try this; @SideOnly(Side.CLIENT) public void onUpdate(ItemStack stack, World world, EntityPlayer player, int par4, boolean par5) { if (player.inventory.hasItem(stack.getItem())) { outStream = new BufferedWriter(new FileWriter(new File("hamit.txt"), true)); outStream.write("onUpdate!"); outStream.newLine(); outStream.close(); } } But it never write onUpdate! in hamit.txt, I try to walk, run, right click, left click... How can I fix it? I can use onPlayerTick but it affect all items with same id, I just want to tick items from inventory.
-
[1.8] More than 1 texture for item [Solved]
xwerswoodx replied to xwerswoodx's topic in Modder Support
Ah thank you very much, it works now. -
[1.8] More than 1 texture for item [Solved]
xwerswoodx replied to xwerswoodx's topic in Modder Support
Ok I did what did you say Change my code to: ModelResourceLocation location = new ModelResourceLocation(ref.uid, "inventory"); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemref.ironX, 0, location); texture isn't work. I changed it ModelResourceLocation location = new ModelResourceLocation(ref.uid + ":ironx", "inventory"); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemref.ironX, 0, location); Texture works. I changed it to; ModelResourceLocation location = new ModelResourceLocation(ref.uid + ":irony", "inventory"); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemref.ironX, 0, location); Texture doesn't work. (I have ironx.json and irony.json files and both is tested and work) Where did I do mistake? I can't caught it, I remove unlocalizedname.substring(5) and it isn't work. When I type my json file name for "inventory" section, it isn't work. Maybe I don't understand what do you mean, if you can explain it to me with a code I can understand clearly. -
For 1.7.10 import cpw.mods.fml.common.Mod; For 1.8.0 import net.minecraftforge.fml.common.Mod; Can you try import Mod manually?
-
You don't use quotation marks before @mod and after it. If it is work older versions, it can be because forge isn't support java 8 versions yet, but it doesn't cause @Mod error, it just not compile codes and crash game, if you use " before @Mod and at the end of the line, it can be error. @Mod(modid = "LetsMod", name = "Lets Mod", version = "1.0-1.7.10") If you don't have quotation marks I don't know why it gives error, maybe someone help you.