Jump to content

Codasylph

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by Codasylph

  1. OptiFine doesn't like two of my TESRs, as explained in this post: https://www.minecraftforge.net/forum/topic/71841-1122-optifine-causes-crash-when-rendering-obj-in-tesr/. Since I'm becoming increasingly dubious that there's a good answer for dealing with that issue I'd like to just change the way I render things if OptiFine is loaded. This presents an issue because apparently OptiFine isn't actually loaded by Forge so something like Loader.isModLoaded("OptiFine") doesn't tell me anything. So I ask, is there any reasonable way for my mod to tell whether OptiFine is loaded? And yes, It has already occurred to me that I can just have a config option asking the user if optifine is loaded (and I will be doing that if I can't do anything else), but seeing as if the user happens not to look at the configs and has optifine it will crash their world, i'd like a more aggressive solution.
  2. Well crap. There is one. It's called onInteractionForEntity. Welp, I need to go change some code..
  3. This is actually code in the Entity, not the Item. If you have a new custom animal that you want your custom item to be able to put into "breeding mode" you would override isBreedingItem in your entity's class. If you want a custom item to work on preexisting entities you would have to hook into the EntityInteract event.
  4. I have two TESRs in my mod where I use an IBakedModel to render a .obj. In both cases I do this because the model isn't static, in one case the .obj is several gears which rotate and in the other it is fluid which is only rendered when there is actually an item containing fluid in the TE. Apparently OptiFine does not like this, and when Minecraft attempts to render these with OptiFine installed it produces an IndexOutOfBoundsException and crashes. My question is, what can I do about this? My current plan is to put in some code that checks if OptiFine is loaded and do something else if it is (like rendering an item model instead of an .obj for the gears, and rendering a cube for the fluid, which won't be as pretty but also won't crash!) but I thought before using what I consider to be an imperfect solution I'd ask on here if there is just some other more OptiFine friendly way of rendering the a .obj in a TESR. For reference here is the crash report: https://paste.dimdev.org/isomagozof.cs and here is the code for one of the TESRs: https://paste.dimdev.org/fejagorose.java
  5. But.. but how? ? So, for anyone who stumbles across this thread in the future, I actually figured out how shortly after I made this post, proving that if i'd spent a few more minutes with google I would never have needed to post at all. If you use TextComponentTransation instead of TextComponentString it does the translating on the correct side. example: player.sendMessage(new TextComponentTranslation("text.altar_created.message")); No I18n or anything
  6. In my mod there are a number of times when a message is sent to the player's chat to say something like "Good job you did this thing, now you can do this other thing!" or "That didn't quite work, you should make sure all the blocks are in the right place." I want this messages to able to be changed via the mod's lang files so that someone playing the game in spanish gets a message in spanish, english gets english, etc. Currently I do this by calling something like this on the server side: player.sendMessage(new TextComponentString(DemConstants.ALTAR_CREATED)); and the variable ALTAR_CREATED is defined like this: public static final String ALTAR_CREATED = I18n.format("text.altar_created.message"); and the string "text.altar_created.message" is in my .lang file as whatever I actually want it to be. I currently only have a US English version, but I'm trying to plan ahead. This all works just dandy in single player mode, but when I attempt to run it on a dedicated server I get a NoClassDef error because I18n is client side only. To my knowledge EntityPlayer#SendMessage is *supposed* to be called on the server side. So, clearly what I'm doing is wrong. What should I be doing?
  7. Yeah. I can't think of one either, or I would have just looked at how they did it. The only thing I can think is that it used to be possible to render a TESR in inventory but that was back in 1.7.10 and I don't think its possible anymore. Also i didn't really want to make it a block or a tile entity for something that's actually an item.
  8. This question might be a bit easier to answer if we knew what kind of data you were trying to save, for what purpose. For example, are you trying to save data concerning a tile entity? item? or the player?
  9. I would recommend using nbt data rather than meta data. Meta data is just an integer value between 0 and 15 (inclusive), and obviously you could do all sorts of maths to that to get the burn times you want, but ultimately your item could only have 16 possible states (burn times). With an NBTTagCompound you just store what ever value like and name it say "burntime" when the itemstack is created by your machine. Now, for the function to determine the burn time of an individual container you will need to make an event handler and hook into FurnaceFuelBurnTimeEvent. This is fired when the furnace tries to determine the fuel value of an ItemStack and is where you want to look for the value you stored in nbt under the name "burntime." For the second half of your question, getting it not to remove the item its burning, I would look at how vanilla minecraft handles using buckets of lava as fuel.
  10. I have an item in my mod that can be associated with certain types of mobs and I'm wondering if there is a way to render the entity's model as part of the item. I know you can render an entity model as part of a TESR because that's what the vanilla enchanting table does, but I don't believe the book (which is the model part) is rendered for the ItemBlock, and anyway I would prefer an actual item and not some sort of weird hack, but i'm open to suggestions. I would prefer to use the entity's model in some way because I would like it to work with entities from other mods if they extend EntityAnimal.
  11. Thank you! I actually was returning SUCCESS every time the item "did something", but apparently only on the server side. -_-;
  12. I have a multi purpose tool in my mod (i.e. it does different things depending on whether you click in the air with it, or on a block, what kind of block, etc.) I'm wondering if there is any simple, reasonable way to prevent my code in Item#onItemRightClick from firing if Item#onItemUse already has. I know from testing that onItemUse fires first, and doesn't fire if the user is clicking on air as opposed to a block (which nixes my brilliant plan of putting all the functionality in onItemUse.) I'm mostly just trying to prevent chat spam for the user because onItemRightClick sends a chat message to the client with information about the surroundings, and I think this will become irritating if the user is trying to use the tool to do something like adjust settings on one of my blocks which may involve a lot of clicking.
  13. The Default baked format thing fixed it. As for the translating back thing, literally just because i've gotten this idea in my head that when you do openGL things you have to undo them. There's no actual good reason. Thanks again for the help!
  14. Ok, one more little thing. I don't crash anymore, and it renders the obj properly. But it renders very very dark, almost black. I can tell its actually rendering the texture, just super dark. I've tried using the RenderHelper#enableStandardItemLighting and a few other lighting things within GlStateManager but nothing seems to make the slightest difference. I saw one other post with a similar issue here, but it had no replies. For reference here is my updated code just for rendering the obj (since I wasn't actually binding a texture or anything in the previously posted code): private void renderReagent(CauldronTile te, float red, float green, float blue) { GlStateManager.pushMatrix(); bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // GlStateManager.enableBlend(); // GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GlStateManager.color(red, green, blue, .2f); GlStateManager.enableLight(1); GlStateManager.translate(-te.getPos().getX(), -te.getPos().getY()+1.0F, -te.getPos().getZ()+1.0F); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel( getWorld(), getBakedModel(), getWorld().getBlockState(te.getPos()), te.getPos(), Tessellator.getInstance().getBuffer(), true); tessellator.draw(); // GlStateManager.disableBlend(); GlStateManager.translate(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ()); GlStateManager.popMatrix(); }
  15. weird, the example I saw did not do that. But it was older than 1.12, so that could be it. Thank you!
  16. I have TESR that I need to render an obj with, (there will be animation and the obj in question is not always rendered in every circumstance, so yes, it really does need to be a tesr). Unfortunately, when it tries to load the model it crashes with this error: java.lang.RuntimeException: java.io.FileNotFoundException: demesne:models/item/retort_liquid. I don't really understand why it would event be looking for an item model, but I added the model to models/item as well as models/block and I still get the exact same error. For reference this is my TESR code: and the crash report can be found here: https://pastebin.com/jpgxfm6m
  17. I can't believe I didn't think of that. Thank you I actually looked at that first, but it basically just sends a packet to clients tracking the entity to say "spawn particles here." The client still doesn't "know" that the entity is having particles spawned because of an effect, just to spawn them and nothing about what was already being rendered is changed so that didn't really help me. This helps! Thanks a bunch!!
  18. In my mod I intend to have several potions that alter the way entities are rendered when active. The issue I have is that at the moment the rendering changes only take place if the player is the entity under the effect of the potion. If another player, or any other entity is under the effects they are rendered as they normally would be. I know that the problem is that the client doesn't "know" that other entities are under the effect of a potion. But I'm not sure how to solve this. I assume I need to send a packet but I'm a little reluctant to do anything that involves sending a packet every tick and anyway I not quite sure what info to send. It isn't as though I can send the entity object in the packet and i'm not sure how I would get a hold of the specific entity object on the client to set it to having an active potion effect. For reference this is my code for altering an effected entity's rendering: @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Pre<EntityLiving> event) { if(event.getEntity().isPotionActive(DemEffects.SHRINK)) { GL11.glPushMatrix(); GL11.glTranslated(event.getX(), event.getY(), event.getZ()); GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glTranslated(-event.getX(), -event.getY(), -event.getZ()); } } @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Post<EntityLiving> event) { if(event.getEntity().isPotionActive(DemEffects.SHRINK)) { GL11.glPopMatrix(); } }
  19. Umm... I edited to add to it? I'm sorry I guess? No matter. I ended up doing what i said I probably needed to do and extended AbstractBrewingRecipe and overrode isInput so the stack comparison is nbt and meta data sensitive (in case some poor person runs into the same problem I do and finds this). Soo.. this can can probably be closed.
  20. My mod has several custom potion types and uses BrewingRecipeRegistry to add in recipes to make them in the Brewing Stand. Unfortunately the recipes are not working correctly. When I make them they seem to take in ANY ItemStack with Items.POTIONITEM as the item and return whatever potion matches the ingredient. For example if I brew something with a feather as the ingredient I get a flight potion regardless of whether the input item is a levitation potion (like its supposed to be) or some other random potion like a vanilla Potion of Speed. This is my brewing recipe handler: The only explanation I could come up with was that BrewingRecipeRegistry#getOutput is not metadata sensitive. So a dug through a bit more code and found that if your IBrewingRecipe object is an instance of BrewingRecipe (like it would be if you used the function I used) then it is in fact not metadata sensitive. Soo... I guess my question is, how should I fix this? Do I need to make my own class that implements IBrewingRecipe? or is there anything else I can do? Edit: its nbt not meta data that is the issue.
  21. Doh! No i had not. That would be an issue. Thanks for the second set of eyes/brain cells.
  22. I have a custom Potion that I am trying to register a PotionType for, but when i get to the code to register it, it crashes with a null point exception. This is my code to register it @SubscribeEvent public static void registerBrewing(RegistryEvent.Register<PotionType> event) { event.getRegistry().register(DemPotion.flightType); } I have also tried @SubscribeEvent public static void registerBrewing(RegistryEvent.Register<PotionType> event) { event.getRegistry().register(new PotionType("flight", new PotionEffect(DemEffects.FLIGHT, 100))); } both result in the same error. flightType is declared like this in my Potion class. public static final PotionType flightType = new PotionType(new PotionEffect(DemEffects.FLIGHT, 100)); https://pastebin.com/3FHQTgg8 The Potion class is fine, and i can apply it as a potion effect through means other than a potion item and it works as intended.
  23. That actually fixed, I had to also remove the "textures/" from the beginning as well. I could have sworn I had tried that, but I may not have tried both changes together. Any idea why for the texture atlas you need the short form (e.g. "demesne:particles/su" but when you bind a texture to the texture manager for a gui it has to be the longer version with the file extension? Either way, thank you very much!
  24. I'm going to preface this by saying that, no, I have never used TextureAtlasSprites. I'm trying to make a custom particle and through my reading of the vanilla Particle code and looking at other people's projects, I've gotten as far as, that I need a TextureAtlasSprite, and that I ought to register it to the TextureMap in TextureStitchEvent.Pre (or at least that's what all the code I've seen is doing.) However, when I do all this and try to retrieve my sprite from the TextureMap I get the missing texture texture, and if I try to use it more directly I get null. My event handler registering the sprite public class DemTextureHandler { public static final DemTextureHandler textures = new DemTextureHandler(); private DemTextureHandler(){} public static TextureAtlasSprite su; @SubscribeEvent public void onTextureStitch(TextureStitchEvent.Pre event) { ResourceLocation resource = new ResourceLocation("demesne:textures/particles/su.png"); TextureAtlasSprite su = event.getMap().registerSprite(resource); System.out.println("Debug: "+su.toString()); System.out.println("Debug: "+event.getMap().getAtlasSprite(resource.toString())); } } Note: my debug statements here give me the following in the log: [08:26:29] [Client thread/INFO] [sTDOUT]: [me.codasylph.demesne.handlers.DemTextureHandler:onTextureStitch:25]: Debug: TextureAtlasSprite{name='demesne:textures/particles/su.png', frameCount=0, rotated=false, x=0, y=0, height=0, width=0, u0=0.0, u1=0.0, v0=0.0, v1=0.0} [08:26:29] [Client thread/INFO] [sTDOUT]: [me.codasylph.demesne.handlers.DemTextureHandler:onTextureStitch:26]: Debug: TextureAtlasSprite{name='missingno', frameCount=1, rotated=false, x=0, y=0, height=16, width=16, u0=0.0, u1=0.0, v0=0.0, v1=0.0} my particle's constructor public SuParticle(World world, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed) { super(world, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed); // this.setParticleTexture(DemTextureHandler.textures.su); this.setParticleTexture(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("demesne:textures/particles/su.png")); System.out.println("Debug: "+this.particleTexture.toString()); } As you can see from commented out code I have also tried using the sprite that gets returned by TextureMap#registerSprite but this ends up being null and when my debug statement is called I crash with a null pointer exception, which kind of makes sense since it clearly isn't registering properly given that it can't find the texture in the map even immediately after I register it.. So clearly I'm doing something very wrong. I have checked the spelling of my path what feels like a 100 times and I for certain have a folder in my textures folder named particles that has a su.png in it. If anyone knows what is happening here and how to fix it, or some better way to do this, please help. edit: Added version tag to subject line. Someday I will remember to do this the first time.
×
×
  • Create New...

Important Information

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