Schoperation / SchopCraft

A Minecraft mod that makes Minecraft hell and not hell.
MIT License
5 stars 0 forks source link

Is it possible that the canteen suck up a water source? #1

Closed cyberpunkbln closed 7 years ago

cyberpunkbln commented 7 years ago

Hello,

great Mod, but ihave a finite water mod and the canteen don't suck a water source. is it possible that the canteen can suck up a water source like a bucket? And then every unit is a 1000mb unit, that can hold the canteen 3 buckets and each bucket is a nip from the canteen.

thx

cyberpunkbln commented 7 years ago

Hello,

i have made a new Item, called and Plastic Bottle that sucks up water sources and has more uses. I have done this with NBT-Data. But i have a few short questions. Iam only an old java developer :) and not so confirm about forge-specials.

  1. How do you have made your config class, i cannot add an extra option?

  2. How can i use special textures for MetaData-Items?

thx

Schoperation commented 7 years ago

Hey,

Yes, it would be possible to make the canteen suck up a water source block. However, I doubt that would ever make it into the mod because well, a canteen isn't a bucket. The canteen is smaller than a normal bucket (even though the textures look the same size), thus there are only 3 sips per full canteen, and thus filling a canteen doesn't consume an entire water source block.

I also doubt there would be a bigger canteen, as I feel that the thirst system doesn't need much tweaking at the moment; it's fairly easy to quench with the current tools available.

Now for your two other questions.

  1. My ModConfig class is the only class that I have (and need) to make a config file. The annotation above the entire class tells forge it's a config class, and it'll make the file automatically. The boolean is a configurable option (the only one for now), and can be any primitive data type. It can be accessed just by referencing it. The method near the bottom is for forge's config gui on the title screen, making sure the config file changes with the gui correctly.

  2. I'm pretty sure you can accomplish that with the model json file of the item. Check out the structure of an item model json near the bottom of http://minecraft.gamepedia.com/Model

cyberpunkbln commented 7 years ago

Hello,

thx for your answer. I have forget to say that my Plastic Bottle can suck up water sources. Your Vector-Calculactions are very usefull and a easy world.setBlockToAir(pos); functioned very well. Now i have a Canteen that no source block suck up and can only be 3 times used and a Plastic Bottle (internal called Enhanced Canteen:)) that suck up a water source and can be used 20times.

I'm not a git or github guru:) but i will show how i can use simple functions here to publish my code for that. I think my switch to NBT-Data referencing are good for make Liquid-Container that use a flexible variable of amount. That the only Metadata that are useable are Damage are a little bit scary for me, but i think every mod-dev has this:).

Edit: Iam an idiot, now i understand the Config-File. I have looked in the forge-api-sources.

@Config.Comment("If true, the Extendend CAnteen (Plastic Bottle) will suck up waTER SOURCE")
public static boolean watersource = false;

That your comment and @Config.Comment are equal has me make confused, i have thinked that was an Config Pattern with Comment capital and the reference var lowercase:).

  1. ConfigMod. A i understand a Config Pattern (sorry primarly i code in php and have code in the past j2me). If the Config Vars is in the config file i can compile the source with the new Config var.
//@Config.Watersource("If true, the Extendend CAnteen (Plastic Bottle) will suck up waTER SOURCE")
//public static boolean watersource = false;

for that code i need to find the place for the config in the source/ressource?

  1. Oh yeah i have 2 jsons and i can switch that json with your reference. But not bind.

setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen"));

But i must look to bind public String getUnlocalizedName(ItemStack stack) with the new JSON-Model System. I hope the answer is the rigth JSON-File and i can make this with a json. In all forums the most coder says make different items but that are old <1.8 threads.

Move the Type of an Item to an NBT-Data and sit on perfect IF/ELSEIF are ground base knowledge:), now the time comes where i must dive into the deeps of forge-dev.

And of sure i must find a good Public Domain Texture for my Plastic Bottle :).

Thx at the moment, now i test the Plastic Bottle in my ModPack with 100 Mods:).

cyberpunkbln commented 7 years ago

So the Config works and i can put more Config Options in it:).

At the point that i bind my Plastic Bottle to Mods that makes plastic that are very far in the horizont and i must cheat with glass_panels in my json-recipes:). That will come:).

At the moment i must understand setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen")); :).

All source-snippets that i found are a little bit difference to your code. Google has many problems with code specific search terms and i found not enough informations.

My search term "minecraft forge different models with item metadata" helps a little bit but not at all and not so good usably with your source code to understand.

I think setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen")); calls getUnlocalizedName Method at the stage but this method only take the right vars from the localisation.json and every SubItem became the right metadata.

But i dont know how i can implement more models in your code. Must i use a complete different call as this setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen")); or can i use your?

setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen")); can i not call more than one time in my item class or?

setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "enh_canteen")); setRegistryName(new ResourceLocation(SchopCraft.MOD_ID, "cold_water_enh_canteen"));

?

cyberpunkbln commented 7 years ago

I have the right position found and can now test why it don't functioned that MetaData >0 don't will be showed in minecraft.

