Jump to content

Ninjaguy169

Members
  • Posts

    36
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Ninjaguy169

  1. Yeah, I figured. So I got it to work (finally), but is there a specific event I can use to see if the player is holding a certain item and change the attribute's value based on that?
  2. EntityAttributeModificationEvent: @SubscribeEvent public static void onEntityAttributeModificationEvent(final EntityAttributeModificationEvent event) { event.add(EntityType.PLAYER, ForgeMod.REACH_DISTANCE.get()); } Test Weapon Item: protected static final UUID ATTACK_KNOCKBACK_MODIFIER = UUID.fromString("C59EC38E-DC43-11EB-BA80-0242AC130004"); public static final UUID REACH_MODIFIER = UUID.fromString("5C05J864-4748-24CE-90D6-0242AC170006"); private final Multimap<Attribute, AttributeModifier> attributeModifiers; public AnimationFactory factory = new AnimationFactory(this); public TestItem(IItemTier t, int dmg, float speed, double reachDistance, double knockBack, Properties prop) { super(t, dmg, speed, prop); float attackDamage = (float) dmg + t.getAttackDamageBonus(); ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", dmg, AttributeModifier.Operation.ADDITION)); builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", speed, AttributeModifier.Operation.ADDITION)); ForgeMod.getInstance(); if (ForgeMod.REACH_DISTANCE.isPresent()) { builder.put(ForgeMod.REACH_DISTANCE.get(), new AttributeModifier(REACH_MODIFIER, "Weapon modifier", reachDistance, AttributeModifier.Operation.ADDITION)); } builder.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(ATTACK_KNOCKBACK_MODIFIER, "Weapon modifier", knockBack, AttributeModifier.Operation.ADDITION)); this.attributeModifiers = builder.build(); } @Override public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlotType equipmentSlot) { return equipmentSlot == EquipmentSlotType.MAINHAND ? this.attributeModifiers : super.getDefaultAttributeModifiers(equipmentSlot); } Registry Item: public static final RegistryObject<TestItem> TEST_ITEM = ITEMS.register("test_item", () -> new TestItem(ModItemTiers.TEST, 100, -3.2F, 15F, 0, new Item.Properties().rarity(Rarity.EPIC).tab(ModItemGroups.EQUIPMENT))); Pretty sure I need to do something else, although I just can't seem to lay my finger on it.
  3. So the attribute should work. I have it registered in the EntityAttributeModificationEvent, but when I try to modify it for an item, it doesn't work. Do I need to use events?
  4. Well, it no longer crashes, but the attack reach remains the same
  5. Description: Unexpected error java.lang.IllegalArgumentException: Can't find attribute reachmod:attack_reach at net.minecraft.entity.ai.attributes.AttributeModifierMap.getAttributeInstance(AttributeModifierMap.java:21) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.ai.attributes.AttributeModifierMap.getValue(AttributeModifierMap.java:28) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.ai.attributes.AttributeModifierManager.getValue(AttributeModifierManager.java:62) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1731) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at com.creator.reachmod.client.ClientEvent$ReachClientHelper.checkForReachAttack(ClientEvent.java:105) ~[main/:?] {re:classloading} at com.creator.reachmod.client.ClientEventEvent$ReachClientHelper.mouseEvent(ClientEvent.java:131) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_60_ReachClientHelper_mouseEvent_MouseInputEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.client.ForgeHooksClient.fireMouseInput(ForgeHooksClient.java:811) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.client.MouseHelper.onPress(MouseHelper.java:118) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:181) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:94) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.lambda$setup$5(MouseHelper.java:180) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:102) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MainWindow.updateDisplay(MainWindow.java:306) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runTick(Minecraft.java:997) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:607) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.entity.ai.attributes.AttributeModifierMap.getAttributeInstance(AttributeModifierMap.java:21) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.ai.attributes.AttributeModifierMap.getValue(AttributeModifierMap.java:28) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.ai.attributes.AttributeModifierManager.getValue(AttributeModifierManager.java:62) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1731) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at com.creator.reachmod.client.ClientEvent$ReachClientHelper.checkForReachAttack(ClientEvent.java:105) ~[main/:?] {re:classloading} at com.creator.reachmod.client.ClientEvent$ReachClientHelper.mouseEvent(ClientEvent.java:131) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_60_ReachClientHelper_mouseEvent_MouseInputEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.client.ForgeHooksClient.fireMouseInput(ForgeHooksClient.java:811) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading} at net.minecraft.client.MouseHelper.onPress(MouseHelper.java:118) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:181) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:94) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.lambda$setup$5(MouseHelper.java:180) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:102) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A} -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Dev'/407, l='ClientLevel', x=107.50, y=84.00, z=-191.50]] Chunk stats: Client Chunk Cache: 841, 529 Level dimension: minecraft:overworld Level spawn location: World: (112,78,-192), Chunk: (at 0,4,0 in 7,-12; contains blocks 112,0,-192 to 127,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 179 game time, 179 day time Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillReportDetails(ClientWorld.java:447) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A,re:mixin,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.fillReport(Minecraft.java:2031) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:628) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {re:classloading,pl:runtimedistcleaner:A} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.33_mapped_official_1.16.5.jar:?] {}
  6. Whenever I subscribe to the forge event bus, the game crashes indicating that the attribute is null
  7. Registry Class: public static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(ForgeRegistries.ATTRIBUTES, ReachMod.MODID); //ATTRIBUTES public static final RegistryObject<Attribute> ATTACK_REACH = ATTRIBUTES.register("attack_reach", () -> (Attribute) new RangedAttribute("attribute.mod.attack_reach", 5.0D, 0.0D, 1024.0D).setSyncable(true)); //MODIFIERS public static final UUID ATTACH_REACH_MODIFIER = UUID.fromString("7cc9a781-fdde-4e1b-85fe-acb912fc0430"); Main Class: //Register stuff IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); ModAttributes.ATTRIBUTES.register(bus); Extra stuff (events): @EventBusSubscriber(bus = Bus.MOD) public static class ClientHelper{ @SuppressWarnings("unused") private static RayTraceResult getEntityMouseOverExtended(float reach) { BlockRayTraceResult blockRayTraceResult = null; RayTraceResult result = null; Minecraft mc = Minecraft.getInstance(); Entity viewEntity = mc.crosshairPickEntity; PlayerController p = mc.gameMode; if (viewEntity != null) { double d0 = reach; RayTraceResult rayTrace = viewEntity.pick(d0, 0.0F, false); Vector3d eyePos = viewEntity.getEyePosition(0.0F); boolean flag = false; double d1 = d0; if (p.hasFarPickRange() && d1 < 6.0D) { d1 = 6.0D; d0 = d1; } else if (d0 > reach) { flag = true; } d1 *= d1; if (rayTrace != null) d1 = rayTrace.getLocation().distanceToSqr(eyePos); Vector3d lookVec = viewEntity.getEyePosition(1.0F); Vector3d attackVec = eyePos.add(lookVec.x * d0, lookVec.y * d0, lookVec.z * d0); AxisAlignedBB expBounds = viewEntity.getBoundingBox().expandTowards(lookVec.scale(d0)).inflate(1.0D, 1.0D, 1.0D); EntityRayTraceResult entityRayTrace = ProjectileHelper.getEntityHitResult(viewEntity, eyePos, attackVec, expBounds, entity -> (!entity.isSpectator() && entity.canBeCollidedWith()), d1); if (entityRayTrace != null) { Vector3d hitVec = entityRayTrace.getLocation(); double d2 = eyePos.distanceToSqr(hitVec); if (flag && d2 > (reach * reach)) { blockRayTraceResult = BlockRayTraceResult.miss(hitVec, Direction.getNearest(lookVec.x, lookVec.y, lookVec.z), new BlockPos(hitVec)); } else if (d2 < d1 || blockRayTraceResult == null) { EntityRayTraceResult entityRayTraceResult = entityRayTrace; } } else { blockRayTraceResult = BlockRayTraceResult.miss(attackVec, Direction.getNearest(lookVec.x, lookVec.y, lookVec.z), new BlockPos(attackVec)); } } return (RayTraceResult)blockRayTraceResult; } private static void checkForReachAttack() { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity clientPlayerEntity = mc.player; if (clientPlayerEntity == null || clientPlayerEntity.isSpectator()) return; double reach = (float)clientPlayerEntity.getAttributeValue(ModAttributes.ATTACK_REACH.get()); if (reach == ModAttributes.ATTACK_REACH.get().getDefaultValue()) return; RayTraceResult rayTrace = getEntityMouseOverExtended((float)reach); if (!(rayTrace instanceof EntityRayTraceResult)) return; EntityRayTraceResult entityRayTrace = (EntityRayTraceResult)rayTrace; Entity entityHit = entityRayTrace.getEntity(); if (entityHit != null && entityHit.invulnerableTime == 0 && entityHit != clientPlayerEntity && entityHit != clientPlayerEntity.getControllingPassenger()) { float velocity = 0.0F; if (clientPlayerEntity.getControllingPassenger() != null) { Entity riding = clientPlayerEntity.getControllingPassenger(); Vector3d vec = riding.getDeltaMovement(); velocity = (float)vec.length(); } PacketHandler.sendPacketToServer(new PacketReach(velocity, entityHit.getId())); } } @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) @SuppressWarnings("resource") public static void mouseEvent(InputEvent.MouseInputEvent event) { if (Minecraft.getInstance().level == null || Minecraft.getInstance().screen == null || Minecraft.getInstance().isPaused()) return; KeyBinding keyAttack = Minecraft.getInstance().options.keyAttack; if (event.getButton() == keyAttack.getKey().getValue() && event.getAction() == 1 && ModAttributes.ATTACK_REACH.isPresent()) checkForReachAttack(); } } All I need is to register the events and my registries to the mod event bus, right?
  8. I want to make a custom attack reach attribute, however it doesn't register when I launch my game. Yes, any events using it were register to the mod event bus. I'm using DeferredRegister. Do I need to work with capabilities or something?
  9. Apologies for the late reply, but thanks. Turned out the issue was with immersive portals not being up to date with the forge version I was using at the time (mixin changes to be exact). Hope this helps anyone reading this running into this problem, even if its by the slightest
  10. To clarify further, forge for 1.16.5 (versions 36.2.0 - 36.2.4) has been having problems with mods. You see, I wanted to play an old kitchensink modpack that I made almost a year ago, and it worked perfectly fine. I grabbed the mod files exactly where I left them off and pasted them into the mods folder. However, I got this error when I loaded forge up: https://imgur.com/mIPPnow Now to clarify, not only has this worked previously with me back when I played this modpack long ago, I have also attempted to install specified versions of mods mentioned on the error screen, but to no avail. My theory here was/is that forge is somehow corrupted/broken. To test that theory out, I grabbed my old server files (containing all mods used when firing up this installation of forge, including client side ones since back then I wasn't exactly fluent with minecraft modding) and launched the server successfully. It should be noted that no server-side mods (except performant) were included in my forge mods directory. In conclusion, I'm asking for any possible solutions to forge simply refusing to detect that the installed mod versions are compatible with each other. Yes, some 1.16.3 mods (as mentioned in the above screenshot) do work on 1.16.5, according to how I launched it myself. Finally, this wouldn't be a proper forge forums post without including my crash report and latest.log file. (It's worth noting that since it crashes so early during the pre-loading phase, no other mods show up in the crash report file) Apologies for any obvious mistakes I may have not noticed while posting this here in advance, if there were any. https://gist.github.com/RaveTr/6a30411b367958c30e8f37dbc9b4d25a https://gist.github.com/RaveTr/56308af48ecdf60f3f32106a3a138170
×
×
  • Create New...

Important Information

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