Skip to content

Commit

Permalink
I forgor 💀
Browse files Browse the repository at this point in the history
  • Loading branch information
Superkat32 committed Dec 26, 2023
1 parent c3b2f6c commit 922d063
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.superkat.flutterandflounder.entity.client.cod;

import net.minecraft.util.Identifier;
import net.superkat.flutterandflounder.FlutterAndFlounderMain;
import net.superkat.flutterandflounder.entity.custom.cod.ChillCodEntity;
import software.bernie.geckolib.model.DefaultedEntityGeoModel;

public class ChillCodModel extends DefaultedEntityGeoModel<ChillCodEntity> {
public ChillCodModel() {
super(new Identifier(FlutterAndFlounderMain.MOD_ID, "chillcod"), true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.superkat.flutterandflounder.entity.client.cod;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.superkat.flutterandflounder.entity.custom.cod.ChillCodEntity;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class ChillCodRenderer extends GeoEntityRenderer<ChillCodEntity> {
public ChillCodRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new ChillCodModel());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package net.superkat.flutterandflounder.entity.custom.cod;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.RangedAttackMob;
import net.minecraft.entity.ai.TargetPredicate;
import net.minecraft.entity.ai.goal.ActiveTargetGoal;
import net.minecraft.entity.ai.goal.LookAtEntityGoal;
import net.minecraft.entity.ai.goal.ProjectileAttackGoal;
import net.minecraft.entity.ai.goal.WanderAroundFarGoal;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.thrown.PotionEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.potion.PotionUtil;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.superkat.flutterandflounder.entity.custom.CommonBossFish;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.core.animation.AnimationController;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil;

import java.util.Collections;
import java.util.List;

public class ChillCodEntity extends CommonBossFish implements RangedAttackMob {
protected static final RawAnimation IDLE_ANIM = RawAnimation.begin().thenLoop("animation.chillcod.idle");
protected static final RawAnimation ATTACK_ANIM = RawAnimation.begin().thenPlay("animation.chillcod.attack");
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);

public ChillCodEntity(EntityType<? extends HostileEntity> entityType, World world) {
super(entityType, world);
}

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(new AnimationController<>(this, "controller", 5, this::animController));
}

protected<E extends ChillCodEntity> PlayState animController(final AnimationState<E> event) {
if(this.isAttacking()) {
return event.setAndContinue(ATTACK_ANIM);
} else {
return event.setAndContinue(IDLE_ANIM);
}
}

@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return geoCache;
}

public static DefaultAttributeContainer.Builder createAttributes() {
return MobEntity.createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 10)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20)
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 2)
.add(EntityAttributes.GENERIC_ATTACK_SPEED, 0.3)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 48);
}

@Override
protected void initGoals() {
this.goalSelector.add(1, new ProjectileAttackGoal(this, 1.0, 200, 10.0F));
this.goalSelector.add(2, new LookAtEntityGoal(this, PlayerEntity.class, 15f, 1f));
this.goalSelector.add(3, new WanderAroundFarGoal(this, 1));
this.targetSelector.add(1, new ActiveTargetGoal<>(this, PlayerEntity.class, true));
}

@Override
public void tickMovement() {
Box box = this.getBoundingBox().expand(50, 8, 50);
List<PlayerEntity> players = this.getWorld().getPlayers(TargetPredicate.createNonAttackable().setBaseMaxDistance(45), this, box);
float range = 8.5f;
//divided by 50 to reduce particle count from roughly 5k to 150 particles
float rangeTimesALotOfDigits = MathHelper.ceil((float) Math.PI * range * range) / 50f;
Box freezingBox = this.getBoundingBox().expand(7, 5, 7);
for (PlayerEntity player : players) {
boolean inRange = freezingBox.contains(player.getPos());
if(this.getWorld().isClient) {
for (int i = 0; i < rangeTimesALotOfDigits; i++) {
float h = this.random.nextFloat() * (float) (Math.PI * 2);
float k = MathHelper.sqrt(this.random.nextFloat()) * range;
double x = this.getX() + (double)(MathHelper.cos(h) * range);
double y = this.getY();
double z = this.getZ() + (double)(MathHelper.sin(h) * range);
this.getWorld().addImportantParticle(ParticleTypes.SNOWFLAKE, x, y, z, 0.001, 0.001, 0.001);
}
} else {
if(inRange) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 100, 2), this);
}
}
if(inRange) {
player.setFrozenTicks(player.getFrozenTicks() + 3);
} else {
player.setFrozenTicks(Math.max(0, player.getFrozenTicks() - 10));
}
}
super.tickMovement();
}

