#custom projectile for custom bow / ranged weapon previously made [and fixing model + texture files]
135 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
i do not know which tag a projectile takes
also very maybe change said ranged weapon's sound.ogg so some other thing
theres this for the projectile entity but i think we also need an itemstack for it as well #1140722827440431164 message
havent really looked much into it past just making the entity be spawnable in game
bump ^^
Paste version of message.txt from @azure ridge

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 
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"
ye
how fix
is removing $ModCategory.MISC an option?
if not
try make the value not null>
idk how
but its something
i mean you can try
though probably wont work
its the wrong script for this anyways @azure ridge dont figure it out, this is what we need to register https://lexxie.site/forge/1.19.2/net/minecraft/world/item/ProjectileWeaponItem.html
declaration: package: net.minecraft.world.item, class: ProjectileWeaponItem
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
though it shoots normal arrow entities
oof
hm
this is weird because if i log this js console.log(event.projectileItemStack.getItem())it returns this
chute_ammo[net.minecraft.world.item.ArrowItem]
so it's using the new ammo though i guess it's missing the entity for it
maybe
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
you change the server/client too?
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
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
your chute arrow gets turned into a regular arrow
also that desync has been an issue since the last ticket
really i think you should try registering the arrow entity with the same name, maybe it'll use it
not sure tho
it definately did
and still will if you test it out
[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
so that didnt work, theres probably some way to link the arrow item to a projectile entity
bummer
Got any progress on it?
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
thats probably because you didnt remove the conflicting mod, that being torchmaster
like i said here #1183435050142924963 message
i want to solve the conflict
thats something youd ask the mod author about
the entity type returns null
i feel like it has something to do with the
const $MobCategory = Java.loadClass('net.minecraft.world.entity.MobCategory')
well at the moment kubejs doesnt have a good way of registering an entity without extending classes
maybe when lat finishes ichor
const DUMMY_ENTITY = () => $EntityType.Builder.of((entityType, level) => new $Arrow(entityType, level), $MobCategory.MISC).sized(0.5, 0.5).build('dummy')
category.MISC
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
??tryitandsee
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
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
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
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
that, or find a dumb workaround
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.
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
i get one to appear for a moment, then the game crashes