Everything posted by person5996
-
Custom Bottle in 1.18.2
package com.projectmushroom.lavapotions.item; import java.util.List; import com.projectmushroom.lavapotions.LavaPotions; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; import net.minecraft.tags.FluidTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemUtils; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; public class ReinforcedBottle extends Item { public ReinforcedBottle(Item.Properties p_40648_) { super(p_40648_); } public InteractionResultHolder<ItemStack> use(Level p_40656_, Player p_40657_, InteractionHand p_40658_) { List<AreaEffectCloud> list = p_40656_.getEntitiesOfClass(AreaEffectCloud.class, p_40657_.getBoundingBox().inflate(2.0D), (p_40650_) -> { return p_40650_ != null && p_40650_.isAlive() && p_40650_.getOwner() instanceof EnderDragon; }); ItemStack itemstack = p_40657_.getItemInHand(p_40658_); if (!list.isEmpty()) { AreaEffectCloud areaeffectcloud = list.get(0); areaeffectcloud.setRadius(areaeffectcloud.getRadius() - 0.5F); p_40656_.playSound((Player)null, p_40657_.getX(), p_40657_.getY(), p_40657_.getZ(), SoundEvents.BOTTLE_FILL_DRAGONBREATH, SoundSource.NEUTRAL, 1.0F, 1.0F); p_40656_.gameEvent(p_40657_, GameEvent.FLUID_PICKUP, p_40657_.blockPosition()); return InteractionResultHolder.sidedSuccess(this.turnBottleIntoItem(itemstack, p_40657_, new ItemStack(Items.DRAGON_BREATH)), p_40656_.isClientSide()); } else { HitResult hitresult = getPlayerPOVHitResult(p_40656_, p_40657_, ClipContext.Fluid.SOURCE_ONLY); if (hitresult.getType() == HitResult.Type.MISS) { return InteractionResultHolder.pass(itemstack); } else { if (hitresult.getType() == HitResult.Type.BLOCK) { BlockPos blockpos = ((BlockHitResult)hitresult).getBlockPos(); if (!p_40656_.mayInteract(p_40657_, blockpos)) { return InteractionResultHolder.pass(itemstack); } if (p_40656_.getFluidState(blockpos).is(FluidTags.LAVA)) { p_40656_.playSound(p_40657_, p_40657_.getX(), p_40657_.getY(), p_40657_.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); p_40656_.gameEvent(p_40657_, GameEvent.FLUID_PICKUP, blockpos); return InteractionResultHolder.sidedSuccess(this.turnBottleIntoItem(itemstack, p_40657_,(new ItemStack(LavaPotions.REINFORCED_BOTTLE), .LAVA)), p_40656_.isClientSide()); } } return InteractionResultHolder.pass(itemstack); } } } protected ItemStack turnBottleIntoItem(ItemStack p_40652_, Player p_40653_, ItemStack p_40654_) { p_40653_.awardStat(Stats.ITEM_USED.get(this)); return ItemUtils.createFilledResult(p_40652_, p_40653_, p_40654_); } } This is what I have so far, it's pretty much just the waterbottle code but I'm just trying to figure out how to get it to pick up lava rather than water
-
Custom Bottle in 1.18.2
anyone seen this yet
-
Custom Bottle in 1.18.2
I really need help on this one, I have a custom bottle that I'm working on and I need it to pick up lava and I'm just not sure how to do that. Any help would be greatly appreciated.
-
Trying to get custom stair to rotate 1.18.2
was looking into the issue more and turns out that its the defaultBlockState() that's messing it up and setting the stairs to face north (which is their default) instead of keeping them in the direction that they are facing so anyhelp with that would be much more helpful
-
Trying to get custom stair to rotate 1.18.2
As the name suggests I'm trying to get custom stairs that I added to the game to be able to rotate and do what normal stairs do when you use stairs to build a roof but am having some trouble any help would be greatly appreciated.
-
how to grow a tree in java modding for 1.18.2
Never mind I solved it
-
how to grow a tree in java modding for 1.18.2
So I'm working on an item that will regrow things from a different item and it requires me to replace the trees so I was wondering if anyone could help me with that. In the same item in bone meals the ground in a small area around you and I am having issues with the bone mealing as well if that is also something that you guys can assist with.
-
deleting Item after its dropped
thanks
-
deleting Item after its dropped
just as the name suggests I need a way to get rid of items after they are dropped I have it so that an Item can get removed from the players inventory but I also want it so that the item that I remove from the inventory doesn't drop when the player dies. 1.18
-
removing Item from inventory
nevermind figured it out
-
removing Item from inventory
so probably a basic this that I'm forgetting or something simple that I'm doing wrong but I'm having an issue with removing an Item from the players inventory again in 1.18 and here's the code if(event.getEntityLiving() instanceof Player) { Player player = ((Player)event.getEntityLiving()); player.getInventory().removeItem(new ItemStack(ItemInit.SCYTHE.get())); }
-
removing potion effect after death
I'm having some trouble with my mod. what I'm trying to do is make it so that you have the ability to kill everything within 100 blocks that's not the issue though, the issue is after you die the effect sticks around in the world and follows you around so every 15 seconds you die can anyone help with this, it is in 1.18. here's my code package com.projectmushroom.lavapotions.client; import java.util.Random; import java.util.UUID; import com.projectmushroom.lavapotions.effect.LavaEffects; import com.projectmushroom.lavapotions.effect.Thanatos; import com.projectmushroom.lavapotions.init.BlockInit; import com.projectmushroom.lavapotions.init.ItemInit; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerBlock; import net.minecraft.world.level.block.GrassBlock; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.TallFlowerBlock; import net.minecraft.world.level.block.TallGrassBlock; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent; import net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent; import net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class ThanatosStartEvent { boolean dead = false; Random rnd = new Random(); AttributeModifier thanatos = new AttributeModifier(UUID.fromString("b48ce840-2916-4c28-acab-f6693bf3cf58"), "thanatos", 5.0D, AttributeModifier.Operation.MULTIPLY_TOTAL); AttributeModifier thanatos_speed = new AttributeModifier(UUID.fromString("04ceb1a3-516f-4489-940f-24c8da10462c"), "thanatos_speed", -0.03D, AttributeModifier.Operation.ADDITION); int timer = 0; LivingEntity entity = null; @SubscribeEvent public void onThanatosStart (PotionAddedEvent event) { if(event.getPotionEffect().getEffect().equals(LavaEffects.THANATOS.get())) { entity = event.getEntityLiving(); if(!event.getEntityLiving().getAttribute(Attributes.MAX_HEALTH).hasModifier(thanatos)) { event.getEntityLiving().getAttribute(Attributes.MAX_HEALTH).addTransientModifier(thanatos); event.getEntityLiving().heal(100); } if(!event.getEntityLiving().getAttribute(Attributes.MOVEMENT_SPEED).hasModifier(thanatos_speed)) { event.getEntityLiving().getAttribute(Attributes.MOVEMENT_SPEED).addTransientModifier(thanatos_speed); } if(event.getEntityLiving() instanceof Player) { Player player = ((Player)event.getEntityLiving()); player.getInventory().add(new ItemStack(ItemInit.SCYTHE.get())); dead = false; } } } @SubscribeEvent public void thanatosTick(TickEvent event) { if(entity != null) { timer += 1; if(!entity.hasEffect(LavaEffects.THANATOS.get())) { entity = null; dead = true; } if(timer >= 2400) { thanatosKill(entity); timer = 0; } } } public void thanatosKill(LivingEntity entity) { if(entity.hasEffect(LavaEffects.THANATOS.get()) && !dead) { int limit = 0 ; if(!entity.getAttribute(Attributes.MAX_HEALTH).hasModifier(thanatos)) { entity.getAttribute(Attributes.MAX_HEALTH).addPermanentModifier(thanatos); entity.heal(100); } if(entity.getLevel() instanceof ServerLevel) { ServerLevel level = (ServerLevel) entity.getLevel(); for(int i = -20; i <= 20; i+= 1) { for(int x = -20; x <= 5; x+= 1) { for(int z = -20; z <= 20; z+= 1) { Block block = level.getBlockState(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z)).getBlock(); if(block instanceof GrassBlock) { if (rnd.nextInt(2) == 0) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.COARSE_DIRT.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a grass block at " + i + x + z); } else { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.ROOTED_DIRT.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a grass block at " + i + x + z); } } if(block instanceof LeavesBlock || block instanceof TallGrassBlock) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a leaf or tall grass block at " + i + x + z); } if(block instanceof FlowerBlock || block instanceof TallFlowerBlock ) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.WITHER_ROSE.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a flower at " + i + x + z); } if(block instanceof RotatedPillarBlock ) { RotatedPillarBlock wood = ((RotatedPillarBlock)block); if(wood == Blocks.OAK_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), BlockInit.DEAD_OAK_LOG.get().defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } if(wood == Blocks.BIRCH_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.STRIPPED_BIRCH_LOG.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } if(wood == Blocks.ACACIA_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.STRIPPED_ACACIA_LOG.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } if(wood == Blocks.DARK_OAK_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.STRIPPED_DARK_OAK_LOG.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } if(wood == Blocks.JUNGLE_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.STRIPPED_JUNGLE_LOG.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } if(wood == Blocks.SPRUCE_LOG) { level.setBlock(new BlockPos(entity.getBlockX() - i, entity.getBlockY() - x, entity.getBlockZ() - z), Blocks.STRIPPED_SPRUCE_LOG.defaultBlockState(), Block.UPDATE_ALL); System.out.println("there is a peice of wood at " + i + x + z); } } } } } for(int i = 0; i < 100; i+= 5) { for (Entity entities : level.getAllEntities()) { if(!(entities == entity) && entities instanceof LivingEntity) { LivingEntity target = ((LivingEntity)entities); if((!(target.getBlockX() > (entity.getBlockX() + i)) && !(target.getBlockX() < (entity.getBlockX() - i))) && (!(target.getBlockY() > (entity.getBlockY() + i)) && !(target.getBlockY() < (entity.getBlockY() - i))) && (!(target.getBlockZ() > (entity.getBlockZ() + i)) && !(target.getBlockZ() < (entity.getBlockZ() - i))) && limit <= 200) { if(target.hasEffect(LavaEffects.INVINC.get())) { target.removeEffect(LavaEffects.INVINC.get()); } if(target.hasEffect(MobEffects.DAMAGE_RESISTANCE)) { target.removeEffect(MobEffects.DAMAGE_RESISTANCE); } target.hurt(new DamageSource("Devil"), 20000); System.out.println(i + " Killed " + target); limit += 1; } } } } System.out.println("total killed " + limit); } } } @SubscribeEvent public void onThanatosEnd (PotionRemoveEvent event) { if(event.getPotionEffect().getEffect().equals(LavaEffects.THANATOS.get())) { dead = true; if(event.getEntityLiving().getAttribute(Attributes.MAX_HEALTH).hasModifier(thanatos)) { event.getEntityLiving().getAttribute(Attributes.MAX_HEALTH).removeModifier(thanatos); } if(event.getEntityLiving().getAttribute(Attributes.MOVEMENT_SPEED).hasModifier(thanatos_speed)) { event.getEntityLiving().getAttribute(Attributes.MOVEMENT_SPEED).removeModifier(thanatos_speed); } if(event.getEntityLiving() instanceof Player) { Player player = ((Player)event.getEntityLiving()); player.getInventory().removeItem(new ItemStack(ItemInit.SCYTHE.get())); } } } // @SubscribeEvent // public void onThanatosDeath (PotionExpiryEvent event) // { // LivingEntity target = ((LivingEntity)event.getEntityLiving()); // if(target.hasEffect(LavaEffects.THANATOS.get())) // { // target.removeEffect(LavaEffects.THANATOS.get()); // } // } }
-
Stopping entity movement
ok this might sound dumb but I'm unsure of how to cancel the living entity's logic using LivingUpdateEvent. could I get some help on this
-
Stopping entity movement
so what I'm trying to do is stop all entity movement and make knockback and damage stack but allow the player to move this does help tho so thanks
-
Stopping entity movement
Hey I'm back again, so I have been working on a mod and while doing so have encountered several issues and difficult things to code the hardest that the people and I have thought about was basically freezing time for everything besides the player. I just started working on this and this is the code I've got for it so far so any help would be huge and greatly appreciated and I am modding for 1.18. AttributeModifier timestop = new AttributeModifier(UUID.fromString("ce90df2c-feb2-4fb9-b98f-666a26458ed2"), "time_stop", 25.0D, AttributeModifier.Operation.ADDITION); public class FreezeEntities { public static void freezeAllEntities() { MinecraftForge.EVENT_BUS.register(new Object() { @SubscribeEvent public void onEntityTick(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.END) { for (Entity entity : event.world.getEntities(null, null)) { entity.setNoGravity(true); entity.lerpMotion(0, 0, 0); } } } }); } }
-
How to make player fly
I've been working still and think I almost have it but still don't have the flight bit down here's my code and I'm just wondering if there is anything wrong with it or if I just have it in the wrong place because its not in the potions start event. public void command() { Commands.literal("fly").executes( (commandContext) -> {return fly(commandContext);} ); } private int fly(CommandContext<CommandSourceStack> commandContext) throws CommandSyntaxException { Player player = commandContext.getSource().getPlayerOrException(); player.getAbilities().mayfly = !player.getAbilities().mayfly; System.out.println("Fly set to : "+player.getAbilities().mayfly); player.onUpdateAbilities(); return 1; }
-
How to make player fly
hey so I've been trying this and even edited some of it but its not working I also don't understand what they meant by the "call onUpdateAbillities" here's what I've got any reccomendations. public void command() { LiteralArgumentBuilder command = Commands.literal("fly").executes( (commandContext) -> {return fly(commandContext);} ); } private int fly(CommandContext<CommandSourceStack> commandContext) throws CommandSyntaxException { Player player = commandContext.getSource().getPlayerOrException(); player.getAbilities().mayfly = !player.getAbilities().mayfly; System.out.println("Fly set to : "+player.getAbilities().mayfly); return 1; }
-
How to make player fly
hey so I'm attempting to make a player fly but have run into an issue that bring that I don't exactly know how to make that happen. I have tried a few things but one of the methods I tried crashed my game, I am trying to get it very similar to the creative code where you double tap the space bar to fly but there is no clear method, that I saw, to do this. Any help would be greatly appreciated. I'm also in 1.18
-
Dolphins grace but for lava
I knew about the dolphins grace and how it worked I just didn't know how to modify it for what I was trying to do but thanks for the recommendations
-
Dolphins grace but for lava
hey, so I'm looking to add dolphins grace to one of the potions that I am working on and I don't know where to look to see how it works and also don't know how to change it so that it works for lava rather than water if anyone knows any links to see how it works I would be grateful if you shared them or if you know how I can do it that would also be great. also this is in 1.18.2
-
Making player Invincible
So here's the issue, I'm making a mod with a few of my friends and we are trying to make a potion that will make the player invincible and immune to knockback we already figured the knockback out its the invincibility we're struggling with. If anyone can help I would greatly appreciate it. This is also in 1.18
IPS spam blocked by CleanTalk.