Skip to content

Commit 407a29f

Browse files
Merge remote-tracking branch 'upstream/master' into cleanup
2 parents 0190ef1 + ddd5e8a commit 407a29f

35 files changed

+1177
-39
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ repositories {
3636
name "ModMaven"
3737
url "https://modmaven.dev"
3838
}
39+
maven {
40+
name = 'GeckoLib'
41+
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
42+
}
3943
google()
4044
}
4145

@@ -50,6 +54,8 @@ dependencies {
5054
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${rei_version}"
5155
modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}"
5256

57+
modImplementation "software.bernie.geckolib:geckolib-fabric-1.18:${geckolib_version}"
58+
5359
// Dev QOL
5460
modLocalRuntime("com.terraformersmc:modmenu:${modmenu_version}")
5561
modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}")

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ org.gradle.jvmargs=-Xmx2G
2929
yttr_version = 7.626+1.18.2
3030

3131
# create
32-
create_version = 0.5.1-f-build.1333+mc1.18.2
32+
create_version = 0.5.1-f-build.1333+mc1.18.2
33+
34+
# geckolib
35+
geckolib_version = 3.0.80
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.github.ethanicuss.astraladditions.effects.parry;
2+
3+
import com.github.ethanicuss.astraladditions.registry.ModEffects;
4+
import com.github.ethanicuss.astraladditions.util.ModUtils;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.damage.DamageSource;
8+
import net.minecraft.entity.effect.StatusEffect;
9+
import net.minecraft.entity.effect.StatusEffectCategory;
10+
import net.minecraft.particle.ParticleTypes;
11+
import net.minecraft.server.world.ServerWorld;
12+
import net.minecraft.sound.SoundCategory;
13+
import net.minecraft.sound.SoundEvents;
14+
import net.minecraft.util.UseAction;
15+
import org.jetbrains.annotations.Nullable;
16+
17+
18+
public class ParryEffect extends StatusEffect{
19+
public ParryEffect(StatusEffectCategory category, int color) {
20+
super(category, color);
21+
}
22+
23+
24+
@Override
25+
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
26+
// Entity attacker = entity.getAttacker();
27+
// onUserDamaged(entity, attacker, amplifier);
28+
super.applyUpdateEffect(entity, amplifier);
29+
}
30+
31+
public static void onUserDamaged (LivingEntity user, Entity attacker, int level) {
32+
if (attacker != null) {
33+
attacker.damage(DamageSource.thorns(user), (float)getDamageAmount(level));
34+
user.world.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.ITEM_TRIDENT_THUNDER, SoundCategory.NEUTRAL, 0.5f, 1.4f / (user.world.getRandom().nextFloat() * 0.4f + 0.8f));
35+
ModUtils.spawnForcedParticles((ServerWorld)user.world, ParticleTypes.END_ROD, user.getX(), user.getY(), user.getZ(), 20, 0.8, 0.8, 0.8, 0.7);
36+
user.heal(level+5);
37+
}
38+
user.setAttacker(null);
39+
}
40+
41+
public static boolean parryWindow(LivingEntity user) {
42+
int lastAttacked = user.age-user.getLastAttackedTime();
43+
return user.getLastAttackedTime() >= user.age - 20;
44+
}
45+
46+
public static int getDamageAmount(int amplifier) {
47+
return amplifier+5;
48+
}
49+
50+
@Override
51+
public boolean canApplyUpdateEffect(int duration, int amplifier) {
52+
return true;
53+
}
54+
55+
@Override
56+
public boolean isInstant() {
57+
return false;
58+
}
59+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.github.ethanicuss.astraladditions.entities.blackhole;
2+
3+
import com.github.ethanicuss.astraladditions.util.ModUtils;
4+
import net.minecraft.entity.EntityType;
5+
import net.minecraft.entity.ai.goal.*;
6+
import net.minecraft.entity.attribute.DefaultAttributeContainer;
7+
import net.minecraft.entity.attribute.EntityAttributes;
8+
import net.minecraft.entity.damage.DamageSource;
9+
import net.minecraft.entity.mob.HostileEntity;
10+
import net.minecraft.entity.player.PlayerEntity;
11+
import net.minecraft.particle.ParticleTypes;
12+
import net.minecraft.sound.SoundEvent;
13+
import net.minecraft.sound.SoundEvents;
14+
import net.minecraft.world.World;
15+
import software.bernie.geckolib3.core.IAnimatable;
16+
import software.bernie.geckolib3.core.PlayState;
17+
import software.bernie.geckolib3.core.builder.AnimationBuilder;
18+
import software.bernie.geckolib3.core.controller.AnimationController;
19+
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
20+
import software.bernie.geckolib3.core.manager.AnimationData;
21+
import software.bernie.geckolib3.core.manager.AnimationFactory;
22+
23+
24+
25+
public class BlackholeEntity extends HostileEntity implements IAnimatable {
26+
27+
private AnimationFactory factory = new AnimationFactory(this);
28+
29+
public BlackholeEntity(EntityType<? extends HostileEntity> entityType, World world) {
30+
super(entityType, world);
31+
this.experiencePoints = 20;
32+
}
33+
@Override
34+
protected void initGoals() {
35+
this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 12.0f));
36+
this.goalSelector.add(5, new GoToWalkTargetGoal(this, 1.0));
37+
this.goalSelector.add(5, new WanderAroundFarGoal(this, 0.75, 1f));
38+
this.goalSelector.add(3, new MeleeAttackGoal(this, 0.8D, false));
39+
this.goalSelector.add(5, new FlyGoal(this, 0.8D));
40+
41+
this.targetSelector.add(4, new ActiveTargetGoal<>(this, PlayerEntity.class, true));
42+
}
43+
44+
public static DefaultAttributeContainer.Builder createBlackholeAttributes(){
45+
return HostileEntity.createHostileAttributes()
46+
.add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0D)
47+
.add(EntityAttributes.GENERIC_ATTACK_SPEED, 2.0f)
48+
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 3.0f)
49+
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20f)
50+
.add(EntityAttributes.GENERIC_FLYING_SPEED, 0.55)
51+
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 32.0);
52+
}
53+
54+
55+
@Override
56+
protected SoundEvent getAmbientSound() {
57+
return SoundEvents.ENTITY_ILLUSIONER_PREPARE_MIRROR;
58+
}
59+
60+
@Override
61+
protected SoundEvent getHurtSound(DamageSource source) {
62+
return SoundEvents.ENTITY_FIREWORK_ROCKET_BLAST;
63+
}
64+
65+
@Override
66+
protected SoundEvent getDeathSound() {
67+
return SoundEvents.ENTITY_FIREWORK_ROCKET_TWINKLE_FAR;
68+
}
69+
70+
71+
@Override
72+
public void tickMovement() {
73+
if (this.world.isClient) {
74+
this.world.addParticle(ParticleTypes.GLOW, this.getParticleX(2), this.getRandomBodyY(), this.getParticleZ(2), 0.0, 0.0, 0.0);
75+
}
76+
super.tickMovement();
77+
}
78+
79+
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
80+
event.getController().setAnimation(new AnimationBuilder().addAnimation("regularLoop.blackhole.new", true));
81+
return PlayState.CONTINUE;
82+
}
83+
84+
85+
int pullCooldown = 30;
86+
87+
@Override
88+
public void tick() {
89+
pullCooldown--;
90+
PlayerEntity p = this.world.getClosestPlayer(this, 32);
91+
if (p != null) {
92+
//this.getMoveControl().moveTo(p.getX(), p.getY(), p.getZ(), 1.0);
93+
if (pullCooldown == 0){
94+
pullCooldown=30;
95+
if (!p.isCreative()) {
96+
ModUtils.pullPlayer(this, this.world, true, 0.35, 0.02, this.getX(), this.getZ(), this.getX() - 12, this.getY() - 3, this.getZ() - 12, this.getX() + 12, this.getY() + 3, this.getZ() + 12);
97+
}}
98+
}
99+
super.tick();
100+
}
101+
102+
@Override
103+
public void registerControllers(AnimationData animationData) {
104+
animationData.addAnimationController(new AnimationController(this, "controller",
105+
0, this::predicate));
106+
}
107+
108+
@Override
109+
public AnimationFactory getFactory() {
110+
return factory;
111+
}
112+
113+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.github.ethanicuss.astraladditions.entities.blackhole;
2+
3+
import com.github.ethanicuss.astraladditions.AstralAdditions;
4+
import net.minecraft.util.Identifier;
5+
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
6+
import software.bernie.geckolib3.core.processor.IBone;
7+
import software.bernie.geckolib3.model.AnimatedGeoModel;
8+
import software.bernie.geckolib3.model.provider.data.EntityModelData;
9+
10+
public class BlackholeEntityModel extends AnimatedGeoModel<BlackholeEntity> {
11+
@Override
12+
public Identifier getModelLocation(BlackholeEntity object) {
13+
return new Identifier(AstralAdditions.MOD_ID, "geo/blackhole.geo.json");
14+
}
15+
16+
@Override
17+
public Identifier getTextureLocation(BlackholeEntity object) {
18+
return new Identifier(AstralAdditions.MOD_ID, "textures/entity/blackhole/blackhole_texture.png");
19+
}
20+
21+
@Override
22+
public Identifier getAnimationFileLocation(BlackholeEntity animatable) {
23+
return new Identifier(AstralAdditions.MOD_ID, "animations/blackhole.animation.json");
24+
}
25+
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.ethanicuss.astraladditions.entities.blackhole;
2+
3+
import com.github.ethanicuss.astraladditions.AstralAdditions;
4+
import net.minecraft.client.render.entity.EntityRendererFactory;
5+
import net.minecraft.util.Identifier;
6+
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;
7+
8+
public class BlackholeEntityRenderer extends GeoEntityRenderer<BlackholeEntity> {
9+
public BlackholeEntityRenderer(EntityRendererFactory.Context renderManager) {
10+
super(renderManager, new BlackholeEntityModel());
11+
}
12+
13+
@Override
14+
public Identifier getTexture(BlackholeEntity entity) {
15+
return new Identifier(AstralAdditions.MOD_ID, "textures/entity/blackhole/blackhole_texture.png");
16+
}
17+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.github.ethanicuss.astraladditions.entities.cogfly;
2+
3+
import com.github.ethanicuss.astraladditions.AstralAdditions;
4+
import com.github.ethanicuss.astraladditions.entities.boomerang.BoomerangEntity;
5+
import com.github.ethanicuss.astraladditions.registry.ModItems;
6+
import net.minecraft.entity.Entity;
7+
import net.minecraft.entity.EntityType;
8+
import net.minecraft.entity.LivingEntity;
9+
import net.minecraft.entity.damage.DamageSource;
10+
import net.minecraft.entity.data.DataTracker;
11+
import net.minecraft.entity.data.TrackedData;
12+
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
13+
import net.minecraft.entity.effect.StatusEffectInstance;
14+
import net.minecraft.entity.player.PlayerEntity;
15+
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
16+
import net.minecraft.item.Item;
17+
import net.minecraft.item.ItemStack;
18+
import net.minecraft.util.Identifier;
19+
import net.minecraft.util.hit.EntityHitResult;
20+
import net.minecraft.util.registry.Registry;
21+
import net.minecraft.world.World;
22+
23+
import java.util.Objects;
24+
import java.util.UUID;
25+
26+
public class CogflyEntity extends ThrownItemEntity {
27+
28+
private static final TrackedData<String> OWNER = DataTracker.registerData(CogflyEntity.class, TrackedDataHandlerRegistry.STRING);
29+
private static final TrackedData<String> ITEM = DataTracker.registerData(CogflyEntity.class, TrackedDataHandlerRegistry.STRING);
30+
31+
public int attackCount = 0;
32+
public int damage = 3;
33+
PlayerEntity owner = world.getPlayerByUuid(UUID.fromString(this.getDataTracker().get(OWNER)));
34+
35+
public CogflyEntity(EntityType<? extends ThrownItemEntity> entityType, World world) {
36+
super(entityType, world);
37+
this.setNoGravity(true);
38+
}
39+
40+
@Override
41+
protected Item getDefaultItem() {
42+
return ModItems.COGFLY;
43+
}
44+
45+
public void setOwner(String UUID){
46+
this.getDataTracker().set(OWNER, UUID);
47+
}
48+
49+
public ItemStack getCogflyItem(){
50+
return Registry.ITEM.get(new Identifier(AstralAdditions.MOD_ID, this.dataTracker.get(ITEM))).getDefaultStack();
51+
}
52+
53+
@Override
54+
public void tick() {
55+
if (attackCount > 3) {
56+
kill();
57+
}
58+
if (OWNER != null) {
59+
LivingEntity p = owner.getAttacking();
60+
if (p != null) {
61+
pullToEntity(p);
62+
}
63+
}
64+
}
65+
66+
@Override
67+
protected void onEntityHit(EntityHitResult entityHitResult) {
68+
super.onEntityHit(entityHitResult);
69+
Entity entity = entityHitResult.getEntity();
70+
if (!Objects.equals(entity.getUuidAsString(), this.getDataTracker().get(OWNER))) {
71+
entity.damage(DamageSource.player(owner), damage);
72+
attackCount++;
73+
pullToEntity(owner);
74+
}
75+
}
76+
77+
//Thanks Ethan for the code!
78+
private void pullToEntity(LivingEntity p) {
79+
double strength = 0.15;
80+
double xdiff = this.getX() - p.getX();
81+
double zdiff = this.getZ() - p.getZ();
82+
double dist = Math.sqrt(Math.pow(xdiff, 2) + Math.pow(zdiff, 2));
83+
//if (dist < 20) {
84+
if (xdiff == 0) {
85+
xdiff = 0.01;
86+
}
87+
if (zdiff == 0) {
88+
zdiff = 0.01;
89+
}
90+
double angleX = Math.atan(Math.abs(zdiff) / xdiff);
91+
double angleZ = Math.atan(Math.abs(xdiff) / zdiff);
92+
double cosX = Math.cos(angleX);
93+
double cosZ = Math.cos(angleZ);
94+
if (cosX == 0) {
95+
cosX = 0.01;
96+
}
97+
if (cosZ == 0) {
98+
cosZ = 0.01;
99+
}
100+
//dist = -dist + 20;
101+
//dist = -dist;
102+
dist = -1;
103+
104+
double yVel;
105+
yVel = dist * 0.5;
106+
if (p.getY() > this.getY()){
107+
yVel = -dist;
108+
}
109+
110+
this.addVelocity(dist * cosX * strength * (Math.abs(angleX) / angleX), yVel * strength, dist * cosZ * strength * (Math.abs(angleZ) / angleZ));
111+
}
112+
113+
@Override
114+
protected void initDataTracker() {
115+
super.initDataTracker();
116+
this.dataTracker.startTracking(OWNER, "");
117+
this.dataTracker.startTracking(ITEM, "minecraft:dirt");
118+
}
119+
120+
}
121+

0 commit comments

Comments
 (0)