#help-development
1 messages · Page 32 of 1
Sure
?workdistro
Im a rust dev not a spigot dev
still down 😅
does the Entity.remove method silently kill without particles?
Ok so all you need to do is keep a Set<Long> of the modified chunk keys
and then run a second task that relights each chunk after all blocks are set.
it should
thanks
Bukkit.getScheduler().runTaskTimer(plugin, task -> {
System.out.println("Hi");
if (Math.random() < 0.01) {
task.cancel();
}
}, 1, 1);```
it removes it internally from the server and sends entity destroy packets
@noble lantern
Math.random
🤮
chunk keys?
so its silent as well?
Not the important part
The only relevant thing here is cancelling the task from within itself
x and z are 32 bit integers. You can bit shift them into one long.
Which can easily be done with the scheduler
ok, got it
I've had a deployment where switching from Math.random to ThreadLocalRandom.current increased performance by like 20x
There are so many new people joining and im campin waiting to ban people
Why
but i think an issue here is
Are they new accounts
the lighting engine operates on its own... i dont think i can cancel it?
Oh lol
I didn't know it was that slow
so I despise Math.random
Still doesn't matter for this use case though
but it was on a concurrent environment
That could be it
are you unaware of the spigot website situation
Math.random might be synchronized
What about it
It's back up now
When you said that you have "problems with light updates"
Did you mean that they slow down your placements? How do the
problems manifest?
Math.random uses a static random
so it kinda is synchronized yeah
gimme a min or two
This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number generator.```
From docs
How?
So yeah that's probably your problem
Not Math.random() itself
Then you might just need to manually run the steps
Did you register the listener?
Set their health to full, teleport them to their spawn point, set their hunger to max, clear potion effects
Would this glitch if a totem is being used?
(player.getHealth() - finalDamage) <= 0
Can also do if (e.getFinalDamage() >= player.getHealth())
Whats wrong with using the PlayerDeathEvent here?
Checking like this seems unreliable if other plugins modify the damage.
And thats a problem because...
Yeah there is
They said it didn't work for them
i should modify my original help message
i think had some ?xy
my thought process was lighting updates, but in general is that my algo produces lag spikes
@EventHandler
public void onPlayerDeath(final PlayerDeathEvent event) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> event.getEntity().spigot().respawn(), 4L);
}
This works
i dont care if it takes longer, but lag spikes are a problem
ive tried makign ti slower and it doesnt seem to make the server smoother (in fact... its worse than just using no work distro)
which is why i think its lighting updates but have no reason to confirm that
oh?
Server or client side lag spikes?
serverside definitely
Timings v2 
would timings make sense for this?
i will look into it
let me post this vid first in case any of you have intuition
of what may be happening
This doesn't work, no effects are applied to the potion. If anyone could help me figure out what is wrong that would help. Thanks!
ItemStack fireres = new ItemStack(Material.SPLASH_POTION);
PotionMeta pm = (PotionMeta)fireres.getItemMeta();
pm.setColor(Color.ORANGE);
pm.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 0), true);
fireres.setItemMeta(pm);
I don't know if this is related to your problem
But you're passing 10 for the duration
That's 10 ticks
A potion that lasts half a second
oh its in ticks
yea that probably is it
thanks
I thought it was seconds
How precise is the bukkit scheduler? It seems to be consistently off but I might be timing it wrong
its pretty precise as far as I know, but I could be wrong
Good enough I guess
Precise in the scope of ticks? 100%
Alright thanks.
Is there a better alternative for using real-world time? I probably don't need it, but it would be better if its easy to migrate to
(I accidently put in a slightly off number, makes a lot more sense now)
ok finally
Yes. Plenty. But syncing back to the main thread will always have a discrepancy of 0-50ms
Consistent or no?
No
Because you'll have to wait until the beginning of the next tick
And that amount of time won't always be the same
Oh its just until tick? Thats probably fine then
I would split the placement of each room into smaller pieces as well.
And Generate bedrock. The void can be quite cpu intensive to work with.
oh yeah lighting
How would I do that then?
Run timers on a seperate thread?
Use an Executor
Then you can schedule things in it and use CompletableFutures
Which are quite nice
Will it create a new thread each time?
oh really? thats counter intuitive to what i thought
also about splitting room placement
theyre structures
like the default mc ones
No
It literally says in the method
newSingleThreadScheduledExecutor
SingleThread
Oh...
I was wondering if the executor was on a single thread lol
Haven't worked with threads much if you cant tell
You should basically never work with Threads directly
Fair enough
You can also create a thread pool with 900 threads. But you can imagine how many the SingleThreadExecutor has..
Alright. Can you cancel these?
Probably about 6
Since 1.18.2 I think you can use ConfigurationSection#setComments or something
yea i did a poor job of explaining that
i mean i could handle block placement on my own... just seems like a huge hassle
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
Is that for bungee cord
?jd
Nope
Not much you can do then.
Dont place one structure per tick. Do one per second.
i jsut like the ease of filling the structures in the first place
Spigot I already done that a while it more spigot I’m confused about
fawe
Oh does ScheduledExecutorService just have a cancel method?
ive never had good things with fawe
always breaks
hmmm maybe i could copy paste nms structure code 🙊
and just do the workloads that way
Anything you schedule via the executor service will be a ScheduledFuture
Which you can then call cancel on later
mmm thanks
👍
Fur structs of this size we alone would work too.
But start with bigger delays between placements.
Spigot can kind of catch up some longer ticks if it has not much to do otherwise.
I've got a library that specifically has functionality for building structures across multiple ticks
It uses its own structure format though
declaration: package: redempt.redlib.multiblock, class: MultiBlockStructure
(which I added to structures by the waY! that was MY PR!!)
Which is mostly everything but not skull textures, chest contents and the like
Wait so I make 1 executor and then tell it to run multiple things?
well what does it save it as
A custom format
yea i need a way to serialize some data in there
I've done it before
It's not really designed for it though
I guess I could always rewrite it...
I've already done that several times though lol
yeah they brokey
how many millis do you reckon it takes to place a block
or nanos
@lost matrix maybe this is a suitable workaround?
uses volume to compute time
so im a little confused
im new to protocollib
this thing hasn't been updated in two years
does it still work?
?tas
protocollib just wraps nms packets
right but are the packetwrappers still valid
im just trying to understand how it all works
I created a basic tutorial
which explains the internals in a basic way
it says for 1.8
definitely not for later versions
actually latest update was for 1.15.2
its a very easy pattern
all it does is take the decompiled data from MC and make it easier to handle without NMS
you could look at the NMS yourself and figure it out too
ok
that makes more sense
@echo basalt ill check out your tutorial
i just want to use the vehicle steer packet 😭
that tutorial also doesnt use the mojang mappings
hello, you know when you type a command, you can press tab to complete it for you, for example in the arguments, you can press tab on player names? can we add our own options to it?
which i would recommend
also something extremely useful for figuring out packet data:
what's the name of that website where you can type in the nms name and it gives you the mojang name
pressing tab for it to complete for you is just a way of saying you're behind 1.13
im in 1.19 tho
pressing tab (or any character on 1.13+) sends a packet to the server asking for tab complete data
oh so there is an event for it?
to give the player more options other than just player names
you register a tab completer too
ah so its called tab completer okay, will look into it
i don't really know how it works though i have yet to use it
there's also that thing aikar made
was the vehicle steer packet moved/replaced
or is vehicle move the same as vehicle steer
omg did they replace vehicle steer with vehicle move in 1.19????
😭 😭 😭 😭
does anyone know how vehicle move works
incoming packet
and how i can use it to get wsad
it has 2 floats
one for left-right
the other for forward-backward
-1 is left, 1 is right
-1 is backwards, 1 is forwards iirc
this thing right?
it doesn't exist on latest wiki vg
and theres no packetplayinvehiclesteer on that website you sent me
PacketPlayInVehicleSteer is the nms obfuscated name
ok
but that's different
its not steer anymore
its move now
on wiki vg for today there's no vehicle steer packet
it's gone
there's a different vehicle move packet
it isn't the same!!!
instead of two input floats it just has a location and a rotation
did the vehicle code move from server to client??
please i feel like im going insane here
?tas
debug incoming packets
😭😭😭
one thing you need to be careful of
I don’t know how to do that!!
I’ve never messed with nms before
NOT the fields in the java file
Hm that’s true
you need to physically look at hte decompiled file for yourself
the data is then serialized into primitives and etc
and thats what wki.vg shows
@lost matrix it takes longer to generate bedrock-floor worlds btw so im not quite sure what you meant
Ok I looked at the packets fields
They’re different from before when it would give you two floats for steering a vehicle
Now the client just gives a new absolute position and rotation of the vehicle
I might just be stupid
Give me a sec here
Alright I’m kinda lost
Ok here’s my interpretation
There was always a Vehicle Move packet
This has always existed
There used to be a vehicle steer packet
There is no longer a vehicle steer packet
I can’t access my computer anymore tonight
So someone who has free time and computer access if you would be willing to look into this for me it would be majorly appreciated
Bump
OH MY GOD
They renamed it to Player Input Packet
That took you sent me earlier is super helpful
Oh this is so great
Do you just want to add a prefix or color?
So wait are mojang mappings now recommended over nms mappings?
I haven’t been doing spigot since like 1.15 things are a little different now
You mean over spigot mappings. And yes. There are no spigot mappings anymore.
Methods are now obfuscated a() b() c() etc.
https://www.spigotmc.org/threads/spigot-bungeecord-1-19.559742/
Scroll down to the "nms" section. It shows an example setup for the special sources maven plugin.
No I want to replace the text entirely
Specifically replace the username with a player’s in-game first and last name
LightEngineSky
Generate Bedrock as i told you
If you generate it at top and bottom layer then you should be fine
ok let see here
So rename the player
ok so
i need a bedrock layer at -64 and 319
which makes the air blocks in between...
How so
Also will that effect other aspects of the plugin
Like will the result of Bukkit.getOnlinePlayers change so that the players have a new name
brilliant
went from 50 seconds to 12 seconds
Nice
now i need to find a way to decrease the world generation time
do you reckon storing a preset bedrock world thing will help?
The tag above a players head is his actual name. If you want to change only the name tag without renaming the player then you need some trickery.
and just load that in whenever i need it?
Sure. But generating a bedrock chunk like that should take < 1ms
yea right now it takes around 10 seconds to generate the world
and then my portion is between4-6 seconds
So just want to confirm that there’s no way to access the vehicle steer without using nms
No vehicle steer event or anything?
Try VehilcelMoveEvent and VehicleUpdateEvent
Alright I’ll give them a look
Nope neither are really what I want
Alright I’ll use the packet then
Just wanted to double check
Not really...
Might be something that should become part of the spigot api at some point but idk where to even begin with something like that
@lost matrix I figured it out btw… storing stuff in nbt data. Only issue now is cancelling that mob from spawning and spawning my custom one instead
And carrying over the data
Well yes I only want to change the tag above the player
not the player’s actual name
Use CreatureSpawnEvent maybe ? 🤔
I am
The issue is copying the entity nbt data to the new entity
Isn't it LivingEntity#getPersistentDataContainer ?
Mh, feeling like you have to use NMS no ?
don't you have list for the bees that enters?
Ah yeah
can also store the pdc in a list or map and once it exits you can set it again
not sure if thats feasible in your case though
Found this
https://www.spigotmc.org/threads/set-entity-nbt.311186/
But as I thought, you have to use NMS ...
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
event.setCancelled(true);
}
Wait, here is the right link
https://www.spigotmc.org/threads/1-8-x-1-19-x-v7-18-3-maven-single-class-nbt-editor-for-items-skulls-mobs-and-tile-entities.269621/
Because you can't actually prevent the player from disconnecting.
why? that would be fun
😄
Forcing players to play on server
XD
What if he turns off his computer? 😂😂
😄
Stacktrace help
about that
you can send lot of packets
and crash user's pc
xD
thats illegall maybe
Player#sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut);
You are supposed to put values in the paramaters, not the paramaters
Like this
Player.sendTitle("Hi", "Hello there", 5, 10, 5);
🤦
np
Could not find bungeecord-chat-1.12-SNAPSHOT.jar (net.md-5:bungeecord-chat:1.12-SNAPSHOT:20200123.020804-1).
nice error
does anyone know this error?
i create new project but same error
Hi. Trying to find out easiest way to sum up how many iron ingots player smelts
bungeecord generally follows the same version as spigot
It can be triggered by furnace-take, doesnt matter
but... which event should I use?
I mean you could probably use scoreboards
hmm... like from vanilla? nah, I really want Java/Spigot solution here xD
Fair enough, just saying
There are 2 approaches:
- Store the player in the pdc of the furnace
- Use the click event when the player takes something out
yeh I want to make it simple and just use FurnaceExtract then
dont care about laser accuracy
imagine tracking the player that originally dropped the item
that went into a hopper
that went into a furnace
Simple just track the person that generated the chunk with that iron ore in it
and if the api just loads it, print the stacktrace and source it to the last player object created
perfection
Just track down the personal information of the server owner and blackmail him into writing down every smelted ore and giving rewards to the users
much simpler
we should make an api that blackmails server owners
then PR it into essentials or protocollib
That should be pretty easy now no? PDC is op.
the real fun is doing it without nbt
what if the player puts an item in a dropper
and then triggers a redstone signal
type thing
i have a question in bungee PostLoginEvent
will this e.getPlayer().getAddress().getHostString(); return me IP like 1.1.1.1?
?tas
but it should
click it
jumpscare
trying it takes time
i dont want to restart my server 19023821x times
bothering us takes our time as well
Ideally asking in here should be the last option
u can also not answer me
if you dont want
xd
Then you'd be wasting your own time
:vvv
-
Ideally, first you do basic research (if you're looking for a specific event, try your IDE's autocompleter or check javadocs)
-
Then, if it doesn't work, google it ("spigot whatever my problem is")
-
Then, if it doesn't work, check the source code of any project that might have faced a similar problem to yours
-
Then, if it doesn't work, ask us for help
And we'll just repeat the same steps
and maybe look into nms or the protocol
Huh
That's my R&D method for developing and it has had a huge success rate over the years
mans just wrote out my problem solving technique
I just wrote out the standard development technique
funnily enough thats how I solve other peoples issues on here
I look up "spigot insert issue here"
and copy paste the thread/answer
Except I replace the 4th solution with "dive deep into nms"
free social credit
hacks
Man was suffering with bee PDC loss whenever a bee entered the beehive
so I made him override NMS's save method
👍
The amount of stuff I learned just by looking at NMS is insane
specially after I setup mojmappings after dealing with obfuscated nms for 2 years
I never touch nms but I do enjoy looking around in it
I'm sure I could do more packet fuckery though
I've never used a packet before lol
I've done lots of packet fuckery and custom mob AI recently
these cows were fun to make
I eventually made the pentagram spin
damn thats cool
that was like 150 lines of nms
give them a helicopter
holy crap
the spinning pentagram made it funny
I also made OP skeletons that shot a lil faster
wtf are you a sadist
lol wtf I wanna know who wants that and why skeletons
there are like 20 other custom mobs
tell them that there tastes in skeleton modifcitions is shit thats nasty why skeletons are terrifying enough with there aimbot already
this is the sadist part
i have a problem with pdc
for some reason its not working
it won't get applied
i sout the item and there is nothing
i get it's data and its nothing
this channel was active like 1 minute ago
why its dead now
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
yeah bro so helpful
i just said whats not working
it won't get applied
and if you have 1% of a brain
you can understand my goal is to apply something!!!
?pdc
Thats all you get from me now
getSize
is that actual capacity?
It returns the number of slots
okay thanks
and how do I get the amount of items in an inventory?
is that getcontents?
size
Inventories are only limited in the amount of item slots they have
yeah im trying to add an auto pagination thing to my util
7smile you should go to bed
im adding it to additem
I can tell very well we have both been up all night
so the best approach would be to check the size, if it overloads then move the bottom row to a new inventory and get a back and forwards button in the old one
I have slept for 4h
Then my gf forced me to go grocery shopping and i have a D&D session in a few hours so i cant really sleep anymore 
we haven't touched grass, and definitely not a woman
Yes oops. I mean ugah buga im gonna turn out my lights and hack the government.
oh okay that seems more reasonable
should I get the full 10$ discord nitro to boost the server so I can spam hacker and crazy frog emotes
A true hacker would just post the emotes without paying money.

