Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/10/17 in all areas

  1. Override TileEntity::getRenderBoundingBox to return appropriate size of the rendered object. If it's about rendering, you are not marking the TE as updated for rendering. I think you should call World#markAndNotifyBlock. (The flag parameter is explained on World#setBlockState)
    1 point
  2. To send data to the server you would have to create a custom packet (IMessage) along with a handler (IMessageHandler) and a NetworkWrapper for your mod using NetworkRegistry.INSTANCE.newSimpleChannel. All it'd have to do is contain the relevant data (x,y,z) and on the handler get the tile entity at that location and update your data. Hope this helps in some way
    1 point
  3. Post the code you tried and the crash(es) that resulted. It can't really be done in a much easier way. The standard vanilla system bakes all models at start-up, so if you want to do something other than that, you need to alter the model loading and baking steps yourself. But that said, it really isn't as complicated as it might seem. For a simple system (i.e. one that would be simple enough to render using ordinary JSON blockstates), you can do it all within one object which implements ICustomModelLoader, IModel, and IBakedModel: Register your object with ModelLoaderRegistry.registerLoader. accepts should check for your block (probably by checking that the ResourceLocation path contains your block's registry name). loadModel should load all the models you will need from ModelLoaderRegistry.getModel (or one of the variant methods like getModelOrLogError) by passing the ResourceLocations of the json files, and store those in fields to use later. Then it can return itself. bake should do nothing except store the parameters as fields to use later, and return itself. getQuads should do the actual baking as needed. From the IBlockState parameter, decide which model(s) are needed for the block. Use your previously-stored IModel fields, call bake (using your previously-stored parameters) and then getQuads and return the result. You should also have a cache to store models which have already been created. In simple cases it can just be a Map<IBlockState, List<BakedQuad>>. The first step in your getQuads should be to check whether the state has a cached result (and return it if so), and the last step should be to add the result to the cache if it's not already present. For simple cases, a lot of this can be done automatically and the same for every case (rather than needing to write it individually for every block). I have an abstract class which I use for all the stuff that's the same every time here. Then I only have to write loadModel and getQuads individually, which is not really any more complicated than writing a big messy blockstates file.
    1 point
  4. It's usually a bad idea to set the base value of health. Is there a reason you can't do this with multiplier attribute modifier? If you can't to it, setting the event priority to LOWEST might work. It marks the event subscribing method to get called on the last pass.
    1 point
  5. It would not make it incompatible with other mods. Just make sure to "save" GL state before you start rendering with shaders to restore it after. First, create custom shader helper class, that sets all uniforms, uploads shader, binds, etc... Now, if you want your shader to be customizable with resource packs, implement and register IResourceManagerReloadListener, in which you load/reload shaders. Otherwise, just upload it in post init. Now, when your TESR is called, bind your shader, render OBJ model and then unbind the shader. Seems easy? It isn't. For the rendering part, as i said previously, you can either change how you upload things to shader or how you shader reads things. The first option is easier. Just create all necessary classes using modern GL functions - Mesh, Matrix Handler, etc... For the mesh, it is recommended to use VAO with indexed position VBO and non-indexed texture & normal VBOs, because that's how OBJ model is encoded. Now you just have to write your own OBJ reader and compiler (which compiles it into a mesh). There are plenty of tutorials online on how to do this. Read, compile and upload your model into mesh either in resource reload listener or post init and render this mesh in TESR. Now just make sure that you inform users of your mod that at least GL3 support is required (all modern graphics cards support it, so no much worries). Note: Rendering performance can be improved very much, by binding shader once... But i'll let you think on how that can be done .
    1 point
  6. public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(par1ItemStack.stackTagCompound.getIteger("onItemRightClickDelay") == 0) { par1ItemStack.stackTagCompound.setInteger("onItemRightClickDelay", 5); //do stuff } } Then you can either tick that value down in onUpdate or you can wait for the onItemStoppedUsing (sp?) and set it back to zero
    1 point
×
×
  • Create New...

Important Information

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