Jump to content

SHiLLySiT

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by SHiLLySiT

  1. Is it possible to translate a chat message and then replace a specified pattern with a replacement string upon translation? Say for example I have this in my language file: my.test.string=Hello {PLAYERNAME}! How are you today? Ideally the string would arrive at the client, be translated, and then replace "{PLAYERNAME}" with the player's display name.
  2. Ah sorry if that wasn't clear in my first post - yes the chunk that the AI is in before attempting to move it is definitely unloaded.
  3. How do you do it in 1.10 then?
  4. Is there a way to force the AI on?
  5. I'm trying to move an entity when a player right-clicks with an item. It works as intended if the Entity is in a nearby loaded chunk, but if its far enough away, the player has to move a bit before the entity appears after right clicking. Here's the code: public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float offsetX, float offsetY, float offsetZ) { if (!player.getEntityWorld().isRemote) { if (side == 1) { // only spawn on top of blocks EntityExtendedPlayer extPlayer = EntityExtendedPlayer.get(player); if (extPlayer.state.pet.hasPet) { EntityCorgi corgi = (EntityCorgi) Util.getEntityByUUID(world, extPlayer.state.pet.uuid); if (corgi == null) { Empathy.questManager.spawnCorgi(player, x, y + 1, z); } else { corgi.setLocationAndAngles(x, y + 1, z, 0.0F, 0.0F); } } } } return true; } Is there a method that I need to call to force an update of sorts?
  6. I just realized its because forge creates a new player each time I compile and run the mod, which is generating a new UUID. If I simply leave the world without closing the client it works as intended.
  7. I've extended the EntityTameable class, so the methods I'm using are the ones found in there. I had assumed they were setup to sync since other classes do nothing extra. Here they are anyway: public void func_152115_b(String p_152115_1_) { this.dataWatcher.updateObject(17, p_152115_1_); } public EntityLivingBase getOwner() { try { UUID uuid = UUID.fromString(this.func_152113_b()); return uuid == null ? null : this.worldObj.func_152378_a(uuid); } catch (IllegalArgumentException illegalargumentexception) { return null; } }
  8. My custom mob is losing its owner after I logout and back into a world. public EntityCustom(World world) { super(world); this.setSize(0.6F, 0.8F); _type = 0; preventEntitySpawning = true; this.func_110163_bv(); // forces entity to not despawn this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 5.0F, 1.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); System.out.println("OWNER: " + this.getOwner() + " " + FMLCommonHandler.instance().getEffectiveSide()); } public EntityCustom(World world, EntityPlayer player) { this(world); this.setTamed(true); this.func_152115_b(player.getUniqueID().toString()); // sets owner this.worldObj.setEntityState(this, (byte)7); System.out.println("SET OWNER: " + this.getOwner() + " " + FMLCommonHandler.instance().getEffectiveSide()); } The output of those logs: SET OWNER: EntityPlayerMP['Player54'/45, l='Copy of New World', x=261.50, y=69.00, z=317.50] SERVER OWNER: null CLIENT From what I could tell func_152115_b() sets the UUID on the datawatcher which (from what I understand) is automatically synced between the server and clients. Am I missing a step?
  9. I'm trying to add custom structures (similar to villages) to map generation. I've so far worked out that I need to create a generator that implements the IWorldGenerator class and I can generate blocks within a single chunk. Beyond that I'm not sure where to go; most tutorials I've found have been for ore generation. If anyone can point out any tutorials or open-source mods that accomplish something similar I'd greatly appreciate it!
  10. I'm having an issue with chat colors not carrying over to new lines. You can see the behavior here: https://s32.postimg.org/4lbyeg5xh/2016_07_13_1027.png[/img] Here's the code I used to produce the message: sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Lorem ipsum dolor sit amet, eius maiorum accusam at cum, eu congue facilisi quaerendum mea, est id discere honestatis intellegebat. Et vel iuvaret aliquando sadipscing. Nam et dolore nominati. Est ancillae adolescens no, his falli dolor ut. An vel feugait nusquam indoctum, ad ius munere putant aperiri.")); Am I applying the formatting wrong or is this a bug? I only found one post with a solution, but its not very pretty: http://www.minecraftforge.net/forum/index.php?topic=15445.0
  11. I'd love to upgrade but we must be able to support MinecraftEDU and the current stable version is forked from 1.7.10. In what class is getRegistryName() located? It doesn't seem to be on Item or ItemStack.
  12. I want to search through the players inventory to check and see if any of the items match a specified string which is defined in an XML. I've found getUnlocalizedName(), however the string is often quite long. Is there anything more concise? I've seen websites that list ids similar to this website: http://minecraft-ids.grahamedgecombe.com/
  13. Oh I just assumed that since the command was being run on the server that it should check the entity on the server rather than the client, but if this isn't a problem then I will leave it!
  14. I just discovered IEntityAdditionalSpawnData which seems to have fixed the issue, but as you pointed out, I'm using the client to get the entity the player is looking at. What would be the alternative for the server?
  15. I created a new Entity that has two properties - bundleId and npcId: public EntityQuestNpc(World world, String bundleId, String npcId) { super(world); this.bundleId = bundleId; this.npcId = npcId; preventEntitySpawning = true; } Currently the entity is only spawned via a console command: private void commandSpawnNpc(ICommandSender sender, String bundleId, String npcId) { EntityQuestNpc npc = new EntityQuestNpc(sender.getEntityWorld(), bundleId, npcId); npc.setLocationAndAngles(sender.getPlayerCoordinates().posX, sender.getPlayerCoordinates().posY, sender.getPlayerCoordinates().posZ, 0.0F, 0.0F); sender.getEntityWorld().spawnEntityInWorld(npc); } And I have the properties being saved with the NBT data: @Override public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); NBTTagCompound data = tag.getCompoundTag(PROP_NAME); bundleId = data.getString("bundleId"); npcId = data.getString("npcId"); System.out.println("[readEntityFromNBT] BUNDLE:" + bundleId + " NPC:" + npcId); } @Override public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); NBTTagCompound data = new NBTTagCompound(); data.setString("bundleId", bundleId); data.setString("npcId", npcId); tag.setTag(PROP_NAME, data); System.out.println("[writeEntityToNBT] BUNDLE:" + bundleId + " NPC:" + npcId); } The logs show that the correct data is being written and read. However when I use the following command to attempt to print the properties to the chat window, they are null: private void commandNpcInfo(ICommandSender sender) { if (Minecraft.getMinecraft().objectMouseOver.entityHit != null) { if (Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityQuestNpc) { EntityQuestNpc npc = (EntityQuestNpc) Minecraft.getMinecraft().objectMouseOver.entityHit; sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "ID:" + npc.npcId + " BUNDLE:" + npc.bundleId)); } else { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be looking at a quest NPC")); } } else { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be looking at a quest NPC")); } } From my understanding all commands are run on the server, so even if I'm not syncing the properties with clients it should still be printing out a value?
  16. Okay this is starting to make sense! Just have some follow up questions: As I mentioned above, I found that I was able to load the external files when via: File file = FMLCommonHandler.instance().getMinecraftServerInstance().getFile("mods/empathymod/settings.xml"); While this works on the dedicated server it fails on the combined client because the MinecraftServerInstance is null. What is the proper method to load the data for the combined client (single player)? How much data can I send over packets? Are there any problems with send large amounts of data? There's going to be quite a few large XML files, but I'd only need to send it to clients when either they first logged in or when the server reloaded the external files.
  17. Right, but once the server has started and loaded the data, how would a client ask the server for the data? Better yet, are there any mods that are doing something similar? I'm aware of what needs to be done, but I'm confused how to accomplish it within the Forge API.
  18. Can you elaborate?
  19. I have worded my question poorly. I already have the XML data being loaded and parsed, I'm just unsure of how to determine if the mod is running as the client vs the server. Then if the mod is running as the client, it needs to ask the server for the data it needs. We have a team of designers writing the content and XML is the markup language that they are most familiar with.
  20. I'm building a mod that relies on external XML files that define the content of the mod. I've managed to figure out how to load the files when the mod is being run on a dedicated server. Here's an example of how I'm loading files: File file = FMLCommonHandler.instance().getMinecraftServerInstance().getFile("mods/empathymod/settings.xml"); // parse loaded file However the game crashes when loading (before the title screen is reached) when running the mod on the CombinedClient because FMLCommonHandler.instance().getMinecraftServerInstance() returns null. What is the best way load these files that works for the Combined Client and Dedicated Server? Also, I'd ideally only want the server to be managing this content. In other words, the client shouldn't load any of the externals files but instead receive what the server has loaded from its external files. Is this possible? Are there any tutorials on the matter?
  21. Ahhhhh, that fixed it. So it indeed was just the texture size. Thank you!
  22. Hm, I took a look at the zombie texture and the png dimensions are the same. Although the zombie appears to be laid out differently on the texture, is this what you were referring to? Regardless, I figured I'd test with the zombie texture so I changed my resource location to this: private static final ResourceLocation texture = new ResourceLocation("minecraft:textures/entity/zombie/zombie.png"); Which resulted in this: https://s31.postimg.org/v8n57m67v/2016_07_06_1211.png[/img] Unless I'm misunderstanding, it appears I still have something else wrong.
  23. I've followed through with the tutorial and made any changes where my code had differed, but I still have the mangled texture.
  24. I just downloaded this skin to test. Its 64x64 which I assume is the right size?
  25. I'm attempting to create an NPC using the Biped model. While I can get the NPC to spawn, it spawns with the texture mangled. https://s32.postimg.org/9gd2ryu45/2016_07_06_1000.png[/img] Any ideas? Here's the relevant code: Renderer: import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderQuestNpc extends RenderLiving { private static final ResourceLocation texture = new ResourceLocation(EmpathyMod.MODID + ":textures/npc/testskin2.png"); public RenderQuestNpc() { super(new ModelBiped(), 0.75f); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return texture; } } Entity: import net.minecraft.entity.monster.EntityMob; import net.minecraft.world.World; public class EntityQuestNpc extends EntityMob { private final Emotions _emotions; public EntityQuestNpc(World world) { super(world); _emotions = new Emotions(this); } public void render(double x, double y, double z) { _emotions.render(x, y, z); } } Render Registry: import cpw.mods.fml.client.registry.RenderingRegistry; public class Renderers { public static void init() { RenderingRegistry.registerEntityRenderingHandler(EntityQuestNpc.class, new RenderQuestNpc()); } } Client Proxy: import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.common.MinecraftForge; public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); MinecraftForge.EVENT_BUS.register(new EventHandler()); Entities.preInit(); } @Override public void init(FMLInitializationEvent e) { super.init(e); Renderers.init(); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } @Override public void serverLoad(FMLServerStartingEvent e) { super.serverLoad(e); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.