@SubscribeEvent
    @SideOnly(Side.CLIENT)
    public static void registerModels(ModelRegistryEvent event)
    {   
        //System.out.println ("Items Foo :" + ModItems.ITEMS[1]);

        // render item models
        for (Item item : ModItems.ITEMS) {

            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
            ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName()+"_fresh_water","inventory"));
            //System.out.println ("Items Foo :" + item.getRegistryName());
            //System.out.println ("Items Foo :" + SchopCraft.MOD_ID.toLowerCase());
        }

        // render block models
        for (Block block : ModBlocks.BLOCKS) {

            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
        }
        //ModelLoader.setCustomModelResourceLocation(ModItems.ITEMS[1], 0, new ModelResourceLocation(SchopCraft.MOD_ID.toLowerCase() + ":" + "fresh_water_enh_canteen","inventory"));
        //ModelLoader.setCustomModelResourceLocation(ModItems.ITEMS[1], 1, new ModelResourceLocation(SchopCraft.MOD_ID.toLowerCase() + ":" + "fresh_water_enh_canteen","inventory"));
    }

I know not the perfect code but i first search the right point to hook in the other metadata ressource.

The enc_canteen_fresh_water.json functioned on point MetaData-0 but not on point MetaData-1. Is not an json-error i think, why its functioned on MetaData-0.

You have use an fully Minecraft-Event-Pattern Register some other coders code Events all manually. No Prob your code is very well but i must search the right register event or search another thing why all other metadatas above 0 don'r will be accepted in RessourceLocationObj.

But now i know how make a RessourceLocation for Items without MetaData:).

cyberpunkbln commented 7 years ago

I have the failure, when i remove setDamage(105) then the correct textures will be showed. It's look like setDamage will be called before the subtype-textures will be set.

I think you have developed your Event-Classes without NBT-Tags and without the need of subtextures. But i think the easy way is to search an item event after subtextures-setting like ItemCreated or so.

Schoperation commented 7 years ago

In case you haven't found, the registry name and the unlocalized name of an item/block are completely different things. The registry name is how forge, the mod, the game, that type of stuff, references the item. The unlocalized name is just for the language files (currently there's only en_US in my mod), where they are localized into a human-readable name in-game. So for items with metadata, they only need one registry name, and an unlocalized name for every subitem created with metadata (including the original item with metadata 0)

Now for the models (the latest post above this one, I'm assuming you've got everything else under control from what I've read. If you don't go ahead and say so). As you see, that method iterates through a list of item objects to give them a model resource location. It doesn't check for metadata items to give them separate textures, as I haven't needed them so far (but I probably will). So the last two lines you added to the file (commented) would probably work, assuming you can get the correct registry name, there are actually subitems with the metadata, and that the json files are alright. I believe you need a model json file for each subitem too, separate from the main one. To do THAT correctly, you'll need to have different unlocalized names for the subitems, as stated in the above paragraph, and you'll need to use the overrides tag to specify when to use the other model jsons.

Hope this helps. Thanks for trying out my mod, I really appreciate it. About you finding old code. There are still plenty of examples out there using GameRegistry because well, it was fairly easy and was used forever. It was eventually deprecated and the methods themselves were marked private very recently while forge was updating to 1.12, so people could move on to more efficient methods of registering and rendering. Therefore there aren't many tutorials out there using newer methods yet. Same with the events and config file (and probably other crap too); they've moved on to annotations and other crap to get those to work better.

Aaanndd.. I posted when you posted... go figure. Yeah my canteen class is pretty messed up with metadata and crap. It's a pretty fragile system that could use a rework.

cyberpunkbln commented 7 years ago

Edit: my browser has not updatet:) And now i know the problem. Items wit MaxDamage cannot be an MetaData-Item with multiple Textures. I must it compelete rewrite and use nbt-data fpr drink uses.

cyberpunkbln commented 7 years ago

Yeah i think i rewrite the canteen class a little bit completly. I will use nbt-tags:).

cyberpunkbln commented 7 years ago

I don't can it belive,i laughing:).

I have think oh yeah forge and minecraft not with me, i save the time for nbb-datas and set the MaxDamage then when nbt-data was null and this is after all texture mapping:).

When i set the MaxDamage with this.setMaxDamage(105) in the rigthhanduse in your code, then Minecraft set the textures back if when i have setDamage at Initializing. A great effect:).

Smile nbt-tags, i hope i can use the duratiion bar.

cyberpunkbln commented 7 years ago

I have it done:),

Type and Durability per NBT Data, and MetaData for Textures, Models and Recipes.

The Durability will be show with an AddInformaton the Plastic Bottle.

The Durability has an Config Option;

Hardened Clay must be used to make an Empty Plastic Bottle, and this is why the Bottle can burned.

At the moment i want to make more Options (ironBottle that can really be burned for Filtered Water) and so on and i look for Mod-Integration.

For now Optifine 1.12 preview C5 is out and compatible with Tinkers Construct now and i test this first on my ModPack:).

Schoperation commented 7 years ago

Glad you got it to work.

cyberpunkbln commented 7 years ago

