Skip to content

Commit

Permalink
Start of FlounderFest rewards and fish upgrades
Browse files Browse the repository at this point in the history
FEAT: Started work on FlounderFest reward system
REFACTOR: Increased the size and hitboxes of many fish to make them slightly easier to hit, but also way more scary LOl
  • Loading branch information
Superkat32 committed Dec 30, 2023
1 parent 9927efe commit db68b99
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@ public class FlutterAndFlounderEntities {
Registries.ENTITY_TYPE,
new Identifier(MOD_ID, "whacker"),
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, WhackerSalmonEntity::new)
.dimensions(EntityDimensions.fixed(1.5f, 0.9f)).build()
.dimensions(EntityDimensions.fixed(3f, 1.8f)).build()
);

public static final EntityType<ChillCodEntity> CHILL_COD = Registry.register(
Registries.ENTITY_TYPE,
new Identifier(MOD_ID, "chilldcod"),
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, ChillCodEntity::new)
.dimensions(EntityDimensions.fixed(0.9f, 0.8f)).build()
.dimensions(EntityDimensions.fixed(1f, 0.9f)).build()
);

public static final EntityType<SalmonSniperEntity> SALMON_SNIPER = Registry.register(
Registries.ENTITY_TYPE,
new Identifier(MOD_ID, "salmonsniper"),
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, SalmonSniperEntity::new)
.dimensions(EntityDimensions.fixed(0.9f, 1.3f)).build()
.dimensions(EntityDimensions.fixed(1.8f, 2.6f)).build()
);

public static final EntityType<ClownCodEntity> CLOWN_COD = Registry.register(
Registries.ENTITY_TYPE,
new Identifier(MOD_ID, "clowncod"),
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, ClownCodEntity::new)
.dimensions(EntityDimensions.fixed(0.9f, 0.8f)).build()
.dimensions(EntityDimensions.fixed(1.8f, 1.6f)).build()
);

public static final EntityType<GoonCodEntity> GOON = Registry.register(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package net.superkat.flutterandflounder.entity.client.cod;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.superkat.flutterandflounder.entity.custom.cod.ChillCodEntity;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class ChillCodRenderer extends GeoEntityRenderer<ChillCodEntity> {
public ChillCodRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new ChillCodModel());
}

// @Override
// public void render(ChillCodEntity entity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
// poseStack.scale(1.2f, 1.2f, 1.2f);
// super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
// }


@Override
public void scaleModelForRender(float widthScale, float heightScale, MatrixStack poseStack, ChillCodEntity animatable, BakedGeoModel model, boolean isReRender, float partialTick, int packedLight, int packedOverlay) {
poseStack.scale(1.2f, 1.2f,1.2f);
super.scaleModelForRender(widthScale, heightScale, poseStack, animatable, model, isReRender, partialTick, packedLight, packedOverlay);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package net.superkat.flutterandflounder.entity.client.cod;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.superkat.flutterandflounder.entity.custom.cod.ClownCodEntity;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class ClownCodRenderer extends GeoEntityRenderer<ClownCodEntity> {
public ClownCodRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new ClownCodModel());
}
// @Override
// public void render(ClownCodEntity entity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
// poseStack.scale(2f, 2f, 2f);
// super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
// }


@Override
public void scaleModelForRender(float widthScale, float heightScale, MatrixStack poseStack, ClownCodEntity animatable, BakedGeoModel model, boolean isReRender, float partialTick, int packedLight, int packedOverlay) {
poseStack.scale(2f, 2f, 2f);
super.scaleModelForRender(widthScale, heightScale, poseStack, animatable, model, isReRender, partialTick, packedLight, packedOverlay);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package net.superkat.flutterandflounder.entity.client.salmon;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.superkat.flutterandflounder.entity.custom.salmon.SalmonSniperEntity;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class SalmonSniperRenderer extends GeoEntityRenderer<SalmonSniperEntity> {
public SalmonSniperRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new SalmonSniperModel());
}
// @Override
// public void render(SalmonSniperEntity entity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
// poseStack.scale(2f, 2f, 2f);
// super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
// }


@Override
public void scaleModelForRender(float widthScale, float heightScale, MatrixStack poseStack, SalmonSniperEntity animatable, BakedGeoModel model, boolean isReRender, float partialTick, int packedLight, int packedOverlay) {
poseStack.scale(2f, 2f, 2f);
super.scaleModelForRender(widthScale, heightScale, poseStack, animatable, model, isReRender, partialTick, packedLight, packedOverlay);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package net.superkat.flutterandflounder.entity.client.salmon;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.superkat.flutterandflounder.entity.custom.salmon.WhackerSalmonEntity;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class WhackerSalmonRenderer extends GeoEntityRenderer<WhackerSalmonEntity> {
public WhackerSalmonRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new WhackerSalmonModel());
}

