Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. Get world via proxy. In Common: public World getClientWorld() { return null; } In Client: public World getClientWorld() {return Minecraft.getMinecraft().theWorld; } EDIT Dammit, he was faster
  2. 1. Events should be registered in preInit of mod. 2. This event is fired for client and server logical side - thus 2 msgs. You can use !entity.world.isRemote to get server side. 3. Don't use this "chat stuff" you did above. You can send msg to player directly by using methods in EntityPlayerMP class (I think, will edit post if mistaken). EDIT 2 public class ServerEventHandler { @SubscribeEvent public void onJoinWorldEvent(EntityJoinWorldEvent event) { if (event.entity instanceof EntityPlayerMP) // This is 2 checks in one. EPMP can only exist on server logical side. { ((EntityPlayerMP) event.entity).addChatMessage(new ChatComponentText("YAY")); } } }
  3. Block has client side method #randomDisplayTick. You can use it to spawn fire particles. For examples look into vanilla furnace (when it's burning).
  4. PlayerLoggedInEvent is fired not when you join world, but when you log in on server, once per session. What you want is EntityJoinWorldEvent. If you do not want to do checks for all entities (just for players), you can also use combination of: PlayerLoggedInEvent PlayerRespawnEvent PlayerChangedDimensionEvent Which will probably give you same results with better performance. As to events themselves - google it, there are more than enough tuts on this field.
  5. Lol, at 1st I thought, this was a GIGANTIC plant growing on top of grass!! As to transparency: http://greyminecraftcoder.blogspot.com.au/2015/03/troubleshooting-block-and-item-rendering.html http://greyminecraftcoder.blogspot.com.au/2015/05/common-mistakes-in-block-models.html (isOpaqueCube)
  6. this.buttonList.clear(); This is NOT needed inside initGui(), UNLESS you are calling initGui() on your own somewhere. The only place initGui() is called is by vanilla, and vanilla clears buttons on its own. As to problem: this.mc.renderEngine.bindTexture(new ResourceLocation(RPGSkills.MOD_ID, "/textures/gui/container.png")); Minecraft can only have one "currently" bound texture. In most cases it will be widgets or icons. After changing it, you need to revert it back to original state. * bindTexture which holds widgets (button icons).
  7. Subscribe to net.minecraftforge.event.entity.player.PlayerOpenContainerEvent, you can ALLOW/DENY opening any type of container of any mod or vanilla itself. Note: It also allows you to DENY opening given container and do any other action (e.g write chat msg or open other container). Hopefully you know how to use events, if not - use google (plenty of tuts).
  8. One thing tho: player.openGui, when called on: (logical side) * Client = will ONLY call #getClientGuiElement * Server = will call #getServerGuiElement and send packet to client that will call #getClientGuiElement, but ONLY if you return Container on server (not null). Thus I stated: If you won't have Container on server, you can (should) send custom packet.
  9. Bukkit != Vanilla I think it's would be fair to say that Bukkit supports more symbols?
  10. After using fontRendererObj.drawString(...) you need to re-set texture to widgets (or icons, whatever their name) with mc.getTextureManager().bindTexture(...).
  11. http://www.minecraftforge.net/forum/index.php/topic,31297.0.html Might be of help. Also - you know you SHOULD not have stuff like "ContainerEmpty"? You use GuiContainer only if you have a Container for it. Having an "Empty" container means that you don't need it, therefore yo ushould use GuiScreen. Only case I can think of where you might actually have such setup and say it's not stupid is when you want to open client gui from player.openGui on server. Other option - you can utilize canInteractWith, other than that - it's a bad coding (modding) practice.
  12. @TGG - indeed :3
  13. Sorry to not give straight answer, but that's a lot of text to go through. Since you know your code it might be faster to just give example: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe11_item_variants Check out resources: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/resources/assets/minecraftbyexample You sure you got all variants in json files? Hm, just look at example, pretty much perfect one.
  14. http://new4.fjcdn.com/comments/Whyyy+_645558cc3b3180c92ab02120fa0eddc8.jpg[/img] @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class HarshNature { @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { HarshNatureBlocks.init(); HarshNatureBlocks.register(); HarshNatureItems.init(); HarshNatureItems.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) {} } public class Reference { public static final String MODID = "hnmod"; public static final String NAME = "Harsh Nature"; public static final String VERSION = "Harsh Nature - Alpha 0.1"; public static final String CLIENT_PROXY_CLASS = "com.drunksmanknife.harshnature.proxy.ClientProxy"; public static final String SERVER_PROXY_CLASS = "com.drunksmanknife.harshnature.proxy.CommonProxy"; } public class ClientProxy extends CommonProxy { @Override public void registerRenders() { HarshNatureBlocks.registerRenders(); HarshNatureItems.registerRenders(); } } public class HarshNatureItems { public static Item Small_Flint; public static Item Twigs; public static void init() { Small_Flint = new Item().setUnlocalizedName("Small_Flint"); Twigs = new Item().setUnlocalizedName("Twigs"); } public static void register() { GameRegistry.registerItem(Small_Flint, Small_Flint.getUnlocalizedName().substring(5)); GameRegistry.registerItem(Twigs, Twigs.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(Small_Flint); registerRender(Twigs); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } }
  15. This is like REALLY mod-specific question. You can put data anywhere you want. I personally do it in /.minecraft/MyModFoler/myData.something Diesieben just said that your /mods/ should not contain anything other than mods.
  16. My utility: public static File getMcDir() { if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; } Note: Returns /.minecraft/ for client and /server_folder/ for dedic.
  17. Difficulty: * Logical (6/10) * Rendering (7/10) * Don't even start this if you don't know Java enough. Requirements: (learn to use) * TileEntity (TE) - You don't need ticking one. * IInventory - implement this to your TE to hold inventory. * NBT - Learn how to store stack to TE's NBT. * SimpleNewtorkWrapper (SNW) - When you put ItemStack into TileEntity, you will need to do that on server logical side. Since your and other clients need to know that this ItemStack is inside TileEntity (to render it), you will need to learn how to use packets that will update client's ItemStack field. * TileEntitySpecialRenderer (TESR) - you can assign special (very powerful) renderer to TEs. That allows you to literally render anything in place of TE's Block. Note: You might be able to use Block models to render it (without TESR), but that is STRONG "might be", I don't think it would be good idea to dig there. Well, Your block class is a start, After getting item, you neeed to get TileEntity in given BlockPos you clicked at and inform TileEntity that you clicked it, then on server you will remove ItemStack from inv and move it to TE's inventry, then send packet to client around about change, receivers will use TESR to render ItemStack "onto" block. EDIT I ment to ask - what parts you EVER encountered? I will post tuts/hints on others (my guess is that you are new to modding at this point) .
  18. http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html http://jabelarminecraft.blogspot.com/ http://www.minecraftforge.net/forum/index.php/topic,26267.0.html If you know Java and ask right questions (tip: Just tell what exacly you want to get as result.) I can assure you - "Modding Support" will be always able to help you, and if not, then you are on deep seas where most likely noone ever sailed before (read: "Not your every-day mod idea"), yet still - help can be expected.
  19. You need to register rendering class in client proxy. You can use vanillas renderer in case of "human" renderer. And ModlBiped as model. Or, obviously make your own Renderer and Model. Something like this for example. And yeah - making nice renderers is hard and long work, have fun reading vanilla classes. RenderingRegistry.registerEntityRenderingHandler(MyEntity.class, new RenderMyEntity(Minecraft.getMinecraft().getRenderManager())); @SideOnly(Side.CLIENT) public class RenderMyEntity extends RenderBiped { public RenderMyEntity(RenderManager rm) { super(rm, new ModelZombie(), 0.5F, 1.0F); } .... }
  20. It's like I told you all that stuff and you only focused on fixing one thing. There is a reason why that all was written. Your code does same stuff milion times, not really thing I want to look deep into. You chanve repeating chaines if statements. Unclear actions, again - repeating code. Stop using events for this. This is NOT the right way to to work with custom item effects. Events are for not-your-mod-stuff. As to bumps - I mean, my guesss would be at least N*12h (minimum work/sleep cycle, where N is repeating bump number, lol). Other: if (hasItem == true) - really? just do if (hasItem). Finally to problem: Read the damn tutorial AND Vanilla code. You declared 4 different modifiers with different names, yet same UUID. You need to handle each modifier on its own. e.g: buff1 (10.0D), buff2 (20.0D), buff3 (30.0D) where each would be checked separately. I guess (quick look) you can also have 4 modifiers using SAME name and UUID and operation, and just have different value, idk for sure tho.
  21. http://www.minecraftforge.net/forum/index.php/topic,26267.0.html
  22. Okay, so basically (I think you finally got the idea). There is the Attribute. It kinda looks like this: (example) Note: It obviously doesn't look like this in internals, I am just presenting idea. Attribute<maxHealth> --->Map<UUID, AttributeModifier> Now the AttributeModifier is something that can be added/removed from Attribute based on it's UUID (internals also allow operating on names or operations, but it's not really place for you in this case, those are internals). What you actually do here is save basic data about modifier as static thing and apply it to any number of entities you want. Example: public static String theUUID = "1F28C409-EA90-4E54-AD57-13F3D92F68B2"; // this is supposed to be some static-for-your-modifier UUID. You decide what this String is, it must be in an UUID format tho. public static String theName = "MySuperModifier"; // This will be the name of modifier. public static AttributeModifier myAttributeModifier = new AttributeModifier(UUID.fromString(theUUID), theName, 10.0D, 0); // And yes, you can put those above inside this one's declaration. //Now what you do in method to apply/remove: event.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(myAttributeModifier); // 10.0D is modifier value, in this case 10.0F health // 0 is an operation - there are few operations, 0 is literally "+". // After doing this - your entity's health will be 20+10. // The Modifier is saved in entity with a key (theUUID). // If you want to remove it, you simply: event.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).removeModifier(myAttributeModifier); // note that it is the same modifier instance used on all entities. Lemme just note: I DO NOT personally use this fkd up system. For me - it's the most badly and overly-complicated thing that they've added to MC since they started "sane" and "code-cleanup" updates. I personally go with my own much clearer, faster and expanded system that operates direcly on BASE value. I have no idea if this will work, I literally just readup it in past 20min directly from code. Guess it should.
  23. Block that can fall (including Anvil) extend BlockFalling class and the moment of their "fall" they are "transformed" into an entity that ships all data about falling block. Then, when "EntityFallingBlock" hits the ground - it uses saved data to recreate block on hit ground. Now - the problem is obviously in fact that Forge has only LivingUpdateEvent that runs for living things. EntityFallingBlock is not living entity. Why is that? It is probably reasonable to not fire events for non-living things (performance or hard to implemets for all cases), yet I for example think thare should be some events regarding updating "dead" entities, e.g - falling blocks. Anyway, if you can't find anything useful on this field (look for things that would allow you to pick moment of EntityFallingBlock death), then what you simply do: Subscribe to "EntityJoinWorldEvent", check if entity is EntityFallingBlock, then check if EntityFallingBlock.fallTile is Anvil. Extend EntityFallingBlock with your MyEntityFallingBlock and override onUpdate() method adding a subtle change that will instead of placing anvil on ground-hit, spawn an explosion in world (spawn boom on server). Obviously - you will want to remove old EntityFallingBlock and replace it with new one MyEntityFallingBlock by simple spawning it in same place as precedessor.
  24. NEI requires CodeChickenCore. Also - it's bad subforum.
  25. It all happens in TileEntityFurnace#update(). if (!this.isBurning() && this.canSmelt()) { this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); Consuming fuel item. There is no such field as "isBurning" - it is only a method that tells you that fuel is > 0.
×
×
  • Create New...

Important Information

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