Not sure if worth 
oh free gets 50mb now
I got nitro classic
ohhh classic
everybody gangsta until the server limits emojis to nitro boosters
Free users can get 50mb upload if the server has a enough level.
you can get 100mb upload if the server has enough level
you can upload 100mb files here
that's like the whole shrek movie compressed really hard
brb imma go down the street and get some breakfast
haven't eaten in 14 hours
any way to get the size of inventory without it being in an event?
purely just with the Inventory
I thought Inventory#getSize() was a thing?
no it doesnt
^
its that one
getContents().size is amount of slots that have items in them
?paste
wait im dyslexic
getSize
uhm
InventoryView
how do I get inventoryview?
Inventory#getView#getTitle
okay
i just fat fingered that method so hard lol
You can no longer get the inventory title from the normal Inventory object.
oh
getview doesnt exist
It does under the InventoryClickEvent
i cant rely on an event for this
yeah in that case you need an object that holds the Inventory + its name
eg like a InventoryWrapper
ffs i cant type
sec
Also, I have a feeling, but don't compare inventory titles. Compare the instances themselves.
code review: https://paste.md-5.net/abilayocok.cs
ah so thats what its doing
is the code alright?
Do you not have a variable that you can modify?
Smth like
String inventoryName = "Page %pageNum%";
public void test() {
int page = 1;
Inventory inv = Bukkit.createInventory(null, 9 * 6, inventoryName.replace("pageNum", page));
}
I use this class to handle all my inventories, you can ignore most of the functional interface shit, essentially just variables and the constructor is important
Its essentially shadows code but put into production
I test libs like this locally ngl
A lot easier
too much of a pain to change code, commit, make tag for github and wait for its slow build servers to build my jar
Ik, i forgot to do that
Does anyone know if plugin.getLogger() is thread safe?
I think it should be, but knowing the complexity of log4j I'm not sure
I'm also interested in this answer ^^
is there anyway to listen if i place a block (its this red wool for example)
get the 5 block infront of it depending on player's yaw ? (like the blue one is)
of course
there are possibly multiple ways to go about this. one way is to get the placed block, depending on the player's yaw, get the block beside it on that direction ("relative to" it might be called?) and do that 4 times
You are looking for a simple direction
in blockPlace java Vector direction = event.getPlayer().getDirection(); direction.setPitch(90); Block target = event.getBlock().getLocation().add(direction.multiply(5)).getBlock();
it may be a pitch of 0 I forget
yeah its early 😉
is the restart.sh script run with sudo?
?paste for the love of god
I think you need more whitespace
It's 10am and I haven't slept
Idk who's more fucked up atm
Anyways a simple way I think of pitch
Is by thinking on a piano's pitch knob
It defaults at 0, increasing it will look up
Isn't pitch your left to right? And then yaw is your up and down?
i have errors pls help me https://paste.md-5.net/efozifivov.java
pitch is up/down
And descreasing it will look down
yaw is turning
Oh, then 90 pitch would make you look straight down.
There's also roll but we don't mention it
Think of roll as leaning your neck to the side
Attempting to crack it
does the restart script run with sudo permissions?
Which one of these is your pitch and yaw then? Cause -90 seems to be up.
I mean it's bash so most likely
Running java with sudo perms can be dangerous sometimes but it's your fault
Or is that under normal math context? Cause in game -90 points me straight up.
But I have. You are telling me it's wrong even though it's not. -.-
If your client says -90 then it's -90
Not arguing, just stating the obvious
Minecraft is weird sometimes
it will run with whatever permissions you use to initially start the server
Which event is called when player uses Destroy item in creative inventory?
Isn't it this event ? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryCreativeEvent.html
declaration: package: org.bukkit.event.inventory, class: InventoryCreativeEvent
Then depends on slot
Nah the destroy item button is fully client side
how to change world time from a thread? Exception in thread "Thread-110" java.lang.IllegalStateException: TimeSkipEvent may only be triggered synchronously.
Bukkit.runTask
can you give me example please?
thanks
how to now make pauses like sleep()?
How can i get a player from tab without vanishing him?
only options are hidePlayer or send a packet to all players
HashMap<Integer, Sheep> sheepTable = new HashMap<>();
for (Integer i = 0; i<5; i++) {
Sheep s = (Sheep) Sheepstack.this.world.spawnEntity(p.getLocation(), EntityType.SHEEP);
s.setGravity(false);
s.setAI(false);
s.setSilent(true);
s.setColor(Sheepstack.this.playerDyeColors.get(p.getUniqueId()));
sheepTable.put(i, s);
}
Sheepstack.this.playersSheep.put(p.getUniqueId(), sheepTable);
Sheepstack.this.playersSheep.get(UUID) will now point to the same memory location initialized on the first line right
sheepTable and playersSheep are not the same object
Why would I use BlockVector instead of Vector?
reading the docs, it says it floors the coordinates
so its just less precise?
or does it have advantages
what do you mean
I believe schmatics use them?
so its a copy?
You never showed your playersSheep so I can;t tell
but besides saving memory that uses double/floats over integers I really don't see the point of BlockVector could you give me usecases?
Cuz everything that works with blockvector should work with vector am i wrong? If so do you have an example
private HashMap<UUID, HashMap<Integer, Sheep>> playersSheep = new HashMap<>();
each Sheep is an entity so is unique
any Sheep in either Map will be the same Object
thanks
yay i made it, async time changing with pauses), every time i need change time, runTask() runs a new TimeSetTask() maybe this genius or im stupid
Hang on, you’re changing world time async?
yes
That just sounds like
A: Performance overhead
B: Using an async timer to run a sync timer which then does it
Or C: If it’s fully async and if you’re not caught by spigot, thread safety issues
this is work and this everything i need
Here's what I'm doing, and I'm struggling to find out whether I should use BlockVector, because at least for the second part of the algorithm the ray needs to be precise.
I have an entity at some coordinates x,y,z. My goal is to find out whether this entity is in the field of view of the player. (I will consider that the player is using the default fov on their client, which is 104.2° horizontal field of view.)
Therefore I determine the angle between two following vectors: the eloc=player.getEyeLocation().getDirection() and the **towardsEntity=Vector(**x-eloc.x, y-eloc.y, z-eloc.z) (which is basically the vector which direction is the line between player and entity)
I then only need to check whether the non oriented angle is less than 104.2/2=52.1°, and i also check that the entity is in the sphere of radius 30 blocks of the player.... Easy...
I then raytrace the towardsEntity vector to make sure there ain't any opaque block in the way
Everything works, BUT MY QUESTION IS: Should I use BlockVector for what's in bold? A part of me says yes cuz technically we are tracing the blocks that are in the way, and the entity itself coordinates is the coordinates of a block with integer coordinates, but at the same time, reading the docs of BlockVector it just states that its like Vector which coordinates are floored, so i feel like i'm losing in precision, and that could be very unfortunate if it considers there is an opaque block in the way whereas it was a neighbor block of the ray that was opaque, u know what i mean
^ no one?
No use vector as BlockVector is floored
but I dont want it as a plugin like a player doing the command
Random question, if ur in 1.19.1, report chat enabled, but a plugin takes care of cancelling every messages, and rebroadcasting (tellraw or whatever, or just player.sendMessage) to everyone the intercepted message, will it still be somehow reportable and readable by mojang/microsoft?
?paste
uh
Why tho 
im making a forge mod
some mod
is receiving a socket
from a backend
then souting it
and using it somewhere else
i wanna inject my own behaviour to it as wlel
so i thought maybe i can just listen to the sout
and i cant use setOut cuz it bugs out mixins for some reason
do u have an idea
then what do i do
lol
do i just listen for that socket the other mod is listening for
too
but it's so annoying
Listening to a sys out, especially for a mod, is a terrible idea lol
Pretty much
I'm confused, so you have another mod that uses channels and you want to listen to those channels?
I imagine there is. Doesn't mean you should though.
why are you using Integers instead of ints btw
isnt int and Integer same thing?
no
whats the difference?
Difference between an Integer and int in Java - A Java both int and Integer are used to store integer type data the major difference between both is type of int ...
it's not the cause of your problem, just wanted to mention because using for(Integer i = 0; ...) is weird
not using the bukkitscheduler :(
why is that a problem tho
Because you really shouldn't rely on reading system.out for information. I'm not saying it wouldn't work but especially with forge and the client-server relationship you have to be careful when doing it
just use the logger and add a handler to the logger
okay thanks for pointing it out
eventually yhe bukkits logger
Do you know what the cause is?
i wanna listen for all those ws clients' onTextMessage
do i just replicate what theyre doing
are u talking to me
if you are, then no im not using bukkit
yes
should I use int outside for loops too?
Wait it's forge and they're using WS
theres no reason to not use an int

?whereami
AND THEY'RE USING SYSTEM.OUT INSTEAD OF A LOGGER
14 yo?
uh
Why not just take their mod and make it better first
register listeners
thats for later
anyways
im not even familiar with sockets
so like
only reason to ever use an Integer instead of int is when you have to
so as long as using "int" throws no errors, use int
WebSocketFactory factory = new WebSocketFactory();
factory.setVerifyHostname(false);
factory.setSSLContext(NaiveSSLContext.getInstance("TLSv1.2"));
factory.setConnectionTimeout(10*1000);
this.socket = factory.createSocket(uri);
this.socket.addListener(this);
but can you use int in a map?
no, for generics you need Integers
Okay firstly websockets are a nono
Yeah, you can take their code and make it better
could the problem have something to do with me referencing the count instead of this.count?
bruh
it depends
you can have a class variable called count, and an argument called count
if yours is like that, i reccomend just changing the names
even with this no need to confuse yourself
so count/this.count doesnt really matter then since they both will referance the same thing
this is mainly a keyword to help developers out, so they know that the variables is tied to this class
but, can also excplicity tell a method body what variable to use at the same time
Will this return the item used in an interact event, or does that not count as using?
why not just get the item from interact event directly
it's complicated
in that case, likely not
it would return null on empty hands
or items that cant be used
like a stick
kk
aaagh, this is so confusing. I have absolutely no clue why my for loop is repeating itself
show code

you want the whole class?
just the for loop for now
?paste it
erm
how many times do you want it to repeat tho
it will repeat 5 times atm for each loop
its only supposed to spawn 1 sheep tower
of 5 sheep
in each tower
1 tower per player
screenshots are a big help
?paste
why even use a task timer tho
my eyes
this should just be something called once
yea
you will see
its a countdown
anyways does anyone know where the minecraft files are located
like code
or just game files
oh have no idea for that
i cant seem to find a gist or anything
yea
you can just use any
it isnt tied to a mc version i think
unless theyre doing some fuck shit
hm ok
i've seen gists for 1.11, 1.12, 1.14, 1.15.2 and 1.18
by random people
and the descrption is just 'minecrtaft default log4j2 as of <ver>'
so im not even sure
so why is your countdown handling spawning sheep?
cause I want to spawn sheep at the end of it
hm, whenever i try my own configuration the colors from my console are just gone completely. Only ANSI escapes work
the §4 or wahhteerv don't work
the § character seems to be completely gone
please do Map<>
i will say this
its not canceling the timer
so you got a mem leak
but, its not the cause
oh
IE something thats meant to be closed but wasnt and is still running
so it takes up system resources
and, typically its something that happens over an over
so eventually you end up with all these dead processing wasting resources until the server crashes
so use this.cancel() then return
isnt that what I did?
Sheepstack.this.gameLoop.runTaskTimer(Sheepstack.this, 0L, 1L);
this.cancel();
return;
see at the bottom of run
thats just a return guard
return guard :/
so, why not cancel in the guard
thats kind of the point
guard clauses should entirely stop the code in that scope
well
my idea is that it should handle the counting
until the countdown is at zero
then the sheep should spawn
ah
after the guard
i see
I thought it was good practice
Thats fine, sorry just hard to read large blocks of code all at once without an idea
Totally get that
"Sheepstack is now starting"
How many times is this broadcasted once?
the function is only running once
um
so thats not the problem
does anyone know what do i do
i fi wanna listen to System.out
.println
without System.setOut
unless im overlooking something really simple i dont see the issue
its all relatively fine to me
try a refactor
of the whole code?
just the method
split up your glass code and stuff
you should really have seperate classes for it
#startSheepstack?
yes that seems to be the method at hand causing issues
Hi does anyone know how to run two tasks in Gradle (Kotlin DSL) in order? So first a jar is built and after its built, its copied to where we want.
This doesn't run the tasks sequentially.
tasks.register<GradleBuild>("buildAndDeploy") {
dependsOn("shadowJar", "copyToServer")
}
yes and shorten code
Whenevr i have an issue i typically refactor and i find my issue that way, basically just restructure the method a few times
Also try i<=5
but that would just spawn 4 sheep?
well, you said its infinitley spawning sheep, so maybe the for loop conditions arent getting met
and thus making them inifinite
that would spawn 6 if i was set to 0
indeed, im bad at math
fixed it
lmfao
but, im out of ideas
I can make other methods inside the runnable right?
i guess you should just clean your code up and have proper methods for spawning your sheep
methods are only definable as class scopes
^
splitting code up while sounds daughnting helps debugging overall
Also makes readability so much better
you may think having the entire code block in one method is nice, and it is when you first get started but after a while it becomes a headache maintaining a wall of code
is coding without guard clauses, then adding them in afterwards even do anything?
i find it easier to read without
and then tidying up code afterwards
guard clauses are preferantial
wether you use explicit or implicit statements doesnt rly matter to much
however
heres is my evidence
as to why you should use guard clauses
case closed
yeahh lmfao
my code never looks like that
tbf in java it never does
thats js callback hell
but, java can have callbacks easily and run into same issue
especially with lambdas
i've been doing js xmlhttprequests for the past 3 days
i hate js
arrow syntax => yesyesy
whats this supposed to mean?
can I do Map x = new HashMap
yes with the generic stuff
Any additional constructor for a record must call the record's constructor to create an instance of it.
this(var, var...)
ah and this() must be the first call smh
So instead of doing this.location = thing, etc.. you call the constructor of the record
