Skip to content

Commit

Permalink
Remove attribute inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Jan 2, 2025
1 parent b094c07 commit d88a748
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.wenxin2.marioverse.entities;

import com.wenxin2.marioverse.Marioverse;
import com.wenxin2.marioverse.entities.ai.controls.AmphibiousMoveControl;
import com.wenxin2.marioverse.entities.ai.goals.GoombaRideGoal;
import com.wenxin2.marioverse.entities.ai.goals.GoombaSitGoal;
import com.wenxin2.marioverse.entities.ai.goals.GoombaSleepGoal;
import com.wenxin2.marioverse.entities.ai.goals.NearestAttackableTagGoal;
import com.wenxin2.marioverse.init.AttributesRegistry;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.EntityRegistry;
import com.wenxin2.marioverse.init.SoundRegistry;
Expand All @@ -15,16 +13,13 @@
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
Expand Down Expand Up @@ -102,42 +97,18 @@ public void remove(Entity.RemovalReason removalReason) {
double zOffset = Math.sin(angle) * width;
double upwardMotion = 0.3 + this.random.nextDouble() * 0.2;

AttributeInstance heightScale = this.getAttribute(AttributesRegistry.HEIGHT_SCALE);
AttributeInstance widthScale = this.getAttribute(AttributesRegistry.WIDTH_SCALE);

GoombaEntity goomba = EntityRegistry.GOOMBA.get().create(this.level());
if (goomba != null) {
if (this.isPersistenceRequired())
goomba.setPersistenceRequired();

AttributeInstance goombaHeightScale = goomba.getAttribute(AttributesRegistry.HEIGHT_SCALE);
AttributeInstance goombaWidthScale = goomba.getAttribute(AttributesRegistry.WIDTH_SCALE);

goomba.setCustomName(component);
goomba.setNoAi(flag);
goomba.setInvulnerable(this.isInvulnerable());
goomba.moveTo(this.getX() + xOffset, this.getY() + 0.5, this.getZ() + zOffset, this.random.nextFloat() * 360.0F, 0.0F);
goomba.setDeltaMovement(xOffset * 0.5, upwardMotion, zOffset * 0.5);
goomba.move(MoverType.SELF, goomba.getDeltaMovement());

if (heightScale != null && heightScale.getValue() != 1) {
AttributeModifier heightScaleModifier = new AttributeModifier(
ResourceLocation.fromNamespaceAndPath(Marioverse.MOD_ID, "height_scale_goomba_modifier"),
heightScale.getValue(), AttributeModifier.Operation.ADD_MULTIPLIED_BASE);

if (goombaHeightScale != null && !goombaHeightScale.hasModifier(heightScaleModifier.id()))
goombaHeightScale.addTransientModifier(heightScaleModifier);
}

if (widthScale != null && widthScale.getValue() != 1) {
AttributeModifier widthScaleModifier = new AttributeModifier(
ResourceLocation.fromNamespaceAndPath(Marioverse.MOD_ID, "width_scale_goomba_modifier"),
widthScale.getValue(), AttributeModifier.Operation.ADD_MULTIPLIED_BASE);

if (goombaWidthScale != null && !goombaWidthScale.hasModifier(widthScaleModifier.id()))
goombaWidthScale.addTransientModifier(widthScaleModifier);
}

spawnedGoombas.add(goomba);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.wenxin2.marioverse.entities;

import com.wenxin2.marioverse.Marioverse;
import com.wenxin2.marioverse.entities.ai.controls.AmphibiousMoveControl;
import com.wenxin2.marioverse.entities.ai.goals.GoombaRideGoal;
import com.wenxin2.marioverse.entities.ai.goals.GoombaSitGoal;
import com.wenxin2.marioverse.entities.ai.goals.GoombaSleepGoal;
import com.wenxin2.marioverse.entities.ai.goals.NearestAttackableTagGoal;
import com.wenxin2.marioverse.init.AttributesRegistry;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.EntityRegistry;
import com.wenxin2.marioverse.init.SoundRegistry;
Expand All @@ -15,16 +13,13 @@
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
Expand Down Expand Up @@ -102,43 +97,18 @@ public void remove(Entity.RemovalReason removalReason) {
double zOffset = Math.sin(angle) * width;
double upwardMotion = 0.2 + this.random.nextDouble() * 0.2;

AttributeInstance eyeHeightScale = this.getAttribute(AttributesRegistry.EYE_HEIGHT_SCALE);
AttributeInstance heightScale = this.getAttribute(AttributesRegistry.HEIGHT_SCALE);
AttributeInstance widthScale = this.getAttribute(AttributesRegistry.WIDTH_SCALE);

GoombaEntity goomba = EntityRegistry.HEFTY_GOOMBA.get().create(this.level());
if (goomba != null) {
if (this.isPersistenceRequired())
goomba.setPersistenceRequired();

AttributeInstance goombaHeightScale = goomba.getAttribute(AttributesRegistry.HEIGHT_SCALE);
AttributeInstance goombaWidthScale = goomba.getAttribute(AttributesRegistry.WIDTH_SCALE);

goomba.setCustomName(component);
goomba.setNoAi(flag);
goomba.setInvulnerable(this.isInvulnerable());
goomba.moveTo(this.getX() + xOffset, this.getY() + 0.5, this.getZ() + zOffset, this.random.nextFloat() * 360.0F, 0.0F);
goomba.setDeltaMovement(xOffset * 0.3, upwardMotion, zOffset * 0.3);
goomba.move(MoverType.SELF, goomba.getDeltaMovement());

if (heightScale != null && heightScale.getValue() != 1) {
AttributeModifier heightScaleModifier = new AttributeModifier(
ResourceLocation.fromNamespaceAndPath(Marioverse.MOD_ID, "height_scale_goomba_modifier"),
heightScale.getValue(), AttributeModifier.Operation.ADD_MULTIPLIED_BASE);

if (goombaHeightScale != null && !goombaHeightScale.hasModifier(heightScaleModifier.id()))
goombaHeightScale.addTransientModifier(heightScaleModifier);
}

if (widthScale != null && widthScale.getValue() != 1) {
AttributeModifier widthScaleModifier = new AttributeModifier(
ResourceLocation.fromNamespaceAndPath(Marioverse.MOD_ID, "width_scale_goomba_modifier"),
widthScale.getValue(), AttributeModifier.Operation.ADD_MULTIPLIED_BASE);

if (goombaWidthScale != null)
goombaWidthScale.addTransientModifier(widthScaleModifier);
}

spawnedGoombas.add(goomba);
}
}
Expand Down

0 comments on commit d88a748

Please sign in to comment.