perromercenary00 Posted December 29, 2022 Posted December 29, 2022 Im trying to realese code a been working for like 8 months but having weird small problems and to add salt to the wound mi hard disk fails this morning and cost me to recover mi work lest talk about this one first in eclipse the code just works nice and all soo lets build the debt to test it on minecraft and make some videos to show the mod on curse now all the bows gets displaced upside in a weird angle [explaining whit patience] the mod works perfectly fine in eclipse ide, but afther build it on and paste into minecraft folder this exactly piece of code stops working #########################################################################3 @Override public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { //return ( oldStack.getItem() == newStack.getItem() )? true : false; return ( newStack.getItem() instanceof bow00 )? true : false; } i use this piece of code to avoid the bows to going down and up everitime i write change nbt data in the bow is an old history but in minecraft game it dont works and i dont know why this method is added by the IForgeItem class so i implement it again in mi bow class "even knowing is alredy implemented by the item super class" public class bow00 extends BowItem implements IForgeItem { Spoiler package mercbow.item.arco; import mercbow.entity.EntityInit; import mercbow.entity.mercenaryarrow_entity; import mercbow.item.ItemInit; import mercbow.util.Target; import mercbow.util.util; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BowItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.UseAnim; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.extensions.IForgeItem; public class bow00 extends BowItem implements IForgeItem { public static final int MAX_DRAW_DURATION = 15; public static final int DEFAULT_RANGE = 20; // ########## ########## ########## ########## public bow00(Properties propiedad) { super(propiedad); // TODO Auto-generated constructor stub } // ########## ########## ########## ########## @Override public InteractionResultHolder<ItemStack> use(Level warudo, Player pe, InteractionHand hand) { // //System.out.println("use();"); Target target = new Target(warudo, pe, 10); Vec3 vh = target.getVh();// util.calcularVectores(pe, 10 , 0.0F );// // if (vh != null) ItemStack arrows = getProjectile(pe); if (!arrows.isEmpty()) { pe.startUsingItem(hand); } if(vh != null && warudo.isClientSide) { //warudo.addParticle(ParticleInit.SKULL_PARTICLE.get() , vh.x, vh.y+0.5D, vh.z, 0.0D, 0.0D, 0.0D);//ParticleInit.SKULL_PARTICLE.get() ParticleTypes.HEART //warudo.addAlwaysVisibleParticle(ParticleTypes.FLAME, vh.x, vh.y, vh.z, 0.0D, 0.0D, 0.0D); //velocidad dx,dy,dz } // return InteractionResultHolder.consume(itemstack); // shootthis(warudo, pe); return InteractionResultHolder.pass(pe.getItemInHand(hand)); } // ########## ########## ########## ########## public static void shootthis(Level warudo, LivingEntity pe, ItemStack itemstack, float power) { // ,float power if (!warudo.isClientSide()) { mercenaryarrow_entity arrow = new mercenaryarrow_entity(EntityInit.MERCENARY_ARROW.get(), pe, warudo); // arrow.setDeltaMovement(0, 1, 0); // directly up float f = 5.0F; arrow.shootFromRotation(pe, pe.getXRot(), pe.getYRot(), 1.0F, f * power, 1F); if (f == 1.0F) { // arrow.setCritArrow(true); } int j = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, itemstack); if (j > 0) { arrow.setBaseDamage(arrow.getBaseDamage() + (double) j * 0.5D + 0.5D); } int k = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, itemstack); if (k > 0) { arrow.setKnockback(k); } if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) { arrow.setSecondsOnFire(100); } warudo.addFreshEntity(arrow); //icon_entity p_entity = new icon_entity(EntityInit.ICON_ENTITY.get(), warudo, arrow); //warudo.addFreshEntity(p_entity); } } // #########################################################################3 public static Vec3 calcularXY(Vec3 vi, float distancia, float angle) { // rotacion Horizontal en grados float gyaw = angle;// player.getViewYRot(0.0F); float factor = (90F); gyaw = (float) ((gyaw - (factor / 2))); gyaw = util.fixGrad(gyaw); // rotacion Horizontal en radianes double ryaw = util.gradosAradianes(gyaw); double rpitch = -0.7853981852531433D; // //System.out.println("rpitch=" + rpitch); // correcccion de -90 grados double tmpryaw = ryaw - 1.5707964D; Vec3 vo = new Vec3(vi.x - ((Math.cos(tmpryaw)) * (Math.cos(rpitch) * distancia)), vi.y, vi.z - ((Math.sin(tmpryaw)) * (Math.cos(rpitch) * distancia))); return vo; } // ########## public double doublex2(double f) { int i = (int) (f * 100); return ((double) i / 100.0D); } // ########## public BlockPos blockpos_from_vec3(Vec3 in) { return new BlockPos((int) in.x, (int) in.y, (int) in.z); } // ########## public static Vec3 vec3_from_blockpos(BlockPos in) { return new Vec3(in.getX() + 0.5, in.getY() + 0.5, in.getZ() + 0.5); } // ########## public static void particle(Level warudo, BlockPos vh) { particle(warudo, vec3_from_blockpos(vh.above())); } // ########## public static void particle(Level warudo, Vec3 vh) { //System.out.println("particle(" + vh); // util.showthis( String.format(" %1$s, %2$s, %3$s", vh.x, vh.y, vh.z ) , pe); warudo.addAlwaysVisibleParticle(ParticleTypes.FLAME, vh.x, vh.y, vh.z, 0.0D, 0.0D, 0.0D); warudo.addParticle(ParticleTypes.SMOKE, vh.x, vh.y, vh.z, 0.0D, 0.0D, 0.0D); // pe.playSound(SoundEvents.FIRE_EXTINGUISH, 1.0F, 1.0F); } // ########## // ########## ########## ########## ########## public static void showthis(String mensaje, LivingEntity le) { if (le instanceof Player) { Player pe = (Player) le; //System.out.println(mensaje); pe.displayClientMessage(Component.translatable(mensaje), true); } } // ########## ########## ########## ########## public int getUseDuration(ItemStack p_40680_) { return 72000; } public UseAnim getUseAnimation(ItemStack p_40678_) { return UseAnim.BOW; } // ########## ########## ########## ########## public void releaseUsing(ItemStack itemstack, Level warudo, LivingEntity pe, int time) { float ticks = (itemstack.getUseDuration() - pe.getUseItemRemainingTicks()); ticks = (ticks > 15.0F) ? 15.0F : ticks; float power = ticks / 15F; ItemStack arrows = new ItemStack(ItemInit.ARROW_STEEL.get()); // //System.out.println("releaseUsing(" + time + "), " + ticks); if (ticks > 9.9F) { if (pe instanceof Player) { arrows = getProjectile((Player) pe); } if (!arrows.isEmpty()) { SoundSource soundsource = pe instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; warudo.playSound((Player)null, pe.getX(), pe.getY(), pe.getZ(), SoundEvents.ARROW_SHOOT, soundsource, 1.0F, 1.0F ); shootthis(warudo, pe, itemstack, power); arrows.shrink(1); } } } public static float getPowerForTime(int p_40662_) { float f = (float) p_40662_ / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if (f > 1.0F) { f = 1.0F; } return f; } // ########## ########## ########## ########## public ItemStack getProjectile(Player pe) {// , ItemStack projectile Item projectile_item = ItemInit.ARROW_STEEL.get(); Item slotitem = ItemStack.EMPTY.getItem(); int count = 0; ItemStack finded = ItemStack.EMPTY; for (int i = 0; i < pe.getInventory().getContainerSize(); ++i) { slotitem = pe.getInventory().getItem(i).getItem(); if (slotitem == projectile_item) { finded = pe.getInventory().getItem(i); count += finded.getCount(); } } // //System.out.println("Se encontraron " + count + " flechas" ); return finded; } // #########################################################################3 @Override public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { //return ( oldStack.getItem() == newStack.getItem() )? true : false; return ( newStack.getItem() instanceof bow00 )? true : false; } // ########## ########## ########## ########## // ########## ########## ########## ########## // ########## ########## ########## ########## // ########## ########## ########## ########## // ########## ########## ########## ########## } [/explaining whit patience] again the method shouldCauseReequipAnimation() works perfect inside the eclipse ide but not in the minecraft game runing forge ################################################################################################### the next thing this is just a custome iron pickaxe whit double the duration it works just fine in eclipse but afther build and put inside minecraft if stop being a pickaxe it takes too mutch to break the block and the block dont drops weir it is coze the rest of tools works fine , steel_shovel steel_axe steel_hoe works as intended inside minecraft this its not custome code its just extending the vainilla PickaxeItem public static final RegistryObject<Item> PICKAXE_STEEL = ITEMS.register("pickaxe_steel", () -> new PickaxeItem(MTiers.IRON, 1, -2.8F, (new Item.Properties().tab(tab.instance) ))); theres a third thing but probably the same reason ############################## at this point i dont know what to ask for why this things works in eclipse but no in the minecraft game is a kind of forge bug or its some how a modder error ? Quote
warjort Posted December 29, 2022 Posted December 29, 2022 Sorry, but you've been told many times that snippets are not enough to debug anything but the most trivial problems. We shouldn't have to keep repeating ourselves. Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
warjort Posted December 29, 2022 Posted December 29, 2022 (edited) Quote public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { //return ( oldStack.getItem() == newStack.getItem() )? true : false; return ( newStack.getItem() instanceof bow00 )? true : false; } This code says to always play the animation if the new item is your item? Edited December 29, 2022 by warjort Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
perromercenary00 Posted December 30, 2022 Author Posted December 30, 2022 yaa i notice that but if i invert it , it moves the bow model up causing the same problem as it happend in the minecraft game ################################################################### AAAiiiiiiiiiiiiiiiiiiiiiiiiiiiaaiiiiiiiiiiiiiiiia yap is the optifine mod i delete the all the .minecraft folder and download again all the game again an put only mi bow mod, its working as intended so i begin to add the others mods one by one to see what happends and afther OptiFine_1.19.2_HD_U_H9.jar it fails again soo its optifine must be some option messing up whit the shouldCauseReequipAnimation thing anyway the pickaxe keeps failing i change the warhammer to be also an pickaxe and fail as well public static final RegistryObject<Item> PICKAXE_STEEL = ITEMS.register("pickaxe_steel", () -> new PickaxeItem(MTiers.STEEL_SMALL, 1, -2.8F, (new Item.Properties().tab(tab.instance) ))); public static final RegistryObject<Item> WARHAMMER_STEEL = ITEMS.register("warhammer_steel", () -> new PickaxeItem(MTiers.STEEL, 1, -2.8F, (new Item.Properties().tab(tab.instance) ))); Quote
warjort Posted December 30, 2022 Posted December 30, 2022 Try the latest preview release of optifine. That version is old. For the rest, I will repeat, for the last time. Small pieces of code are NOT enough. And youtube videos are useless. I can't read the code or debug a video. e.g. What does this do? MTiers.STEEL_SMALL Inside that is the mining level which determines what can be mined, or more accurately what will drop items when mined. And since it is a custom tier it needs to be registered properly. But that is just a guess. I have no desire to spend 20 posts playing a guessing game to try to get enough information from you to locate the real problem. Either show all the code, or learn how to attach a debugger to a minecraft production instance and debug obfuscated code. 🙂 Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
perromercenary00 Posted December 30, 2022 Author Posted December 30, 2022 hellow MTiers.STEEL_SMALL is just the custome tier material i create for steel i also check that change the material tier from mi items to iron just to test and is still failing Spoiler package merctool.item; import java.util.function.Supplier; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.util.LazyLoadedValue; import net.minecraft.world.item.Items; import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.Tags; public enum MTiers implements Tier { WOOD(0, 59, 2.0F, 0.0F, 15, () -> { return Ingredient.of(ItemTags.PLANKS); }), STONE(1, 131, 4.0F, 1.0F, 5, () -> { return Ingredient.of(ItemTags.STONE_TOOL_MATERIALS); }), IRON(2, 250, 6.0F, 2.0F, 14, () -> { return Ingredient.of(Items.IRON_INGOT); }), STEEL(2, 750, 6.5F, 2.0F, 14, () -> { return Ingredient.of(ItemInit.INGOT_STEEL.get()); }), STEEL_SMALL(2, 750, 12.0F, 1.0F, 14, () -> { return Ingredient.of(ItemInit.INGOT_STEEL.get()); }), STEEL_BIG(2, 750, 12.0F, 4.0F, 14, () -> { return Ingredient.of(ItemInit.INGOT_STEEL.get()); }), DIAMOND(3, 1561, 8.0F, 3.0F, 10, () -> { return Ingredient.of(Items.DIAMOND); }), GOLD(0, 32, 12.0F, 0.0F, 22, () -> { return Ingredient.of(Items.GOLD_INGOT); }), NETHERITE(4, 2031, 9.0F, 4.0F, 15, () -> { return Ingredient.of(Items.NETHERITE_INGOT); }); private final int level; private final int uses; private final float speed; private final float damage; private final int enchantmentValue; private final LazyLoadedValue<Ingredient> repairIngredient; private MTiers(int p_43332_, int p_43333_, float p_43334_, float p_43335_, int p_43336_, Supplier<Ingredient> p_43337_) { this.level = p_43332_; this.uses = p_43333_; this.speed = p_43334_; this.damage = p_43335_; this.enchantmentValue = p_43336_; this.repairIngredient = new LazyLoadedValue<>(p_43337_); } public int getUses() { return this.uses; } public float getSpeed() { return this.speed; } public float getAttackDamageBonus() { return this.damage; } public int getLevel() { return this.level; } public int getEnchantmentValue() { return this.enchantmentValue; } public Ingredient getRepairIngredient() { return this.repairIngredient.get(); } @org.jetbrains.annotations.Nullable public net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> getTag(MTiers tier) { return switch(tier) { case WOOD -> Tags.Blocks.NEEDS_WOOD_TOOL; case GOLD -> Tags.Blocks.NEEDS_GOLD_TOOL; case STONE -> BlockTags.NEEDS_STONE_TOOL; case IRON -> BlockTags.NEEDS_IRON_TOOL; case STEEL -> BlockTags.NEEDS_IRON_TOOL; case STEEL_SMALL -> BlockTags.NEEDS_IRON_TOOL; case STEEL_BIG -> BlockTags.NEEDS_IRON_TOOL; case DIAMOND -> BlockTags.NEEDS_DIAMOND_TOOL; case NETHERITE -> Tags.Blocks.NEEDS_NETHERITE_TOOL; }; //return net.minecraftforge.common.ForgeHooks.getTagFromVanillaTier(Tiers); } } so i change public static final RegistryObject<Item> PICKAXE_STEEL = ITEMS.register("pickaxe_steel", () -> new PickaxeItem(MTiers.STEEL_SMALL, 1, -2.8F, (new Item.Properties().tab(tab.instance) ))); to public static final RegistryObject<Item> PICKAXE_STEEL = ITEMS.register("pickaxe_steel", () -> new PickaxeItem(Tiers.IRON, 1, -2.8F, (new Item.Properties().tab(tab.instance) ))); but no avail is the same problem it works in eclipse but not in minecraft i have a bunch of mods in mi minecraft game and i realize it fails only when mi other mod mercenary_blocks_1.19.2-006.jar is in the folder curously the vainilla pickaxes also fail to break blocks long story short i have somehow messed up the tags in src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json Spoiler { "replace": false, "values": [ "mercblk:steel_ladder", "mercblk:steel_fence_panel", "mercblk:steel_fence_puerta", "mercblk:steel_fence_trampilla", "mercblk:cooper_guide_block", "mercblk:cooper_guide_panel", "mercblk:cooper_guide_puerta", "mercblk:cooper_guide_trampilla", "mercblk:blackstone_panel", "mercblk:blackstone_puerta", "mercblk:blackstone_trampilla", "mercblk:cobblestone_panel", "mercblk:cobblestone_puerta", "mercblk:cobblestone_trampilla", "mercblk:deepslate_panel", "mercblk:deepslate_puerta", "mercblk:deepslate_trampilla", "mercblk:stone_panel", "mercblk:stone_puerta", "mercblk:stone_trampilla", "mercblk:sandstone_panel", "mercblk:sandstone_puerta", "mercblk:sandstone_trampilla", "mercblk:red_sandstone_panel", "mercblk:red_sandstone_puerta", "mercblk:red_sandstone_trampilla", "mercblk:diorite_panel", "mercblk:diorite_puerta", "mercblk:diorite_trampilla", "mercblk:andesite_panel", "mercblk:andesite_puerta", "mercblk:andesite_trampilla", "mercblk:polished_andesite_panel", "mercblk:polished_andesite_puerta", "mercblk:polished_andesite_trampilla", "mercblk:granite_panel", "mercblk:granite_puerta", "mercblk:granite_trampilla", "mercblk:polished_granite_panel", "mercblk:polished_granite_puerta", "mercblk:polished_granite_trampilla", "mercblk:prismarine_panel", "mercblk:prismarine_puerta", "mercblk:prismarine_trampilla", "mercblk:mud_brick_panel", "mercblk:mud_brick_puerta", "mercblk:mud_brick_trampilla", "mercblk:brick_panel", "mercblk:brick_puerta", "mercblk:brick_trampilla", "mercblk:red_nether_brick_panel", "mercblk:red_nether_brick_puerta", "mercblk:red_nether_brick_trampilla", "mercblk:deepslate_brick_panel", "mercblk:deepslate_brick_puerta", "mercblk:deepslate_brick_trampilla", "mercblk:nether_brick_panel", "mercblk:nether_brick_puerta", "mercblk:nether_brick_trampilla", "mercblk:polished_blackstone_brick_panel", "mercblk:polished_blackstone_brick_puerta", "mercblk:polished_blackstone_brick_trampilla", "mercblk:end_stone_brick_panel", "mercblk:end_stone_brick_puerta", "mercblk:end_stone_brick_trampilla", "mercblk:prismarine_brick_panel", "mercblk:prismarine_brick_puerta", "mercblk:prismarine_brick_trampilla", "mercblk:stone_brick_panel", "mercblk:stone_brick_puerta", "mercblk:stone_brick_trampilla", "mercblk:white_terracotta_panel", "mercblk:white_terracotta_puerta", "mercblk:white_terracotta_trampilla", "mercblk:orange_terracotta_panel", "mercblk:orange_terracotta_puerta", "mercblk:orange_terracotta_trampilla", "mercblk:magenta_terracotta_panel", "mercblk:magenta_terracotta_puerta", "mercblk:magenta_terracotta_trampilla", "mercblk:light_blue_terracotta_panel", "mercblk:light_blue_terracotta_puerta", "mercblk:light_blue_terracotta_trampilla", "mercblk:yellow_terracotta_panel", "mercblk:yellow_terracotta_puerta", "mercblk:yellow_terracotta_trampilla", "mercblk:lime_terracotta_panel", "mercblk:lime_terracotta_puerta", "mercblk:lime_terracotta_trampilla", "mercblk:pink_terracotta_panel", "mercblk:pink_terracotta_puerta", "mercblk:pink_terracotta_trampilla", "mercblk:gray_terracotta_panel", "mercblk:gray_terracotta_puerta", "mercblk:gray_terracotta_trampilla", "mercblk:light_gray_terracotta_panel", "mercblk:light_gray_terracotta_puerta", "mercblk:light_gray_terracotta_trampilla", "mercblk:cyan_terracotta_panel", "mercblk:cyan_terracotta_puerta", "mercblk:cyan_terracotta_trampilla", "mercblk:purple_terracotta_panel", "mercblk:purple_terracotta_puerta", "mercblk:purple_terracotta_trampilla", "mercblk:blue_terracotta_panel", "mercblk:blue_terracotta_puerta", "mercblk:blue_terracotta_trampilla", "mercblk:brown_terracotta_panel", "mercblk:brown_terracotta_puerta", "mercblk:brown_terracotta_trampilla", "mercblk:green_terracotta_panel", "mercblk:green_terracotta_puerta", "mercblk:green_terracotta_trampilla", "mercblk:red_terracotta_panel", "mercblk:red_terracotta_puerta", "mercblk:red_terracotta_trampilla", "mercblk:black_terracotta_panel", "mercblk:black_terracotta_puerta", "mercblk:black_terracotta_trampilla" ] } i dont see any error nor eclipse marks red nothing but anyway something wrong Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.