Jump to content

daveash

Members
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

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

daveash's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I was using the WolfEntity as an example for my spider. My model exports from BlockBench, so it inheirits from EntityModel. I switched my Spider model and implemented the methods to AgeableModel but could not access childBodyScale since it is private (I think I'd also need childHeadScale). I'm using 1.16. The wolfEntity class of the Model for that matter doesn't seem to have a scaling step to make the wolf appear as a child. I'm sure it does, but I haven't found it yet.
  2. I have got my custom spider working and I'm tweaking the AI and child code. The spider behaves like a wolf and protects the player. The problem I have is when I breed him, I know how to make it breed a normal spider entity, which the code considers a child, even though the model is an adult (which originally was done for a test.) How do I make this a smaller sized child spider? Here's my code for the createChild and I know why it creates the normal spider, but I don't know how to change it to make a smaller version of my spider. @Nullable @Override public AgeableEntity createChild(AgeableEntity ageable) { OrangeSpiderEntity entity = new OrangeSpiderEntity(RaydenhallEntities.ORANGE_SPIDER_ENTITY.get(), this.world); entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(this.getPosX(), this.getPosY(), this.getPosZ())), SpawnReason.BREEDING, (ILivingEntityData) null, (CompoundNBT) null); UUID uuid = this.getOwnerId(); if (uuid != null) { entity.setOwnerId(uuid); entity.setTamed(true); } return entity; } This code basically makes the adult looking spider, sets owner and spawns it in. How do I make a smaller version of the OrangeSpiderEntity?
  3. I am trying to make a spider a pet. So far, it is tameable, but once it is tamed, it sits there. It seems to be ignoring its goals even though I get the tamed advancement and his texture switches. He moves and if he's attacked, he defends himself, but he won't follow. I'm completely new to this, maybe a few weeks in, but I know C# and some Java. I used the TameableEntity class extending IAngerable mimicking the WolfEntity class without all the collar and swim code. Any suggestions would help. I hope it's something simple I'm not doing. I've added some unnecessary code trying to figure out what I'm missing from the WolfEntity class but would appreciate any help or ideas. package com.shortman.raydenhall.entities; import com.shortman.raydenhall.RaydenHall; import com.shortman.raydenhall.init.RaydenhallEntities; import com.shortman.raydenhall.init.RaydenhallItems; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.entity.WolfRenderer; import net.minecraft.entity.*; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.monster.AbstractSkeletonEntity; import net.minecraft.entity.monster.CreeperEntity; import net.minecraft.entity.monster.GhastEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.passive.TurtleEntity; import net.minecraft.entity.passive.WolfEntity; import net.minecraft.entity.passive.horse.AbstractHorseEntity; import net.minecraft.entity.passive.horse.LlamaEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.Objects; import java.util.UUID; import java.util.function.Predicate; public class OrangeSpiderEntity extends TameableEntity implements IAngerable { private static final DataParameter<Integer> ANGER_TIME = EntityDataManager.createKey(OrangeSpiderEntity.class, DataSerializers.VARINT); private UUID oSpiderUUID; public static final Predicate<LivingEntity> TARGET_ENTITIES = (OrangeSpiderEntity) -> { EntityType<?> entitytype = OrangeSpiderEntity.getType(); return entitytype == EntityType.ZOMBIE || entitytype == EntityType.HUSK || entitytype == EntityType.ZOMBIE_VILLAGER; }; public OrangeSpiderEntity(EntityType<? extends TameableEntity> type, World worldIn) { super(type, worldIn); this.setTamed(false); } @Override protected void registerGoals() { this.goalSelector.addGoal(1, new SwimGoal(this)); this.goalSelector.addGoal(2, new SitGoal(this)); this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F)); this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true)); this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false)); this.goalSelector.addGoal(7, new BreedGoal(this, 1.0D)); this.goalSelector.addGoal(8, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); this.goalSelector.addGoal(10, new LookAtGoal(this, PlayerEntity.class, 8.0F)); this.goalSelector.addGoal(10, new LookRandomlyGoal(this)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this)); this.targetSelector.addGoal(3, (new HurtByTargetGoal(this)).setCallsForHelp()); this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, 10, true, false, this::func_233680_b_)); this.targetSelector.addGoal(5, new NonTamedTargetGoal<>(this, AnimalEntity.class, false, TARGET_ENTITIES)); this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeletonEntity.class, false)); this.targetSelector.addGoal(8, new ResetAngerGoal<>(this, true)); } @Override protected void updateAITasks() { super.updateAITasks(); } public static AttributeModifierMap.MutableAttribute registerAttributes() { return MobEntity.func_233666_p_() .createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.7D) .createMutableAttribute(Attributes.MAX_HEALTH, 16.0D) .createMutableAttribute(Attributes.ATTACK_DAMAGE, 8.0D); } @Override public void registerData() { super.registerData(); this.dataManager.register(ANGER_TIME, 0); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F); } protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_SPIDER_AMBIENT; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_SPIDER_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_SPIDER_DEATH; } protected float getSoundVolume() { return 0.4F; } public void onDeath(DamageSource cause) { super.onDeath(cause); } public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { return false; } else { Entity entity = source.getTrueSource(); this.func_233687_w_(false); if (entity != null && !(entity instanceof PlayerEntity) && !(entity instanceof AbstractArrowEntity)) { amount = (amount + 1.0F) / 2.0F; } return super.attackEntityFrom(source, amount); } } public boolean attackEntityAsMob(Entity entityIn) { boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getAttributeValue(Attributes.ATTACK_DAMAGE))); if (flag) { this.applyEnchantments(this, entityIn); } return flag; } public void setTamed(boolean tamed) { super.setTamed(tamed); if (tamed) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(20.0D); this.setHealth(20.0F); } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(14.0D); } this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); } @Override public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { ItemStack itemstack = p_230254_1_.getHeldItem(p_230254_2_); Item item = itemstack.getItem(); if (this.world.isRemote) { boolean flag = this.isOwner(p_230254_1_) || this.isTamed() || item == Items.ROTTEN_FLESH && !this.isTamed() && !this.func_233678_J__(); return flag ? ActionResultType.CONSUME : ActionResultType.PASS; } else { if (this.isTamed()) { if (this.isBreedingItem(itemstack) && this.getHealth() < this.getMaxHealth()) { if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } this.heal((float) Objects.requireNonNull(item.getFood()).getHealing()); return ActionResultType.SUCCESS; } } else if (item == Items.ROTTEN_FLESH && !this.func_233678_J__()) { if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { this.setTamedBy(p_230254_1_); this.navigator.clearPath(); this.setAttackTarget((LivingEntity) null); this.func_233687_w_(true); this.world.setEntityState(this, (byte) 7); } else { this.world.setEntityState(this, (byte) 6); } return ActionResultType.SUCCESS; } //getEntityInteractionResult return super.func_230254_b_(p_230254_1_, p_230254_2_); } } @Nullable @Override public AgeableEntity createChild(AgeableEntity ageable) { OrangeSpiderEntity orangeSpiderEntity = RaydenhallEntities.ORANGE_SPIDER_ENTITY.get().create(this.world); UUID uuid = this.getOwnerId(); if (uuid != null) { orangeSpiderEntity.setOwnerId(uuid); orangeSpiderEntity.setTamed(true); } return orangeSpiderEntity; } public boolean isBreedingItem(ItemStack stack) { Item item = stack.getItem(); return item.isFood() && item.getFood().isMeat(); } public int getMaxSpawnedInChunk() { return 8; } @Override public int getAngerTime() { return this.dataManager.get(ANGER_TIME); } @Override public void setAngerTime(int time) { this.dataManager.set(ANGER_TIME, time); } @Nullable @Override public UUID getAngerTarget() { return this.oSpiderUUID; } @Override public void setAngerTarget(@Nullable UUID target) { this.oSpiderUUID = target; } @Override public void func_230258_H__() { this.setAngerTime(160); } @Override public boolean canBeLeashedTo(PlayerEntity player) { return !this.func_233678_J__() && super.canBeLeashedTo(player); } @Override public void playTameEffect(boolean play) { this.playSound(SoundEvents.ENTITY_SPIDER_AMBIENT, 0.15F, 1.0F); } public void tick() { OrangeSpiderEntity.this.setAttackTarget((LivingEntity)null); super.tick(); } public boolean canMateWith(AnimalEntity otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof OrangeSpiderEntity)) { return false; } else { OrangeSpiderEntity spiderentity = (OrangeSpiderEntity)otherAnimal; if (!spiderentity.isTamed()) { return false; } else if (super.func_233684_eK_()) { return false; } else { return this.isInLove() && spiderentity.isInLove(); } } } }
  4. Hi, New to the board. I have a C#, javascript, C++ background, but haven't coded in 5 years, so I believe this is a newb question: I'm making a super food that gives temporary effects for a battle (i.e. eat a chicken leg and get one minute of strength, etc) Here's my class: public class ChickenLeg extends Item { public ChickenLeg() { super(new Item.Properties().food(new Food.Builder() .hunger(4) .meat() .saturation(6.0f) .build() ).group(RaydenHall.CUSTOM_ITEMS)); } When I do .effect, all the examples I see are for what IntelliJ is saying is a deprecated item. .effect(EffectInstance effectIn, float probability) verses the new way: .effect(Supplier<EffectInstance> effectIn, float probability) Is is possible to get an example on how to use the new method? I've tried to find one and all I get are examples of the old way. Thank you and thank you for forge. I've had fun reconnecting with my programming roots.
×
×
  • Create New...

Important Information

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