#custom projectile for custom bow / ranged weapon previously made [and fixing model + texture files]

135 messages · Page 1 of 1 (latest)

azure ridge
#

am looking to make a custom projectile for a ranged weapon someone gloriously helped create, and to fix model/texture files of said weapon as the .json files are broke

hot auroraBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

azure ridge
#

i do not know which tag a projectile takes

#

also very maybe change said ranged weapon's sound.ogg so some other thing

tiny carbon
#

havent really looked much into it past just making the entity be spawnable in game

azure ridge
#

im taking a small rythm game break

#

but will look into that

azure ridge
#

bump ^^

azure ridge
ornate pagodaBOT
#

Paste version of message.txt from @azure ridge

azure ridge
#

it crashed due to

tiny carbon
#

odd, loads for me

#

also it says it was a torchmaster error, is that a mod?

#

looks like it is

#

so entitytypes null, lemme figure that out

#

wait what whatcat

#

we have a mob category

#

looks like an incompatability with torchmaster then

#

torchmaster probably is looking at registries to take note of every mob type to see what category it's in so it can either prevent it from spawning or not

#

then it's looking at our arrow entity and going "wtf"

azure ridge
#

ye

#

how fix

#

is removing $ModCategory.MISC an option?

#

if not

#

try make the value not null>

#

idk how

#

but its something

tiny carbon
#

i mean you can try

#

though probably wont work

tiny carbon
# azure ridge how fix

we dont need to register an arrow entity, this works

const $bowItem = Java.loadClass('net.minecraft.world.item.BowItem')
const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties')
const $arrowitem = Java.loadClass('net.minecraft.world.item.ArrowItem')
const $kubejs = Java.loadClass('dev.latvian.mods.kubejs.KubeJS')
StartupEvents.registry('item', event => {
    event.createCustom('dart_chute', () => new $bowItem(new $ItemProperties().tab($kubejs.tab).defaultDurability(23)))
    event.createCustom('chute_ammo', () => new $arrowitem(new $ItemProperties().tab($kubejs.tab)))
})```, just register the arrow item below your dart chute, also change the spectral arrow out for it and it works
azure ridge
#

oh col

#

lemme try

tiny carbon
#

though it shoots normal arrow entities

azure ridge
#

oof

tiny carbon
#

hm

azure ridge
#

it also breaks when in survival

#

no matter the ammo i have, i dont fire

tiny carbon
#

its cause you didnt change the server/client/startup events

#

from spectral arrows

tiny carbon
#

so it's using the new ammo though i guess it's missing the entity for it

#

maybe

azure ridge
#

code so far:

const $bowItem = Java.loadClass('net.minecraft.world.item.BowItem')
const $arrowitem = Java.loadClass('net.minecraft.world.item.ArrowItem')
const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties')

const $kubejs = Java.loadClass('dev.latvian.mods.kubejs.KubeJS')
StartupEvents.registry('item', event => {
    event.createCustom('dart_chute', () => new $bowItem(new $ItemProperties().tab($kubejs.tab).defaultDurability(23)))
    event.createCustom('chute_ammo', () => new $arrowitem(new $ItemProperties().tab($kubejs.tab)))
})


ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingGetProjectileEvent', event => {
    global.projectile(event)});    ForgeEvents.onEvent('net.minecraftforge.event.entity.player.ArrowLooseEvent', event => {
        global.shoot(event)
})

global.projectile = event => {
    if (event.entity.level.clientSide) return
    if (event.projectileWeaponItemStack.id != 'kubejs:dart_chute') return
    event.setProjectileItemStack('kubejs:chute_ammo')
}

global.shoot = event => {
    if (event.entity.level.clientSide) return
    if (event.bow.id != 'kubejs:dart_chute') return

    let entity = event.entity
    let maxSlots = 41
    for (let slotIndex = 0; slotIndex < maxSlots; slotIndex++) {
        let slot = entity.getSlot(slotIndex)
        let itemStack = slot.get()

        if (!itemStack.count <= 0) {
            let itemId = itemStack.id
            if (itemId === 'kubejs:chute_ammo') {
                if (event.charge <= 2 || event.entity.isCreative()) return
                itemStack.count--
                return
            }
        }

    }
    if (!entity.isCreative()) {
        event.setCanceled(true)
    }
}


#

as reference point

tiny carbon
#

you change the server/client too?

azure ridge
#

AH

#

i am the dummest dummy

#

to every dummy

#

in dumyyland'' dummyvile'

tiny carbon
#

i mean you could make the arrow item infinite and have it be a consumable arrow item maybe to avoid picking up normal arrows, though i wonder if you register that arrow entity and also name it the same the chute_ammo if it will use it

azure ridge
#

maybe idk

#

or just try modify properties of chute_ammo and make sure it
-doesnt get picked up as arrow
-retextured
-inventory item

#

ok so slight issue

#

theres a desync somehow

#

it consumes regular arrows

#

as a desync

#

before firing:

#

after firing

#

after pickup

tiny carbon
#

your chute arrow gets turned into a regular arrow

#

also that desync has been an issue since the last ticket

ornate pagodaBOT
#

[Quote ➤](#1183093106384576602 message) the only issue is client desync when you have normal arrows in your inventory and it cancels the event
though im sure you could maybe open up another ticket and someone will know how to fix that

azure ridge
#

it didnt happen before with spectral arrows btw

#

iirc

#

or did it and i missed it

tiny carbon
#

really i think you should try registering the arrow entity with the same name, maybe it'll use it

#

not sure tho

tiny carbon
#

and still will if you test it out

azure ridge
#

mm

#

theres gotta be a way to fix that

tiny carbon
#

you should read my messages😮‍💨

azure ridge
#

i saw those

#

i just though it got fixed with a later script

ornate pagodaBOT
#

[Quote ➤](#1183093106384576602 message) aight, i would open up a ticket labeled "client desync in forge event" for someone who knows about the subject to see

azure ridge
#

will make 2nd ticket

#

but rn the arrow

tiny carbon
#

ah

#

yeah imma try this

azure ridge
#

alr

#

goodluck and thanks

tiny carbon
#

so that didnt work, theres probably some way to link the arrow item to a projectile entity

azure ridge
#

bummer

azure ridge
#

Got any progress on it?

azure ridge
#

e, ticket system deleted this from following

#
const $DeferredRegister = Java.loadClass('dev.architectury.registry.registries.DeferredRegister')
const $Registry = Java.loadClass('net.minecraft.core.Registry')
const $EntityType = Java.loadClass('net.minecraft.world.entity.EntityType')
const $MobCategory = Java.loadClass('net.minecraft.world.entity.MobCategory')
const $Arrow = Java.loadClass('net.minecraft.world.entity.projectile.Arrow')

//Create the deferred register, so that the entity can be registered
const ENTITIES = $DeferredRegister.create('kubejs', $Registry.ENTITY_TYPE_REGISTRY)
//Use the existing Arrow entity registry and name it "dummy"
const DUMMY_ENTITY = () => $EntityType.Builder.of((entityType, level) => new $Arrow(entityType, level), $MobCategory.MISC).sized(0.5, 0.5).build('dummy')
//Pass it to a global variable so that the client can read it and make an entity renderer
global.ENTITY = {
    DUMMY: ENTITIES['register(java.lang.String,java.util.function.Supplier)']('dummy', DUMMY_ENTITY)
}

//Register the entity
StartupEvents.init(event => {
    ENTITIES.register()
})
```from this code you wrote
#

