Jump to content

SnowyEgret

Members
  • Posts

    112
  • Joined

  • Last visited

Everything posted by SnowyEgret

  1. Finally, got it working. I'll submit an issue to the MBE Github repository with notes about the additional interface needed to render the block as an item. Thanks for the help, TGG.
  2. The block in place should look the same as when in inventory, tossed, and in hand. Here are #handleBlockState and #handleItemState: This is all working fine. Each method generates the same quads. When I debug with a breakpoint in ItemModelMesher#getItemModel, stack.getItem() is still not returning an ISmartItemModel and this if statement evaluates false: if(ibakedmodel instanceof net.minecraftforge.client.model.ISmartItemModel) { ibakedmodel = ((net.minecraftforge.client.model.ISmartItemModel)ibakedmodel).handleItemState(stack); } Now that my smart model implements both ISmartModel and ISmartItemModel, what should my ModelBakeEvent handler look like? Which ModelResourceLocation should be registered? or should both be registered? public void onModelBake(ModelBakeEvent event) { event.modelRegistry.putObject(new ModelResourceLocation("mojo:block_maquette"), new BlockMaquetteSmartModel()); event.modelRegistry.putObject(new ModelResourceLocation("mojo:block_maquette", "inventory"), new BlockMaquetteSmartModel());
  3. Ok, I understand. My smart model must implement both ISmartModel and ISmartItemModel. ISmartItemModel adds one method #handleItemState. Giving it a try...
  4. What should the ModelResourceLocator look like? I have already registered an ISmartModel for my block with mrl=mojo:block_maquette. When I register the ISmartItemModel should the mrl be mojo:block_maquette#inventory? Also, and this is a question for TGG, MB04 seems to suggest that an ISmartItemModel is not necessary and all we have to do is the extra work during the init stage on the client side. Have I misunderstood?
  5. A line from the player's eyes to the cursor will pass through many air blocks. If you could somehow get a list of all of them, then you could choose the air block at the depth you want. A non-air hit will be the first non air block encountered along the line from the player's eyes to the maximum hit depth.
  6. Thanks Sir Ghost for getting back to me I've got a breakpoint in ItemModelMesher.getItemModel(). For reference here is the method: item is an ItemBlock as expected, but ibakedmodel is an IFlexibleBakedModel. Seems I want it to be and ISmartItemModel. In MB04 there is no mention of an ISmartItemModel, only the block's ISmartModel. What do I need to do so that this.getItemModel(item, this.getMetadata(stack)) returns an ISmartItemModel? Do I need an implementation of ISmartItemModel? If so, how do I register it in my ModelBakeEvent handler? Here is my ModelBakeEvent handler:
  7. Has anyone got advice? From someone who's been there, done that - things that I absolutely must do, things that I must never, never do? Distribution, versioning, bug tracking, logo, github, videos, Minecraft Forum, Adfly, CurseForge, beta testing, personal website, etc. (Hoping this is this the right place for a question like this)
  8. Can someone suggest where I can put a breakpoint to debug my problem? TGG, in MBE04, you suggest overriding #getActualState but this doesn't help me. It is not being called when the item model is being rendered.
  9. Raflex, onBlockPlacedBy is called after the block has been placed which is why DirtyDan can get his tile entity at pos. If you look at super#onBlockPlacedBy, it is an empty method. Is there another method which can be overridden to change how the block is set?
  10. I have a block with an ISmartModel that renders fine when placed. When in inventory, tossed, or in hand, it is being rendered as a block with a texture (with its .png in the textures folder). It is my understanding that if I want my smart model to render as an item, I have to do this (#initClientOnly): https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe04_block_smartblockmodel1/StartupClientOnly.java Here is my implementation: And here is the console: As you can see, the model is being registered in init and on the client side as instructed. I am assuming the json is set up properly because it is rendering with a texture in inventory, tossed, and in hand. The ISmartModel is rendering fine when placed. Is there something I have missed? Where can I insert printlns or breakpoints to debug this?
  11. Finally Got it working like this: Please contribute any suggestions to abbreviate the code
  12. Here is what I have based on http://greyminecraftcoder.blogspot.com.au/2014/12/block-models-texturing-quads-faces.html. I've screwed something up somewhere. It's close but not quite right. translation is t and scale is s. Any advice? private BakedQuad scaleAndTranslateQuad(BakedQuad q, Vec3i t, float s) { int[] v = q.getVertexData().clone(); int x = t.getX(); int y = t.getY(); int z = t.getZ(); switch (q.getFace()) { case UP: v[0] = transform(v[0], x, s); v[7] = transform(v[7], x, s); v[14] = transform(v[14], x, s); v[21] = transform(v[21], x, s); v[1] = transform(v[1], -z, s); v[8] = transform(v[8], -z, s); v[15] = transform(v[15], -z, s); v[22] = transform(v[22], -z, s); v[2] = transform(v[2], y, s); v[9] = transform(v[9], y, s); v[16] = transform(v[16], y, s); v[23] = transform(v[23], y, s); break; case DOWN: v[0] = transform(v[0], x, s); v[7] = transform(v[7], x, s); v[14] = transform(v[14], x, s); v[21] = transform(v[21], x, s); v[1] = transform(v[1], z, s); v[8] = transform(v[8], z, s); v[15] = transform(v[15], z, s); v[22] = transform(v[22], z, s); v[2] = transform(v[2], -y, s); v[9] = transform(v[9], -y, s); v[16] = transform(v[16], -y, s); v[23] = transform(v[23], -y, s); break; case EAST: v[0] = transform(v[0], z, s); v[7] = transform(v[7], z, s); v[14] = transform(v[14], z, s); v[21] = transform(v[21], z, s); v[1] = transform(v[1], y, s); v[8] = transform(v[8], y, s); v[15] = transform(v[15], y, s); v[22] = transform(v[22], y, s); v[2] = transform(v[2], x, s); v[9] = transform(v[9], x, s); v[16] = transform(v[16], x, s); v[23] = transform(v[23], x, s); break; case WEST: v[0] = transform(v[0], z, s); v[7] = transform(v[7], z, s); v[14] = transform(v[14], z, s); v[21] = transform(v[21], z, s); v[1] = transform(v[1], y, s); v[8] = transform(v[8], y, s); v[15] = transform(v[15], y, s); v[22] = transform(v[22], y, s); v[2] = transform(v[2], -x, s); v[9] = transform(v[9], -x, s); v[16] = transform(v[16], -x, s); v[23] = transform(v[23], -x, s); break; case NORTH: v[0] = transform(v[0], -x, s); v[7] = transform(v[7], -x, s); v[14] = transform(v[14], -x, s); v[21] = transform(v[21], -x, s); v[1] = transform(v[1], y, s); v[8] = transform(v[8], y, s); v[15] = transform(v[15], y, s); v[22] = transform(v[22], y, s); v[2] = transform(v[2], -z, s); v[9] = transform(v[9], -z, s); v[16] = transform(v[16], -z, s); v[23] = transform(v[23], -z, s); break; case SOUTH: // Case where quad coordinates are aligned with world coordinates v[0] = transform(v[0], x, s); v[7] = transform(v[7], x, s); v[14] = transform(v[14], x, s); v[21] = transform(v[21], x, s); v[1] = transform(v[1], y, s); v[8] = transform(v[8], y, s); v[15] = transform(v[15], y, s); v[22] = transform(v[22], y, s); v[2] = transform(v[2], z, s); v[9] = transform(v[9], z, s); v[16] = transform(v[16], z, s); v[23] = transform(v[23], z, s); break; default: break; } return new BakedQuad(v, q.getTintIndex(), q.getFace()); } private int transform(int i, int t, float s) { float f = Float.intBitsToFloat(i); f = (f + t) * s; return Float.floatToRawIntBits(f); } Edit: A model generated from two stone bricks slabs:
  13. I am trying to create a model from another model at runtime. I need to translate and scale BakedQuads. Is there a method somewhere that does this, or do I have to manipulate the vertex data directly?
  14. Thanks! @Override public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (willHarvest) { // Delay deletion of the block until after getDrops return true; } if (player.capabilities.isCreativeMode) { harvestBlock(world, player, pos, this.getDefaultState(), null); } return super.removedByPlayer(world, pos, player, willHarvest); }
  15. My mod is on GitHub, repository is mo-jo. The Block is named BlockSaved. Please have a look if you are interested. But this is really a generic problem. How do you make a block, any block, drop in creative?
  16. Thanks for the reply Not sure what you mean by " item id of the item you broke". I am breaking a Block. My understanding is that once it is in the player's inventory it is an ItemBlock. Method onBlockBreak is on which class?
  17. I have a block which replaces a selection of blocks and stores the path to a file with the saved selections on its tile entity. In survival, the player picks up the block after breaking and puts it in his inventory to place it at some other time and place and restore the original blocks from file. I would like the same behavior in creative
  18. How can I make my block provide drops when broken in creative mode?
  19. Opposite corners are enough to define a quad which is axis-aligned. BakedQuad's constructor is public. An example of constructing BakedQuads is here: https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe15_item_smartitemmodel/ChessboardSmartItemModel.java Not sure why TGG doesn't use FaceBakery. Maybe because #makeBakedQuad wants a BlockPartRotation and BlockPartFace, which in turn wants a BlockFaceUV ...
  20. I have a block with a ISmartModel which renders fine when placed. When I break the block, the drop does not render, nor does it render when in the player's inventory. Is there a way I can render with the same ISmartModel in these cases?
  21. I am building a BakedQuad and need a texture.
  22. Is there some convenient way to get a TextureAtlasSprite from an IBlockState? state.toString()=minecraft:diamond_block needs to be minecraft:blocks/diamond_block TextureAtlasSprite#getAtlasSprite(String) seems to be the only way to get a sprite
  23. I have tried returning true, false, and super.removedByPlayer when world.isRemote, all with no effect (still two drops).
  24. Hi. I posted a couple of days ago about delaying the deletion of a block and its tile entity until after the drops were picked up by the player. Diesieben pointed me in the right direction (thanks). The solution has created a small problem for me: I am getting two drops when I break the block. When I comment out removedByPlayer, I get only one. Printlns indicate removedByPlayer is being called once on the server side with willHarvest = true, and once on the client side with willHarvest = false. Here is my getDrops, removedByPlayer, and harvestBlock: Here is my console: [10:30:53] [Client thread/INFO] [sTDOUT]: [org.snowyegret.mojo.block.BlockSaved:removedByPlayer:132]: world=net.minecraft.client.multiplayer.WorldClient@77e55368 [10:30:53] [Client thread/INFO] [sTDOUT]: [org.snowyegret.mojo.block.BlockSaved:removedByPlayer:133]: willHarvest=false [10:30:53] [server thread/INFO] [sTDOUT]: [org.snowyegret.mojo.block.BlockSaved:removedByPlayer:132]: world=net.minecraft.world.WorldServer@6caed19b [10:30:53] [server thread/INFO] [sTDOUT]: [org.snowyegret.mojo.block.BlockSaved:removedByPlayer:133]: willHarvest=true For reference, here are BlockFlowerPot's overrides of the three methods:
×
×
  • Create New...

Important Information

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