Jump to content

perromercenary00

Members
  • Posts

    813
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by perromercenary00

  1. 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
  2. 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
  3. 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; }
  4. 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 ??
  5. 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)
  6. 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 ?
  7. 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 ?
  8. 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 ??
  9. 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
  10. 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
  11. 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
  12. !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
  13. 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 minecraft@1.20.4 of loader 'TRANSFORMER' @3e8b3b79; net.minecraftforge.common.extensions.IForgeServerPlayer is in module forge@49.0.26 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
  14. good days i have some small questions and i prefer to make only one post i wanna give the player a briefcase after creating a new world and enter for first time to it i guest that's an event for that, what it is this event? and the same but when players get killed (if possible only if killed by mobs) is an event that triggers after the player respawn ?? the recipe book the book don't shows custom item recipes until player craft them at least one time ¿ is posible to set some of mi items recipes to be visible in the book even if never crafted before ? Villager trades i wanna add some things to some villager trades in this case mi custom bow and arrow how i do that ? thanks foir your time
  15. sorry for the stuborn ness ss test code logs and planks return nothing on minable but i can use the other tags name minecraft:oak_log BlockTags.LOGS name minecraft:oak_planks BlockTags.PLANKS it kinda works but its not like like perfect
  16. i have it as a class in the main mod folder but dont seems to matter whats is the location /home/usuario/workspace/1.20.4/mercmod/src/main/java/mercmod/ColorHandler.java "src/main/java/mercmod/ColorHandler.java" i can not get the item color part to work this is mi grass slab As block when placed it takes the corresponding bioma grass color its fine as item in the inventory or the hotbar and as entityItem dont takes the color is just gray
  17. im following this case coze removing the material class from the code fucks up mi items that depends on it i need to find a replacement for the Material class this is an old item from back 1.8 when turn on hold right click it checks the target block and if its made of wood it changes to cutting animation Material pmat = blkstate.getMaterial(); if (pmat == Material.WOOD){ //then cut it down } this other one checks for dirt or stone its no supposed to work on metal or wood what i could use ?
  18. ya ya i get it boolean find = false; int count = 0; BlockState dblkstate; BlockPos bpos = null; BlockPos dpos = null; for(BlockPos cursor : todos_los_blockes ){ dpos = cursor; target.particle(cursor.getCenter()); dblkstate = warudo.getBlockState(cursor); if( !dblkstate.canBeReplaced() ){ //<---------- //if( dblkstate .getBlock() instanceof tubo ){ find = true; break; } bpos = cursor; count ++; } for this case setting blocks i can know discrimaniting by the canbereplaced tag thanks
  19. can we have a example of that for item inever could make it work for item for blocks i got this
  20. at the use method of the block you must check if the block above or below is a furnace whit the same facing // ########## ########## ########## ########## // On right click @Override public InteractionResult use(BlockState blkstate, Level warudo, BlockPos pos, Player pe, InteractionHand hand, BlockHitResult hit) { //System.out.println("use()"); ItemStack helditem = pe.getItemInHand(hand); int age = blkstate.getValue(AGE); if( !warudo.isClientSide() ){ BlockState blockabove = warudo.getBlockState( pos.above() ); BlockState blockbelow = warudo.getBlockState( pos.below() ); //stuff //stuff //stuff
  21. Good dais this is it i wanna update the briefcase from mi mod this class "NetworkHooks" is resposible for open the screen this class don't exist anymore in 1.20.4 or it is in another place and/or whit another name i check kapenjou tutorials an hes using this same class same place but hes using 1.20.1 so something change from 1.20.1 to 1.20.4 or mi setup is missing something ----------------------------------------------------------------------------------------- thanks for your reading ¿ i need to find if the class was dropped now what replace it ¿ or if it change of location where it is know ¿ or confirm mi setup is lacking or wrong i have intellij 2023.1.1 comunity whit forge-1.20.4-49.0.26-mdk
  22. no thats not // ########## ########## ########## ########## @Override public boolean canBeReplaced(BlockState p_56373_, BlockPlaceContext p_56374_) { return false; } this is the check to select if wanna reset the block or put another on top of the block i need something to know what is a block made of
  23. the removing of the Material class has mess up bad mi code now have to many broken things after updating mi code to 1.20.4 this are mi pipes they conect each others but to have it right i have to made a custome BlockItem the thing its that i need to check the block im looking at if its some something like grass or wheat i need to ignore and replace whit mi pipe block but if its something like leaves then it must respect it and set the pipe above or at the side in x < 1.9just check the material the target block is made of in 1.20 cannot be done like this soo i was trying to make a list of solid blocks but is much work and also it don't have in account blocks from other mods
  24. could it be by making a custome block whit no hitbox or by a falling block entity // ########## ########## ########## public FallingBlockEntity create_FallingBlock(BlockPos cursor){ this.fallingblock = FallingBlockEntity.fall(warudo, cursor, this.getBlockState() ); this.fallingblock.setNoGravity(true); warudo.addFreshEntity(this.fallingblock); return this.fallingblock; }
  25. in 1.19 i notice that an have to fix by hand in 1.20.4 this is not a problem anymore but 1.20 has its own set of new problems // ########## ########## ########## ########## // lista de entidades atravezadas por la linea entre vi y vh|vo public ArrayList<LivingEntity> findHitEntitys() { return findHitEntitys(0.0D); } public ArrayList<LivingEntity> findHitEntitys(double grow) { double hgrow = (grow/2) * -1; Vec3 vi = this.subject.getEyePosition(); Vec3 vo = (this.vh != null) ? this.vh : this.vo; /* Double xn = Math.min(vi.x, vo.x); Double xm = Math.max(vi.x, vo.x); Double yn = Math.min(vi.y, vo.y); Double ym = Math.max(vi.y, vo.y); Double zn = Math.min(vi.z, vo.z); Double zm = Math.max(vi.z, vo.z); Vec3 vdi = new Vec3(xn,yn,zn); Vec3 vdo = new Vec3(xm,ym,zm); */ // particle(warudo, vo); AABB bb = new AABB(vi, vo).inflate(2.0D); //System.out.println( (bb.maxX - bb.minX) + ", " + (bb.maxY - bb.minY) + ", " + (bb.maxZ - bb.minZ) ); ArrayList<LivingEntity> list = new ArrayList<LivingEntity>(); Predicate<? super Entity> cosa = target -> (target instanceof LivingEntity);// for (Entity target_entity : this.warudo.getEntities(this.subject, bb, cosa)) { //System.out.println(entity1.getBoundingBox()); // is the entity in the line //if (entity1 instanceof LivingEntity) { AABB aabb = target_entity.getBoundingBox().inflate(grow); //System.out.println( "x " + (aabb.maxX - entity1.getX()) + ", " + ( entity1.getX() - aabb.minX ) ); //System.out.println( "y " + (aabb.maxY - entity1.getY()) + ", " + ( entity1.getY() - aabb.minY ) ); //System.out.println( "z " + (aabb.maxZ - entity1.getZ()) + ", " + ( entity1.getZ() - aabb.minZ ) ); Optional<Vec3> optional = aabb.clip(vi, vo); //System.out.println(aabb); if (optional.isPresent()) { list.add((LivingEntity) target_entity); } } } list.sort((o1, o2) -> (Double.compare(o1.position().distanceTo(vi), o2.position().distanceTo(vi)))); return list; } 1.20.4 has not this problem anymore
×
×
  • Create New...

Important Information

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