Everything posted by 1Mangomaster1
-
Where can I properly put Block data outside of State Properties
Oh I know how they work but my question is... Do I just... put those things in the BlockEntity's variables regularly.. no special PropertyStuff or idek.. will that work? because putting a regular variable at the block make all blocks of that kind use it
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
Yeah last night I discovered how to do that, thank you!
-
Where can I properly put Block data outside of State Properties
Of course the easiest and most reliable solution are the properties... but there's a limit to how much you can put.. I have a "channel" IntProperty which ranges from 0 to maxChannels(currently a 100), now.. it can run but increasing that number(or adding other properties that multiply with it) can cause it not to run(happened already) my question is: Where else can I store this kind of data? I heard of the option of in the BlockEntity... but how may that be done? and should I do it at all or perhaps there's a better option?
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
Also, Assuming I send nothing in there.. Yeah I can get the container.. but not the screen, what it means is I have no way of telling those values I mentioned above(enum and int) as they are the ones defined in the EditBox and Button... (also the reason in the last post you see me do Integer.parseInt() without check is because the EditBox filter is designed to only allow numbers in)
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
Then how can I get the BlockPos, the enum and the int if not by passing them, after all, they can be mimiced too... Not that in this case it matters all that much... it just changes the functionality of a redstone component block I make... so someone could change them remotely with a hacked client... Still you're right tho and it is a healthier practice, but currently it looks like this: private void applyChanges() { WirelessBlockEntity blockEntity = menu.blockEntity(); BlockPos pos = blockEntity.getBlockPos(); PacketHandler.CHANNEL.sendToServer(new WirelessUpdatePacket(pos, bu_transmissionKind.current(), Integer.parseInt(eb_channel.getValue()))); } How can I pass those values in a different way? (The packet is actually sent not when the button is clicked, but when you GUI is closed, the reason for that is to not just send a lot of unused stuff if the button is spammed, but rather change the values only when they're relavent, which is when I stop editing them(closing the GUI)
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
Wdym validate it? You mean checking if the types match? I do Basically I have a block that opens a GUI when you click it, in it there are EditBoxes and Buttons to change some block properties, so when you apply those changes I want the server to make the changes not the client, so I have to send it(Screen is on Client)
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
I've instead decided to go smaller and make a specific packet for the specific change I want, instead of a general BlockState change, which let me only receive a BlockPos, an Enum and an Integer, making it super easy, thank you!
-
Furnace Recipes that require more than one input item
I was afraid so... thank you
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
I have the Level... I jsut can't read/write it into/from the FriendlyByteBuf so I can't do the encode and decode for the packet. FriendlyByteBuf has stuff like readBlockPos() and stuff but it doesn't have stuff like readLevel()... then how do I encode and decode it? (same applies to BlockState).. I thought I'd make something like private Level world; private BlockPos pos; private BlockState state; public ServerboundBlockUpdatePacket(Level world, BlockPos pos, BlockState state) { this.world = world; this.pos = pos; this.state = state; } but I can't decode and encode both Level and BlockState.. EDIT: wait by that do you mean I do not need to pass the world(?)
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
I've been looking into it and... in order to change a state I need to get a world(Level).. however in the FriendlyByteBuf there's no readLevel() or readWorld().... what do I do?
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
Wait Screen is only on Client?? OOF And if so where should I handle it? How can I ensure a code will run from the server when I click a button?
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
On the screen, on a method called applyChanges() that is called on onClose() (overriding it) private void applyChanges() { RedstoneTransmitterBlockEntity blockEntity = menu.blockEntity(); Level world = blockEntity.getLevel(); BlockState state = blockEntity.getBlockState(); RedstoneTransmitterBlock block = (RedstoneTransmitterBlock)state.getBlock(); int newChannel = Integer.parseInt(eb_channel.getValue()); if (block.channel() != newChannel) { block.channel(newChannel); System.out.println("Changed channel to " + newChannel); } TransmissionKind currentTransmissionKind = state.getValue(RedstoneTransmitterBlock.TRANSMISSION_KIND); TransmissionKind newTransmissionKind = bu_transmissionKind.current(); if (currentTransmissionKind != newTransmissionKind) { System.out.println("Getting Block Pos"); BlockPos pos = blockEntity.getBlockPos(); System.out.println("Setting state"); BlockState nState = state.setValue(RedstoneTransmitterBlock.TRANSMISSION_KIND, newTransmissionKind); System.out.println("Applying to world"); world.setBlock(pos, nState, 2); System.out.println("Changed tranmission kind to " + newTransmissionKind); } } private void setChannelVisibility() { TransmissionKind current = bu_transmissionKind.current(); boolean showChannel = current == TransmissionKind.BROADCAST; eb_channel.active = showChannel; eb_channel.visible = showChannel; } @Override public void onClose() { if (bu_transmissionKind.current() == TransmissionKind.BROADCAST && eb_channel.getValue().isBlank()) return; applyChanges(); super.onClose(); }
-
Furnace Recipes that require more than one input item
I wanna ask if it is possible to ask for more than one of an item to make a furnace recipe. for example: if I could smelt(random blocks for exmaple sake) 4 glass into 1 stone. The idea is that it'll take stuff in groups of 4(or whatever else inputted) and not 1 to 1.. is it possible? if so how to do it? if not, how can I get something similar?
-
Level.setBlock(BlockPos, BlockState, int) causes major lag(sometimes...)
I made a screen and a container and all of that when right clicking a block, it works just fine. There's a button there I customly made called EnumButton, it gets an enum and whenever you click it it cycles between the values, that works alright. I also have an apply button that takes the currently selected value in that enum and sets the block's state to it(this block has an EnumProperty of that specific enum, I get the block by using menu.getBlockEntity().getBlockState().getBlock()) All iis working alright.. The enum has two values: BROADCAST, and TARGETED. When switching from BROADCAST to TARGETED there's 0 lag... However when switching from TARGETED to BROADCAST there's a good few seconds of unexplained lag... I divded the Level.setBlock() code to see where it happens, and it happens in the setBlock() itself: System.out.println("Getting Block Pos"); BlockPos pos = blockEntity.getBlockPos(); System.out.println("Setting state"); BlockState nState = state.setValue(RedstoneTransmitterBlock.TRANSMISSION_KIND, newTransmissionKind); System.out.println("Applying to world"); world.setBlock(pos, nState, 2); System.out.println("Changed tranmission kind to " + newTransmissionKind); Only the last print is delayed when switching from TARGETED to BROADCAST, otherwise no delay... Why would it happen and how can I fix it?? EDIT: This whole code posted here happens only if the current state is different than the button's selected state, so no worries there
-
Change EntityPlaceEvent position
I suspected soo.. I'll have to mess around with the JSON of it to understand how it works there, because I've never really done it for this kinda of thing, but I think I have an idea of how it works.. I'll update soon, thank you! Tho... how do I manage the VoxelShape here... each part of the top and bottom has a different shape(smaller than a single block).. how do I properly have each section its own shape?
-
Change EntityPlaceEvent position
I actually looked at the DoorBlock and I didn't quite get it... I expected an override on onPlace() or something to place the lower/upper pieces.. but I didn't see it
-
Change EntityPlaceEvent position
I've seen models who are larger than a single block.. how do they work??? (Or, perhaps, how do I make a 2-block structure work(like a door or a bed)
-
Change EntityPlaceEvent position
I have a block that is 1.5 blocks tall(by model and VoxelShape), and I want to prevent users from placing a block directly above it, as it will intersect with the block making it look really weird... So what I did is listen to RightClickEvent and cancel it if the block that will be placed by it(EntityPlaceEvent is only server side thus cancelling it still lets it happen on the client so the block is seen placed). However, I want it to automatically place a block above that block(where it doesn't interfare), I already managed to use Level.setBlock(BlockPos, BlockState, int) but this doesn't use sounds or particles or anything.. I tried using EventBus.Post on a RightClickEvent on the right block.. it did nothing.... I also wanted to try on EntityPlaceEvent but it requires a BlockSnapshot which idk how to obtain... What do I do?? My end goal is to place the block naturally(sound, particles, everything, also take one off the stack if not creative) just.. only block above my one and a half blocks tall block
IPS spam blocked by CleanTalk.