Everything posted by Feroov
-
[1.19.1] Entity spawn broken in custom dimensions biome
So I have a custom dimension with a biome, in that biome normal regular minecraft mobs spawn normally but when I try using my own entities, it spawns hundreds of the entity repeating over and over until the game just lags too much and crashes
-
[1.19] Custom needs_diamond_tool.json?
I do understand the general gist, just needed to check how to register it & implement it, I usually understand by having the code on my face, that's how I understand, best to throw myself into the sea, try to learn to swim that way let's say. Thank you though this, does help a lot appreciate it
-
[1.19] Custom needs_diamond_tool.json?
Thanks for this, I basically implement my current ModTier class to "Tier" class, from there how would I set it up, do I need to register the tag or? Could you please explain briefly, or perhaps a repo some sorts?
-
[1.19] Custom needs_diamond_tool.json?
Hi, so I have an ore that is higher tier than diamond, and I want that ore to be mined with a specific pickaxe only, how can I implement it without using the needs_diamond_tools json or create a custom tag?
-
[1.19] How to spawn an entity when the initial entity dies (Slime reference)
Thanks so much all is good now and figured out, cheers
-
[1.19] How to spawn an entity when the initial entity dies (Slime reference)
Yes already checked but I unfortunately couldn't really grasp
-
[1.19] How to spawn an entity when the initial entity dies (Slime reference)
As the title mentioned, I tried checking in the Slime class but I couldn't seem to grasp, how can I make the functionality of the slime basically, but the difference is, when the initial mob dies, it spawns a different type of mob 🤔 Thanks in advance
-
[1.18.2] How to manipulate movement speed of entities
So I have a stationary hostile mob it has movement_speed set to 0, how can I make it move only once it detects the player in range?
-
[1.18.1] How can I make my custom bow/item use my custom arrow/item/ammo?
Here is my main class for it: public class Musket extends BowItem { public Musket(Properties p_40660_) { super(p_40660_); } @Override public int getDefaultProjectileRange() { return 15; } @Override public void releaseUsing(ItemStack stack, Level worldIn, LivingEntity entityLiving, int timeLeft) { if (entityLiving instanceof Player) { Player playerentity = (Player) entityLiving; if (stack.getDamageValue() < (stack.getMaxDamage() - 1)) { playerentity.getCooldowns().addCooldown(this, 45); Player player = (Player) entityLiving; ItemStack itemstack = player.getProjectile(stack); if (itemstack.isEmpty()) { itemstack = new ItemStack(ModItems.MUSKET_BULLET.get()); } MusketBullet arrowitem = (MusketBullet) (itemstack.getItem() instanceof MusketBullet ? itemstack.getItem() : ModItems.MUSKET_BULLET.get()); MusketAmmo abstractarrow = (MusketAmmo) arrowitem.createMusket(worldIn, itemstack, player); abstractarrow = customeArrow(abstractarrow); boolean flag1 = player.getAbilities().instabuild || (itemstack.getItem() instanceof MusketBullet && ((MusketBullet) itemstack.getItem()) .isInfinite(itemstack, stack, player)); if (!worldIn.isClientSide) { MusketAmmo abstractarrowentity = createArrow(worldIn, stack, playerentity); abstractarrowentity = customeArrow(abstractarrowentity); abstractarrowentity.shootFromRotation(playerentity, playerentity.getXRot(), playerentity.getYRot(), 0.0F, 1.0F * 3.0F, 1.0F); abstractarrowentity.setBaseDamage(2.5); abstractarrowentity.tickCount = 35; abstractarrowentity.isNoGravity(); stack.hurtAndBreak(1, entityLiving, p -> p.broadcastBreakEvent(entityLiving.getUsedItemHand())); worldIn.addFreshEntity(abstractarrowentity); worldIn.playSound((Player) null, playerentity.getX(), playerentity.getY(), playerentity.getZ(), ModSoundEvents.MUSKET.get(), SoundSource.PLAYERS, 1.0F, 1.0F / (worldIn.random.nextFloat() * 0.4F + 1.2F) + 0.25F * 0.5F); if (!flag1 && !player.getAbilities().instabuild) { itemstack.shrink(1); if (itemstack.isEmpty()) { player.getInventory().removeItem(itemstack); } } } } } } public InteractionResultHolder<ItemStack> use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { ItemStack itemstack = p_40673_.getItemInHand(p_40674_); boolean flag = !p_40673_.getProjectile(itemstack).isEmpty(); InteractionResultHolder<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); if (ret != null) return ret; if (!p_40673_.getAbilities().instabuild && !flag) { return InteractionResultHolder.fail(itemstack); } else { p_40673_.startUsingItem(p_40674_); return InteractionResultHolder.consume(itemstack); } } public MusketAmmo createArrow(Level worldIn, ItemStack stack, LivingEntity shooter) { MusketAmmo arrowentity = new MusketAmmo(worldIn, shooter); return arrowentity; } @Override public UseAnim getUseAnimation(ItemStack stack) { return UseAnim.BOW; } public MusketAmmo customeArrow(MusketAmmo arrow) { return arrow; } }
-
[SOLVED] Projectile knockback? [1.18.1]
I got a custom projectile that extends abstract arrow, its being used by my cannon entities, how can I change the knockback force of this to a greate amount, do I need to change something on my entity class or the projectile entity itself? One of the methods I use on my projectile entity is: @Override protected void onHitEntity(EntityHitResult entityHitResult) { Entity entity = entityHitResult.getEntity(); if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().is(entity)) { if (!this.level.isClientSide) { this.remove(RemovalReason.KILLED); } } if (entity instanceof LivingEntity) { LivingEntity livingentity = (LivingEntity)entity; if (!this.level.isClientSide && this.getPierceLevel() <= 0) { livingentity.setArrowCount(livingentity.getArrowCount() + 1); } if (this.knockback > 0) { Vec3 vec3 = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale((double)this.knockback * 20.6D); if (vec3.lengthSqr() > 0.0D) { livingentity.push(vec3.x, 0.1D, vec3.z); } } } Entity entity1 = this.getOwner(); DamageSource damagesource; if (entity1 == null) { damagesource = DamageSource.arrow(this, this); } else { damagesource = DamageSource.arrow(this, entity1); if (entity1 instanceof LivingEntity) { ((LivingEntity) entity1).setLastHurtMob(entity); } } if (entity.hurt(damagesource, 10.0F)) { if (entity instanceof LivingEntity) { LivingEntity livingentity = (LivingEntity) entity; if (!this.level.isClientSide && entity1 instanceof LivingEntity) { EnchantmentHelper.doPostHurtEffects(livingentity, entity1); EnchantmentHelper.doPostDamageEffects((LivingEntity) entity1, livingentity); } this.doPostHurtEffects(livingentity); if (entity1 != null && livingentity != entity1 && livingentity instanceof Player && entity1 instanceof ServerPlayer && !this.isSilent()) { ((ServerPlayer) entity1).connection .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F)); } } } else { if (!this.level.isClientSide) { this.remove(RemovalReason.KILLED); } } } SOLUTION For those who might need in the future, in your custom projectile entity (asuming youve extended to abstract arrow entity) just call on the constructor this.setKnockback();
-
[1.18.1] How to make this entity spawning code more efficient?
Hello there, so I currently have this method that works, and my mob do spawn but it doesn't spawn them efficiently at all even though I have set the weight 100: @SubscribeEvent public static void onBiomeLoad(final BiomeLoadingEvent event) { if(event.getName() == null) return; MobSpawnSettingsBuilder spawns = event.getSpawns(); if(event.getCategory().equals(Biome.BiomeCategory.SWAMP)) { spawns.addSpawn(MobCategory.CREATURE, new MobSpawnSettings.SpawnerData(ModEntityTypes.CROAKER.get(), 100,2,4)); } } They basically spawn very rare, is there a better way or to fix this maybe?
-
[1.18.1] Multiple sound events on entities
Thank you so much, managed to do it 👍
-
[1.18.1] Multiple sound events on entities
Hi there, is it possible to make my entity for example ambient noise use two different soundevents randomly, Do I need to create a config or do I just mess around with sounds.json?
-
How to remove duplicate trades? [1.18.1/1.17]
So on my Villager trades class or in this method of mine in my entity class, just a bit confused still so I apologize
-
How to remove duplicate trades? [1.18.1/1.17]
As you read from the title, I have a mob that extends to custom abstract villager etc (literal same function as wandering trader but modified), everything is fine but sometimes I get same duplicate trades, how can I fix that? I was possibly thinking something to do with from: @Override protected void updateTrades() { ModVillagerTrades.ItemListing[] avillagertrades$itrade = ModVillagerTrades.CROAKER_TRADES.get(1); if (avillagertrades$itrade != null) { MerchantOffers merchantoffers = this.getOffers(); this.addOffersFromItemListings(merchantoffers, avillagertrades$itrade, 9); int i = this.random.nextInt(avillagertrades$itrade.length); ModVillagerTrades.ItemListing villagertrades$itrade = avillagertrades$itrade[i]; MerchantOffer merchantoffer = villagertrades$itrade.getOffer(this, this.random); if (merchantoffer != null) { merchantoffers.add(merchantoffer); } } } method thats in my entity class
-
I have a problem finding entitties in a five block radius around the player [1.17]
Yes it worked now, thank you so so much for all who helped appreciate it
-
I have a problem finding entitties in a five block radius around the player [1.17]
I am deeply sorry and apologize, my java knowledge isn't the best but sometimes simple stuff like these confuse me but can do other complex stuff, I've put this and pretty sure this is wrong as well, could you maybe please show me the correct way List<LivingEntity> entities = player.getLevel().getNearbyEntities(LivingEntity.class, TargetingConditions.DEFAULT, player.getBoundingBox().inflate(5,0,5), LivingEntity::isAlive);
-
I have a problem finding entitties in a five block radius around the player [1.17]
I'm still a bit lost, here is a picture just in case: https://imgur.com/a/50EZf6l
-
I have a problem finding entitties in a five block radius around the player [1.17]
How can I do that?
-
I have a problem finding entitties in a five block radius around the player [1.17]
It's a short line I am having an issue with: List<LivingEntity> entities = player.getLevel().getNearbyEntities(LivingEntity.class, player.getBoundingBox().inflate(5,0,5), LivingEntity::isAlive); On the LivingEntity::isAlive part where it says "is not a functional interface" Any suggestions?
-
How can I make my mob completely invincibile to all types of damage [1.17]
Oh my goodness I actually forgot I could do that I apologize but thank you again!
-
How can I make my mob completely invincibile to all types of damage [1.17]
public class Electricity extends Zombie implements IAnimatable { public static final EntityDataAccessor<Integer> STATE = SynchedEntityData.defineId(Electricity.class, EntityDataSerializers.INT); private boolean invulnerable; private int lifeTicks = 42; private final AnimationFactory factory = new AnimationFactory(this); private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { event.getController().setAnimation(new AnimationBuilder().addAnimation("lightning", true)); return PlayState.CONTINUE; } @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController<Electricity> (this, "controller", 0, this::predicate)); } @Override public AnimationFactory getFactory() { return this.factory; } public Electricity(EntityType<? extends Zombie> p_i48549_1_, Level p_i48549_2_) { super(p_i48549_1_, p_i48549_2_); } public static AttributeSupplier.Builder createAttributes() { return Mob.createMobAttributes() .add(Attributes.MAX_HEALTH, 1000.0D) .add(Attributes.MOVEMENT_SPEED, 0.0D) .add(Attributes.ATTACK_DAMAGE, 25.0D) .add(Attributes.FOLLOW_RANGE, 45.0D) .add(Attributes.SPAWN_REINFORCEMENTS_CHANCE); } @Override public boolean doHurtTarget(Entity entityIn) { if (!super.doHurtTarget(entityIn)) { return false; } else { if (entityIn instanceof LivingEntity) { ((LivingEntity)entityIn).addEffect(new MobEffectInstance(MobEffects.CONFUSION, 140)); } return true; } } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(STATE, 0); } @Override protected void registerGoals() { super.registerGoals(); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Monster.class, false)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, FlyingMob.class, false)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Animal.class, false)); } public boolean isInvulnerableTo(DamageSource p_20122_) { return this.isRemoved() || this.invulnerable && p_20122_ != DamageSource.OUT_OF_WORLD && !p_20122_.isCreativePlayer(); } public boolean isInvulnerable() { return this.invulnerable; } public void setInvulnerable(boolean p_20332_) { this.invulnerable = p_20332_; } @Nullable @Override protected SoundEvent getHurtSound(@Nonnull DamageSource damageSourceIn) { this.playSound(SoundEvents.GHAST_HURT, 0.0F, 0.0F); return null; } @Nullable @Override protected SoundEvent getDeathSound() { this.playSound(SoundEvents.LIGHTNING_BOLT_IMPACT, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_IMPACT, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_IMPACT, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_IMPACT, 7.0F, 1.0F); return null; } @Nullable @Override protected SoundEvent getAmbientSound() { this.playSound(SoundEvents.LIGHTNING_BOLT_THUNDER, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_THUNDER, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_THUNDER, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_THUNDER, 7.0F, 1.0F); this.playSound(SoundEvents.LIGHTNING_BOLT_THUNDER, 7.0F, 1.0F); return null; } public void tick() { super.tick(); if (--this.lifeTicks < 0) { this.remove(RemovalReason.DISCARDED); } } @Override public boolean isBaby() { return false; } @Override public boolean isPushable() { return false; } @Override protected void pushEntities() { } } There it is
-
How can I make my mob completely invincibile to all types of damage [1.17]
I found one method on Entity class called isInvulnerable, I used it but it doesn't work any tips
-
On hit method issue between mappings [1.16.5]
Ok I actually found out it actually works with other effects, but poison doesn't seem to be working, interesting
-
On hit method issue between mappings [1.16.5]
Yes it is being called, I use IntelliJ, its called from the ItemStack class, and I tested directly just running the game hitting few entities basically
IPS spam blocked by CleanTalk.