Jump to content

jaxbymc42

Members
  • Posts

    20
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jaxbymc42's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, so recently I was updating my 1.18.1 mod to 1.18.2, and when updating everything, I receive the following in the console: I have played around some with my build.gradle as I know gradle can sometimes be a little finnicky, but I have had no success in fixing this error. I have double-checked that all versions of my dependencies are correct. I have here a copy of my build.gradle if you feel inclined to take a look: https://pastebin.com/WUtQ8HnE Any help or guidance is much appreciated. Thank you.
  2. The last parameter in the shootFromRotation method is for the inaccuracy. In my case, it has nothing to do with the issue of the fireballs practically looping in circles whenever I use the wand item.
  3. Hello! I am trying to create an item that shoots a fireball in the direction of the player's view. Currently, it does shoot the fireball but the fireball is curving a bit depending on where the player is looking (also, when looking down, even slightly, it shoots the fireball directly below the player). I am struggling to figure out the problem. I have already looked at other Minecraft classes, such as the Ghast and Bow classes. Any help would be appreciated, thanks! import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.LargeFireball; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import java.util.Random; public class FlameWandItem extends Item { public FlameWandItem() { super(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT).durability(64)); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) { ItemStack itemStack = player.getItemInHand(usedHand); Vec3 vec3 = player.getViewVector(1.0f); Random random = new Random(); if (!level.isClientSide) { LargeFireball largeFireball = new LargeFireball(level, player, player.getX(), player.getEyeY(), player.getZ(), 1); largeFireball.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 3.0F, 0.0F); level.addFreshEntity(largeFireball); level.playSound((Player)null, player.getX(), player.getY(), player.getZ(), SoundEvents.GHAST_SHOOT, SoundSource.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); if (!player.isCreative()) { itemStack.setDamageValue(itemStack.getDamageValue() + 1); } return new InteractionResultHolder<>(InteractionResult.SUCCESS, itemStack); } return new InteractionResultHolder<>(InteractionResult.FAIL, itemStack); } }
  4. I have changed the code so that it now overrides the method. However, I think there are some problems with my raytracing method. It does not properly trace where the player is looking and grabbing that block pos.
  5. I do now realize that I wasn't using the correct method. I have changed "onItemRightClick" to "use" and now the item does function. It functions because I also added the entity to the world, as you had mentioned that I had not added it (oops). Now, it does summon lightning, but only whenever I look certain ways and my ray tracing does not work well because the lightning is not summoned where I am looking. I will try to use getLookVec (or whatever the name is) to trace instead and see how that goes.
  6. Hello! I am looking to use ray tracing to find the position of the block the player is looking at. Then, when the player right clicks the item, it summons a lightning bolt at that block's location. I have created my own code for this, but nothing is currently working (not summoning lightning at all). I am new to ray tracing but apparently this is not how it is done (question mark?). I am just looking to see what I have done wrong and to build on knowledge for the future. import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; public class LightningWandItem extends Item { public LightningWandItem(Properties properties) { super(properties); } private RayTraceResult rayTrace(World world, PlayerEntity player) { float rotationPitch = player.getYHeadRot(); float rotationYaw = player.xRot; Vector3d eyePosition = player.getEyePosition(1.0F); // look vector float f2 = MathHelper.cos(-rotationYaw * ((float)Math.PI / 180F) - (float)Math.PI); float f3 = MathHelper.sin(-rotationYaw * ((float)Math.PI / 180F) - (float)Math.PI); float f4 = -MathHelper.cos(-rotationPitch * ((float)Math.PI / 180F)); float f5 = MathHelper.sin(-rotationPitch * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; double rayTraceDistance = 54; // from start pos, add look vector multiplied by rayTraceDistance Vector3d endPosition = eyePosition.add((double)f6 * rayTraceDistance, (double)f5 * rayTraceDistance, (double)f7 * rayTraceDistance); return world.clip(new RayTraceContext(eyePosition, endPosition, RayTraceContext.BlockMode.OUTLINE, FluidMode.NONE, player)); } public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { if(!worldIn.isClientSide) { ItemStack stack = playerIn.getItemInHand(handIn); RayTraceResult result = this.rayTrace(worldIn, playerIn); if(result instanceof BlockRayTraceResult) { BlockPos pos = ((BlockRayTraceResult) result).getBlockPos(); Block block = worldIn.getBlockState(pos).getBlock(); if(block != Blocks.AIR) { if(worldIn instanceof ServerWorld) { LightningBoltEntity lightningEntity = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn); lightningEntity.setPos(pos.getX(), pos.getY(), pos.getZ()); playerIn.awardStat(Stats.ITEM_USED.get(this)); if (!playerIn.abilities.mayfly) { stack.hurtAndBreak(1, playerIn, (p_219998_1_) -> { p_219998_1_.broadcastBreakEvent(handIn); }); } } } return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack); } else if(result instanceof EntityRayTraceResult) { Entity entity = ((EntityRayTraceResult) result).getEntity(); if(worldIn instanceof ServerWorld) { Vector3d entityPos = entity.position(); LightningBoltEntity lightningEntity = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn); lightningEntity.setPos(entityPos.x(), entityPos.y(), entityPos.z()); playerIn.awardStat(Stats.ITEM_USED.get(this)); if (!playerIn.abilities.mayfly) { stack.hurtAndBreak(1, playerIn, (p_219998_1_) -> { p_219998_1_.broadcastBreakEvent(handIn); }); } } return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack); } playerIn.getItemInHand(handIn); } return super.use(worldIn, playerIn, handIn); } }
  7. How exactly do I go about using LivingEquipmentChangeEvent?
  8. public class HoneyArmorItem extends ArmorItem { public HoneyArmorItem(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { if(player.inventory.armorItemInSlot(0).getItem() == ItemInit.HONEY_BOOTS.get() && player.inventory.armorItemInSlot(1).getItem() == ItemInit.HONEY_LEGGINGS.get() && player.inventory.armorItemInSlot(2).getItem() == ItemInit.HONEY_CHESTPLATE.get() && player.inventory.armorItemInSlot(3).getItem() == ItemInit.HONEY_HELMET.get()) { player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("MaxHealth", 4.0f, AttributeModifier.Operation.ADDITION)); } else { super.onArmorTick(stack, world, player); player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(new AttributeModifier("MaxHealth", 4.0f, AttributeModifier.Operation.ADDITION)); } } }
  9. I tried applying modifiers straight out but then I ran into the issue of infinitely adding 2 more hearts.
  10. I have made a set of armor that, when the full set is worn, the player is granted with 2 additional hearts. Whenever you take the armor off, the two extra hearts disappear but are still "there" and the player acts as though he has 12 hearts when only 10 are shown (until the player takes enough damage to lose those 2 extra hearts then it is like vanilla MC with 10 hearts). I was just wondering what else to do to check and remove the extra life so when the armor is off, the player has only 10 hearts (not the extra 2 hearts that are "there" till damage gets rid of them). public class HoneyArmorItem extends ArmorItem { public HoneyArmorItem(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { if(player.inventory.armorItemInSlot(0).getItem() == ItemInit.HONEY_BOOTS.get() && player.inventory.armorItemInSlot(1).getItem() == ItemInit.HONEY_LEGGINGS.get() && player.inventory.armorItemInSlot(2).getItem() == ItemInit.HONEY_CHESTPLATE.get() && player.inventory.armorItemInSlot(3).getItem() == ItemInit.HONEY_HELMET.get()) { player.getAttributes().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(24); } else { super.onArmorTick(stack, world, player); player.getAttributes().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20); } } }
  11. Okay. I realized I made up a method and also did not check if a player is in creative mode or not to shrink the item stack.
  12. Hello! I am currently trying to add an item that, upon right click, gives the player some experience by spawning some xp orbs on the players location. I thought this was correct but clearly it isn't. When right clicked, the edible experience item does not do anything. Pastebin for edible experience class: https://pastebin.com/5u1vCrx6 Thank you for your time.
  13. I thought that the lines below did that in my main class: @SubscribeEvent public static void onRegisterItems(final RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); BlockInit.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> { final Item.Properties properties = new Item.Properties().group(ChrispyModItemGroup.instance); final BlockItem blockItem = new BlockItem(block, properties); blockItem.setRegistryName(block.getRegistryName()); registry.register(blockItem); }); LOGGER.debug("Registered BlockItems!"); }
  14. Since moving everything to deferred registries, my mod's blocks are not in the game. The ore gen generates the ores underground and the blocks appear with textures and all but there is no possible way of obtaining the blocks (not in creative menu, /give doesn't work, middle clicking the ore doesn't work). The blocks can't even be crafted. The only leading bit of information I have is the log says this for every one of my mod's blocks when loading a world: "[Server thread/ERROR] [minecraft/LootTableManager]: Couldn't parse loot table chrispymod:blocks/cyan_redstone_lamp com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'chrispymod:cyan_redstone_lamp'" There are also parsing errors when loading recipes. My loot tables have not been moved and I did not encounter this issue before switching to deferred registries. I have attached ChrispyMod.java (Main), BlockInit.java, and my latest.log. If something will not load or you need more info, let me know. I am genuinely stuck and have no idea what is wrong. Any help is appreciated. Thank you for your time. ChrispyMod.java BlockInit.java latest.log
  15. This is resolved
×
×
  • Create New...

Important Information

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