-
Posts
28 -
Joined
-
Last visited
Everything posted by bigMojitos
-
I tried to do it by running it in debug mode and rebuilding the mod after I edit a value in my Mesh Definition Method but it doesn't work until I actually fully restart the program. I understand this is probably a dumb question but I'm just wondering if anything remotely like this is possible with forge.
-
Hi, I'm kind of new to Forge and 3D Rendering in Java and have some questions regarding what a render layer does. If anyone could give any answer no matter the length it would be greatly appreciated! 1. Are you able to have multiple RenderLayers on one mob for which each have their own different animations? 2. Are render layers useful for rendering items in a custom entity's hand? 3. Should a custom RenderLayer class be an extension of its parent EntityRenderer? 4. What are Render Layers mostly used for?
-
So I did what you told me and put my entity registering method in the EntityRenderersEvent.RegisterRenderers handler and then I moved that Handler, along with the EntityAttributeCreationEvent handler, too a separate client side class. It lead to the error "Entity has no attributes". Since my project is not the big I uploaded that version of it to Github so if you're okay with looking at it heres the link : github.com/bigMojitos/MilMedi . So ater that didn't work I reverted back to registering in the Main Mod class and running debug on the EntityAttributeCreationEvent, heres what I got: https://imgur.com/a/CehO5A3 . It seems like its working but I'm not seeing the affects in game, my mob is still moves and attacks at the same speed no matter how much I adjust those two attributes. What should I do?
-
empty comment mistake
-
Hi, I have a custom entity with Attributes which aren't applying. Before when I didn't have an EntityAttributeCreationEvent handler my entity wouldn't event load but, I added one and It now spawns and renders/animates. However, none of the Entity Attribute modifiers are actually applying to my entity. No matte how much I change the Attack Speed or Movement variable it always stays the same. Heres my Entity Class package willh.org.medieval.entity.reus; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.*; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; import net.minecraft.world.entity.animal.Cow; import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.AttackEntityEvent; import software.bernie.geckolib3.core.IAnimatable; import software.bernie.geckolib3.core.PlayState; import software.bernie.geckolib3.core.builder.AnimationBuilder; import software.bernie.geckolib3.core.controller.AnimationController; import software.bernie.geckolib3.core.event.predicate.AnimationEvent; import software.bernie.geckolib3.core.manager.AnimationData; import software.bernie.geckolib3.core.manager.AnimationFactory; public class ReusEntity extends Monster implements IAnimatable { boolean attacking; public ReusEntity(EntityType<? extends Monster> p_20966_, Level p_20967_) { super(p_20966_, p_20967_); attacking =false; } private AnimationFactory factory = new AnimationFactory(this); @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController(this, "controller", 0, this::predicate)); } public static void print(String r){ if(Minecraft.getInstance().player != null) { Player p = Minecraft.getInstance().player; p.sendSystemMessage(Component.nullToEmpty(r)); } } @Override public boolean doHurtTarget(Entity p_21372_) { this.level.broadcastEntityEvent(this, (byte)10); return super.doHurtTarget(p_21372_); } @Override public void handleEntityEvent(byte p_21375_) { attacking = p_21375_ == 10; super.handleEntityEvent(p_21375_); } protected void registerGoals() { this.goalSelector.addGoal(0, new MeleeAttackGoal(this, 1.1d, false) {}); this.goalSelector.addGoal(1, new FloatGoal(this)); this.goalSelector.addGoal(2, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(3, new NearestAttackableTargetGoal(this, Cow.class,true)); this.goalSelector.addGoal(4, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(5, new RandomLookAroundGoal(this)); this.targetSelector.addGoal(6, (new HurtByTargetGoal(this)).setAlertOthers()); } private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { if (event.isMoving()) { event.getController().setAnimation(new AnimationBuilder().addAnimation("walkEquipped.model.new", true)); return PlayState.CONTINUE; } event.getController().setAnimation(new AnimationBuilder().addAnimation("idle_equipped.new", true)); return PlayState.CONTINUE; } public static AttributeSupplier setAttributes() { return Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 20.0D) .add(Attributes.ATTACK_DAMAGE, 3.0f) .add(Attributes.ATTACK_SPEED, 0.9) .add(Attributes.MOVEMENT_SPEED, 0.3f).build(); } @Override public AnimationFactory getFactory() { return this.factory; } } And heres my main mod class where I register my EntityAttributeCreationEvent handler: @Mod(Medieval.MOD_ID) public class Medieval { public static final String MOD_ID = "medi"; private static final Logger LOGGER = LogUtils.getLogger(); public static ResourceLocation modLoc(String name) { return new ResourceLocation(MOD_ID, name); } public Medieval() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); // Add to the constructor ItemInit.register(modEventBus); EntityInit.ENTITIES.register(modEventBus); modEventBus.addListener(this::commonSetup); modEventBus.addListener(this::clientSetup); GeckoLib.initialize(); modEventBus.addListener(this::commonSetup); MinecraftForge.EVENT_BUS.register(this); } private void commonSetup(final FMLCommonSetupEvent event) { } private void clientSetup(FMLClientSetupEvent event){ EntityRenderers.register(EntityInit.REUS.get(), ReusRenderer::new); } @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public static class ClientModEvents { @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { LOGGER.info("HELLO FROM CLIENT SETUP"); LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); } @SubscribeEvent public static void registerEntityAttributes(EntityAttributeCreationEvent event){ event.put(EntityInit.REUS.get(), ReusEntity.setAttributes()); } } } Any help would be appreciated thanks!
-
Ok so I got it working and it seems to register fine but I cant spawn my entity. I heard that its supposed to appear with /summon command but I cant find it. Here is my new ClientBus with the working EntityRenderersEvent: @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public static class ClientBus { @SubscribeEvent public static void playerRender(RenderPlayerEvent.Pre ev){ print("Event has fired"); //not firing } @SubscribeEvent public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event){ event.registerEntityRenderer(REUS.get(), ReusRenderer::new); } @SubscribeEvent public void entityAttributeCreationEvent(EntityAttributeCreationEvent event) { LOGGER.info("Entity Attribute Event"); event.put(REUS.get(), ReusEntity.setAttributes()); } @SubscribeEvent public static void keyTest(InputEvent.Key key){ if(key.getKey() == InputConstants.KEY_C) print("Test Working"); } } And here is my register: @Mod.EventBusSubscriber(modid =Inceptor.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEntityTypes { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, Inceptor.MODID); // Entity Types public static final RegistryObject<EntityType<ReusEntity>> REUS = ENTITY_TYPES.register("reus", () -> EntityType.Builder.of(ReusEntity::new, MobCategory.CREATURE) .sized(1.0f, 1.0f) // Hitbox Size .build(new ResourceLocation(Inceptor.MODID, "reus").toString())); public static void register(IEventBus eventBus) { ENTITY_TYPES.register(eventBus); } } Is there a better way to check if its registered rather than spawning it?
-
So do I need to create a new EntityRendererProvider? Sorry most of the tutorial I'm looking at are in 1.18 so I dont know if everything is correct. And what about for the first parameter with ModEntityTypes.Reus.get() but it says its incorrect?
-
package me.wdh.inceptor.entity.custom; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.level.Level; import software.bernie.geckolib3.core.IAnimatable; import software.bernie.geckolib3.core.PlayState; import software.bernie.geckolib3.core.builder.AnimationBuilder; import software.bernie.geckolib3.core.controller.AnimationController; import software.bernie.geckolib3.core.event.predicate.AnimationEvent; import software.bernie.geckolib3.core.manager.AnimationData; import software.bernie.geckolib3.core.manager.AnimationFactory; public class ReusEntity extends Mob implements IAnimatable { public ReusEntity(EntityType<? extends Mob> p_20966_, Level p_20967_) { super(p_20966_, p_20967_); } private AnimationFactory factory = new AnimationFactory(this); @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController(this, "controller", 0, this::predicate)); } private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { if (event.isMoving()) { event.getController().setAnimation(new AnimationBuilder().addAnimation("pose.model.new", true)); return PlayState.CONTINUE; } event.getController().setAnimation(new AnimationBuilder().addAnimation("pose.model.new", true)); return PlayState.CONTINUE; } public static AttributeSupplier setAttributes() { return Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 20.0D) .add(Attributes.ATTACK_DAMAGE, 3.0f) .add(Attributes.ATTACK_SPEED, 2.0f) .add(Attributes.MOVEMENT_SPEED, 0.3f).build(); } @Override public AnimationFactory getFactory() { return this.factory; } } package me.wdh.inceptor.entity.client; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import me.wdh.inceptor.Inceptor; import me.wdh.inceptor.entity.custom.ReusEntity; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; import software.bernie.geckolib3.model.AnimatedGeoModel; import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; public class ReusRenderer extends GeoEntityRenderer<ReusEntity> { public ReusRenderer(EntityRendererProvider.Context renderManager, AnimatedGeoModel<ReusEntity> modelProvider) { super(renderManager, modelProvider); } @Override public ResourceLocation getTextureLocation(ReusEntity instance) { return new ResourceLocation(Inceptor.MODID, "textures/reus.png"); } public RenderType getRenderType(ReusEntity animatable, float partialTicks, PoseStack stack, MultiBufferSource renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, ResourceLocation textureLocation) { stack.scale(0.8F, 0.8F, 0.8F); return super.getRenderType(animatable, partialTicks, stack, renderTypeBuffer, vertexBuilder, packedLightIn, textureLocation); } } public class ModEntityTypes { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, Inceptor.MODID); // Entity Types public static final RegistryObject<EntityType<ReusEntity>> REUS = ENTITY_TYPES.register("reus", () -> EntityType.Builder.of(ReusEntity::new, MobCategory.CREATURE) .sized(1.0f, 1.0f) // Hitbox Size .build(new ResourceLocation(Inceptor.MODID, "reus").toString())); } @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public static class ClientBus { @SubscribeEvent public static void playerRender(RenderPlayerEvent.Pre ev){ print("Event has fired"); //not firing } @SubscribeEvent public static void livingRender(EntityRenderersEvent.RegisterRenderers event){ event.registerEntityRenderer(REUS.get(),ReusRenderer::new); } @SubscribeEvent public static void keyTest(InputEvent.Key key){ if(key.getKey() == InputConstants.KEY_C) print("Test Working"); } } The error im getting at living render event is this --> https://imgur.com/a/3CtbJOM
-
Hi I'm having trouble understanding what needs to go in the parameters of this method: EntityRenderers.register(ModEntityTypes.REUS.get(), ReusRenderer::new); ^ Both the options I have in those parameters are wrong but I dont know where to get the right objects for the params any help would be appreciated thanks!
-
Dude. Holy shit. I did not know that was how you had to problem completely fixed. Thank you so much!
-
package com.example.examplemod; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.apache.logging.log4j.LogManager; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @Mod(ExampleMod.MODID) public class ExampleMod { // Define mod id in a common place for everything to reference public static final String MODID = "examplemod"; // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); // Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); // Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); // Creates a new Block with the id "examplemod:example_block", combining the namespace and path public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); // Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); public ExampleMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); // Register the Deferred Register to the mod event bus so blocks get registered BLOCKS.register(modEventBus); // Register the Deferred Register to the mod event bus so items get registered ITEMS.register(modEventBus); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new ClientBus()); } private void commonSetup(final FMLCommonSetupEvent event) { // Some common setup code LOGGER.info("HELLO FROM COMMON SETUP"); LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT)); } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { // Do something when the server starts LOGGER.info("HELLO from server starting"); } // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public static class ClientModEvents { @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { // Some client setup code LOGGER.info("HELLO FROM CLIENT SETUP"); LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); } } // Add this field to your main class // You can use it from anywhere: @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public static class ClientVan { public static void print(String r){ if(Minecraft.getInstance().player != null) { Player p = Minecraft.getInstance().player; p.sendSystemMessage(Component.nullToEmpty(r)); } } @SubscribeEvent public static void playerRender(RenderPlayerEvent.Pre ev){ print(" CV Event has fired"); //not firing } @SubscribeEvent public static void clientBustTest(InputEvent.@NotNull Key ev){ if(ev.getKey() == InputConstants.KEY_C) print( " CV Test event has fired"); } } } I just created a new mod added my EventBus class to the Mod class and got the same results(KeyEvent is firing while RenderPlayerEvent is not). I ran it through the debugger and put the breakpoint at right below the declaration of the KeyEvent and I got these results : https://imgur.com/gallery/oOUNTYI . Any thing I'm noticeably doing wrong here to cause the issue? I also want to thank you rq for being so responsive and helpful
-
To check if it worked I just put a static print to chat method down in the InputEvent.Key and used it with the same EventHandler and it did manage to work. Let me know if the debugger can give me more insight than that but yea I'm confused. Im making a new Mod right now just to test this event to see if its something internal, as in my computer.
-
@Mod.EventBusSubscriber(modid = "incp",bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientBus {... Just tried it nothing changed, same output as before. Do you want me to pastebin it?
-
package me.wdh.inceptor.client; import com.google.common.eventbus.Subscribe; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.world.entity.EntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import static me.wdh.inceptor.Inceptor.print; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientBus { @SubscribeEvent public static void playerRender(RenderPlayerEvent.Pre ev){ print("Event has fired"); //not firing } @SubscribeEvent public static void clientBustTest(InputEvent.Key ev){ if(ev.getKey() == InputConstants.KEY_C) print("Test event has fired"); } } I also tried moving the whole ClientBus Class into the Mod Class so I could make it static but it still had the same output.
-
Which one would it be? I just tried the First one, same result, and the second one was my previous set up. Would it be either of the two bottom ones?
-
public class ClientBus { @SubscribeEvent public void playerRender(RenderPlayerEvent.Pre ev){ print("Event has fired"); //not firing } @SubscribeEvent public void clientBustTest(InputEvent.Key ev){ if(ev.getKey() == InputConstants.KEY_C) print("Test event has fired"); } } So here's my client bus and all its events. The KeyEvent is firing perfectly but the RenderPlayerEvent, both .pre and .post, do not fire at all, at least to my knowledge. If you could help and point out my issues with this I'd really appreciate it. Here's my Mod Class where I register this event bus: public Inceptor() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); // Register the Deferred Register to the mod event bus so blocks get registered BLOCKS.register(modEventBus); // Register the Deferred Register to the mod event bus so items get registered ITEMS.register(modEventBus); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new ClientBus()); }
-
I want to create new animations for the players arms that can be seen in third person. As for the actual animations I'm still deciding which method to use; rotating the arms with the renderer or creating some new model and animations in blender. I will most likely use the latter but I've read online and was told in discord that for both options having a custom PlayerRenderer would be viable and useful but if you have any other ideas let me know please!
-
How do I register it if its not a custom Entity but instead a Player. When ever I put this in: IntelliJ tells me both parameters are wrong and invalid. For reference my 'IntRender' class is an extension of the PlayerRenderer.
-
Hi I'm having trouble figuring out how to register a created PlayerRenderer I Currently have this: private final IntRender test = new IntRender(question goes here, false); but I dont know where to get my games instance for the first parameter which is ; EntityRendererProvider.Context . Any help would be appreciated!