@Override
public void shootAt(LivingEntity target, float pullProgress) {
if(target != null && target.getVelocity() != null) {
Vec3d vec3d = target.getVelocity();
double d = target.getX() + vec3d.x - this.getX();
double e = target.getEyeY() - 1.1F - this.getY();
double f = target.getZ() + vec3d.z - this.getZ();
double g = Math.sqrt(d * d + f * f);
PotionEntity potionEntity = new PotionEntity(this.getWorld(), this);
potionEntity.setItem(PotionUtil.setCustomPotionEffects(new ItemStack(Items.SPLASH_POTION), Collections.singleton(new StatusEffectInstance(StatusEffects.SLOWNESS, 100, 5))));
potionEntity.setPitch(potionEntity.getPitch() - -20.0F);
potionEntity.setVelocity(d, e + g * 0.2, f, 0.75F, 8.0F);
if (!this.isSilent()) {
this.getWorld()
.playSound(
null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F
);
}

this.getWorld().spawnEntity(potionEntity);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"format_version": "1.8.0",
"animations": {
"animation.chillcod.idle": {
"loop": true,
"animation_length": 3,
"bones": {
"head": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [0, -27.5, 0],
"easing": "easeInOutCubic"
},
"1.0": {
"vector": [0, -27.5, 0],
"easing": "easeInOutCubic"
},
"1.75": {
"vector": [0, 0, 0],
"easing": "easeOutBack"
}
},
"position": {
"vector": [0, 0, 0]
}
}
}
},
"animation.chillcod.attack": {
"animation_length": 1,
"bones": {
"right_fin": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.25": {
"vector": [0, 0, 30],
"easing": "easeInOutCirc"
},
"0.75": {
"vector": [0, 0, 30],
"easing": "easeInOutCirc"
},
"1.0": {
"vector": [0, 0, 0],
"easing": "easeInOutBack"
}
}
},
"left_fin": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.25": {
"vector": [0, 0, -30],
"easing": "easeInOutCirc"
},
"0.75": {
"vector": [0, 0, -30],
"easing": "easeInOutCirc"
},
"1.0": {
"vector": [0, 0, 0],
"easing": "easeInOutBack"
}
}
},
"head": {
"rotation": {
"vector": [0, 0, 0]
},
"position": {
"vector": [0, 0, 0]
}
},
"bone2": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.2917": {
"vector": [0, -180, 0],
"easing": "easeInExpo"
},
"0.5": {
"vector": [0, -360, 0],
"easing": "linear"
},
"0.5417": {
"vector": [0, -35, 0],
"easing": "linear"
},
"0.75": {
"vector": [0, -180, 0],
"easing": "linear"
},
"1.0": {
"vector": [0, -360, 0],
"easing": "easeOutExpo"
}
},
"position": {
"vector": [0, 0, 0]
}
}
}
}
},
"geckolib_format_version": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.chillcod",
"texture_width": 32,
"texture_height": 32,
"visible_bounds_width": 3,
"visible_bounds_height": 2.5,
"visible_bounds_offset": [0, 0.75, 0]
},
"bones": [
{
"name": "body",
"pivot": [0, 2, 0],
"cubes": [
{"origin": [-1, 0, 0], "size": [2, 4, 7], "uv": [0, 0]}
]
},
{
"name": "right_fin",
"parent": "body",
"pivot": [-1, 1, 0],
"rotation": [0, 0, -45],
"cubes": [
{"origin": [-3, 1, -1], "size": [2, 0, 2], "uv": [24, 1]}
]
},
{
"name": "left_fin",
"parent": "body",
"pivot": [1, 1, 0],
"rotation": [0, 0, 45],
"cubes": [
{"origin": [1, 1, -1], "size": [2, 0, 2], "uv": [24, 4]}
]
},
{
"name": "head",
"pivot": [0, 2, 0],
"cubes": [
{"origin": [-1, 0, -3], "size": [2, 4, 3], "uv": [11, 0]}
]
},
{
"name": "hat",
"parent": "head",
"pivot": [0, 1.5, 1],
"cubes": [
{"origin": [-3, 3.5, -5], "size": [6, 3, 6], "uv": [0, 11]},
{"origin": [-3, 3.5, -8], "size": [6, 0, 3], "uv": [-3, 21]}
]
},
{
"name": "bone",
"parent": "hat",
"pivot": [0, 7.66667, -2],
"cubes": [
{"origin": [-0.5, 6.5, -2.5], "size": [1, 1, 1], "uv": [12, 27]}
]
},
{
"name": "bone2",
"parent": "bone",
"pivot": [0, 7.5, -2],
"cubes": [
{"origin": [-2, 7.5, -2.5], "size": [4, 0, 1], "uv": [8, 26]}
]
},
{
"name": "nose",
"parent": "head",
"pivot": [0, 2, -3],
"cubes": [
{"origin": [-1, 1, -4], "size": [2, 3, 1], "uv": [0, 0]}
]
},
{
"name": "fin_left",
"pivot": [0, 0, 0]
},
{
"name": "fin_right",
"pivot": [0, 0, 0]
},
{
"name": "fin_back",
"pivot": [0, 4, 0],
"cubes": [
{"origin": [0, 4, -1], "size": [0, 1, 6], "uv": [20, -6]}
]
},
{
"name": "tail",
"pivot": [0, 2, 7],
"cubes": [
{"origin": [0, 0, 7], "size": [0, 4, 4], "uv": [22, 3]}
]
}
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 922d063

Please sign in to comment.