@Override
public void scaleModelForRender(float widthScale, float heightScale, MatrixStack poseStack, WhackerSalmonEntity animatable, BakedGeoModel model, boolean isReRender, float partialTick, int packedLight, int packedOverlay) {
poseStack.scale(2f, 2f, 2f);
super.scaleModelForRender(widthScale, heightScale, poseStack, animatable, model, isReRender, partialTick, packedLight, packedOverlay);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void shootAt(LivingEntity target, float pullProgress) {
ItemStack salmonItem = new ItemStack(Items.SALMON);
SalmonSniperProjectile projectile = new SalmonSniperProjectile(this.getWorld(), this, salmonItem);
double x = target.getX() - this.getX();
double y = target.getBodyY(0.333) - this.getY();
double y = target.getEyeY() - this.getEyeY();
double z = target.getZ() - this.getZ();
double pos = Math.sqrt(x * x + z * z);
projectile.setVelocity(x * 0.2f, y * 0.2f, z * 0.2f, 1.6f, (float) (14 / this.getWorld().getDifficulty().getId() * 8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public void tick() {
}

this.mob.getLookControl().lookAt(this.target, 30.0F, 30.0F);
if(shootUpdateTicks >= 50) {
if(shootUpdateTicks >= 50) { //terrible i know but I'm on a time limit
ticksPerShot = 30;
if(shootUpdateTicks >= 80) {
ticksPerShot = 20;
Expand All @@ -313,20 +313,6 @@ public void tick() {
float g = MathHelper.clamp(f, 0.1F, 1.0F);
this.owner.shootAt(this.target, g);
}
// if (--this.updateCountdownTicks == 0) {
// if (!bl) {
// return;
// }
//
// float f = (float)Math.sqrt(d) / this.maxShootRange;
// float g = MathHelper.clamp(f, 0.1F, 1.0F);
// this.owner.shootAt(this.target, g);
// this.updateCountdownTicks = MathHelper.floor(f * (float)(this.maxIntervalTicks - this.minIntervalTicks) + (float)this.minIntervalTicks);
// } else if (this.updateCountdownTicks < 0) {
// this.updateCountdownTicks = MathHelper.floor(
// MathHelper.lerp(Math.sqrt(d) / (double)this.maxShootRange, (double)this.minIntervalTicks, (double)this.maxIntervalTicks)
// );
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class FlounderFest {
public int secondsRemaining = 100;
public int maxQuota;
public int quotaProgress = 0;
public int totalQuotaAcrossAllWaves = 0;
private final Set<UUID> enemies = Sets.newHashSet();
public int enemiesToBeSpawned;
public int totalEnemyCount;
Expand Down Expand Up @@ -76,6 +77,7 @@ public FlounderFest(ServerWorld world, NbtCompound nbt) {
this.maxWaves = nbt.getInt("MaxWaves");
this.quotaProgress = nbt.getInt("QuotaProgress");
this.maxQuota = nbt.getInt("MaxQuota");
this.totalQuotaAcrossAllWaves = nbt.getInt("TotalQuotaAcrossAllWaves");
this.ticksSinceStart = nbt.getInt("TicksSinceStart");
this.ticksSinceEnd = nbt.getInt("TicksSinceEnd");
this.ticksSinceWaveClear = nbt.getInt("TicksSinceWaveClear");
Expand Down Expand Up @@ -112,6 +114,7 @@ public NbtCompound writeNbt(NbtCompound nbt) {
nbt.putInt("MaxWaves", this.maxWaves);
nbt.putInt("QuotaProgress", this.quotaProgress);
nbt.putInt("MaxQuota", this.maxQuota);
nbt.putInt("TotalQuotaAcrossAllWaves", this.totalQuotaAcrossAllWaves);
nbt.putInt("TicksSinceStart", this.ticksSinceStart);
nbt.putInt("TicksSinceEnd", this.ticksSinceEnd);
nbt.putInt("TicksSinceWaveClear", this.ticksSinceWaveClear);
Expand Down Expand Up @@ -342,6 +345,7 @@ public void tick() {
if(wave < maxWaves) {
this.status = Status.WAVE_CLEAR;
ticksSinceWaveClear = 0;
totalQuotaAcrossAllWaves += quotaProgress;
involvedPlayers.forEach(playerUuid -> sendWaveClearPacket((ServerPlayerEntity) world.getEntity(playerUuid)));
} else {
winFlounderFest();
Expand Down Expand Up @@ -374,11 +378,15 @@ public void tick() {
public void winFlounderFest() {
this.status = Status.VICTORY;
involvedPlayers.forEach(playerUuid -> sendVictoryPacket((ServerPlayerEntity) world.getEntity(playerUuid)));
totalQuotaAcrossAllWaves += quotaProgress;
rewardPlayers();
}

public void lossFlounderFest() {
this.status = Status.LOSS;
involvedPlayers.forEach(playerUuid -> sendDefeatPacket((ServerPlayerEntity) world.getEntity(playerUuid)));
totalQuotaAcrossAllWaves += quotaProgress;
rewardPlayers();
}

public boolean shouldMobsFlee() {
Expand Down Expand Up @@ -475,6 +483,10 @@ public void updateQuota(int amount) {
}
}

public void rewardPlayers() {
FlounderFestApi.spawnFlounderFestRewards(this.world, this.startingPos, this.totalQuotaAcrossAllWaves, this.hasWon());
}

public void updateNbt() {
FlounderFestManager flounderFestManager = FlounderFestApi.getFlounderFestManager(this.world);
flounderFestManager.markDirty();
Expand Down Expand Up @@ -518,16 +530,13 @@ public boolean hasLost() {
public void invalidate() {
this.status = Status.STOPPED;

// enemies.forEach(entityFromSet -> (entityFromSet).remove(Entity.RemovalReason.DISCARDED));

enemies.forEach(enemyUuid -> {
Entity entity = world.getEntity(enemyUuid);
if(entity != null) {
entity.remove(Entity.RemovalReason.DISCARDED);
}
});


involvedPlayers.forEach(playerUuid -> sendDeleteHudPacket((ServerPlayerEntity) world.getEntity(playerUuid)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
Expand All @@ -18,6 +21,7 @@
import net.superkat.flutterandflounder.flounderfest.FlounderFestManager;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -197,6 +201,36 @@ private static BlockPos fishSpawningPos(ServerWorld world, BlockPos festCenterPo
return null;
}

public static void spawnFlounderFestRewards(ServerWorld world, BlockPos festCenterPos, int totalQuota, boolean didWin) {
//Quota already scales with the amount of players, naturally meaning more players = more rewards
double quotaCalc = totalQuota / (didWin ? 3d : 9d);
int totalRewards = (int) (didWin ? Math.ceil(quotaCalc) : Math.floor(quotaCalc));

for (int i = 0; i < totalRewards; i++) {
dropStack(world, festCenterPos, getRandomFlounderFestReward());
}
}

private static void dropStack(ServerWorld world, BlockPos dropPos, ItemStack stack) {
if(stack.isEmpty()) {
return;
} else {
ItemEntity itemEntity = new ItemEntity(world, dropPos.getX(), dropPos.getY(), dropPos.getZ(), stack);
itemEntity.setToDefaultPickupDelay();
world.spawnEntity(itemEntity);
itemEntity.setGlowing(true);
}
}

public static ItemStack getRandomFlounderFestReward() {
ArrayList<ItemStack> rewards = new ArrayList<>();

rewards.add(Items.SPYGLASS.getDefaultStack());
rewards.add(Items.GOLDEN_APPLE.getDefaultStack());

return rewards.get(new Random().nextInt(rewards.size()));
}

/**
* Get a world's FlounderFestManager. Used for all things related to FlounderFests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class FlutterAndFlounderItems {
new PrismarineDiamondItem(new FabricItemSettings()),
"prismarine_diamond");

public static final Item PRISMARINE_PEARL = register(
new Item(new FabricItemSettings()),
"prismarine_pearl"
);

public static final Item FROGMOBILE_SPAWN_EGG = register(
new SpawnEggItem(FlutterAndFlounderEntities.FROGMOBILE, 0xffffff, 0xffffff, new FabricItemSettings()),
"frogmobile_spawn_egg"
Expand All @@ -34,7 +39,10 @@ public static <T extends Item> T register(T item, String ID) {
public static void init() {
ItemGroupEvents.modifyEntriesEvent(
ItemGroups.INGREDIENTS)
.register((itemGroup) -> itemGroup.add(PRISMARINE_DIAMOND));
.register((itemGroup) -> {
itemGroup.add(PRISMARINE_DIAMOND);
itemGroup.add(PRISMARINE_PEARL);
});

ItemGroupEvents.modifyEntriesEvent(
ItemGroups.SPAWN_EGGS)
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/flutterandflounder/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"item.flutterandflounder.prismarine_diamond.tooltip": "You might want to be careful when holding this...",
"item.flutterandflounder.prismarine_diamond.expand": "[Shift for Expand]",
"item.flutterandflounder.prismarine_diamond.shiftedtooltip": "Interact to start a FlounderFest, an event of total chaos",
"item.flutterandflounder.prismarine_diamond.fail": "A FlounderFest is already happening nearby!"
"item.flutterandflounder.prismarine_diamond.fail": "A FlounderFest is already happening nearby!",

"item.flutterandflounder.prismarine_pearl": "Prismarine Pearl"
}

0 comments on commit db68b99

Please sign in to comment.