Jump to content

perromercenary00

Members
  • Posts

    825
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by perromercenary00

  1. thast right kapenjoe says something about not going up from 1.20.2 for some package issue i have the mine working messing around until the code start working still seems like you have some more complex than the mine //in mi main class //########## ########## ########## ########## ########## ########## ########## ########## private void commonSetup(final FMLCommonSetupEvent event) { ModMessage.register(); } ModMessage.class
  2. i has that anyway i test it at the beginning and the end of the function just to be sure @Override public void load( CompoundTag nbt ){ super.load( nbt ); Level warudo = this.getLevel(); itemhandler.deserializeNBT( nbt.getCompound("itemhandler") ); this.progress = nbt.getInt("progress" ); System.out.println("load(nbt)"); System.out.println(NbtUtils.prettyPrint(nbt)); //super.load( nbt ); } but it does the same looking at it a second time it seems like it only store the nbt data when the entity is created and set into the world then never update values
  3. hola thanks for answering i set some system outs to test and see whats going on @Override protected void saveAdditional( CompoundTag nbt ){ nbt.put("itemhandler", itemhandler.serializeNBT() ); nbt.putInt("progress", this.progress ); System.out.println("saveAdditional(nbt)"); System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats getting saved super.saveAdditional( nbt ); } @Override public void load( CompoundTag nbt ){ itemhandler.deserializeNBT( nbt.getCompound("itemhandler") ); this.progress = nbt.getInt("progress" ); System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats minecraft is giving back to the entity System.out.println("load(nbt)"); super.load( nbt ); } This dead adventurer body has two parts a block and a block Item both has their own item-handlers and their own menus all of that seems fine Testing remarks : *when i change some element inside the gui it triggers the saveAdditional(nbt) system out and shows a pretty print of the data being saved *when the world map loads it triggers the load(nbt) system out and shows a pretty print of the data minecraft is giving to this Block Entity For the testing i gonna set mi BlockEntityBodyBlock, save something in it, close minecraft, fireup the game again and check if the items remain ################ first try set the block entity (dead adventurer body like shaped) and left only a weath seed in the slot 10 the console says its all right close minecraft, launch it again i see the system out whit the data returned to the entity and its look good theres is only a weed seed ################ Second try, now i gonna change the seed for two arrows the console says its all right the two arrows are being saved ######### Now close and run again bam Error minecraft returns the original data whit only a wheat seed the two arrows has been loss ########## try again now i gonna put 3 wheat seeds Console system out says it gets it and is saving the data ############## but after close fire again wheat seed, data losed once more time and it just throw the original ####################################################################################### sorry for the long post and the crappy video this is the reason why i say its saving the Block Entity data only when it feels like coze its saves data when it feels like ¿ its something wrong whit mi BlockEntity.saveAdditional() if i keep trying eventually it updates and the data chages i alredy try to level.removeBlockEntity(pos); level.setBlockEntity(pos, bebb); BlockEntityBodyBlock.class BlockEntityInit.class body_blockitem.class
  4. well The problem is the data in mi blockentity, its not being saved when i close the game i put items on it i retrive items from it all just seems good, the problem cames until i close minecraft then when i reload the word i have an older version of the items saved or just an empty briefcase normally when you declare an entity or a block entity or an item capability, forge automatically keeps track of changes and save the data in nbt format all of this by itself in this moments i have some items whit capabilities, those work right i have entities , those also works right but all of mi blockentities all of them are storages briefcase and all of them fails, save the data sometimes most of the time don't well i have only like 3 blockentities up now
  5. im stuck in a problem whit BlockEntities i cannot solve so im trying to work around it but in the less complex way possible i think is posible to store data to the minecraft world in older versions people talk about WordDataSave i dont find anything about it for 1.20.4 i find a tutorial for player capability in 1.19 here is an event //########## ########## ########## ########## @SubscribeEvent public static void onAttachCapabilitiesPlayer(AttachCapabilitiesEvent<Entity> event) { if(event.getObject() instanceof Player) { if(!event.getObject().getCapability(PlayerThirstProvider.PLAYER_THIRST).isPresent()) { event.addCapability(new ResourceLocation(mercmod.MOD_ID, "properties"), new PlayerThirstProvider()); } } } soo i made this //########## ########## ########## ########## @SubscribeEvent public static void onAttachCapabilitiesLevel(AttachCapabilitiesEvent<Level> event) { } i think i can do some witchcraft here but is many things don't understand to start whit i dont get yet how to recall the saved data from a BlockEntity the handler still in progress the plan is to make a Map to store nbt data using the block coordinates as index later store that map as a big nbt ########## any way the question is if theres alredy a tutorial for 1.20.4 for this ?? or some alredy working code from someone else doing something similar ?
  6. looking around for the capabilities thing i found a piece of code and find this piece of code //########## ########## ########## ########## @SubscribeEvent public static void addCustomTrades(VillagerTradesEvent event) { if(event.getType() == VillagerProfession.FLETCHER) { System.out.println("\n\n### VillagerProfession.FLETCHER \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.ARROW_STEEL.get(), 16); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,1,3,0.02F)); } if(event.getType() == VillagerProfession.TOOLSMITH) { System.out.println("\n\n### VillagerProfession.TOOLSMITH \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.INGOT_STEEL.get(), 1); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,10,8,0.02F)); } } //########## ########## ########## ########## the event is aknoledge and execute when the maps load ### VillagerProfession.FLETCHER ### VillagerProfession.TOOLSMITH //########## But is not working is a random piece of code is not working could it be than this code is old 1.18 and no valid anymore for 1.20.4 or the thing are this numbers stack,10,8,0.02F)); i dont know what this numbers means ########## the question is ¿how to add things to the villager traders thanks for your attention
  7. I have problems whit mi blockEntities they just save data only when it feels like I just retake he topic after several weeks i know it not the menu nor the packages system was thinking something xtreame like make the block entities to read write the data as .nbt text files just coze i can but think don't worts the effort ################# mi question is if theres a way to espose and directly messup whit the minecraft nbt database system ?? like SELECT nbt FROM miwarudo WHERE x='127' and y='80' and z='-3627' or something whit CompoundTag worldnbt = warudo.getLevelData().something; ?? CompoundTag blockentitynbt = worldnbt.getDataAt(x,y,z) ??
  8. make your item spawns the minecrafts extructure block at the desire position gets the block entity from that block and use the block entity to load and spawns the extructure
  9. the log says your "is missing mods.toml file" check your toml file on "/src/main/resources/META-INF/mods.toml"
  10. sound like thing for arrow loose event @SubscribeEvent public static void ArrowLoose(ArrowLooseEvent event) { System.out.println("\n\n\n### ArrowLoose "); Player shooter = event.getEntity(); String sshooter = (shooter != null)? shooter.getDisplayName().getString() : "null"; ItemStack bow = event.getBow(); if( bow != null ){ bow.enchant( Enchantments.FLAMING_ARROWS, 3 ); System.out.println("### by " + sshooter ); System.out.println("### whit " + bow.getDisplayName().getString() ); } } this ones fires up before the arrow is released and for some reason dont works whit mi custom bows
  11. looks like this is the error "0": "blocks/tea", probably must looks something like this "0": "examplemod:block/tea",
  12. not a bug you have something wrong int the json files, the blockstate the block or the model of the block has some error
  13. good days this is a kind of cursed block intended to to be set in some dungeons and give lot as a chest The problem is it saves the items only when it feels like the gold and the emeralds just get loss after reload the world the block entity just goes back to the last saved state data the one whit the carbono armor item in the chest slot i made some experiments i made a custome itemhandler whit system outs to see whats happening the important part is this here this system out must only print when a change afects the itemhandler in the server side and here i manually force the block entity to save that custom itemhandler to the Block entity nbt and then save the BlockEnt to the world // ########## ########## ########## ########## public void save() { if (this.container == null) { System.out.println("\n#this.container is Null at save()#\n"); } if (this.container != null) { Level warudo = this.container.getLevel(); if(!warudo.isClientSide()) { System.out.println("\n#this.container is saving()#\n"); CompoundTag nbt = this.container.serializeNBT(); nbt.put("inventory", this.serializeNBT()); this.container.load(nbt); warudo.setBlockEntity(this.container); } return; } //this.container.saveAdditional( this.serializeNBT() ); } in the console i see this every time i take or move some item from the gui #this.container is saving()# #this.container is saving()# #this.container is saving()# #this.container is saving()# #this.container is saving()# #################################################### this means the menu is working and sending the changes to the server side but this blockentity nbt data is not getting save to the world warudo.setBlockEntity(this.container); is doing nothing i have more block entities and those entities has the same problem i just no notice it until know my guest is coze this happends before in 1.19 and that time whats coze i dont register the blockentities to the bus but this time im doing it the thing is that i think this is not valid for 1.20.4 coze i get it from a 1.20.1 tutorial an probably the way of declaring it has change again public static final RegistryObject<BlockEntityType<BlockEntityBodyBlock>> BLOCKENTITYMOBBLOCK = BLOCK_ENTITIES.register( "blockentitymobblock", () -> BlockEntityType.Builder.of( BlockEntityBodyBlock::new, BlockInit.DEAD_BODY.get() ).build(null) ); ############################################################################################ what i think i need is an example a working code gits whit block entities register soo i could fix the mines according to 1.20.4 thanks for reading the long post
  14. Good days advancing whit the problem from a post a made short ago and dint find anyway anyway i want to give the player a briefcase whit random stuff when play a new world for the first time i made this this event triggers once the world map finish loading but before the players and the entities get loaded into the world an from it i can get a block position close to the player random spawn point and do it every time yo play the world this block position returned is always the same and is no the same as the bonus chest ###WorldInit### New World warudo false, => BlockPos{x=0, y=54, z=0} lista 0 //<-- no players yet ###WorldInit### - first problem there's no player yet when triggered - second one it triggers every time you star the game and loads the world so it keeps creating again the glow stone block those giving the briefcase again ############## i was thinking into also spawn a black wool block at the block position but at y -63 soo every time its fires check if its a black wool block at -63 this way knows if its the first time or not the other think would be not create directly the briefcase but some block whit logic to tick() 5 seconds later when i suppose the players already loaded and then create the briefcase in front of the player ########## ########## ########## ########## someone knows about another event that trigger only once when the world is loaded and the players already inside the world ? way i dont have to made complicated stuff like this to make something like that thanks for your attention
  15. may you are talking about catching all the AGE declaration even the ones from other mods custom properties ? one would be to check only againts the minecraft BlockStateProperties class the other would be dirt your hands on the nbt data of the block and check if it have a string whit same name // ########## public String print() { BlockState blkstate = this.getBlockState(); String json = ""; //int id = Block.getId(blkstate); String propiedades = ""; for (Property<?> porp : blkstate.getProperties()) { System.out.println(porp.getName() + " -> " + blkstate.getValue(porp)); propiedades += String.format( ",\"%1$s\":\"%2$s\"", porp.getName(), blkstate.getValue(porp) ); } json = String.format("{\"blockname\":\"%1$s\",\"x\":\"%2$s\",\"y\":\"%3$s\",\"z\":\"%4$s\"%5$s}", this.get_blkfullname(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), propiedades ); //System.out.println("\n" + json + "\n" ); return json; }
  16. good days in the chicken it does areference to an entity place event triggering when chicken lays an egg if (!this.level().isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.spawnAtLocation(Items.EGG); this.gameEvent(GameEvent.ENTITY_PLACE); this.eggTime = this.random.nextInt(6000) + 6000; } followin the trail it takes to a GameEvent class that just register events and dont works for suscribing events internally must be register under other name i was searching the events tree on net.minecraftforge.event but no avail @SubscribeEvent public static void entityPlace(GameEvent event) { } ------- wheres the event when a chiken layes an egg ??
  17. could it be something whit the SmiffleModConfig.ENABLE_POLAR_BEAR_MEAT.get() or could be coze onLivingDeathEvent has two entities @SubscribeEvent public static void onLivingDeathEvent(LivingDeathEvent event) { Level level = event.getEntity().level(); Entity target = event.getEntity(); Entity entity = event.getSource().getEntity(); if(!level.isClientSide() && target != null && entity != null ){ System.out.println("onLivingDeathEvent(" + entity.getDisplayName().getString() + ", " + target.getDisplayName().getString() + ")"); BlockPos pos = entity.blockPosition(); Villager['Butcher'/47, l='ServerLevel[New World]', x=41.51, y=72.00, z=84.30] died, message: 'Butcher was slain by Zombie' onLivingDeathEvent(Zombie, Butcher)
  18. good days still working on the briefcases now i want to save/read inventory presets from tangible nbt files i have and old class i use to read and write nbts for structures and wanna dust out step by step goes to here return NbtIo.readCompressed(rs.get().open() );// <-- this is the error the thing is NbtIo.readCompressed now demands a second parameter from the class NbtAccounter and that seems like a kind of limiter for the nbt file size i dont get what the numbers are for is good if i just made an NbtAccounter.unlimitedHeap() and call it a day //or this piece of code gonna blowsdown something further in the way return NbtIo.readCompressed(rs.get().open(), NbtAccounter.unlimitedHeap() );// <-- this is the error can someone point me a git hub where they use this or du something similar ?
  19. if wanna do some custome blocks and items you dont need to create a parallel texture atlas you just made some json files and left that atlas part to forge to manage are you trying to do something especial ?
  20. this was the code used in older versions @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if(!event.getPlayer().hasPlayedBefore()) { event.getPlayer().sendMessage("Hi!"); } } dont works for moddern versions what could be the equivalent in 20.4 ??
  21. Im trying to get a way to set a custome briefcase next to the player similar to the Bonus chest Digging on the code i found this two events @SubscribeEvent public static void onPlayerRespawn( PlayerEvent.PlayerRespawnEvent event) { Player pe = event.getEntity(); Level warudo = pe.level(); System.out.println("\n\n\n #### player has respawn " + ", " + warudo.isClientSide() + "\n\n\n" ); //PlayerEvent$Clone } @SubscribeEvent public static void onPlayerStarAWorld( LevelEvent.CreateSpawnPosition event) { //Player pe = event.getEntity; <--- dont exists in LevelEvent Level warudo = (Level)event.getLevel(); ServerLevelData settings = event.getSettings(); //ServerPlayer player = Minecraft.getInstance().player;<--- this crash the game PlayerEntity is null //player.position() //player.getRespawnPosition() System.out.println("\n\n\n #### onPlayerStarAWorld " + ", " + warudo.isClientSide() + ", " + "\n\n\n" ); //PlayerEvent$Clone } CreateSpawnPosition seems like he way to go but i cannot find a way extract a block position from it nor the player to then know wheres the player ################################# what i want is to get the player from this event soo i can know where it is and spawns a briefcase next to it or maybe another event that could do the same
  22. Good days I finnaly manage to fix and get a working gui from BlockItem and from BlockEntity the next issues i have to fix is this the block Entity model for some reason is moved to the south west this briefcase model must be centered but is moved to a side, i have nothing weird in the code but this is happening // ########## ########## ########## ########## @Override public RenderShape getRenderShape(BlockState blkstate) { return RenderShape.MODEL; } the block model is out of place However The hitBox of the block is right in place ########################################################################################################### This next issue Mi gui also adds the 5 slots from the player equipment the thing is theres no filter to determine whats can be put in an armor slot and what not i have this method that draws the slots for the armor, the part i dont get i slike wheres the code that responds when you set an item in a item slot to do checks and allow the item to be set or not //########## ########## ########## //Draw Player Armor private void addPlayerArmorSlots(Inventory playerInventory) { // 36 this.addSlot(new Slot(playerInventory, 39, 8, 8)); this.addSlot(new Slot(playerInventory, 38, 8, 26)); this.addSlot(new Slot(playerInventory, 37, 8, 44)); this.addSlot(new Slot(playerInventory, 36, 8, 62)); this.addSlot(new Slot(playerInventory, 40, 26, 53)); } theres must be a method that triggers when you set a itemstack inside an slot and allows to do a check if its a valid item for that slot
  23. ya i got i miss the client side thing // ########## ########## ########## @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { shield_carbon_Item.make_shield_shield( ItemInit.SHIELD_CARBON.get() ); bow_item.make_bow_bow( ItemInit.BOW_CARBON.get() ); bow_item.make_bow_bow( ItemInit.CROSSBOW_CARBON.get() ); bow_item.make_bow_bow( ItemInit.CROSSBOW01_CARBON.get() ); solution_redstone_item.make_solution_shake( ItemInit.SOLUTION_REDSTONE.get() ); briefcase_blockitem.make_briefcase_briefcase( BlockInit.BRIEFCASE_BLOCK.get().asItem() ); MenuScreens.register(MenuInit.GEM_POLISHING_MENU.get(), GemPolishingStationScreen::new); now the next part make a itemblock and open the gui from It
  24. !warudo.isClientSide() still not a gui not an error just a simple message [06:44:39] [Render thread/WARN] [minecraft/MenuScreens]: Failed to create screen for menu type: mercmod:gem_polishing_menu Not a hint of what the problem is this silent simple error dont tell much about the problem the code i made don't show errors highlighted in mi old code 1.19.4 i launch the menu part from client side but now i recheck the video and kapenjoe does it server side
  25. good days i get this error: java.lang.ClassCastException: class net.minecraft.client.player.LocalPlayer cannot be cast to class net.minecraftforge.common.extensions.IForgeServerPlayer (net.minecraft.client.player.LocalPlayer is in module [email protected] of loader 'TRANSFORMER' @3e8b3b79; net.minecraftforge.common.extensions.IForgeServerPlayer is in module [email protected] of loader 'TRANSFORMER' @3e8b3b79) at mercmod.blocks.classes.panel_whit_entity_inside.use(panel_whit_entity_inside.java:576) ~[main/:?] {re:classloading} at net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.use(BlockBehaviour.java:826) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading} at net.minecraft.client.multiplayer.MultiPlayerGameMode.performUseItemOn(MultiPlayerGameMode.java:324) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.multiplayer.MultiPlayerGameMode.lambda$useItemOn$4(MultiPlayerGameMode.java:292) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.multiplayer.MultiPlayerGameMode.startPrediction(MultiPlayerGameMode.java:251) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.multiplayer.MultiPlayerGameMode.useItemOn(MultiPlayerGameMode.java:291) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.startUseItem(Minecraft.java:1799) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.handleKeybinds(Minecraft.java:2083) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.tick(Minecraft.java:1902) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runTick(Minecraft.java:1216) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:801) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:234) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} ------------------------------------------------------------------------------------------------------------------ context: im updating the briefcase from mi mod an i need to make a gui whit this image that gonna be launched from a block and from a item soo im using kapenjoe tutorials ---------------------------------------------------------------------------------------- The problem is that tutorial is for 1.20.1 and im using 1.20.4 and i really dont get how to call and open the gui from the block nor from the item i made this based on post i made short ago everything seems find but when right click the block to open the gui it crash the game @Override public InteractionResult use(BlockState blkstate, Level warudo, BlockPos pos, Player pe, InteractionHand hand, BlockHitResult hitresult) { if(warudo.isClientSide()){ BlockEntity blkentity = warudo.getBlockEntity(pos); if(blkentity instanceof Panel_BlockEntity){ // ↓↓↓ open the menu from the block IForgeServerPlayer ifpe = (IForgeServerPlayer)pe; //<--- this is wrong "class net.minecraft.client.player.LocalPlayer cannot be cast to class net.minecraftforge.common.extensions.IForgeServerPlayer" ifpe.openMenu( (Panel_BlockEntity) blkentity, pos ); //<-- i need an example of how open a gui in 1.20.4 } } return InteractionResult.sidedSuccess(warudo.isClientSide()); } Theres nothing highlighted in red in the code like everything where right an possible but dont works ####################################################################################################### i need to see an example, just the piece of code for the use() method of the block whit the block entity for 1.20.4 and the same but for the item @Override public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level warudo, @NotNull Player pe, @NotNull InteractionHand interactionHand) { if (!warudo.isClientSide()) { ItemStack heldItem = pe.getItemInHand(interactionHand); if (heldItem.getCapability(ForgeCapabilities.ITEM_HANDLER).isPresent()) { // ↓↓↓ open the menu from the item NetworkHooks.openScreen((ServerPlayer) pe, this); } } return super.use(warudo, pe, interactionHand); } thanks for your attention
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.