1.15 Mob Climbing Code

Started by gustavowizard123 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
1.15 Mob Climbing Code

guys im trying to set a climbing code (from spider mob) to my custom mob, i was able to do on 1.12 but nto now...

private static final DataParameter<Byte> CLIMBING = EntityDataManager.createKey(CapuchinBrownEntity.class, DataSerializers.BYTE);

//CLIMB CODE 1.15 WIP

		protected PathNavigator createNavigator(World worldIn) {
      		return new ClimberPathNavigator(this, worldIn);
   		}

   		protected void registerData() {
      	super.registerData();
      	this.dataManager.register(CLIMBING, (byte)0);
   		}

   
   		public void tick() {
      	super.tick();
      		if (!this.world.isRemote) {
        		 this.setBesideClimbableBlock(this.collidedHorizontally);
      		}
   		}

   		public boolean isBesideClimbableBlock() {
      		return (this.dataManager.get(CLIMBING) & 1) != 0;
   		}

   
   public void setBesideClimbableBlock(boolean climbing) {
      byte b0 = this.dataManager.get(CLIMBING);
      if (climbing) {
         b0 = (byte)(b0 | 1);
      } else {
         b0 = (byte)(b0 & -2);
      }

      this.dataManager.set(CLIMBING, b0);
   }
	

	/// CLIMB CODE

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
this is what i did so far;…
Fri, 06/12/2020 - 21:49

this is what i did so far; the first call line goes just below the mob first line, like on the spider file, the rest below, i took this code from the spider mob, so i must be doing something wrong

 

public class SpiderEntity extends MonsterEntity {
   private static final DataParameter<Byte> CLIMBING = EntityDataManager.createKey(SpiderEntity.class, DataSerializers.BYTE);

   public SpiderEntity(EntityType<? extends SpiderEntity> type, World worldIn) {
      super(type, worldIn);
   }

   protected void registerGoals() {
      this.goalSelector.addGoal(1, new SwimGoal(this));
      this.goalSelector.addGoal(3, new LeapAtTargetGoal(this, 0.4F));
      this.goalSelector.addGoal(4, new SpiderEntity.AttackGoal(this));
      this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 0.8D));
      this.goalSelector.addGoal(6, new LookAtGoal(this, PlayerEntity.class, 8.0F));
      this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
      this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
      this.targetSelector.addGoal(2, new SpiderEntity.TargetGoal<>(this, PlayerEntity.class));
      this.targetSelector.addGoal(3, new SpiderEntity.TargetGoal<>(this, IronGolemEntity.class));
   }

   /**
    * Returns the Y offset from the entity's position for any entity riding this one.
    */
   public double getMountedYOffset() {
      return (double)(this.getHeight() * 0.5F);
   }

   /**
    * Returns new PathNavigateGround instance
    */
   protected PathNavigator createNavigator(World worldIn) {
      return new ClimberPathNavigator(this, worldIn);
   }

   protected void registerData() {
      super.registerData();
      this.dataManager.register(CLIMBING, (byte)0);
   }

   /**
    * Called to update the entity's position/logic.
    */
   public void tick() {
      super.tick();
      if (!this.world.isRemote) {
         this.setBesideClimbableBlock(this.collidedHorizontally);
      }

   }

   protected void registerAttributes() {
      super.registerAttributes();
      this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
      this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue((double)0.3F);
   }

   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 void playStepSound(BlockPos pos, BlockState blockIn) {
      this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
   }

   /**
    * Returns true if this entity should move as if it were on a ladder (either because it's actually on a ladder, or
    * for AI reasons)
    */
   public boolean isOnLadder() {
      return this.isBesideClimbableBlock();
   }

   public void setMotionMultiplier(BlockState state, Vec3d motionMultiplierIn) {
      if (state.getBlock() != Blocks.COBWEB) {
         super.setMotionMultiplier(state, motionMultiplierIn);
      }

   }

   public CreatureAttribute getCreatureAttribute() {
      return CreatureAttribute.ARTHROPOD;
   }

   public boolean isPotionApplicable(EffectInstance potioneffectIn) {
      if (potioneffectIn.getPotion() == Effects.POISON) {
         net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, potioneffectIn);
         net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
         return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW;
      }
      return super.isPotionApplicable(potioneffectIn);
   }

   /**
    * Returns true if the WatchableObject (Byte) is 0x01 otherwise returns false. The WatchableObject is updated using
    * setBesideClimableBlock.
    */
   public boolean isBesideClimbableBlock() {
      return (this.dataManager.get(CLIMBING) & 1) != 0;
   }

   /**
    * Updates the WatchableObject (Byte) created in entityInit(), setting it to 0x01 if par1 is true or 0x00 if it is
    * false.
    */
   public void setBesideClimbableBlock(boolean climbing) {
      byte b0 = this.dataManager.get(CLIMBING);
      if (climbing) {
         b0 = (byte)(b0 | 1);
      } else {
         b0 = (byte)(b0 & -2);
      }

      this.dataManager.set(CLIMBING, b0);
   }

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The errors it gives:   C:…
Fri, 06/12/2020 - 21:53

