Jump to content

Zemelua

Members
  • Posts

    190
  • Joined

  • Last visited

Everything posted by Zemelua

  1. I pondered it, but I still don't know much about Baked Quad ... Perhaps SimpleBakedModel.Builder only creates a completely empty BakedModel, setTexture only specifies the texture of the particles, and the texture of each face needs to be specified in BakedQuad. After creating an instance of BakedQuadBuilder in order to generate BakedQuad, I understand that it is necessary to put vertex data by put, but what value is passed as to how the vertex data is defined? I don't know how it will be modeled. I also searched for a tutorial on this, but couldn't find it, and I'm completely out of luck. Please Please Please give me a detailed explanation!
  2. public class VariantsTextureModel implements IModelGeometry<VariantsTextureModel> { private JsonObject variants; public VariantsTextureModel(JsonObject variants) { this.variants = variants; } @Override public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { return new BakedModel(variants, new SimpleBakedModel.Builder(owner, overrides)); } @Override public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) { return Collections.emptyList(); } public static final class BakedModel implements IBakedModel { private SimpleBakedModel.Builder simple; private JsonObject variants; public BakedModel(JsonObject variants, SimpleBakedModel.Builder simple) { this.simple = simple; this.variants = variants; } @Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { Collection<Property<?>> properties = state.getProperties(); for (Map.Entry<String, JsonElement> variantElements : variants.entrySet()) { //String JSONVariants = variantElement.getAsString(); String[] JSONProperties = variantElements.getKey().split(",", 0); for (String JSONProperty : JSONProperties) { String propertyName = JSONProperty.split("=", 2)[0]; Integer propertyValue = Integer.valueOf(JSONProperty.split("=", 2)[1]); for (Property<?> property : properties) { if (!property.getName().equalsIgnoreCase(propertyName) && state.get(property) == propertyValue) { ExpansionMod.LOGGER.debug(variantElements.getValue().getAsJsonObject().get("top").getAsString()); TextureAtlasSprite spriteTop = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(/*variantElements.getValue().getAsJsonObject().get("top").getAsString()*/"block/oak_planks")).getSprite(); List<BakedQuad> quads = new ArrayList<BakedQuad>(); return simple.setTexture(spriteTop).build().getQuads(state, side, rand); } } } } return getBakedModel().getQuads(state, side, rand); } @Override public boolean isAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return false; } @Override public boolean isSideLit() { return false; } @Override public boolean isBuiltInRenderer() { return false; } @Override public TextureAtlasSprite getParticleTexture() { return null; } @Override public ItemOverrideList getOverrides() { return null; } } public static class Loader implements IModelLoader<VariantsTextureModel> { public static final Loader INSTANCE = new Loader(); @Override public void onResourceManagerReload(IResourceManager resourceManager) { } @Override public VariantsTextureModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { System.out.println("qffewrbvtb"); JsonObject variants = new JsonObject(); if (modelContents.has("variants")) { variants = modelContents.get("variants").getAsJsonObject(); } return new VariantsTextureModel(variants); } } } With further changes, it looks like this. Before the fix, it crashed when I opened the world, but it's gone. However, the texture of the block remains transparent and when destroyed it crashes with a net.minecraft.crash.ReportedException: Rendering Particle. What's wrong?
  3. sorry. It was a really stupid mistake. I rewrote it this way, but it crashes with Caused by: java.lang.IllegalStateException: not enough data. public class VariantsTextureModel implements IModelGeometry<VariantsTextureModel> { private JsonObject variants; public VariantsTextureModel(JsonObject variants) { this.variants = variants; } @Override public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { return new BakedModel(variants); } @Override public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) { return Collections.emptyList(); } public static final class BakedModel implements IBakedModel { private JsonObject variants; public BakedModel(JsonObject variants) { this.variants = variants; } @Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { Collection<Property<?>> properties = state.getProperties(); for (Map.Entry<String, JsonElement> variantElements : variants.entrySet()) { //String JSONVariants = variantElement.getAsString(); String[] JSONProperties = variantElements.getKey().split(",", 0); for (String JSONProperty : JSONProperties) { String propertyName = JSONProperty.split("=", 2)[0]; Integer propertyValue = Integer.valueOf(JSONProperty.split("=", 2)[1]); for (Property<?> property : properties) { if (!property.getName().equalsIgnoreCase(propertyName) && state.get(property) == propertyValue) { TextureAtlasSprite spriteTop = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(variantElements.getValue().getAsJsonObject().get("top").getAsString())).getSprite(); BakedQuadBuilder builder = new BakedQuadBuilder(spriteTop); VertexFormat format = builder.getVertexFormat(); for (int i = 0; i < format.getElements().size(); i++) { builder.put(i, 225, 45); } List<BakedQuad> quads = new ArrayList<BakedQuad>(); quads.add(builder.build()); return quads; } } } } return null; } @Override public boolean isAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return false; } @Override public boolean isSideLit() { return false; } @Override public boolean isBuiltInRenderer() { return false; } @Override public TextureAtlasSprite getParticleTexture() { return null; } @Override public ItemOverrideList getOverrides() { return null; } } public static class Loader implements IModelLoader<VariantsTextureModel> { public static final Loader INSTANCE = new Loader(); @Override public void onResourceManagerReload(IResourceManager resourceManager) { } @Override public VariantsTextureModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { System.out.println("qffewrbvtb"); JsonObject variants = new JsonObject(); if (modelContents.has("variants")) { variants = modelContents.get("variants").getAsJsonObject(); } return new VariantsTextureModel(variants); } } } To be honest, I only understand that Baked Quad is a class that represents a face with four vertices, and I know I need to put something, but what exactly do I do? I don't know what to do. What is the list of BakedQuads and what is each BakedQuad? I would like to know in as much detail as possible. I'm sorry to ask you many times.
  4. I made the following code, but the actual block is displayed as a missing texture. What's wrong?Regietring is complete and works fine. public class VariantsTextureModel implements IModelGeometry<VariantsTextureModel> { private JsonArray variants; public VariantsTextureModel(JsonArray variants) { this.variants = variants; } @Override public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { return new BakedModel(variants); } @Override public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) { return null; } public static final class BakedModel implements IBakedModel { private JsonArray variants; public BakedModel(JsonArray variants) { this.variants = variants; } @Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { Collection<Property<?>> properties = state.getProperties(); for (JsonElement variantElement : variants) { String JSONVariants = variantElement.getAsString(); String[] JSONProperties = JSONVariants.split(",", 0); for (String JSONProperty : JSONProperties) { String propertyName = JSONProperty.split("=", 1)[0]; Integer propertyValue = Integer.valueOf(JSONProperty.split("=", 1)[1]); for (Property<?> property : properties) { if (!property.getName().equalsIgnoreCase(propertyName) && state.get(property) == propertyValue) { return null; } } } TextureAtlasSprite spriteTop = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(variantElement.getAsJsonObject().get("top").getAsString())).getSprite(); BakedQuadBuilder builder = new BakedQuadBuilder(); builder.setTexture(spriteTop); List<BakedQuad> quads = new ArrayList<BakedQuad>(); quads.add(builder.build()); return quads; } return null; } @Override public boolean isAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return false; } @Override public boolean isSideLit() { return false; } @Override public boolean isBuiltInRenderer() { return false; } @Override public TextureAtlasSprite getParticleTexture() { return null; } @Override public ItemOverrideList getOverrides() { return null; } } public static class Loader implements IModelLoader<VariantsTextureModel> { public static OBJLoader INSTANCE = new OBJLoader(); @Override public void onResourceManagerReload(IResourceManager resourceManager) { } @Override public VariantsTextureModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { JsonArray variants = new JsonArray(); if (modelContents.has("variants")) { variants = modelContents.getAsJsonArray("variants"); } return new VariantsTextureModel(variants); } } } JSON model: { "parent": "block/oak_planks", "loader": "expansionmod:variants-texture", "variants": { "x_width=0,z_width=0": { "top": "minecraft:block/oak_planks" } } }
  5. I'm now trying to create a texture that is also assigned by a property in model json, like the variants in blockstates. For that, I'm looking for a class that is reading variants in blockstates, but I can't find it. Where is it? Also, are there any plans to add the above features to forge in the future? If not, can you suggest it?
  6. Thank you. We were able to confirm the operation as planned. The question changes, but I'm not sure about Baked Quad, how do I specify a sprite for each face? Should I specify each Direction in face and return them as a List of 6?
  7. I read the Document, but I didn't know where to call or register for getQuads to be called. Can anyone solve this?
  8. public static class BakedModel implements IBakedModel { @Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { if (state.getBlock() instanceof OreBlock) { BakedQuadBuilder builder = new BakedQuadBuilder(ModelLoader.White.instance()); List<BakedQuad> quads = new ArrayList<BakedQuad>(); quads.add(builder.build()); return quads; } return null; } } I want to make the texture of an ore block pure white as a sample in getQuads of the class that implements IBakedModel, but I don't know how to register it.
  9. I'm working on creating a Connection Texture block. I knew I needed to use something like IModelGeometry for that, but I don't know exactly what to do. I would like to refer to ANDESITE_VARIANTS of Create mod ( https://github.com/Creators-of-Create/Create/tree/9d77f85b9442910a3f595c58f41cb3363093384e ). Could you please explain?
  10. https://github.com/Chisel-Team/ConnectedTexturesMod I looked into this, but I don't know which one is the goal because there are too many elements ...
  11. What is the reason for doing so? Why use ItemStackHandler?
  12. I'm trying to extend a LockableLootTileEntity to make a simple custom chest, similar to a vanilla barrel or chest, but looking at the code for some mods seems to require the use of packets and capabilities. , I don't understand this well. When and what should I do when using capabilities?
  13. For example, when the blocks are placed side by side in 2x1, the specified texture is drawn on the 2x1 surface. In other words, right.png is used as the texture if the same block is located at x + 1, and left.png is used as the texture if it is located at x-1. However, the 2x1 rectangular parallelepiped is 1x1 in some respects, so you need to use normal.png as the texture. I'm not sure how to use IModelLoader, IModelGeometry, and IDynamicBakedModel. How can I specifically overwrite the texture of the specified face?
  14. I want to dynamically change the texture of blocks individually. I've found it to be good to use the IBakedModel for this, but I have no idea exactly where or what to do. Is it possible to refer to the modeling of normal vanilla blocks? Also, if you have any sample code or tutorials for that, please do.
  15. Vector3d eyeVec = playerIn.getEyePosition(1.0F); Vector3d lookVec = playerIn.getLook(1.0F); final double distance = 20.0D; Vector3d finVec = eyeVec.add(lookVec.getX() * distance, lookVec.getY() * distance, lookVec.getZ() * distance); AxisAlignedBB axisalignedbb = playerIn.getBoundingBox().expand(lookVec.scale(distance)).grow(1.0D, 1.0D, 1.0D); double d1 = distance * distance; if (Minecraft.getInstance().objectMouseOver != null) { d1 = Minecraft.getInstance().objectMouseOver.getHitVec().squareDistanceTo(eyeVec); } EntityRayTraceResult entityRayTraceResult = ProjectileHelper.rayTraceEntities(playerIn, eyeVec, finVec, axisalignedbb, (p_215312_0_) -> { return !p_215312_0_.isSpectator() && p_215312_0_.canBeCollidedWith(); }, d1); I tried to get the entity beyond the line of sight of playerIn with this code, but I can only get up to about 3 blocks. In the first place, I'm not sure what each argument of rayTraceEntities of ProjectileHelper represents. For example, which parameter should I use to get the entity in the line of sight (within 20 blocks from the player)?
  16. I'm sorry. I'm still not sure, what is BakedQuad, what field the texture itself is in BakedQuad, is there a good tutorial or sample code?
  17. I tried various things, but I couldn't understand it well, so I wanted to refer to the animation texture, but where is the class that deals with it?
  18. Well, does that mean you can combine textures with block properties like fence's multi-model? If so or not, can you tell me exactly how to do it?
  19. So does that mean that all combinations of models have to be defined to achieve my goal?
  20. I was not good at explaining. Although it is timbered, the actual block is the same cube as usual, as it is actually drawn on the texture of the wall and used as is.
  21. I understand there is a way to do that. However, for example, comparing the textures of the blocks when 2x2x1 and 2x2x2, the state of the bar with the x-plane of 45 degrees and the angle of the z-plane with a small angle is 45 for both the x-plane and the z-plane. I need to have both the state of the degree bar. I plan to do this in many combinations such as 2x1, 3x2 as well as 2x2 and 1x2, and the method of using block properties is not realistic. I need to replace the texture for each face.
  22. Specifically, I would like to implement a half-timbered wall. For example, when these are arranged in a square with two in the x direction and two in the y direction, the texture of a large half-timber at an angle of 45 degrees on the 2x2 surface and a vertically long half-timber on the 2x1 surface. I want it to be displayed.
  23. Is it possible to dynamically change only one side of the texture of a custom item (apply changes to only one block depending on the top, bottom, left and right blocks)? I think there is a class in vanilla that draws textures, but I couldn't find it when I searched for it.
  24. I solved it by giving SpellItem a RegistryObject <Magic> instead of the Magic class type. Thank you!
×
×
  • Create New...

Important Information

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