• Recently Browsing

    No registered users viewing this page.

  • Posts

    • oh wait I just realized how dumb I was this is what it should be: this.dataManager.register(Fuel, this.movedDistance);  
    • //updated code public class Car extends AbstractChestedHorseEntity { public boolean outofgas; private boolean particle_reducer; public static final DataParameter<Float> Fuel = EntityDataManager.createKey(Car.class, DataSerializers.FLOAT); public Car(EntityType<? extends Car> type, World worldIn) { super(type, worldIn); this.outofgas = false; this.particle_reducer = false; } //forgot to do super.registerAttributes() [Sorry] @Override protected void registerAttributes() { this.getAttributes().registerAttribute(SharedMonsterAttributes.MAX_HEALTH); this.getAttributes().registerAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); this.getAttributes().registerAttribute(SharedMonsterAttributes.FOLLOW_RANGE); this.getAttributes().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE); this.getAttributes().registerAttribute(SharedMonsterAttributes.ARMOR); this.getAttributes().registerAttribute(LivingEntity.SWIM_SPEED); this.getAttributes().registerAttribute(LivingEntity.ENTITY_GRAVITY); this.getAttributes().registerAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS); this.getAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1.0F); this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4F); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0F); this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(0.0F); this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0F); this.getAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(2.0F); this.getAttribute(LivingEntity.SWIM_SPEED).setBaseValue(0.05F); } @Override protected void registerData() { super.registerData(); this.dataManager.register(Fuel, 0.0F); } @Override protected void registerGoals() { } @Override public boolean canBeLeashedTo(PlayerEntity player) { return false; } @Override public void readAdditional(@NotNull CompoundNBT compound) { super.readAdditional(compound); this.setFuelValue(compound.getFloat("movedDistance")); } @Override public void writeAdditional(@NotNull CompoundNBT compound) { super.writeAdditional(compound); compound.putFloat("movedDistance", this.movedDistance); } @Override public void tick() { super.tick(); outofgas = this.movedDistance > 2000; this.particle_reducer = !this.particle_reducer; ClientWorld world = Minecraft.getInstance().world; Vec3d vec = new Vec3d(this.getPosX(),this.getPosY(), this.getPosZ()); Vec3d speedvec = new Vec3d(-0.3d, 0.2d, 0d); vec.add(this.getLookVec()); this.getDataManager().set(Fuel, this.movedDistance); if(world != null && !this.outofgas && this.particle_reducer) world.addParticle(ParticleTypes.SQUID_INK, vec.x, vec.y, vec.z, speedvec.x, speedvec.y, speedvec.z); // this.setHealth(this.getDataManager().get(Car.health)); } public void Refuel(){ this.distanceWalkedModified = 0; this.distanceWalkedOnStepModified = 0; this.prevDistanceWalkedModified = 0; this.prevMovedDistance = 0; this.movedDistance = 0; LOGGER.info("REFUELED"); } public void setFuelValue(float value){ this.distanceWalkedModified = value; this.distanceWalkedOnStepModified = value; this.prevDistanceWalkedModified = value; this.prevMovedDistance = value; this.movedDistance = value; } @Override protected boolean canMate() { return false; } @Override public boolean canBreed() { return false; } @Nullable @Override protected SoundEvent getDeathSound() { return null; } @Nullable @Override protected SoundEvent getAmbientSound() { return null; } @Nullable @Override protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return null; } @Override protected void playStepSound(BlockPos pos, BlockState blockIn) { // this.playSound(ModSoundEvents.MOVING_CAR, 0.5F, 1.0F); } @Override public void setMoveStrafing(float amount) {} @Override public boolean hasChest() { return true; } @Override public boolean isTame() { return true; } @Override public boolean canEatGrass() { return false; } @Override public boolean isHorseSaddled() { return !this.outofgas; } @Override public boolean canBeSteered() { return !this.outofgas; } @Override public boolean isBreedingItem(@NotNull ItemStack stack) { return false; } @Override public boolean wearsArmor() { return false; } @Override public boolean canDespawn(double distanceToClosestPlayer) { return false; } @Override public boolean canJump() { return false; } @Override public boolean canBeRiddenInWater() { return false; } @Override public boolean canBePushed() { return false; } @Override public boolean canBeSaddled() { return false; } @Override protected int getInventorySize() { return 29; } @Override public int getInventoryColumns() { return 9; } }
    • How sad.   Now, assuming you want help: Show your code.
    • I tried using the data manager and it didn't work
    • I don't know what kind of trial and error you did, but this is entirely untrue. In fact this event is server-only, as far as I can tell. Also note: If you want to completely replace an entity whenever it is spawned, you will need to use EntityJoinWorldEvent (which is fired on client and server, so check World#isRemote)-   I am not sure why you need a specific subclass of the entity to do this.
  • Topics

  • Who's Online (See full list)