The errors it gives:

 

C:\Users\Guatavo\MCreatorWorkspaces\wizard_animals_plus\src\main\java\net\mcreator\wizardanimalsplus\entity\CapuchinBrownEntity.java:73: error: method createKey in class EntityDataManager cannot be applied to given types; 
   private static final DataParameter<Byte> CLIMBING = EntityDataManager.createKey(CapuchinBrownEntity.class, DataSerializers.BYTE); 
                                                                        ^ 
  required: Class<? extends Entity>,IDataSerializer<T> 
  found: Class<CapuchinBrownEntity>,IDataSerializer<Byte> 
  reason: cannot infer type-variable(s) T 
    (argument mismatch; Class<CapuchinBrownEntity> cannot be converted to Class<? extends Entity>) 
  where T is a type-variable: 
    T extends Object declared in method <T>createKey(Class<? extends Entity>,IDataSerializer<T>) 
1 error 
> Task :compileJava FAILED 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':compileJava'. 
> Compilation failed; see the compiler error output for details.

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
> Task :compileJava C:…
Fri, 06/12/2020 - 21:54
> Task :compileJava 
C:\Users\Guatavo\MCreatorWorkspaces\wizard_animals_plus\src\main\java\net\mcreator\wizardanimalsplus\entity\CapuchinBrownEntity.java:158: error: cannot find symbol 
         this.dataManager.register(CLIMBING, (byte)0); 
                                   ^ 
  symbol:   variable CLIMBING 
  location: class CustomEntity 
C:\Users\Guatavo\MCreatorWorkspaces\wizard_animals_plus\src\main\java\net\mcreator\wizardanimalsplus\entity\CapuchinBrownEntity.java:170: error: cannot find symbol 
            return (this.dataManager.get(CLIMBING) & 1) != 0; 
                                         ^ 
  symbol:   variable CLIMBING 
  location: class CustomEntity 
C:\Users\Guatavo\MCreatorWorkspaces\wizard_animals_plus\src\main\java\net\mcreator\wizardanimalsplus\entity\CapuchinBrownEntity.java:175: error: cannot find symbol 
      byte b0 = this.dataManager.get(CLIMBING); 
                                     ^ 
  symbol:   variable CLIMBING 
  location: class CustomEntity 
C:\Users\Guatavo\MCreatorWorkspaces\wizard_animals_plus\src\main\java\net\mcreator\wizardanimalsplus\entity\CapuchinBrownEntity.java:182: error: cannot find symbol 
      this.dataManager.set(CLIMBING, b0); 
                           ^ 
  symbol:   variable CLIMBING 
  location: class CustomEntity 
4 errors 
> Task :compileJava FAILED 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':compileJava'. 
> Compilation failed; see the compiler error output for details.

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
actually the problem is only…
Sat, 06/13/2020 - 00:37

actually the problem is only here:

 

private static final DataParameter<Byte> CLIMBING = EntityDataManager.createKey(CapuchinBrownEntity.class, DataSerializers.BYTE);

 

When i use SpiderEntity class it works but the model wotn appear off course, so im missing something here to make it work for my entity