Many bugs but all are resolvable. So many of your Core-Objects was overwritten by me. How we can this make possible. I don't know, should i fork you and pull this with git or something else? I'm only a git cloner that make little bugfixes for me.

At this time you have to craft an empty Plastic Bottle and with this Plastic Bottle you can all what the Canteen can but more:

Config for Watersource and Durability (Uses) of the PlasticBottle You can smelt the Plastic Bottle (Like BushCraft:)) and then you have a plastic bottle that hurts you or you cold it down in water ressource to an Fresh Water Plastic Bottle without sucks water source up.

(I will try to get the Lava Particles:))

Now i will bugfix and look for others mod and his water container. Forestrys Rain Collector i will made usably:).

Schoperation commented 7 years ago

Once you smash more bugs and perhaps add some more compatibility, you could just fork this repository, then commit your changes to the fork, and submit a pull request back to the original repository. There I can look at the code and you could make changes (thus more commits) as needed, and then it could be integrated into the legit mod. I'll probably end up committing some formatting tweaks and some core file changes (since you changed them a bit) after that.

I've been thinking about your new item and thought that it would actually be alright to include as more of a mid or late tier item, so it isn't obtainable on the first day of any world (probably not even the hundredth day). Another thing I'd like is a name change of the new plastic bottle. It doesn't fit with the theme of the mod (or what theme it'll probably be). The mod will most likely end up being like another video game called Don't Starve. In case you don't know what that is, it's another survival game with pretty much the same mechanics I implemented, but it also has some mystical, mysterious feel and look to it. It also includes some random magic items. So there's a lore behind the world of the game, but it isn't an RPG.

I personally found it very cool, and thought this mod could kind of go in that same direction. So instead of some plastic bottle, perhaps it could be some interesting name like... (from the top of my head) the HydroPouch, the C.U.P. (Compact Uni-Pool) or just the Enhanced Canteen. Who knows, but to me "plastic bottle" doesn't click... I don't know.

cyberpunkbln commented 7 years ago

Hello,

ah okay i think i fork your repo and you can look into my source code, how i have made the new additions. I think there are only usefull if you want to use more complicated items, how i use my plastic bottle.

Smile i only want maketoAir-/DurabilityConf-Function for the canteen, smile. Now its a drug.

So the Plastic Bottle functioned for my needs and have reached my knowledge about java and forge dev:).

At this stage i must some code cleaned before my code goes public and some very little bugs will be resolved, the i fork your repo and push my changes and you can look about:).

Now i have this functionality in my additions:

dev:

game: so we have enh_canteen - empty plastic bottle where made from ceramic and glass bottle _fresh_water _dirt_water used with charcoal-filter to filtered water bottle _salt_water _filtered_water _cold_water - can burned for fresh water bottle

_hot_water which can be made with smelting dirt water bottle and salt water bottle when i smelt cold water bottle ir receive fresh water bottle when i put hot water bottle on water source it will not be sucked up and i receive filtered water bottle

The enh_canteen have additional item informations and a durability bar without the need of setMaxDamage. And different textures for full and for used.

Can you help me for a little bug? Can you say me how i can put more that one shapeless and shaped recipe in one json-recipe?

Schoperation commented 7 years ago

I looked up recipe jsons and it looks like you have that problem solved.

I'll probably end up cleaning some of the code, so you could leave that to me if you'd like.

Also, what does hot water do at the moment?

cyberpunkbln commented 7 years ago

Hello, yes i can now make Cold Plastic Water Bottle with a Fresh Plastic Water Bottle or a Filtered Plastic Water Bottle. I go hot with the newest Recipe-System :).

So when i have burned Dirty Plastic Water Bottle or Salt Plastic Water Bottle to Hot Plastic Water Bottle i can refresh the Hot Plastic Water Bottle in a Vanilla Water Source and became an Fresh Plastic Watter Bottle, without sucking up a Water Source and Lava Particles and Fizz Sound:).

So now you can see all my changes. Was my first Git-Process about cloning. I hope all is okay and you can see all my changes.

Hmm i have forgot the german translation :). But now i can do this with git.

So i hope my code are not to crappy.

cyberpunkbln commented 7 years ago

Hmmm some things i found a little bit unrealistic. The word plastic from clay or ceramic. I must think about the hole process. I have made a mistake :).

The better Name where Iron Canteen like in the army. Was an logically better Enhancedment for the leather canteen. But this are only a change of recipes and names and cap logics. :).

At the moment i hope my code can help you. How i say my only thing was that i have an Item with Multitextures without SetMaxDamage and checking about nbt-datas and with durabilty without SetMaxDamage. I hope that help.

I go now and play with my my modpack and show where i can make real plastic from trees or so, and i think about mod integration, that was not easy for me, but i hope some thinks are solveable about json-recipes.

Schoperation commented 7 years ago

Your new canteen is really cool. I like your implementation of NBT tags to keep track of uses and the type of canteen, so durability doesn't have to be messed up. I'll definitely implement that part into the main mod if you don't mind. May as well figure out a simple way to implement multiple textures of metadata items now. I'll probably get this done by the beginning of next week or so. Thanks for helping out. Suppose I'll close this for now.