Jump to content

immortalmice

Members
  • Posts

    14
  • Joined

  • Last visited

Recent Profile Visitors

7458 profile views

immortalmice's Achievements

Tree Puncher

Tree Puncher (2/8)

3

Reputation

  1. ActionResultType has four elements, please correct me if i'm wrong. SUCCESS All the things is valid, and this action actually modified something in someway. FAIL Some thing is invalid, so this action failed. PASS This action is not related to me, and I didn't do anything with it. CONSUME ... I can't understand what does consume mean. I looked all the place that ActionResultType.CONSUME is used in vanilla Minecraft code, but I still can't sum up what this is. The only things I found is that it used in logical client side mostly. (Ex. ArmorStand, Bed, Cake...etc) And it seems doesn't change anything. Is it mean to consume the item held by player? Or is it consume the result itself?
  2. There's no texture under resource folder, because I want to use item's texture instead. I override the IForgeEffect#renderHUDEffect but it'll show a broken texture in the background. I tried to cover it, but failed. @OnlyIn(Dist.CLIENT) @Override public void renderHUDEffect(EffectInstance effect, AbstractGui gui, int x, int y, float z, float alpha){ /* Cover original icon */ Minecraft minecraft = Minecraft.getInstance(); minecraft.getTextureManager().bindTexture(ContainerScreen.INVENTORY_BACKGROUND); gui.blit(x, y, 141, 166, 24, 24); /* Show custom icon */ ItemRenderer itemRenderer = minecraft.getItemRenderer(); itemRenderer.zLevel = z; itemRenderer.renderItemAndEffectIntoGUI(new ItemStack((Ingredients.getIngredientByName(this.getIngredientName())).asItem()) , x + 4, y + 4); } But I also override the IForgeEffect#renderInventoryEffect and do it with very similar way, and it worked. @OnlyIn(Dist.CLIENT) @Override public void renderInventoryEffect(EffectInstance effect, DisplayEffectsScreen<?> gui, int x, int y, float z){ /* Cover original icon */ Minecraft minecraft = gui.getMinecraft(); minecraft.getTextureManager().bindTexture(ContainerScreen.INVENTORY_BACKGROUND); gui.blit(x + 6, y, 6, 166, 18, 32); /* Show custom icon */ ItemRenderer itemRenderer = minecraft.getItemRenderer(); itemRenderer.zLevel = z; itemRenderer.renderItemAndEffectIntoGUI(new ItemStack((Ingredients.getIngredientByName(this.getIngredientName())).asItem()) , x + 6, y + 7); } I tried a lot, like using static blit method instead of non-static blit and pass in z, gui.getBlitOffset(), z + 10, gui.getBlitOffset() + 100 etc.... I think maybe I don't really know what does blitOffset and zlevel mean, but I can't find a way to blit a layer over that broken texture. I also read code in IngameGui#renderPotionEffects, and I found that it construct a List<Runnable> and run them after EffectInstance#renderHUDEffect. Why blit can't cover the broken texture, but ItemRenderer can? Can anyone help me? thx.
  3. OK, because nobody reply me, so I tried to generate quads by my own code. Repo is here But I got another problem. Now everything looks fine when stack is in item frame or dropped on the ground, the side quads is not missing. They are in the right place with right color. But when on the left/right hand of first person camera, the side quads missing. BTW, stack in third person camera looks fine. I don't know where I did it wrong....and it confuse me why only first person camera will get this problem. I think I did something wrong when processing Model Transform, but I can't find it.? ================================== UPDATE I found that if right hand is empty or holding a block, stack in left hand will render correctly, otherwise not. How strange it is......I'm really confused..... ======================================= Ok.....I found problem and it fixed now. Only y need to be subtracted by 1 like (1 - y). But z doesn't need to do this..... Everything is fine now, and I plan to make catch of the baked quads next, since it won't change after a stack is made. thx.
  4. Thanks for replied and advice, I finished the exercise. PS. I spend a lot of time seeking which field I can hack in PotionSpriteUploader and plan to do it in TextureStitchEvent.Pre. After hours I realize that just hack TextureStitchEvent.Pre and everything will be done ?
  5. I have my effects, and I using DeferredRegister to regist them. Here's my effects. For FoodEffect, I need to reuse texture from specific items, I override the IForgeEffect#renderInventoryEffect to finish these. @OnlyIn(Dist.CLIENT) @Override public void renderInventoryEffect(EffectInstance effect, DisplayEffectsScreen<?> gui, int x, int y, float z){ /* Cover original icon */ Minecraft minecraft = gui.getMinecraft(); minecraft.getTextureManager().bindTexture(ContainerScreen.INVENTORY_BACKGROUND); gui.blit(x + 6, y, 6, 166, 18, 32); /* Show custom icon */ ItemRenderer itemRenderer = minecraft.getItemRenderer(); itemRenderer.zLevel = z; itemRenderer.renderItemAndEffectIntoGUI(new ItemStack(Ingredients.getIngredientByName(this.getIngredientName())) , x + 6, y + 7); } FoodEffect's code It worked. But there's a problem on console log, it complained that it can't find file under mob_effect folder. Of course, I put nothing in the mob_effect folder. [m[1;31m[23:14:54] [Server-Worker-11/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/fermented_endereye_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/fermented_endereye_power.png [m[1;31m[23:14:54] [Server-Worker-11/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/orange_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/orange_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/porkchop_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/porkchop_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/egg_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/egg_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/papaya_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/papaya_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/spinach_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/spinach_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/beetroot_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/beetroot_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/honey_bottle_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/honey_bottle_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/ghast_tear_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/ghast_tear_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/mint_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/mint_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/sweet_berries_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/sweet_berries_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/nether_wart_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/nether_wart_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/beef_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/beef_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/salt_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/salt_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/dragon_breath_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/dragon_breath_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/cheese_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/cheese_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/sauce_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/sauce_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/flour_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/flour_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/kelp_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/kelp_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/cream_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/cream_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/dough_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/dough_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/red_mushroom_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/red_mushroom_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/rice_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/rice_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/oil_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/oil_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/pumpkin_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/pumpkin_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/chicken_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/chicken_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/chorus_fruit_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/chorus_fruit_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/butter_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/butter_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/ketchup_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/ketchup_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/cabbage_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/cabbage_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/cocoa_beans_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/cocoa_beans_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/kiwi_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/kiwi_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/melon_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/melon_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/tomato_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/tomato_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/chili_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/chili_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/carrot_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/carrot_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/apple_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/apple_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/experience_bottle_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/experience_bottle_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/lemon_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/lemon_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/mutton_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/mutton_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/milk_bucket_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/milk_bucket_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/sugar_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/sugar_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/magma_cream_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/magma_cream_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/brown_mushroom_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/brown_mushroom_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/corn_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/corn_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/water_bucket_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/water_bucket_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/potato_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/potato_power.png [m[1;31m[23:14:54] [Server-Worker-13/ERROR] [minecraft/AtlasTexture]: Using missing texture, unable to load foodpower:textures/mob_effect/mango_power.png : java.io.FileNotFoundException: foodpower:textures/mob_effect/mango_power.png These error log are annoyed me, and it's not nessery to trying load textures for these effects in my mod. So is there a way I can tell minecraft no need to load these textures? Or a way I can set all these effects to a single texture like mob_effect/default.png. I'm tired about copy a lot png files and rename them, it's make extra work when I add new effects, and I think I may avoid this. I tried using TextureManager#deleteTexture in FMLClientSetupEvent and TextureStitchEvent.Pre, but it didn't work.
  6. This is what ItemStack look now. All the thing in the front and back of ItemStack rendered correctly, but when holding in hand, you'll see the every side of this ItemStack is broken. Repo is here The code closely related with model is under meal folder I used a custom Loader, IModelGeometry and ItemOverrideList. My goal is select what textures to use by overriding ItemOverrideList#getModelWithOverrides And at the final of method I directly using ItemLayerModel to bake a new model.To stack textures together is actually what I want. @Override public IBakedModel getModelWithOverrides(IBakedModel model, ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn){ IBakedModel returnModel = model; if(stack.getItem() instanceof Meal){ CompoundNBT nbt = stack.hasTag() ? stack.getTag() : new CompoundNBT(); List<Material> textures = new ArrayList<Material>(); textures.add(this.materials.get("base")); if(nbt.contains("ingredients")){ ListNBT list = (ListNBT)nbt.get("ingredients"); for(INBT ele : list){ CompoundNBT element = (CompoundNBT)ele; textures.add(this.materials.get(element.getString("name"))); } } returnModel = new ItemLayerModel(ImmutableList.copyOf(textures)) .bake(this.owner, this.bakery, this.spriteGetter, this.modelTransform, this.overrides, this.modelLocation); } return returnModel; } It success, the three thing in the item frame is the same Item "salad" with different CompoundNBT. But as the title, the side of this item is broken. I tried using ItemLayerModel#getQuadsForSprites before, but every thing is the same, including which little square surface is missiing. Someone has any idea?
  7. Ok, here's repo. I set it public now. https://github.com/immortalmice/FoodPower This mod is under construction, so everything will be what I mention in README.txt. My mod have many parts. About making food, this mod has some cooking patterns, such as cake, pizza, salad...etc. You can select a pattern to make a recipe, pattern will tell you what ingredients is necessary, and what is optional(with certain food types). With recipe, you can follow cooking steps on it to make your food by using oven, frying pan, juicer...etc. Depend on what you used in this food, after eating it will give you some buff and some special experience. Experience will help you on cooking new meals, and most important - some special power for you in gaming minecraft. And there some other features in this mod, so I still working hard for it
  8. It seem that I solve my problem in someway. I still don't know how IModelConfiguration#resolveTexture worked, and I can't get a Material from it now too. But, now I found I can directly call new Material to solve my need. I tried new Material before but it fail at that point in time, because I missed a thing. I need to subscribe TextureStitchEvent, so that I can add my texture to AtlasTexture. @SubscribeEvent public static void onTextureStitch(TextureStitchEvent.Pre event){ if(event.getMap().func_229223_g_().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)){ event.addSprite(new ResourceLocation(FoodPower.MODID, "meals/salad/salad_base")); } } So now directly new a Material and transform it to TextureAtlasSprite will work. Material m = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(FoodPower.MODID, "meals/salad/salad_base")); Thx from everyone who replied this post. But I still open for any better suggestion
  9. Bow use a thing called ItemOverride, it can use key word "overrides" in json file to select a model depend on a float value. For example, how hard is the bow pulled, where should compass point to and what time is it now(Vanilla clock). To use your own float value, just call Item#addPropertyOverride and write the "predicate" field in the "overrides" section in json file that will be fine. This is what vanilla bow model json file like. { "parent": "item/generated", "textures": { "layer0": "item/bow" }, "display": { //... }, "overrides": [ { "predicate": { "pulling": 1 }, "model": "item/bow_pulling_0" }, { "predicate": { "pulling": 1, "pull": 0.65 }, "model": "item/bow_pulling_1" }, { "predicate": { "pulling": 1, "pull": 0.9 }, "model": "item/bow_pulling_2" } ] } But my case is a combination of Strings, not a float. Yes, I can map them to each float, however, a salad, the possible combination will be 3*13*5.(Salad is made with three kinds of ingredient, each kind has its possible choices) That means I need to wirte 195 model file, I think it will make things worst and terrible. Currently I planed to do, is extend ItemOverrideList to my custom MealItemOverrideList, and override ItemOverrideList#getModelWithOverrides, so that I can generate my model depend on my itemstack. And it seems that I need to make my own model geometry, baked mode and model loader too, and I encounter a problem in IModelGeometry#bake, then this post spawn. Oh, thx. 1.12.2 is a lot different to 1.15.2 now, but its may be helpful to me in sometimes~
  10. What I need is the itemstack texture depend on its nbt, nbt will store some information about what ingredient player used to make this itemstack. For example, I may need a.png, b.png, c.png 3 picture and stack them together to display this itemstack. But according by how player maked this itemstack, I may need to stack a.png, d.png and e.png together now. I think it's not just a single json file can solve it. Thx for reply :).
  11. OK, now I know something more. Texture channel is the thing you write under "textures" in your json file. { "parent": "item/generated", "textures": { "layer0": "foodpower:blocks/juicer_top" }, "loader": "foodpower:meal" } I pass in "layer0", it finally return a normal Material instead of missing texture. IModelConfiguration#isTexturePresent also return true. But now I have another problem, if I change "layer0" to another key name, it won't work. And I found that BlockModelConfiguration#isTexturePresent called BlockModel#isTexturePresent. (net.minecraftforge.client.model.BlockModelConfiguration is the only one who implement IModelConfiguration) BlockModel has its own JsonDeserializer, and call BlockModel#getTextures to construct a Map<String, Either<Material, String>> textures, and this field is used in BlockModel#isTexturePresent. Code is here. the JsonObject passed in is the whole json file. The map it return is used in construct BlockModel and place in textures field directly. private Map<String, Either<Material, String>> getTextures(JsonObject object) { ResourceLocation resourcelocation = AtlasTexture.LOCATION_BLOCKS_TEXTURE; Map<String, Either<Material, String>> map = Maps.newHashMap(); if (object.has("textures")) { JsonObject jsonobject = JSONUtils.getJsonObject(object, "textures"); for(Entry<String, JsonElement> entry : jsonobject.entrySet()) { map.put(entry.getKey(), func_228819_a_(resourcelocation, entry.getValue().getAsString())); } } return map; } So, I think it will take every key under textures, but it don't. What I missed? And I saw code in DynamicBucketModel#bake. Material baseLocation = owner.resolveTexture("base"); if (MissingTextureSprite.getLocation().equals(baseLocation.func_229313_b_())) { baseLocation = null; } Then I tried change the key name to "bake", but it didn't work too. I really need some help. Thx.
  12. What I need, is a custom itemstack texture present base on some information(Currently I save these information in CompoundNBT). These information decide and pick several textures and I need to combine them just like what vanilla "layer#" do. These information isn't and won't be a float, so vanilla itemoverride can't solve it. I'm searching a way to solve it for several days, but I got stuck in something due to leak tutorial of this kind of things. I already read this intro to advance models in forge wesite, but it's hard to understand because I can't find things like IModel, ICustomModelLoader in this version.(But I found something like them) And I tried hard to read DynamicBucketModel and write my code, but now I'm stuck in loading picture to Material, which I can get TextureAtlasSprite to construct a BakedModel. What I already done/tried/planed: I defined a new IModelLoader called MealModelLoader public enum MealModelLoader implements IModelLoader<MealModel>{ INSTANCE; @Override public void onResourceManagerReload(IResourceManager resourceManager){ } @Override public MealModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents){ System.out.println(modelContents); String pathName = modelContents.has("path_name") ? modelContents.get("path_name").getAsString() : ""; String baseFilePath = modelContents.has("base") ? modelContents.get("base").getAsString() : ""; JsonArray parts = modelContents.has("part") ? modelContents.get("part").getAsJsonArray() : new JsonArray(); //TODO return new MealModel(pathName, baseFilePath, parts); } } It return a MealModel which implement IModelGeometry<MealModel> (I'll talk about MealBakedModel which return in bake method later.) public class MealModel implements IModelGeometry<MealModel>{ private String pathName, baseFilePath; private JsonArray parts; public MealModel(String pathNameIn, String baseFilePathIn, JsonArray partsIn){ this.pathName = pathNameIn; this.baseFilePath = baseFilePathIn; this.parts = partsIn; } @Override public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery , Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform , ItemOverrideList overrides, ResourceLocation modelLocation){ TransformationMatrix transform = modelTransform.func_225615_b_(); TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));//Just using something and make game can launch successful ImmutableMap<TransformType, TransformationMatrix> map = PerspectiveMapWrapper.getTransforms(modelTransform); // TODO return new MealBakedModel(ImmutableList.of(), particle, map, transform.isIdentity(), owner.isSideLit()); } @Override public Collection<Material> getTextures(IModelConfiguration owner , Function<ResourceLocation, IUnbakedModel> modelGetter , Set<Pair<String, String>> missingTextureErrors){ Set<Material> texs = Sets.newHashSet(); // TODO return texs; } } And I registed my MealModelLoader using ModelLoaderRegistry in FMLClientSetupEvent. @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event){ Containers.registAllScreen(); RenderHandler.setup(); ModelLoaderRegistry.registerLoader(new ResourceLocation(FoodPower.MODID, "meal"), MealModelLoader.INSTANCE); } Then I write json model using this loader, and try to add some information I may need to make a model. { "parent": "item/generated", "loader": "foodpower:meal", "path_name": "salad", "base": "foodpower:meals/salad/salad_base", "part": [{ "slot": "VEGETABLE", "textures": { "cabbage": "foodpower:meals/salad/salad_cabbage", "tomato": "foodpower:meals/salad/salad_tomato" } }, { "slot": "MEAT", "textures": { "beef": "foodpower:meals/salad/salad_beef", "chicken": "foodpower:meals/salad/salad_chicken" } }, { "slot": "SEASONING", "textures": { "ketchop": "foodpower:meals/salad/salad_ketchop", "sauce": "foodpower:meals/salad/salad_sauce" } }] } Now I can successfully load these json information in MealModelLoader#read, and using them to construct a MealModel. (Maybe it's a bad idea to pass a JsonArray to MealModel? I may change it to be a something like Map<String, Map<String, String>>). I'm now stuck in MealModel#bake. I can get the path string in json file, but how can I using this to get Material? If I get Material, I plan to get TextureAtlasSprite using parameter spriteGetter, then pass it to my MealBakedModel, is that right? public class MealBakedModel extends BakedItemModel{ public MealBakedModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TransformationMatrix> transforms, boolean untransformed, boolean isSideLit){ super(quads, particle, transforms, new MealItemOverrideList(), untransformed, isSideLit); // TODO } } I found a method IModelConfiguration#resolveTexture, I think it may be a key, but I don't know how to use it. /** * Resolves the final texture name, taking into account texture aliases and replacements. * @param name The name of a texture channel. * @return The location of the texture, or the missing texture if not found. */ Material resolveTexture(String name) What does "texture channel" mean? A folder under asset/modid/textures? I tried pass in a lot of String including name of folder which I construct under asset/modid/textures to it, but it always return the "missing texture". Finally, I define a MealItemOverrideList which extends ItemOverrideList. Because I need method ItemOverrideList#getModelWithOverrides, I override it. public class MealItemOverrideList extends ItemOverrideList{ public MealItemOverrideList(){ //TODO } @Override public IBakedModel getModelWithOverrides(IBakedModel model, ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn){ //TODO return null; } } This method pass in a ItemStack, which I can get information in CompoundNBT I stored. Then I'll use this information to make a final MealBakedModel to return. Ok, that all. So how can I make a Material using path string in json file? And is there anything I did/planed is wrong or a bad idea? Or it has another better way to do that. Thanks for reading these.
  13. I'm currently using 1.12.2-14.23.5.2847, I can't find NetworkEvent.Context. The method I process my message is something like this, I only have MessageContext. public static class Handler implements IMessageHandler<RecipeTableMessage, IMessage>{ @Override public IMessage onMessage(RecipeTableMessage message, MessageContext ctx){ /** do something here ...... */ } } Yes, I only send the action client did, and process data always on the server.
  14. OK, this often encounter when I need to change nbt data on gui action in client. I know I need to send custom packet to server when client do something on gui. But I confused the information I give in message (used in let server know what itemstack/tileentity to update) is appropriate or not. I don't want increase too much loading on server and the way must be logical. So, for itemstack. I may want to contain uuid of player in packet. Then on the server, I use uuid to get the PlayerEntity, use some method like PlayerEntity#getHeldEquipment get the itemstack and valid it. Then change it's nbt data. But I found that some thread here said don't trust uuid from client, so what other way I can use will be a good idea? And, for tileentity. I may want to contain postion of the block. Then on server, I use World#getTileEntity to get the tileentity and valid it. Then do something with its nbt data. This is the way I current used in sync tileentity. It worked, but is this a good idea? ==================================================================== OK, my bad sorry. I found I can get player simply using MessageContext#getServerHandler#player...... Just ignore this post qq.
×
×
  • Create New...

Important Information

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