-
Posts
5160 -
Joined
-
Last visited
-
Days Won
76
Everything posted by Choonster
-
What's the issue here? Is it crashing? Is it simply not showing the recipe output when you put the ingredients in the crafting grid?
-
If you look at the code, you'll see that LivingUpdateEvent is called from EntityLivingBase#onUpdate . This is indirectly called from World#updateEntities , which is called on both the client and server. IEEP has been deprecated in favour of the Capability system, so you should consider switching your code to the new system.
-
If you want to store data per-player, use the new Capability system. In previous versions you'd use IExtendedEntityProperties , but that's been deprecated in favour of Capabilities (which are much more flexible). Even if you used a config file, you could still change values by using the appropriate overload of Configuration#get (which returns a Property ) and the appropriate overload of Property#set or Property#setValue . You could also load and save a file using regular Java IO.
-
In the first code block, you're using the wrong location for the model. ModelBakery.registerItemVariants , ModelLoader.setCustomModelResourceLocation and ModelLoader.setCustomMeshDefinition / ItemMeshDefinition all expect the ModelResourceLocation 's domain and path to be in the format modid:modelName , which either maps to the assets/<modid>/models/item/<modelName>.json item model or the model specified in the assets/<modid>/blockstates/<modelName>.json blockstates file (this is added by Forge and only used when the item model isn't found). In this case, use minecraft:diamond_sword (i.e. the assets/minecraft/models/item/diamond_sword.json model) instead of minecraft:items/diamond_sword (this is the texture path used in the minecraft:diamond_sword model, not a model path). If you use ItemMeshDefinition , you must actually return the appropriate ModelResourceLocation from the getModelLocation method rather than returning null . I use vanilla models for several of my mod's items here. There are several chained overloads of registerItemModel , but they all boil down to calling ModelBakery.registerItemVariants with the specified ModelResourceLocation and calling ModelLoader.setCustomMeshDefinition with an ItemMeshDefinition that returns a single constant ModelResourceLocation .
-
You should be able to register substitution aliases for blocks and items (in fact those are the only things you can register substitution aliases for), but I haven't managed to get it working myself (see this thread). You should always try to use events or hooks before you resort to drastic measures like replacing vanilla classes or modifying them with ASM. If there's no hook or event for your use case, consider suggesting one in the Suggestions section or on GitHub. HarvestDropsEvent lets you change drops from blocks. LivingDropsEvent lets you change drops from living entities (including players). There's no direct way to modify the saturation value of existing food without resorting to some hacky reflection that makes the fields in ItemFood non-final, but you can subscribe to PlayerUseItemEvent.Finish and modify the player's food values through their FoodStats object if they used a particular food item.
-
Ah, sorry, it's the registerTickable() method that's throwing it. I tried rebuilding all my forge and gradle stuff, as well as a brand new install, but it still throws that error. I'm using Forge 1764, I believe. EDIT: I tried it with a fresh install of 1722, as well. No dice. Still get the same error. The method certainly exists in my installs of 1764 and 1763. Can you see it in the MinecraftServer class in your IDE? Are you running your mod in your IDE or building it and running it in a normal client? Upload the FML log (logs/fml-client-latest.log) to Gist and link it here.
-
I'm not sure if it's a widely-used convention, but I use ClassName.memberName to denote a static method/field and ClassName#memberName to denote an instance method/field. In this case, registerTickable is an instance method so it needs to be called on an instance of MinecraftServer (returned from the MinecraftServer.getServer method). You already seem to be doing this, though. Could you be more specific about which method the NoSuchMethodError is being thrown for?
-
I tried this, but it doesn't seem to be working. No errors or anything, just doesn't bother calling the update() function. If you set a breakpoint, is MinecraftServer#registerTickable definitely being called? Are you sure your update method isn't being called?
-
ITickable s have to be registered for Minecraft to tick them. This is done automatically for TileEntities , but you can register other tickables using MinecraftServer#registerTickable . [nobbc]Like this[/nobbc]
-
If you have a single canvas Block and store the IBlockState it's imitating in the TileEntity , you need to override Block#getExtendedState to return an extended state with the PAINTED_BLOCK property set to the imitated IBlockState (retrieved from the TileEntity at that position). If you have one canvas Block per IBlockState , you don't need the extended state at all; just get the imitated IBlockState directly from the canvas Block . In CanvasBlockModelFactory#handleBlockState , retrieve the imitated IBlockState from the extended state or from the Block and create the model using it.
-
Create a ResourceLocation or ModelResourceLocation with the new operator like you would any other object. A ResourceLocation consists of a resource domain and a resource path. There are two public constructors: One that takes a single string in the format "<domain>:<path>" One that takes the domain and path as two separate strings ModelResourceLocation extends ResourceLocation and adds a variant. There are three public constructors: One that takes a single string in the format "<domain>:<path>#<variant>" (the variant is optional and defaults to normal ) One that takes a ResourceLocation for the domain and path and a string for the variant One that takes a string in the format "<domain>:<path>" for the domain and path and a string for the variant The domain is the name of the assets folder to look in, usually your mod ID (i.e. the domain minecraft maps to assets/minecraft). If you don't specify a domain, it defaults to minecraft . ModelBakery.registerVariantNames tells Minecraft to load the specified models. It expects <path> to be the name of your model, which either maps to the item model assets/<domain>/models/item/<path>.json (this is the first priority) or the model specified by the variant with name <variant> in the blockstates file assets/<domain>/blockstates/<path>.json (this is added by Forge and only used when the item model wasn't found). If you provide a ResourceLocation , the variant will be inventory . The model will be stored using the provided ModelResourceLocation as the key. ModelLoader.setCustomModelResourceLocation and ModelLoader.setCustomMeshDefinition tell Minecraft which model to use for the Item , using the provided ModelResourceLocation as the key.
-
Use ModelLoader.setCustomModelResourceLocation or ModelLoader.setCustomMeshDefinition in preInit instead of ItemModelMesher#register in init. ModelBakery.registerVariantNames takes arguments in the same format as ModelBakery.addVariantName ( "modid:modelName" ), but expects either ResourceLocation s or ModelResourceLocation s instead of String s.
-
If you use ItemColored for the block's item form, Item#getColorFromItemStack is overridden to call Block#getRenderColor with the state corresponding to the item metadata.
-
World#setBlockState and World#getBlockState only operate on property values that are stored in metadata. If you want to store more than 16 unique value combinations, you need to store the data in a TileEntity (or derive it from the location, e.g. neighbouring blocks) and then retrieve it in Block#getExtendedState / Block#getActualState .
-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
Choonster replied to Looke81's topic in Modder Support
You're returning true (item is valid for slot) when there's already an item of that type in the inventory and false (item isn't valid for slot) when there isn't. -
Use ModelLoader.setCustomModelResourceLocation / ModelLoader.setCustomMeshDefinition in preInit to set the model used by an Item . This can either be an existing model like minecraft:diamond_sword or your own model that uses the same textures as the existing one ( minecraft:items/diamond_sword ).
-
[1.8.9][SOLVED]How to tell if an item is already in custom inventory?
Choonster replied to Looke81's topic in Modder Support
ItemStack#getIsItemStackEqual is client-only, using it in common code will crash the dedicated server. If you only care about the Item , use ItemStack#getItem and compare the Item s directly. If you care about the Item and metadata, use ItemStack.areItemsEqual . If you care about the Item , metadata and NBT, use ItemStack.areItemStacksEqual . Nope http://pastebin.com/HkrTfcia That is a NullPointerException . -
If you look at assets/minecraft/models/block/grass.json, you'll see that it sets the "tintindex" property for the "up" face of the first element (the base cube) and all faces of the second element (the side overlay). This allows the textures of those faces to be coloured and is passed as the renderPass argument of Block#colorMultiplier(IBlockAccess, BlockPos, int) .
-
Do you have missing texture errors in the log? Your model's texture paths don't have a resource prefix, so it's trying to load them from the minecraft domain.
-
[1.8.9] Displaying rf energy bar when rendering item in inventory
Choonster replied to jimmyh's topic in Modder Support
Ah, that makes things trickier. You may be able to use ISmartItemModel to render the bar, but I don't know enough about rendering or the model system to help you any further. -
[1.8.9] Getting IInventory from ItemHandler
Choonster replied to BusyBeever's topic in Modder Support
Use SlotItemHandler instead of Slot . -
[1.7.10] Check if block is fluid source block
Choonster replied to grand_mind1's topic in Modder Support
For BlockLiquid , metadata 0 is a source block. Forge's Fluid system doesn't specify that fluids must have a source block ( BlockFluidClassic does, but BlockFluidFinite doesn't) , but IFluidBlock#drain should return a FluidStack with FluidContainerRegistry.BUCKET_VOLUME as the amount if a bucket can be filled from the block. Make sure you call IFluidBlock#canDrain first and call IFluidBlock#drain with false as the doDrain argument. -
[1.8.9] Displaying rf energy bar when rendering item in inventory
Choonster replied to jimmyh's topic in Modder Support
Override Item#showDurabilityBar to return true when the current RF is less than the maximum and Item#getDurabilityForDisplay to return the percentage of the durability bar to fill (i.e. (maxRF - currentRF) / maxRF ).