-
Posts
151 -
Joined
-
Last visited
Everything posted by Simon_kungen
-
Hi I asked before if there is a way to have multiple items/blocks can share the same model file, but seemed to be quite difficult to do so in 1.13. "Fine, I guess, I'll just do a shell script to create all the model files." I thought. But at this point, it's getting ridiculous: I'm almost at 40 different model files just for items, and I'm planning to add quite a few more. Most of the physical appearance is done through code so most of them are almost identical to one another (apart from the name). So I'm asking again: Is there a good way/is there a way to have items and blocks point to the same model file in Forge 1.13?
-
Nevermind, I didn't see you could fetch for (Entity entity : event.world.loadedEntityList).
-
Alright, thanks. I did it this way: IRadiation cap = event.player.getCapability(RadiationProvider.RAD_CAP).orElse(RadiationProvider.RAD_CAP.getDefaultInstance()); This seems to be working both in singleplayer and multiplayer, but the problem now is that I need to run a tick function on all entities with this capability: public static void onPlayerTick(TickEvent.PlayerTickEvent event) { if (event.player.getCapability(RadiationProvider.RAD_CAP).isPresent()) { IRadiation cap = event.player.getCapability(RadiationProvider.RAD_CAP).orElse(RadiationProvider.RAD_CAP.getDefaultInstance()); cap.tick(event.player); } } Players are fine, but other entities in the world I have no idea how to do it. I thought of maybe utilizing another tickevent WorldTickEvent or ServerTickEvent, but I don't know how to get all entities loaded in the world.
-
Alright, I copied some (pretty much everything) of his code and from CarryOn's Capability Provider here. RadiationProvider.java I can now start the game and I get confirmation that my Capability is applied to the player: public static void attachCapability(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof EntityPlayer) { System.out.println("Adding Capability."); event.addCapability(IntercraftCore.RAD_ID, new RadiationProvider()); } } But when I try to use it the game crashes with ClassCastException: java.lang.ClassCastException: net.minecraftforge.common.util.LazyOptional cannot be cast to net.intercraft.intercraftcore.init.capabilities.radiation.IRadiation And creating an exception with creating a new instance of Radiation() is kind of pointless as it would create a new default one every time.
-
Alright, umm, no idea if it worked. So going to the next step; how do I apply it to an entity? @SubscribeEvent public void entityCaps(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof EntityAnimal || event.getObject() instanceof EntityPlayer) { final IRadiation rad_cap = new RadiationHandler(event.getObject()); event.addCapability(IntercraftCore.RAD_ID, );// <--- what do I add here? } } CapabilityRadiation.java RadiationHandler.java You are using your helper API with the class SimpleCapabilityProvider.java, but I don't have the faintest idea of what that does. I can't even convert it to be used for 1.13.
-
Been away for a few days, which gave me time to think. I have a pretty solid idea on how it would function now, but I'm still stuck on how to register and build the capability.
-
[1.13.2] Mix Classes derived from same Parent Class
Simon_kungen replied to Simon_kungen's topic in Modder Support
Alright, got this: @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void ItemColorHandlerEvent(ColorHandlerEvent.Item event) { Item[] items = { IntercraftItems.COPPERCHUNK, IntercraftItems.TINCHUNK }; // Register the appropriate colour to the item from the ColorHandler class in the item class. } How would I go about registering the ColorHandler in my item class? This is mainly what I've been stuck on, the help you just gave me cleaned up the code somewhat which I like. -
[1.13.2] Mix Classes derived from same Parent Class
Simon_kungen replied to Simon_kungen's topic in Modder Support
I'm a bit confused about how to do this. I added this to my item class (ItemHardChunk.java\): I'm just guessing and not sure how to do this. It does compile but how to register it to EVENT_BUS I have no idea. -
[1.13.2] Mix Classes derived from same Parent Class
Simon_kungen replied to Simon_kungen's topic in Modder Support
Ok. Got it. Not really sure how I would solve the issue with server crashing. I have one item where I colour the top layer and I kind of need to implement IItemColor for it to work: I didn't really find a good way of doing it, and when I learned to use IItemColor I solved it that way. This is how I coloured items before, but I have no idea how to colour a certain layer in that case: -
Hi Alright, first off: I asked before about help with these and got a nice example of it for 1.12.2, but I didn't do much except for copy-pasting their code until it compiled. I kind of pushed it forward and did other things in my mod, but I kind of need to get it working now. I have no idea how to go further. Summary: The idea was to start simple: A Capability that should store a single value and going on that value together with timers would give some effects. An API I would use to make some stuff make that value go up on proximity and some other things would decrease that initial addition value (a block blocking you in line of sight would decrease how much that other things would originally increase your personal value is. Armour would also do that). With all these things working together would add a Radiation System to Minecraft. Every living creature has its own personal value I'll call "exposure". Close proximity to something "Radioactive" would make that value go up depending on the "intensity" and how close you are to it (in your inventory it would be 0 blocks). Made an Issue describing it further here. After I've mastered Capabilities I was going to start adding additional mechanics, such as our own Power unit. But a radiation Capability feels a bit more manageable, a single value for all living things and do stuff depending on that value. We got everything on Github, and the files I made is here. And I added this to my main Mod Class:
-
Hi This is more a Java problem, but because it is in a modding environment it might be better to ask here: I have this ColorHandler function to do all my colour registration. Before I had it split into two functions (items and blocks) and just kept adding exceptions when I made a new item. So some automation is necessary: The compiler says it is fine. But Minecraft crashes with UnsupportedOperationException error; when I first try and put stuff into the items variable it throws the error. They all derive from the Item class so I thought it would be fine to do it that way, but I suppose not, or I did something wrong which is why I'm here. Can Java ArrayList not be mixed with different sub-classes?
-
Nevermind, I figured it out. Had to add the tintindex to my model file: "down": { "tintindex": 1, "texture": "#ore" }, "up": { "tintindex": 1, "texture": "#ore" }, "north": { "tintindex": 1, "texture": "#ore" }, "south": { "tintindex": 1, "texture": "#ore" }, "west": { "tintindex": 1, "texture": "#ore" }, "east": { "tintindex": 1, "texture": "#ore" }
-
How would I use it? This doesn't do anything. Do I have to register it somewhere?
-
Hi 1) So, I got this property of one my blocks, and I want if you break it with a Silktouch pickaxe it should return the item block with NBT of the Blockstate value: protected ItemStack getSilkTouchDrop(IBlockState state) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInt("density",state.get(BlockProperties.DENSITY)); return new ItemStack(this,1,nbt); } When I print out the value (nbt.getInt("density")) I'm getting the correct value, but the actual Itemstack do not have the NBT or the value in it. The idea was then to when you place it it should apply that value to the block as a Blockstate again. public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, @Nullable EntityLivingBase placer, ItemStack stack) { System.out.println(stack.getChildTag("density")); } How do I save a Blockstate to an Item Block and then apply that value again on the newly placed block? 2) My property is called density. And depending on how dense it is it should be slightly harder to break it. I don't really know how to override that value depending on the Blockstate. 3) The last thing I wonder is if it is possible to have the language file go by the Blockstate and/or the NBT value of the Itemstack? When it has the value 0 it should maybe be called "Poor Copper Ore", 1 = "Medium Copper Ore", 2 = "Rich Copper Ore".
-
Here is a bit of my code I would suggest would do it but running this changes the particle's colour and not the actual block: (Note, in my example the colour is orange, but the actual colour should be green)
-
I want to colour the second texture (the metal pieces) to my desired colour and not the base Stone texture:
-
The problem is that I have no idea how to do that.
-
Hi I got help with making an ore that can have different density. But as it is right now they all look the same.. .. with the vanilla Stone texture and then this applied on top of it: ore_3.json
-
[1.13.2] Store value in Block + Advanced Texturing & Colouring
Simon_kungen replied to Simon_kungen's topic in Modder Support
Oh wow. Thanks for spotting it! Works now. -
[1.13.2] Store value in Block + Advanced Texturing & Colouring
Simon_kungen replied to Simon_kungen's topic in Modder Support
Looks like it doesn't find the file. When I change the blockstate file the model works just fine. Unable to load model: 'intercraftcore:block/block/ore_faces/ore_2' referenced from: intercraftcore:cu_ore#density=0: java.io.FileNotFoundException: intercraftcore:models/block/block/ore_faces/ore_2.json -
[1.13.2] Store value in Block + Advanced Texturing & Colouring
Simon_kungen replied to Simon_kungen's topic in Modder Support
Ok, that worked. Can now place the block with the desired density. But it looks like it is still not changing the block model. -
[1.13.2] Store value in Block + Advanced Texturing & Colouring
Simon_kungen replied to Simon_kungen's topic in Modder Support
Alright, not sure if the first one would work if I got this problem solved: Seems like you have to add a property to the block class, so I tried that: But I run into the error: Caused by: java.lang.IllegalArgumentException: Cannot set property IntegerProperty{name=density, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4]} as it does not exist in Block{minecraft:air} So my guess is that I need to register this to the Block class. But I have no idea how to do that. -
[1.13.2] Store value in Block + Advanced Texturing & Colouring
Simon_kungen replied to Simon_kungen's topic in Modder Support
Alright. I managed to do the layer by making it into two models overlapping each other with the second layer being transparent. But I'm having some issues with Blockstates: { "forge_marker": 1, "variants": { "density": { "0": { "model": "minecraft:block/stone" }, "1": { "model": "intercraftcore:block/ore_faces/ore_0" }, "2": { "model": "intercraftcore:block/ore_faces/ore_1" }, "3": { "model": "intercraftcore:block/ore_faces/ore_2" }, "4": { "model": "intercraftcore:block/ore_faces/ore_3" } } } } I would guess it should be like this, but when I try and spawn it into the world it says that property doesn't exist. I'm also having issues with setting the default blockstate when you place it into the world by hand, it should be in that case be variant 4. -
Hi I have a block that needs to store a single int value. When breaking that block will drop n amount of items depending on that block's value. public class BlockHardOre extends Block { private int meta = 4; public BlockHardOre(final String name, final float hardness, final float resistance) { super(Block.Properties.create(Material.ROCK).hardnessAndResistance(hardness,resistance)); setRegistryName(name+"_ore"); } public IItemProvider getItemDropped(IBlockState state, World worldIn, BlockPos pos, int fortune) { return Items.DIAMOND; } public int getItemsToDropCount(IBlockState state, int fortune, World worldIn, BlockPos pos, Random random) { return Math.max(this.meta,1); } } The value meta here is simply a placeholder when I was testing. The real meta value would derive from the stored value in the block. The second would be to have the block's appearance be changed what that value is. Stone's texture as the background and then apply my texture on top of it just like how Potions' model works, the secondary texture would have to be coloured.