which can be renamed as "dart_chute"

#

the crash still happens

tiny carbon
ornate pagodaBOT
azure ridge
#

i want to solve the conflict

tiny carbon
#

thats something youd ask the mod author about

azure ridge
#

the entity type returns null

#

i feel like it has something to do with the

#

const $MobCategory = Java.loadClass('net.minecraft.world.entity.MobCategory')

tiny carbon
#

well at the moment kubejs doesnt have a good way of registering an entity without extending classes

#

maybe when lat finishes ichor

azure ridge
#
const DUMMY_ENTITY = () => $EntityType.Builder.of((entityType, level) => new $Arrow(entityType, level), $MobCategory.MISC).sized(0.5, 0.5).build('dummy')
#

category.MISC

tiny carbon
#

if thats not working and its saying it doesnt have an entity type with torchmaster then youll probably have to wait until it can be done properly with ichor

azure ridge
#

maybe change misc

#

hm sad

tiny carbon
#

??tryitandsee

ornate pagodaBOT
azure ridge
#

YES

#

is that or i just make the item shoot without ammo and its crafting recipe has like a bundle of darts in it [to compensate for balancing]

#

so its just a weapon that fires arrows/darts no matter what

tiny carbon
#

try changing it to ARROW instead of MISC

#

actually that wont work

azure ridge
#

i tried that

#

first instinct was to do just that

#

does a way exist to return a value

#

wait

#

entitytype = null

#

thats the error

#

could you manually set entity type and just have it be fixed

tulip hinge
#

i think this is where i get blocked when trying to make a skeleton clone

#

feels like it's the last piece of the puzzle.

#

goal is to clone existing entities under different IDs so i can apply modificaitons to them (size, model, skin, other attributes, etc.) using kubejs + mods like pehkui, EMF+ETF

#

cause with actual different entities (having their own IDs) it's a lot easier to leverage other minecraft tools for managing them. all the workarounds to have different skins, different features, etc with the same mob in different contexts are nice, but they don't interoperate well to let me build a combined effect that feels like a different mob

tiny carbon
#

i think for entity creation you have to extend classes which kubejs just cannot do right now because of how broken rhino is at the moment. like i said, lats working on a much much better javascript engine called ichor right now which would be able to do this which will make entity creation actually plausable with kubejs

azure ridge
#

that, or find a dumb workaround

tulip hinge
#

yeah, nah, i've been following loosely. how does the regestration of a mob entity under a different ID differ from the tipped arrow example posted by @patent abyss a few months back that we've all been working against?

#

cause my working premise was that if I can just register a mob a second time under a different ID, i can do lots of interesting stuff based on that.

tiny carbon
#

i mean i will admit that i've successfully registered a skeleton entity to the point where i can almost summon it in game, the issue is that it's missing attributes and therefore refuses to be summoned

tulip hinge
#

i get one to appear for a moment, then the game crashes