Jump to content

Dakuro

Members
  • Posts

    8
  • Joined

  • Last visited

Dakuro's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thank you for your response! Oh well, yes that's not so important, I just thought it would be inconsistent to have unwanted potions in the vanilla tabs, but we can't do anything about it. Oh I wasn't aware this was really important, than you for the tip! Just for my curiosity, what kind of problems could it cause?
  2. Hello, I'm currently making an effect and custom potions and it works fine and all, but in the Brewing and Weapons vanilla tabs there is automatically generated potions with my effect (potion, splashpotion, lingering potion and tipped arrows). For example, here is my custom potion : And here is the automatically generated potion : I found a method in the PotionItem and I think it may be related to this : public void fillItemCategory(ItemGroup p_150895_1_, NonNullList<ItemStack> p_150895_2_) { if (this.allowdedIn(p_150895_1_)) { for(Potion potion : Registry.POTION) { if (potion != Potions.EMPTY) { p_150895_2_.add(PotionUtils.setPotion(new ItemStack(this), potion)); } } } } Here is my ModPotions class : public class ModPotions { public static final RegistryObject<Effect> ASTRAAL_EFFECT = Registration.EFFECTS.register("astraal", () -> new ModEffect(EffectType.BENEFICIAL, 0xFF2AC8F2)); public static final RegistryObject<Potion> ASTRAAL_POTION = Registration.POTIONS.register("astraal", () -> new Potion(new EffectInstance(ASTRAAL_EFFECT.get(), 3500, 0))); public static final RegistryObject<Potion> LONG_ASTRAAL_POTION = Registration.POTIONS.register("long_astraal", () -> new Potion(new EffectInstance(ASTRAAL_EFFECT.get(), 6500, 0))); public static final RegistryObject<Potion> STRONG_ASTRAAL_POTION = Registration.POTIONS.register("strong_astraal", () -> new Potion(new EffectInstance(ASTRAAL_EFFECT.get(), 3500, 1))); } For each new Potion I'm making, there is a potion and all its variants generated in the vanilla tabs. I fail to see what I should do to fix this, so any sort of help is appreciated, thank you all in advance.
  3. Thanks to you, it now works ! Here's the code if someone wants to do the same thing : public class ModEvents { @SubscribeEvent public void onAstraalClick(PlayerInteractEvent.RightClickItem event) { if(event.getPlayer().getHeldItemMainhand().getItem() == Items.GLASS_BOTTLE) { RayTraceResult raytraceresult = rayTrace(event.getWorld(), event.getPlayer(), RayTraceContext.FluidMode.SOURCE_ONLY); if (raytraceresult.getType() == RayTraceResult.Type.BLOCK) { BlockPos blockpos = ((BlockRayTraceResult)raytraceresult).getPos(); if (event.getWorld().getFluidState(blockpos).getFluid() == ModFluids.ASTRAAL_FLUID.get()) { event.setCanceled(true); } } } } public static BlockRayTraceResult rayTrace(World worldIn, PlayerEntity player, RayTraceContext.FluidMode fluidMode){ float f = player.rotationPitch; float f1 = player.rotationYaw; Vector3d vector3d = player.getEyePosition(1.0F); float f2 = MathHelper.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f3 = MathHelper.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f4 = -MathHelper.cos(-f * ((float)Math.PI / 180F)); float f5 = MathHelper.sin(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; double d0 = player.getAttribute(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).getValue();; Vector3d vector3d1 = vector3d.add((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); return worldIn.rayTraceBlocks(new RayTraceContext(vector3d, vector3d1, RayTraceContext.BlockMode.OUTLINE, fluidMode, player)); } }
  4. Okay thanks again for your guidance. I'll come back when I have done my best to apply your advices ^^
  5. Thank you for your answer ! I made an event as you recommanded but it works only when the player is in the fluid for some reason. public class ModEvents { public ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER); @SubscribeEvent public void onAstraalClick(PlayerInteractEvent.RightClickItem event) { if(event.getPlayer().getHeldItemMainhand().getItem() == Items.GLASS_BOTTLE) { if(event.getWorld().getFluidState(event.getPos()).getFluid() == ModFluids.ASTRAAL_FLUID.get()){ if(!event.getPlayer().world.isRemote()){ String msg = TextFormatting.AQUA + "You clicked the Astraal water !"; event.getPlayer().sendMessage(new StringTextComponent(msg), event.getPlayer().getUniqueID()); } if(event.getPlayer().inventory.hasItemStack(waterBottle)){ waterBottle.shrink(1); event.getPlayer().inventory.addItemStackToInventory(new ItemStack(ModItems.CHAOS_SHARD.get())); } } } } } Also, the first water bottle isn't replaced, it works only when there is already a water bottle in the player inventory before right-clicking, something is definitely wrong with my if statement (I'm pretty sure the first water bottle isn't already in the inventory when the event is executed) but I don't know what I can do. Is it possible to make the event wait until the water bottle is generated ? I also made some research about event cancelation in order to prevent Minecraft from giving a water bottle (which would be a lot more simplier) but I can't figure out how to use it for this case.
  6. Hey guys ! I created a fluid and a fluidBlock and I had to associate it with the Water tag in order to have proper physics and it works fine. I made exactly this : public static final ITag.INamedTag<Fluid> ASTRAAL = FluidTags.WATER; I'm trying to make it so that, when you right-click it with a glass bottle, it gives you another item instead of the water bottle. I'm using the onBlockActivated method even if it's deprecated because I read that it was okay to override it, but it seems that it doesn't work in the way it did it. Here's my custom FluidBlock class : public class ModFluidBlock extends FlowingFluidBlock { public ITag.INamedTag<Fluid> fluidTag; public ModFluidBlock(Supplier<? extends FlowingFluid> supplier, Properties properties, ITag.INamedTag<Fluid> fluidTag) { super(supplier, properties); this.fluidTag = fluidTag; } public BlockState state; public World worldIn; public BlockPos pos; public LivingEntity liventity; public PlayerEntity player; public Hand handIn; public BlockRayTraceResult hit; ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER); @Override public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entity) { if(entity instanceof LivingEntity) { this.state = state; this.worldIn = worldIn; this.pos = pos; this.liventity = (LivingEntity) entity; if(liventity.areEyesInFluid(fluidTag)) { if(fluidTag == ModFluids.ASTRAAL){ liventity.addPotionEffect(new EffectInstance(Effects.CONDUIT_POWER, 10)); } } } super.onEntityCollision(state, worldIn, pos, entity); } @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { this.state = state; this.worldIn = worldIn; this.pos = pos; this.player = player; this.handIn = handIn; this.hit = hit; String msg = TextFormatting.AQUA + "You clicked the water !"; player.sendMessage(new StringTextComponent(msg), player.getUniqueID()); if(player.getHeldItem(handIn).getItem() == Items.GLASS_BOTTLE){ if(player.inventory.hasItemStack(waterBottle)){ waterBottle.shrink(1); if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.CHAOS_SHARD.get()))){ player.dropItem(new ItemStack(ModItems.CHAOS_SHARD.get()), false); } else { player.inventory.addItemStackToInventory(new ItemStack(ModItems.CHAOS_SHARD.get())); } } return ActionResultType.func_233537_a_(worldIn.isRemote); } else { return ActionResultType.PASS; } } } As you can see, I also overrided the onEntityCollision method, which works perfectly.
  7. Yes and I tried creating a super but I can't manage to do it without getting errors. I also tried to enchant displayStack using this : displayStack.get().addEnchantment(Enchantments.INFINITY,1); but I can't figure out how to place it, because wherever I tried to place it, it resulted in not working or failing to load the game. How would you properly enchant displayStack ?
  8. Hey guys ! I created an ItemGroup for my mod, which works well, but I would like to have a glint effect (like an enchanted item) on the icon of my ItemGroup. In fact, the item I use to make my icon doesn't have a glint effect (because I don't want it), so I'm searching a way to add the glint effect only to the icon and not directly to the item. I tried to use the hasEffect() thing in many different ways that seemed logic to me, without sucess. Here's my actual code : package net.dakuro.arkhesys.utils; import net.dakuro.arkhesys.init.ModItems; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import java.util.function.Supplier; public class ModItemGroups extends ItemGroup{ public Supplier<ItemStack> displayStack; public static final ModItemGroups ARKHESYS_TAB = new ModItemGroups("arkhesys_tab", () -> new ItemStack(ModItems.CHAOS_GEM.get())); public ModItemGroups(String label, Supplier<ItemStack> displayStack) { super(label); this.displayStack = displayStack; } public boolean hasEffect() { return true; } @Override public ItemStack createIcon() { return displayStack.get(); } } Thank you in advance for any answer
×
×
  • Create New...

Important Information

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