Jump to content

Kipama

Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Kipama's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, once again I have run out of ideas how to do this: Im working on a railblock whos RailShape is always ascending, to implement a Rail jump. The logic to make minecarts actually jump works fine, and when placed the Rail is always ascending away from the player. However, any time a rail is placed in front of or behind it, it updates and converts into a straight rail. To solve this, I experimented with the following functions, but without success: updateState() neighborChanged() getRailDirection() updateShape() and updateDir(). Nothing I did with any of these functions stopped the rail from actually changing shape. Does anyone know what I have to do, or at least what part of the code is responsible for this? If I need to provide more info or my existing code, please let me know.
  2. First off, I know should probably be able to debug this on my own, but this is my first mod, and I couldn't figure it out for multiple days now. What I'm trying to do, is to modify the default minecart by replacing it with a slightly different version, but I'm stuck 1 step before that, that being "cloning" the minecart as a separate Entity/Item. Here you can see a GitHub gist of all relevant files: https://gist.github.com/Kipama/cd39127e8891715a3006fa990ca7ff14 If there are files missing or access isn't working as intended, please let me know! In the Gist you can find the following files: -CustomMinecartEntity.java: This file extends AbstractMinecart and is a clone of the vanilla minecart entity. I know I should override the minecart entity directly, but as this should work rn, I didn't change it yet. -CustomMinecartRenderer.java: Basically vanilla MinecartRenderer with a Custom slapped on it, extends MinecraftRenderer. -ModEntities.java: This is where the new Entity gets added to the deferred register ENTITY_TYPES. -ModernMinecarts.java: The main mod file. Relevant part is at the bottom, where I try to use onClientSetup to register the new Entity using EntityRenderers.register(). That last part is where my problem begins. When I try to register the new entity using EntityRenderers.register(ModEntities.CUSTOM_MINECART_ENTITY.get(), CustomMinecartRenderer::new); I get a syntax Error saying the provided and required types don't match. These are the required and provided types: ModEntities.CUSTOM_MINECART_ENTITY.get(): Required: EntityType<? extends T> Provided:EntityType<CustomMinecartEntity> CustomMinecartRenderer::new: Required: EntityRendererProvider<T> Provided:<method reference So far I looked at 2 different Git repositories implementing custom entities, but haven't been able to figure out what I'm doing wrong. Any answers, suggestions and ridicules appreciated.
  3. FML... I did manage to find my error though! For anyone finding this in the future, I didn't pass use() in my block the right parameters. They should be (BlockState state, Level level, BlockPos pos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult).
  4. Preferably on github. Here is a link to my repository. The linked branch should contain everything you might need. The relevant classes are 1. src/main/java/net/lordkipama/modernminecarts/event/ModEvents.java This is where I implemented PlayerInteractEvent.RightClickBlock 2. src/main/java/net/lordkipama/modernminecarts/block/Custom/SwiftPoweredRailBlock.java There you can also so where targetedBlock comes from. It is simply a variable for instance.level.getBlockState(pos).getBlock(); Are there any benefits to using getHitVec() over what I did? Apologies for not including that in the snipped. Additionally, I added the result DENY to useItem(), although this doesn't impact my problem, as useItem should do nothing in this case. Now to my current issue: How to reproduce: Start Minecraft, place Swift Powered Rail, rightClick with Honeycomb in hand. Expected Behaviour: For SwiftPoweredRailblock.use() to trigger, therefore replacing the Block with a Waxed Exposed Swift Rail. Actual Behaviour: Nothing happens, the use function never gets called. I hope reproducing the issue works, and that I followed your advice sufficiently this time. If not, please tell me what to improve, I get that its tiresome to respond to people who don't seem to listen, but I'm genuinely trying to improve.
  5. First off, thanks for taking the time to reply, your comments already helped me a lot! I do however still have a few problems with actually triggering the use() function in my block. I tried the following: @SubscribeEvent public static void PlayerInteractEvent(PlayerInteractEvent.RightClickBlock event) { if(event.getItemStack().getItem() == Items.HONEYCOMB) { if(targetedBlock.equals(ModBlocks.SWIFT_POWERED_RAIL.get())){ event.setResult(Event.Result.ALLOW); event.setUseBlock(event.getResult()); } } } I tried to set the result to allow, and triggered setUseBlock with the Allow result. I also tried this, which is probably really stupid but I tried it anyways: instance.level.getBlockState(pos).getBlock().use(blockstate, level, pos, player, event.getHand(),event.getHitVec()); Any advice on how I can actually trigger the use() function in my block?
  6. I'm trying to add new copper blocks and am working on waxing them right now. As I couldn't figure out how to add my new items to the BiMap in the Vannilla Honeycomb class, I'm now using PlayerInteractEvent.RightClickBlock, to: 1. Check if the player is holding honeycomb 2. Check if the clicked block is a new copper block 3. Replace new copper block with waxed version. Step 1 and 2 work fine, but I can't get step 3 to work. Right now I'm trying to use Level.setBlock(), but as the event is static, I can only use Minecraft.getInstance().Level.setBlock(), where the change is only made for a fraction of a second. If anyone has an idea how to fix this, or if this is a different problem entirely, any help is appreciated.
  7. Thanks for putting me on the right track! I was able to use the RightClickBlock event to check for the held item being honeycomb already. However, I have 2 remaining issues: 1. Checking the clicked block. I know I have to look up the block using the pos provided in the event, but don't know how to do that yet. 2. If the block is waxable, how to actually replace it with the waxed version. I hope you'll be able to help me with this, and sorry once again for these basic questions.
  8. Before I start explaining my situation, I am aware of similar questions on the forum, but so far haven't found a solution. I am working on a mod that adds new copper blocks, and struggle with making them waxable. (New blocks exist, age, and have waxed counterparts already.) Waxable blocks, and their waxed counterparts, are stored in an ImmutableBiMap in the HoneycombItem class, as a static variable. So far I tried creating a new honeycomb item that extends the original, and then registering it using the same name and a separate DeferredRegister with "minecraft" as modid, but that doesn't work, as I can't modify a static variable in retrospect. I also looked into mixIn and bytecode manipulation, but I'm hoping to find an easier solution. If additional info is needed, I can gladly provide that, but I dont think the code of my failed attempt would be useful here. Also apologies if this is a stupid question, while I'm not new to Java or programming in general, I am new to modding minecraft. Edit: Forgot to add, im working with Minecraft version 1.20
×
×
  • Create New...

Important Information

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