#clay with inventory

1 messages · Page 1 of 1 (latest)

steady fractal
#

@wintry heath and @sick cairn

wintry heath
#

You cant assign a TileState to a random Block. It has to be a TileState as well.

steady fractal
#

hm

sick cairn
#

why are you even using reflection?

#

can you pls explain what's your goal?

steady fractal
#

to override the block

sick cairn
#

that's a very bad idea

steady fractal
#

my goal is to add inventory to any block

#

allowing them to receive items from hopper

sick cairn
#

oh yeah well

steady fractal
#

1.12

wintry heath
sick cairn
#

oh shit 1.12 I'm out lol, sorry

steady fractal
#

:c

sick cairn
#

my knowledge about pre 1.13 is very limited

wintry heath
#

Oh then the idea i just cooked up in my head wont work too...

steady fractal
#

say it

wintry heath
#

PDC of Chunks

steady fractal
#

sad

#

:C

sick cairn
#

well you cannot simply register new block / tileentity classes and expect them to work

#

that's not what the API was designed for

wintry heath
#

You need to completely emulate all the properties of a BlockInventoryHolder TileState

sick cairn
wintry heath
#

jep

sick cairn
#

yeah but they are using 1.12.2^^

#

sooo

#

let me rephrase

#

you want hoppers be able to put stuff into your custom block's inventories

#

right?

steady fractal
#

yes

sick cairn
#

if so: there's NO OTHER WAY than checking inventory/hopper events and moving those items manually

wintry heath
#

Events arent fired

steady fractal
#

^

sick cairn
#

well of course events are fired

steady fractal
#

no

sick cairn
#

events for items ENTERING the hopper are

steady fractal
#

yes

wintry heath
#

He has to get all TileStates when a chunk loads, filter the hopper states out and manually tick them depending on their orientation.

sick cairn
#

and then you have to the rest manually

#

I mean what do you expect? of course spigot won't call an event when a hopper doesnt actually attempt to move stuff from a hopper to your custom dirt block^^

#

you will have to check when items ENTER your hopper and then do the rest on your own

#

there DEFINITELY is no other way, sorry

steady fractal
#

:C

#

i was using some breakpoints

#

and i saw that the event was fired in my custom block

sick cairn
#

I made a hopper filtering plugin a few weeks ago ( https://www.spigotmc.org/resources/filtered-hoppers.96037/ ) so I know how hoppers are working in 1.17, aaaaaand: in 1.12.2, the API will definitely not have more methods, soooo I can garantuee: no way! There are no events for hoppers checking blockstates that don't extend/implement container :/

steady fractal
#

my block is a container :D

sick cairn
steady fractal
#

override

sick cairn
#

yes but hear me out

#

of course you can create a new class that extends/implements container

#

but never ever will there exist any REAL block in your world that actually has your custom block as its blockstate

#

the API isn't designed to do that

#

that's why MATERIAL is an enum

steady fractal
#

im not using the api :D

#

nms

#

i can place the block

#

i can override the methods

sick cairn
#

believe me or not, you will not get it to work in this way

steady fractal
#

the only problem here is that the hopper is not transfering items

sick cairn
#

of course it doesn't

#

because

#

vanilla MC works like this:

steady fractal
wintry heath
sick cairn
#

Is the block next to me a hopper? If yes, transfer it. If no, don't. And your block is NOT a hopper, it's just something else

steady fractal
#

ik

#

i want something that works now

sick cairn
#

I'm doing spigot development for more than 3 years now and have sold quite a lot of premium plugins until today. In my opinion, what you are looking for is simply not possible. Of course you can recreate the behaviour you're looking for, but you cannot just do it the way you're currently trying to use. Sure, I might be wrong, but tbh I am very very sure that I aint.

#

Sooo to rephrase:

#

you have to rewrite all the hopper mechanics

#

you cannot simply trick the game into thinking your custom block is a container

#

it just will never work

wintry heath
#

Its possible but he will have to use a LOT of workarounds.
The hardest problem will be serialization.

sick cairn
#

noo nooo

#

well

#

I never looked at the source code that actually saves the world data

#

anyway, let's just agree on the fact that listening to the event that tells you when items ENTER the hopper and then doing the remaining stuff manually is the only viable solution^^

#

ooooor

#

you could fork spigot, create a PR that adds the new events you need, and ask md_5 to merge it. But he probably will never do because hoppers already are one of the largest lag machines that exist in spigot

steady fractal
#

cool

#

the messages i said that were sent to console