#How to Use VS Collision (For Mod Dev)?

1 messages · Page 1 of 1 (latest)

silk trail
#

I am trying my darndest to get the cannon from supplementaries to interact with ships.
I am just browsing the source rn but it will take me a while so i am leaving this here.

Any help with integrating collision will be appreciated.

#

How to Use VS Collision (For Mod Dev)?

#

What kind of object are the ships?

I understand their real blocks are millions of blocks away -but what is being projected that I can further implement projectile collisions onto?

narrow furnace
#

it honestly depends on how the cannon projectile is setup

#

most vanilla-MC distance checks, raycasts, etc are already redirected to ships if needed

#

its only when mods use a custom distance check or raycast that things break

silk trail
#

ah this one definitely is

narrow furnace
#

anyway if a conventional raycast isn't possible to be put into the supplementary system, you can use some of the functions in VSGameUtilsKt

silk trail
#

its kotlin right?

narrow furnace
#

yes but you can use it in java

#

java example: ```java
// level and my_blockpos are variables from elsewhere, depends on where you run this code
Ship the_ship = VSGameUtilsKt.getShipObjectManagingPos(level, my_blockpos)

// Ship will be null if there isn't a ship at that position
if (the_ship != null) {
// do something
}
// normal behaviour


kotlin example: ```kotlin
// level and my_blockpos are variables from elsewhere, depends on where you run this code
var the_ship = level.getShipObjectManagingPos(my_blockpos)

// Ship will be null if there isn't a ship at that position
if (the_ship != null) {
  // do something
}
// normal behaviour
silk trail
#

i am trying to redirect some of those functions from RaycastUtilsKt i wonder if im in the wrong place

#

this looks very helpful

#

idk kotlin btw

#

😳

narrow furnace
#

I've never used raycast utils myself, since vanilla raycast methods (level.clip) should find shipyard positions

narrow furnace
silk trail
#

another question

#

would decompiling to java within Intellij be the right approach for kt?

#

it seems to have missing mappings and poor syntax highlighting so im in doubt

floral hound
#

why are you decompiling anything

narrow furnace
floral hound
#

ok but why

silk trail
floral hound
#

ok?

#

you don't need to know its code

#

just use functions

silk trail
#

i dont know what the functions are tho
nor would i know what they do

floral hound
#

again, just use functions

narrow furnace
narrow furnace
#

decompiling it will probably make you more confused clueless

#

oh and if you need to go between

#

Vec3 and Vector3

#

you can look at

#

VectorConversionKitMcKt or something

#

I forget its exact name

#

JOML is the format VS uses, with Vector3f, Vector3dc, etc wheras minecraft has its own Vec3, Vec3i, etc

narrow furnace
floral hound
#

1.20.1 mc uses joml

narrow furnace
#

no?

floral hound
#

yea?

narrow furnace
silk trail
narrow furnace
#

hang on a sec

floral hound
#

ok there's Vec3 and Vec2

#

but also a lot of joml

narrow furnace
#

where is joml used? thonk

floral hound
#

actually, i was wrong

#

i thought it used joml

#

huh

#

🤔

#

nvm then

narrow furnace
#

maybe like

#

1.21 or smthn uses joml

silk trail
#

since your still here might we discuss this example which gives me hope?

package com.example.bulletfix.mixin;

import com.mrcrayfish.guns.entity.ProjectileEntity;
import java.util.function.Predicate;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.mod.common.world.RaycastUtilsKt;

@Mixin(
        value = {ProjectileEntity.class},
        remap = false
)
public abstract class MixinProjectileEntity<T> {
  @Inject(
          method = {"Lcom/mrcrayfish/guns/entity/ProjectileEntity;rayTraceBlocks(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ClipContext;Ljava/util/function/Predicate;)Lnet/minecraft/world/phys/BlockHitResult;"},
          at = {@At("HEAD")},
          cancellable = true
  )
  private static void injectRayTraceBlocks(Level world, ClipContext context, Predicate<BlockState> ignorePredicate, CallbackInfoReturnable<BlockHitResult> cir) {
    cir.setReturnValue(RaycastUtilsKt.clipIncludeShips(world, context));
  }
}
#

this is for 1.18 tho it looks simple

#

and also for a different mod that messes with projectiles

narrow furnace
#

mixins are very dependent on the mod you're changing

silk trail
narrow furnace
#

so I would recommend trying to find the cannons projectiles code

silk trail
#

ah it makes sense now

#

thanks again

silk trail
narrow furnace
#

ayy

#

you could maybe look at fixing this aswell, if your interested

silk trail
#

is it the aiming mode i bet

narrow furnace
#

its something about

#

/reload doing something funky with a fake level

#

so its the wrong tick phase

#

so VS gets angry

#

its saying something about the onTagUpdated event