Skip to content

Commit

Permalink
devil's hole pupfish
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexModGuy committed Apr 21, 2022
1 parent 81cb22c commit 9c0e323
Show file tree
Hide file tree
Showing 40 changed files with 1,044 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private void setup(final FMLCommonSetupEvent event) {
NETWORK_WRAPPER.registerMessage(packetsRegistered++, MessageStartDancing.class, MessageStartDancing::write, MessageStartDancing::read, MessageStartDancing.Handler::handle);
NETWORK_WRAPPER.registerMessage(packetsRegistered++, MessageInteractMultipart.class, MessageInteractMultipart::write, MessageInteractMultipart::read, MessageInteractMultipart.Handler::handle);
NETWORK_WRAPPER.registerMessage(packetsRegistered++, MessageSendVisualFlagFromServer.class, MessageSendVisualFlagFromServer::write, MessageSendVisualFlagFromServer::read, MessageSendVisualFlagFromServer.Handler::handle);
NETWORK_WRAPPER.registerMessage(packetsRegistered++, MessageSetPupfishChunkOnClient.class, MessageSetPupfishChunkOnClient::write, MessageSetPupfishChunkOnClient::read, MessageSetPupfishChunkOnClient.Handler::handle);
AMAdvancementTriggerRegistry.init();
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/github/alexthe666/alexsmobs/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class ClientProxy extends CommonProxy {
public CameraType prevPOV = CameraType.FIRST_PERSON;
public static int voidPortalCreationTime = 0;
public boolean initializedRainbowBuffers = false;
private int pupfishChunkX = 0;
private int pupfishChunkZ = 0;

public void init(){
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientProxy::onItemColors);
Expand Down Expand Up @@ -173,6 +175,7 @@ public void clientInit() {
EntityRenderers.register(AMEntityRegistry.GIANT_SQUID.get(), RenderGiantSquid::new);
EntityRenderers.register(AMEntityRegistry.SQUID_GRAPPLE.get(), RenderSquidGrapple::new);
EntityRenderers.register(AMEntityRegistry.SEA_BEAR.get(), RenderSeaBear::new);
EntityRenderers.register(AMEntityRegistry.DEVILS_HOLE_PUPFISH.get(), RenderDevilsHolePupfish::new);
MinecraftForge.EVENT_BUS.register(new ClientEvents());
try{
ItemProperties.register(AMItemRegistry.BLOOD_SPRAYER.get(), new ResourceLocation("empty"), (stack, p_239428_1_, p_239428_2_, j) -> {
Expand All @@ -190,6 +193,14 @@ public void clientInit() {
ItemProperties.register(AMItemRegistry.SOMBRERO.get(), new ResourceLocation("silly"), (stack, p_239421_1_, p_239421_2_, j) -> {
return AlexsMobs.isAprilFools() ? 1.0F : 0.0F;
});
ItemProperties.register(AMItemRegistry.PUPFISH_LOCATOR.get(), new ResourceLocation("in_chunk"), (stack, world, entity, j) -> {
int x = pupfishChunkX * 16;
int z = pupfishChunkZ * 16;
if(entity != null && entity.getX() >= x && entity.getX() <= x + 16 && entity.getZ() >= z && entity.getZ() <= z + 16){
return 1.0F;
}
return 0.0F;
});
}catch (Exception e){
AlexsMobs.LOGGER.warn("Could not load item models for weapons");
}
Expand Down Expand Up @@ -398,4 +409,9 @@ public void processVisualFlag(Entity entity, int flag) {
ClientEvents.renderStaticScreenFor = 60;
}
}

public void setPupfishChunkForItem(int chunkX, int chunkZ) {
this.pupfishChunkX = chunkX;
this.pupfishChunkZ = chunkZ;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,7 @@ public void spawnSpecialParticle(int i) {

public void processVisualFlag(Entity entity, int flag) {
}

public void setPupfishChunkForItem(int chunkX, int chunkZ) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.github.alexthe666.alexsmobs.client.model;

import com.github.alexthe666.alexsmobs.entity.EntityDevilsHolePupfish;
import com.github.alexthe666.citadel.client.model.AdvancedEntityModel;
import com.github.alexthe666.citadel.client.model.AdvancedModelBox;
import com.github.alexthe666.citadel.client.model.basic.BasicModelPart;
import com.google.common.collect.ImmutableList;

public class ModelDevilsHolePupfish extends AdvancedEntityModel<EntityDevilsHolePupfish> {
private final AdvancedModelBox root;
private final AdvancedModelBox body;
private final AdvancedModelBox bottom_fin;
private final AdvancedModelBox dorsal_fin;
private final AdvancedModelBox tail;
private final AdvancedModelBox left_fin;
private final AdvancedModelBox right_fin;

public ModelDevilsHolePupfish() {
texHeight = 32;
texWidth = 32;

root = new AdvancedModelBox(this);
root.setRotationPoint(0.0F, 24.0F, 0.0F);

body = new AdvancedModelBox(this);
body.setRotationPoint(0.0F, -2.0F, 0.0F);
root.addChild(body);
body.setTextureOffset(0, 0).addBox(-1.5F, -2.0F, -5.0F, 3.0F, 4.0F, 9.0F, 0.0F, false);

bottom_fin = new AdvancedModelBox(this);
bottom_fin.setRotationPoint(0.0F, 2.0F, 1.0F);
body.addChild(bottom_fin);
bottom_fin.setTextureOffset(0, 0).addBox(0.0F, 0.0F, 0.0F, 0.0F, 2.0F, 3.0F, 0.0F, false);

dorsal_fin = new AdvancedModelBox(this);
dorsal_fin.setRotationPoint(0.0F, -2.0F, 0.0F);
body.addChild(dorsal_fin);
dorsal_fin.setTextureOffset(11, 14).addBox(0.0F, -3.0F, -2.0F, 0.0F, 3.0F, 5.0F, 0.0F, false);

tail = new AdvancedModelBox(this);
tail.setRotationPoint(0.0F, -1.0F, 4.0F);
body.addChild(tail);
tail.setTextureOffset(0, 14).addBox(0.0F, -3.0F, 0.0F, 0.0F, 6.0F, 5.0F, 0.0F, false);

left_fin = new AdvancedModelBox(this);
left_fin.setRotationPoint(1.5F, 1.0F, -2.0F);
body.addChild(left_fin);
setRotationAngle(left_fin, 0.0F, 0.48F, 0.0F);
left_fin.setTextureOffset(0, 14).addBox(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 2.0F, 0.0F, false);

right_fin = new AdvancedModelBox(this);
right_fin.setRotationPoint(-1.5F, 1.0F, -2.0F);
body.addChild(right_fin);
setRotationAngle(right_fin, 0.0F, -0.48F, 0.0F);
right_fin.setTextureOffset(0, 14).addBox(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 2.0F, 0.0F, true);
this.updateDefaultPose();
}

@Override
public void setupAnim(EntityDevilsHolePupfish entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.resetToDefaultPose();
float idleSpeed = 0.3F;
float idleDegree = 0.5F;
float swimSpeed = 1.0F;
float swimDegree = 0.5F;
float partialTick = ageInTicks - entity.tickCount;
float landProgress = entity.prevOnLandProgress + (entity.onLandProgress - entity.prevOnLandProgress) * partialTick;
float feedingProgress = entity.prevFeedProgress + (entity.feedProgress - entity.prevFeedProgress) * partialTick;
this.progressRotationPrev(dorsal_fin, limbSwingAmount, (float) Math.toRadians(-20), 0, 0, 1F);
this.progressPositionPrev(dorsal_fin, limbSwingAmount,0, 0.5F, 0, 1F);
this.progressRotationPrev(bottom_fin, limbSwingAmount, (float) Math.toRadians(10), 0, 0, 1F);
this.progressPositionPrev(bottom_fin, limbSwingAmount,0, -0.5F, -0.5F, 1F);
this.progressRotationPrev(body, landProgress, 0, 0, (float) Math.toRadians(90), 5F);
this.bob(body, idleSpeed, idleDegree, false, ageInTicks, 1F);
this.swing(body, idleSpeed, idleDegree * 0.1F, false, 1F, 0, ageInTicks, 1F);
this.swing(tail, idleSpeed, idleDegree * 0.3F, false, -1F, 0, ageInTicks, 1F);
this.swing(tail, swimSpeed, swimDegree, false, 0, 0, limbSwing, limbSwingAmount);
this.swing(body, swimSpeed, swimDegree * 0.3F, false, 1F, 0, limbSwing, limbSwingAmount);
this.swing(left_fin, swimSpeed, swimDegree, false, 3F, 0.6F, limbSwing, limbSwingAmount);
this.swing(right_fin, swimSpeed, swimDegree, true, 3F, 0.6F, limbSwing, limbSwingAmount);
this.body.rotateAngleX += headPitch * ((float)Math.PI / 180F);
this.body.rotateAngleX += feedingProgress * Math.cos(ageInTicks * 0.3F) * 0.2F * Math.PI * 0.1F;
this.body.rotationPointZ += feedingProgress * Math.abs(Math.sin(ageInTicks * 0.3F));

}


@Override
public Iterable<BasicModelPart> parts() {
return ImmutableList.of(root);
}

@Override
public Iterable<AdvancedModelBox> getAllParts() {
return ImmutableList.of(root, body, dorsal_fin, bottom_fin, tail, left_fin, right_fin);
}

public void setRotationAngle(AdvancedModelBox modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class RenderCachalotEcho extends EntityRenderer<EntityCachalotEcho> {
private static final ResourceLocation TEXTURE_1 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_1.png");
private static final ResourceLocation TEXTURE_2 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_2.png");
private static final ResourceLocation TEXTURE_3 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_3.png");
private static final ResourceLocation GREEN_TEXTURE_0 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_0_green.png");
private static final ResourceLocation GREEN_TEXTURE_1 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_1_green.png");
private static final ResourceLocation GREEN_TEXTURE_2 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_2_green.png");
private static final ResourceLocation GREEN_TEXTURE_3 = new ResourceLocation("alexsmobs:textures/entity/cachalot/whale_echo_3_green.png");

public RenderCachalotEcho(EntityRendererProvider.Context renderManagerIn) {
super(renderManagerIn);
Expand All @@ -34,18 +38,18 @@ public void render(EntityCachalotEcho entityIn, float entityYaw, float partialTi
for(int i = 0; i < arcs; i++){
matrixStackIn.pushPose();
matrixStackIn.translate(0, 0, -0.5F * i);
renderArc(matrixStackIn, bufferIn, (i + 1) * 5, entityIn.isFasterAnimation());
renderArc(matrixStackIn, bufferIn, (i + 1) * 5, entityIn.isFasterAnimation(), entityIn.isGreen());
matrixStackIn.popPose();
}
matrixStackIn.popPose();
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
}

private void renderArc(PoseStack matrixStackIn, MultiBufferSource bufferIn, int age, boolean fast) {
private void renderArc(PoseStack matrixStackIn, MultiBufferSource bufferIn, int age, boolean fast, boolean green) {
matrixStackIn.pushPose();
ResourceLocation res;
if(fast){
res = getEntityTextureFaster(age);
res = getEntityTextureFaster(age, green);
}else{
res = getEntityTexture(age);
}
Expand Down Expand Up @@ -85,15 +89,15 @@ public ResourceLocation getEntityTexture(int age) {
}
}

public ResourceLocation getEntityTextureFaster(int age) {
public ResourceLocation getEntityTextureFaster(int age, boolean green) {
if (age < 3) {
return TEXTURE_0;
return green ? GREEN_TEXTURE_0 : TEXTURE_0;
} else if (age < 6) {
return TEXTURE_1;
return green ? GREEN_TEXTURE_1 : TEXTURE_1;
} else if (age < 9) {
return TEXTURE_2;
return green ? GREEN_TEXTURE_2 : TEXTURE_2;
} else {
return TEXTURE_3;
return green ? GREEN_TEXTURE_3 : TEXTURE_3;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.alexthe666.alexsmobs.client.render;

import com.github.alexthe666.alexsmobs.client.model.ModelDevilsHolePupfish;
import com.github.alexthe666.alexsmobs.client.model.ModelGazelle;
import com.github.alexthe666.alexsmobs.entity.EntityDevilsHolePupfish;
import com.github.alexthe666.alexsmobs.entity.EntityGazelle;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;

public class RenderDevilsHolePupfish extends MobRenderer<EntityDevilsHolePupfish, ModelDevilsHolePupfish> {
private static final ResourceLocation TEXTURE = new ResourceLocation("alexsmobs:textures/entity/devils_hole_pupfish.png");

public RenderDevilsHolePupfish(EntityRendererProvider.Context renderManagerIn) {
super(renderManagerIn, new ModelDevilsHolePupfish(), 0.2F);
}

protected void scale(EntityDevilsHolePupfish entitylivingbaseIn, PoseStack matrixStackIn, float partialTickTime) {
float scale = entitylivingbaseIn.getPupfishScale();
if(entitylivingbaseIn.isBaby()){
scale *= 0.65F;
}
matrixStackIn.scale(scale, scale, scale);
}


public ResourceLocation getTextureLocation(EntityDevilsHolePupfish entity) {
return TEXTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public class AMConfig {
public static int bisonSpawnRolls = 0;
public static int giantSquidSpawnWeight = 3;
public static int giantSquidSpawnRolls = 0;
public static int devilsHolePupfishSpawnWeight = 23;
public static int devilsHolePupfishSpawnRolls = 0;

public static double lavaOpacity = 0.65F;
public static boolean lavaBottleEnabled = true;
Expand Down Expand Up @@ -211,6 +213,8 @@ public class AMConfig {
"minecraft:enchanted_golden_apple|minecraft:oak_sapling",
"alexsmobs:banana|minecraft:jungle_sapling"
);
public static boolean restrictPupfishSpawns = true;
public static int pupfishChunkSpawnDistance = 2000;
public static double rainbowGlassFidelity = 16.0F;
public static boolean bunfungusTransformation = true;
public static boolean superSecretSettings = false;
Expand Down Expand Up @@ -364,6 +368,8 @@ public static void bake(ModConfig config) {
bisonSpawnRolls = ConfigHolder.COMMON.bisonSpawnRolls.get();
giantSquidSpawnWeight = ConfigHolder.COMMON.giantSquidSpawnWeight.get();
giantSquidSpawnRolls = ConfigHolder.COMMON.giantSquidSpawnRolls.get();
devilsHolePupfishSpawnWeight = ConfigHolder.COMMON.devilsHolePupfishSpawnWeight.get();
devilsHolePupfishSpawnRolls = ConfigHolder.COMMON.devilsHolePupfishSpawnRolls.get();

lavaBottleEnabled = ConfigHolder.COMMON.lavaBottleEnabled.get();
bananasDropFromLeaves = ConfigHolder.COMMON.bananasDropFromLeaves.get();
Expand Down Expand Up @@ -411,6 +417,8 @@ public static void bake(ModConfig config) {
tusklinShoesBarteringChance = ConfigHolder.COMMON.tusklinShoesBarteringChance.get();
rainbowGlassFidelity = ConfigHolder.COMMON.rainbowGlassFidelity.get();
bunfungusTransformation = ConfigHolder.COMMON.bunfungusTransformation.get();
restrictPupfishSpawns = ConfigHolder.COMMON.restrictPupfishSpawns.get();
pupfishChunkSpawnDistance = ConfigHolder.COMMON.pupfishChunkSpawnDistance.get();
superSecretSettings = ConfigHolder.COMMON.superSecretSettings.get();
addLootToChests = ConfigHolder.COMMON.addLootToChests.get();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class BiomeConfig {
public static Pair<String, SpawnBiomeData> bunfungus = Pair.of("alexsmobs:bunfungus_spawns", DefaultBiomes.MUNGUS);
public static Pair<String, SpawnBiomeData> bison = Pair.of("alexsmobs:bison_spawns", DefaultBiomes.BISON);
public static Pair<String, SpawnBiomeData> giant_squid = Pair.of("alexsmobs:giant_squid_spawns", DefaultBiomes.GIANT_SQUID);
public static Pair<String, SpawnBiomeData> devils_hole_pupfish = Pair.of("alexsmobs:devils_hole_pupfish", DefaultBiomes.ALL_OVERWORLD);

private static boolean init = false;
private static Map<String, SpawnBiomeData> biomeConfigValues = new HashMap<>();
Expand Down
Loading

0 comments on commit 9c0e323

Please sign in to comment.