Jump to content

Spacejet

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by Spacejet

  1. So basicaly what the title says, is there a way to control and limit a SoundEvent to a specific duration without changing the duration of the sound file itself. For example, if I have a 5 sec long sound and I want it to be played for 1, 2, and 5 seconds based on criteria, how would I go about doing that? P.s: If you would like to know my specific case, just ask and I'll provide my reasons and code.
  2. It's a nice idea, but how would I go about doing it? The white key in which I would need to check if a black key is being hovered does not have access to the black key, so I can't do that For reference: Button class Screen class:
  3. So, generally I have been using this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; for setting any of my custom buttons' hover status, but I noticed this won't really work if I have overlapping buttons. In my specific case, this is the issue: As you can see, the white keys extend under the black keys, meaning that the aforementioned method of setting a button's isHovered variable would not work, as it would return true for the first key (C) even if its the corresponding black key (C#) that is hovered, as long as it is within the width of the first key The green is the area that would return true using the method I mentioned above for the white key, and red for the black, but the blue area esults in both the white and black keys getting their isHovered variable set to true, while the desired behaviour is to only have the black key's isHovered value to be true, and the white key's false. While I know I can use 2 different checks to check the white key in this manner, green first check and yellow second: I was wondering if there is a better method to do this, without having to hardcode the checks for every single key, as all have different indentations regarding black keys. Thanks for taking the time to read this, and I am looking forward to see what you guys suggest.
  4. It worked! seems like the mappings being old was precisely the problem thanks a lot for your help @Animefan8888 and @me1. Marking this problem as solved
  5. Ok I'll try that and get back @me1 and @Animefan8888
  6. I am using Eclipse 2020-03 with JDK 8u241. I followed the instructions in the README.txt file that forge came with. I have, and the method onBlockActivated is not present in the class and how exactly would I go about doing that? do I do a "gradlew clean" before repeating the setup process?
  7. The error: The method onBlockActivated(BlockState, World, BlockPos, PlayerEntity, Hand, BlockRayTraceResult) of type AdvancedNoteBlock must override or implement a supertype method The updated code: package com.spacejet.more_music.block; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; public class AdvancedNoteBlock extends Block { public AdvancedNoteBlock(Properties properties) { super(properties); } @Override public boolean hasTileEntity(BlockState state) { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return super.createTileEntity(state, world); } @Override public ActionResultType onBlockActivated(final BlockState state, final World worldIn, final BlockPos pos, final PlayerEntity player, final Hand handIn, final BlockRayTraceResult hit) { return ActionResultType.SUCCESS; } } So, as you can see, there is apparently no method named onBlockActivated in the minecraft Block class...
  8. For the block itself: package com.spacejet.more_music.block; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; public class AdvancedNoteBlock extends Block { public AdvancedNoteBlock(Properties properties) { super(properties); } @Override public boolean hasTileEntity(BlockState state) { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return super.createTileEntity(state, world); } }
  9. the forge documentation says to use "onBlockActivated", but if I try putting that into my code, it doesn't show up as a method to override. I have been using this resource by @Cadiboo to guide me through the process, and as you can see here, the method "onBlockActivated" is used here as well. Any help on this matter is appreciated.
  10. As you can see yourself these are static fields, meaning they are the same for all your buttons. Why are you setting a static field to a thing passed in a constructor? And that doesn't even matter because by the time your resourcelocation resolver code gets executed state is guaranteed to be 0. ? oops... did not pay attention to that... I don't think so. What's the problem though? No problem, just asking drawTexturedModalRect expects a 256x256 texture, not a 16x16. You can use the overload which takes uv coordinates instead. Of course you would need to override GuiButton#drawButton for that to work. I did also try using a 256 by 256 image, but that did not work either. But I'll just override drawButton().. How are these two things connected? There is a GuiScreen#drawDefaultBackground method which makes the background darker. You are not calling it. Oh. I thought this was being called in the drawContainerBackhround so it was the thing... nice to know! Don’t use (modid+”:”+path)! Use the overload that accepts a resource domain and a path (modid, path) I considered doing that as it seemed like the better way to get the resource location. Will change that. Thanks!
  11. I wanted to have a different kind of button with different states and different images as the texture depending on the state. So, I decided to extend GuiButtonImage() and create class that just checks and sets the state and manages the texture. It is kind of unnecessary but I am going to use the same button with the same textures over and over again so decides to make the class. Also, I think I might have to override drawButton() anyways to update the textures on my button depending on the state. Problems: 1) Texture does not load properly. My Button class- My Gui Class- The image does not fit in the button - only a part of it or none is visible on the button. 2) I am not changing the texture based on state yet but is there any way to do that without overriding drawButton()?? Also, my background is not getting the dark fog effect even though I have GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); in @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(GUI_TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); } Any ideas why? Textures: (Button textures are 16 x 16) Gui: The circled thing is the button. It is not positioned, but as you can see, the texture is not fitting the button... Any help is greatly appreciated!
  12. I'll surely look at it. Thanks a lot to everybody who has helped me
  13. Where are you instantiating(calling the constructor) for them This is my Mod Blocks class which has the list I am adding the blocks into The constructors are called in the class above as you can see..
  14. Yes. I am just adding the blocks extend blockbase to a list and then that list is passed on to the onBlockRegister() event BlockBase: RegistryHandler:
  15. Oh then it's fine as I am indeed using registryevents.. phew.. scared me real good.
  16. I am not sure but you can override Block#getStateForPlacement and return the blockstate with the correct value Ok will try that.....sounds like it will work (hopefully) IBlockState#getValue Oh. That sounds bad. That sound directly accessing the registry levels of bad. And potentially IHasModel levels of bad too I regret writing that as I am not on my computer and cannot check to make sure what I wrote was correct as that is what I thought I was doing in blockbase..... what should I do if I was doing the bad thing?
  17. @V0idWa1k3r the answer to your questions : active is static because I was trying to set it in my block class as ACTIVATED was a part of my block class. I just forgot to change it back. Will do that. I don't really know why I used boxed values when I could have simply used 'true' or 'false' ?. TileEntity already implements ICapabilityProvider I did not know that. Nice to know! The same way you would do it in your block class. You have the world(TileEntity.world) and the position(TileEntity.pos). Get the blockstate from the world at position and change the value of the property in the same way you would for your block Is it with setBlockState() cause now I remember that I did not try that. Thanks a ton. BlockBase is an antipattern. There is already a BlockBase, it's called Block.  I call my Registry Handler and register all my blocks in this class. This will always return 1. Serialize the value of the property, not it's property. I just got to know about an hour ago that .contains() will search every possible output, not the selected. What should I use instead of that?? How do I get the value of the property in the first place?? getBlockState()?? But that returns a BlockStateContainer. EDIT: I want to get its boolean value to set active equal to, but getBlockState() returns the state, not value! Right? This should never happen in onUpdate, and if it does some mod severely messes up and you should crash the game. K. Will crash the game. Thanks a lot for all those improvement tips and answers to some of my questions. P.S: do you know why ACTIVATED returns false when block is first placed into the world? Set default state sets its default state to true!
  18. using Forge 1.12.2 So I have a couple of problems to do with PropertyBool set on a block with a TileEntity. First problem is that the PropertyBool is not setting to it's default state on block placement, set in setDefaultState() this.setDefaultState(this.blockState.getBaseState().withProperty(ACTIVATED, Boolean.valueOf(true))); ACTIVATED is always false on placement, but, after a quick re-log (I don't restart minecraft, just the world) it changes to true. Second Problem is that I don't know how to get and set the value of ACTIVATED from other classes, specifically in this case, the TileEntity class. I have tried everything, searched online, read the documentation but failed to find a mention on how to do it. Full Block class: Full TileEntity class (note- I am using the CJCore Library in this mod) NOTE- I have not set the value of active(In TE class) as I need to set it equal to ACTIVATED(PropBool in Block class), which I cannot find a way to do Thanks for any help! EDIT - After Reading I moved on from using ITileEntityProvider to overriding hasTileEntity() and createTileEntity()
  19. and i did it! it is literally 5 seconds after i posted the last comment and i did it! I replaced with public static final PropertyDirection FACING = BlockDirectional.FACING; and added else if (facing.equals(EnumFacing.DOWN)) { return true; { to right below else if (facing != EnumFacing.UP && facing != EnumFacing.DOWN) { return !isExceptBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID; } here is the whole code for anyone in trouble like me i have not set the correct values for axisalignedbb yet, but you wont need it anyway. the rotation was possible due to draco18s. Thanks a lot. in a different thread, he said so i went to blockdispenser.java and got BlockDirectional.FACING; Thanks a lot everybody. This means a lot to me!
  20. hi. so i looked at the console and it says: Caused by: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecraft:block/lantern with loader VanillaLoader.INSTANCE, skipping so i checked my blockstates file and found that i had not put the modid. actually i had put the modid there, but then the next day i replaced all of my lantern's files from local history, so it is now working . I am trying things to make my block placeable under blocks, unlike torches. will update real soon
  21. it does not matter if you have cubes with same name, feom my ecperience. I actually have not looked at the console but i was also thinking that it must be something with the model. I thinkthe game is searching for the model in minecraft's models folder rather than mine. The items could be showing up because the parent is set to my model. I'll change the cubes and check the console and report back.
×
×
  • Create New...

Important Information

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