Jump to content

perromercenary00

Members
  • Posts

    813
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by perromercenary00

  1. if theres is a work around to make the logic inside the capability it would make things easier i try puting and onload method and launchi it from i notice this methods ticks for a while afther you read the capability from the item and lives while the item is in the hotbar but if you put it on the inventory and close the menu it dies so is not is not reliable becoze it only ticks a few times and stop so is unfited to make a long count and do something after like finishing the drilling action and consume the fuel value saving the numbers back to item the other option would be to call the capability once and again from the itemstack in older version there was a onupdate() method that constantly tick even when you toss the item into the world i dot find it in 1.19.2 surely the name has change
  2. java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.world.entity.Entity, net.minecraft.client.renderer.culling.Frustum, double, double, double)" because "entityrenderer" is null i say its missing the part where you tell it what model renderer to use whit what entity
  3. i get this one from https://crafting.thedestruc7i0n.ca/ and works { "type" : "minecraft:crafting_shaped", "pattern" : [ "###", "#P#", "# #" ], "key" : { "#" : { "item" : "minecraft:redstone" }, "P" : { "item" : "minecraft:potion" } }, "result" : { "item" : "merctool:solution_redstone", "count" : 1 } } the only diference isee is the placeholder they use for the shape all the others is the same { "type" : "minecraft:crafting_shaped", "pattern" : [ "RRR", "RBR", "R R" ], "key" : { "R" : { "item" : "minecraft:redstone" }, "B" : { "item" : "minecraft:potion" } }, "result" : { "item" : "merctool:solution_redstone", "count" : 1 } } well dont mathers issue solved
  4. good days i trying to make a recipe requiring water bottle for what i understand water bottle is a just a potion withoug any efects but this recipe dont works portdata wheres the brewing_stand recipes ?
  5. oo that when i made the animations using the tick provided by onUseTick causes chopping animations when the game start skiping frames an sometimes the animation locks in a cicle and dont let the item continue whit is normal use then i just begin to store the statr time as epoch and calculate the frame from it and fix the problem
  6. hola when you make custom blocks if you want them to break whith a picaxe item you must declare block name inside the pickaxe file src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json but if you mispell a block name or add a non existing block or you forget the ".requiresCorrectToolForDrops()" thing at declaring just one of the blocks public static final RegistryObject<Block> TOILET_BLOCK_COBBLESTONE = registerBlock("toilet_block_cobblestone", () -> new toilet(Block.Properties.copy(Blocks.COBBLESTONE).requiresCorrectToolForDrops()) ); in any of this cases gonna damage the pickaxe behaveour for all the running mods soo be carefull whit that
  7. it makes sense coze your calculatin particule position using age as angle if you change (age / 20f) for (age / 40f) would take 2 full seconds to complete a round
  8. package merctool.item.tool; import java.util.ArrayList; import java.util.Collections; import java.util.Set; import javax.annotation.Nullable; import com.google.common.collect.Sets; import merctool.util.Postate; import merctool.util.Target; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.tags.FluidTags; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedStoneWireBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; //import net.minecraft.item.Item; //########## ########## ########## ########## public class merc_rs_wireblock extends RedStoneWireBlock { private static final float PARTICLE_DENSITY = 0.2F; // private final BlockState crossState; private boolean shouldSignal = true; public merc_rs_wireblock(Properties propiedades) { super(propiedades); } // ########## ########## ########## ########## ########## ########## ########## @Override public void neighborChanged(BlockState blkstate, Level warudo, BlockPos pos, Block blk, BlockPos pos2, boolean cosa) { if (!warudo.isClientSide) { if (blkstate.canSurvive(warudo, pos)) { //this.updatePowerStrength(warudo, pos, blkstate); } else { dropResources(blkstate, warudo, pos); warudo.removeBlock(pos, false); } } } // ########## ########## ########## ########## ########## ########## ########## // @Override public void updatePowerStrength(Level warudo, BlockPos pos, BlockState blkstate) { int i = this.calculateTargetStrength(warudo, pos); if (blkstate.getValue(POWER) != i) { if (warudo.getBlockState(pos) == blkstate) { warudo.setBlock(pos, blkstate.setValue(POWER, Integer.valueOf(i)), 2); } Set<BlockPos> set = Sets.newHashSet(); set.add(pos); for (Direction direction : Direction.values()) { set.add(pos.relative(direction)); } for (BlockPos blockpos : set) { warudo.updateNeighborsAt(blockpos, this); } } } // ########## ########## ########## ########## ########## ########## ########## // @Override public int calculateTargetStrength(Level warudo, BlockPos pos) { this.shouldSignal = false; int i = warudo.getBestNeighborSignal(pos); this.shouldSignal = true; int j = 0; if (i < 15) { for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos blockpos = pos.relative(direction); BlockState blockstate = warudo.getBlockState(blockpos); j = Math.max(j, this.getWireSignal(blockstate)); BlockPos blockpos1 = pos.above(); if (blockstate.isRedstoneConductor(warudo, blockpos) && !warudo.getBlockState(blockpos1).isRedstoneConductor(warudo, blockpos1)) { j = Math.max(j, this.getWireSignal(warudo.getBlockState(blockpos.above()))); } else if (!blockstate.isRedstoneConductor(warudo, blockpos)) { j = Math.max(j, this.getWireSignal(warudo.getBlockState(blockpos.below()))); } } } j = ( j > 0 )? 15 : 0; return Math.max(i, j);//j - 1 } // ########## ########## ########## ########## ########## ########## ########## // @Override private int getWireSignal(BlockState p_55649_) { return p_55649_.is(this) ? p_55649_.getValue(POWER) : 0; } // ########## ########## ########## ########## ########## ########## ########## // ########## // ########## ########## ########## ########## ########## ########## ########## // ########## // ########## ########## ########## ########## ########## ########## ########## // ########## // ########## ########## ########## ########## ########## ########## ########## // ########## }
  9. Good days im testing things to fix the problem whit the detonator for mi mod in this case i decide to make a custome redstone wire that dont update by itself soo it can keep the redstone power farter i just extend the RedStoneWireBlock an copy the json's manually fixing the routes to the assets public class merc_rs_wireblock extends RedStoneWireBlock {} the plan is when the detonators turn on it ramdomly replace vainilla RedStoneWireBlock for the merc_rs_wireblock and when the detonators turn off it search for the merc_rs_wireblock and turn them back to RedStoneWireBlock mi merc_rs_wireblock works it conect whit blocks and vainilla redstone normally and ignore neighborChanged() and just turn on/off externally -> but it is white -> it has the particules but dont shine when on as the vainilla redstone wire i been looking the jsons and notice the variable "tintindex" but dont find whats providing this value coze is not a block property i Have the theory than somewhere is a "ModItemModelProperties" class but for blocks an thats whats providing the tintindex value but dont find it ####################3 do you know what it is ??
  10. well yes but not quite short ago i have to made a capability extending itemhandler to make a custome drill and i need to recalculate the value of tick to calculate animation frame and fuel comsumtion but i cannot make it so i end quickitng an made just a public int get_tick() { if( this.tick > 0) { } else if( this.action > 0) { if( this.start > 0L ) { //System.out.println( "Calcular_tick()\n" ); this.tick = (int) ((System.currentTimeMillis() - this.start) / 50); // 50 this.tick = (this.tick > this.limit)? this.limit : this.tick; } } return this.tick; } so everytime the code ask for that variable it recalculate it coze idont find any ontick() or public void tick() that works inside the capability
  11. does a capabilities has an onTick() method
  12. make the sound 20 ticks long and made the block tick every 20 until power goes off // ########## ########## ########## ########## public boolean turn_on(Postate postate, Entity entity) { if (!postate.get_POWERED()) { Level warudo = postate.level(); BlockPos pos = postate.get_blockpos(); postate.set_POWERED(true); postate.update_WATERLOGGED(); postate.setBlock(2); this.updateNeighbours(postate.getBlockState(), warudo, pos); warudo.gameEvent(entity, true ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos); update_neighbours(warudo, pos, true); //cause the block to tick in 20 postate.level().scheduleTick(pos, this, 20); } return false; } // ########## ########## ########## ########## public void tick(BlockState blkstate, ServerLevel serverlevel, BlockPos pos, RandomSource random) { update_neighbours((Level) serverlevel, pos, false); serverlevel.gameEvent((Entity) null, GameEvent.BLOCK_DEACTIVATE, pos); serverlevel.playSound((Player) null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.CROSSBOW_LOADING_END, SoundSource.PLAYERS, 1.0F, 1.0F); if (blkstate.getValue(POWERED)) { serverlevel.setBlock(pos, blkstate.setValue(POWERED, Boolean.valueOf(false)), 3); // this.updateNeighbours(blkstate, serverlevel, pos); // this.playSound((Player)null, serverlevel, pos, false); } }
  13. hola this code reads all the loaded blocks in the game and stores it to a hash map public static Map<String, BlockState> blocklist = new HashMap<String, BlockState>();// list whit all blocks for (Entry<ResourceKey<Block>, Block> ResourceKey : ForgeRegistries.BLOCKS.getEntries()) { actualBlock = ResourceKey.getValue(); nnn = fix_blkfullname(actualBlock.getName().getString()); blocklist.put(nnn, actualBlock.defaultBlockState()); if (nnn.contains("slab")) { // slablist.put(nnn, ""); } count++; } // ########## ########## ########## ########## ########## ########## // public static String fix_blkfullname(String blkfullname) { if (blkfullname.contains(".")) { String[] split1 = blkfullname.split("\\."); // "\\." if (split1.length > 1) { blkfullname = split1[split1.length - 1].replaceAll("_", " "); } } return blkfullname.toLowerCase(); }
  14. i got this trouble Vec3 works whit real numbers but block has this minusZero hurting mi calculations i need to calculate if an entity inside the block is close to the center on the block but block gets me BlockPos and entity gives me a vec3 when i converty i t by self it works excep if the entity is not on the block -0 causing the calculate value to move towars +0 anyway is there alredy in minecraft a function to return a BlockPos passing a Vec3 habing in count this MinusZero thing ??
  15. hay i made a custome lever block mi detonator block is kinda of tnt activator to work whit a custome explosive that still in wip state but the lever part must be finish first mi lever just extends the minecraft lever class public class detonador extends LeverBlock and works but only whit a reach like 15 blocks and the bloks like piston and lanterns just get stuck in POWERED state dont return to off to try to solve that issue an also make it reach longer i made code to detect all the RedStoneWireBlock in direct contact whit mi detonator block return the blocks as a list of postate objects then manually set the power level to 15 and it works i set like 80 blocks of redstone around the room an all of then turn ligh on but it dont activate neither redstone lamps nor pistons i been diging in the classes i find this two things but are not givin the expected result level.updateNeighbourForOutputSignal(cursor.get_blockpos(), cursor.getBlock() ); level.updateNeighborsAt(cursor.get_blockpos(), cursor.getBlock()); i suspect i must execute some other update method inside level class or maybe is an event that must be casted over the restone wire position in the level to make it trigger blocks the full class is this the Postate class is a tool class i use to facilitate change values on BlockStates and write them again to the Level well the idea is detect a RedStoneWireBlock an artifiacilly turn it on and make the surronding blocks react to this may the RedStoneWireBlock has an inner system to update its state based on a paralel data system as whit the watter fluids thanks for your time
  16. lets try again the drill has two animations and to play this two animations i beign using the same technich used to animate the bow or the shield now this json works whit a property called "pull" and i have to declare it to the drill item and pass the values from the item handler capability to this ItemModelProperties notive than to determine what animation gonna be played i use the variable called "action" from the capability ######################### then it comes the problem the code i have to read from the itemcpability is an enclosed arrow function this is not a problem if just need to read or change some value then return but becoze ItemModelProperties is also an arrow function it dont letme just return the calculate value //register the pull property ItemProperties() action => 1, 0 ItemProperties() action => 1, 1 ItemProperties() action => 1, 2 ItemProperties() action => 1, 3 ItemProperties() action => 1, 4 ItemProperties() action => 1, 5 soo i need to pull out the capability not as an arrow but as normal class/object soo i can just return the tick value thats the problem i currently have @NotNull LazyOptional<IItemHandler> handler00 = itemstack.getCapability(ForgeCapabilities.ITEM_HANDLER); //item_handler ih = (item_handler) handler00;//Cannot cast from LazyOptional<IItemHandler> to item_handler if (handler00 instanceof item_handler) { item_handler ih = (item_handler) handler00; //how i do cast from lazyoptional to mi capability class ???? }
  17. Good days sorry is hard to express compex ideas in a non native languague i been working in a drill and i need this drill needs to have two animation the one is just the drill spining and drilling that one is on right clickand works holding right click anyway to switch the json models and the animation i need to read the values from the capability in the ModItemModelProperties thats an issue i having know i dont know how to get the capability thing to read the values soo i just have his bunch of debris code this is mi capability exactly i need to get the output from the method public int get_tick() to use thnks for your time
  18. this picture shows the problem while the gui says the item has 7 redstone ingots in the capability the print method says i have two potatoes in slots one and eight in the itemstack nbt if i close minecraft and open again the world i still havethe 7 ingots in the gui and the two potatoes in the code
  19. good nights this one is a little hard to explains i finally managae to get working the briefcase i still working whit the block part but still back in the 1.8 the idea whit this briefcase was to give the player an initial inventory soo ineed to preload the briefcase whit items from code digginup in the code i know minecrfas store inventories like nbt data usig a listtag named "Items" so i copy paste code from the chest container class to load things to mi briefcase but notice mi briefacase "ITEMS" and the "ITEMS" in the GUI dont match looks like to separate sets of nbt data both sets of "ITEMS" persist afther closing/reload the world soo is not an overwrite thing this are the methods i use read write the "ITEMS" in the item stack this is the code i use for the test ########################################################################### This getting too long i need to confirm if the capabilities system has its own database apart from the vainilla nbt thing and if its like that how doo i access tha data to put items in the briefcase ? class briefcase_item class item_c_provider class item_handler class menu9 thanks from your time
  20. something more like the shield or the bow changin from inner variable or nbt or two diferent items
  21. expected behaveur nothing to worry about @SubscribeEvent public static void onCrafting(PlayerEvent.ItemCraftedEvent event) { ItemStack items = event.getCrafting(); Entity entity = event.getEntity(); Level warudo = entity.level; System.out.println("--------------" + ((warudo.isClientSide)? " local world " : " server world ") ); System.out.println("Description ID: " + items.getItem().getDescriptionId()); System.out.println("Count: " + items.getCount()); } -------------- local world Description ID: block.mercblk.deepslate_panel Count: 12 -------------- server world Description ID: block.mercblk.deepslate_panel Count: 12
  22. goo days i have made some panels and trapdoors basically you take a block and split in four simetrical parts By the way this panels works it has sense to make them in the cutting table is posible to add mi blocks in a json some where ? or its the cutting table a michine whit a close predefined pool of recipes and i have to make a custome cutting table ?
  23. ya i notice that but dont find an itemstack using the Capability<IItemHandler> to use as example also theres the problem of geting the new inventory from the gui in the container datapart
  24. jumm thanks you and im currently stuck at this point i made a custome gui i made an itemstack class whit the "implements MenuProvider" thing pointing to that gui but - idont get how to read the inventory from the itemstack soo mi upper slots are just draw in the background but no funtionality i dont find other items inside vainilla minecraft implementhing the capabilityt thing soo i letthing eclipse to fill the gap, no succes here //this part of here //this one created by eclipse public RegistryObject<MenuType<menu9>> getCapability(Capability<IItemHandler> itemHandlerCapability) { // TODO Auto-generated method stub return null; } //this one copied from the GemInfusingStationBlockEntity example //@Override public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return lazyItemHandler.cast(); } //return super.getCapability(cap, side); return lazyItemHandler.cast(); } -also a idont know how or where the gui will return the changes isee the player inventory gets the blocks i change of place soo i speculate the gui will return the inventory throught the "this.data = new ContainerData()" and gonna be recived inside the contructor of mi brief_case item class the plan here is to directly pass the itemstack to the custome gui way the inventory gets store inside the brefcase_item as nbt data with no entity/tylenetity in the middle of the operation mercblk.blocks.maletin.briefcase_item; this is the gui i made coping from kaupenjoe tutorial in the second constructor "public menu9(int id, Inventory inv, briefcase_item container_item, ContainerData data)" i need to extract the inventory from the container_item to create the slots but dont get how to make that part works mercblk.blocks.maletin.screen.menu9; the screen thing whit the background image MenuInit Well thanks for your time
  25. what are trying to achive op to understand the raytrace you have to look into te abstrab arrow class mostly is the same but they change the names of things package net.minecraft.world.phys.HitResult; i do this when i want to search things ignoring liquids but stoping on solid blocks this.hitresult = this.warudo.clip(new ClipContext(this.vi, this.vo, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.player_entity));
×
×
  • Create New...

Important Information

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