Skip to content

Commit

Permalink
spawnegg compat and add angler fish
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Nov 15, 2023
1 parent af110b9 commit 86aac4d
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 23 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ repositories {
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/UselessBullets"
patternLayout {
artifact "[organisation]/releases/download/[revision]/[module]-[revision].jar"
m2compatible = true
}
metadataSources { artifact() }
}
}
dependencies {
minecraft "bta-download-repo:bta:${project.bta_version}"
Expand All @@ -110,6 +118,7 @@ dependencies {
modImplementation "TerrainAPI:terrainapi:${project.terrain_api_version}"
modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}"
modImplementation "BTA_Babric_PrismaticLibe:prismaticlibe:${project.prismatic_version}"
modImplementation "BTA_Babric_SpawnEggs:spawneggs:1.3.1"

modImplementation "BetterAI-BTA:better_ai:1.2.0"
modImplementation "ModMenu:ModMenu:2.0.0"
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package baguchan.better_with_aquatic;

import baguchan.better_with_aquatic.block.ModBlocks;
import baguchan.better_with_aquatic.entity.EntityBaseFish;
import baguchan.better_with_aquatic.compat.SpawnEggCompat;
import baguchan.better_with_aquatic.entity.EntityAnglerFish;
import baguchan.better_with_aquatic.entity.EntityFish;
import baguchan.better_with_aquatic.entity.render.AnglerFishModel;
import baguchan.better_with_aquatic.entity.render.FishModel;
import baguchan.better_with_aquatic.entity.render.RenderAnglerFish;
import baguchan.better_with_aquatic.entity.render.RenderFish;
import baguchan.better_with_aquatic.packet.SwimPacket;
import baguchan.better_with_aquatic.util.IDUtils;
Expand All @@ -13,6 +17,7 @@
import turniplabs.halplibe.helper.EntityHelper;
import turniplabs.halplibe.helper.NetworkHelper;
import turniplabs.halplibe.util.ConfigHandler;
import useless.prismaticlibe.helper.ModCheckHelper;

import java.util.Properties;

Expand All @@ -22,6 +27,8 @@ public class BetterWithAquatic implements ModInitializer {
public static final String MOD_ID = "better_with_aquatic";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
private static boolean enable_swim;
public static final boolean spawnEggsModPresent = ModCheckHelper.checkForMod("spawneggs", ">=1.1.0");


private void handleConfig() {
Properties prop = new Properties();
Expand All @@ -42,7 +49,11 @@ public void onInitialize() {
Block.lightOpacity[Block.fluidWaterFlowing.id] = 1;
Block.lightOpacity[Block.fluidWaterStill.id] = 1;
ModBlocks.createBlocks();
EntityHelper.createEntity(EntityBaseFish.class, new RenderFish(new FishModel(), 0.3F), 600, "Fish");
if (spawnEggsModPresent) {
SpawnEggCompat.onInitialize();
}
EntityHelper.createEntity(EntityFish.class, new RenderFish(new FishModel(), 0.3F), 600, "Fish");
EntityHelper.createEntity(EntityAnglerFish.class, new RenderAnglerFish(new AnglerFishModel(), 0.4F), 601, "AnglerFish");
NetworkHelper.register(SwimPacket.class, true, false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package baguchan.better_with_aquatic.compat;

import baguchan.better_with_aquatic.BetterWithAquatic;
import baguchan.better_with_aquatic.util.IDUtils;
import turniplabs.halplibe.helper.ItemHelper;
import useless.spawneggs.ItemSpawnEgg;

public class SpawnEggCompat {

public static void onInitialize() {
ItemHelper.createItem(BetterWithAquatic.MOD_ID, new ItemSpawnEgg("spawn.egg.fish", ItemHelper.findOpenIds(IDUtils.getCurrItemId()),
"Fish", 0x6B9F93, 0xADBEDB), "spawnegg.fish", "spawnEggDefault.png");
ItemHelper.createItem(BetterWithAquatic.MOD_ID, new ItemSpawnEgg("spawn.egg.angler_fish", ItemHelper.findOpenIds(IDUtils.getCurrItemId()),
"AnglerFish", 0x7B3E3E, 0x3D1818), "spawnegg.angler_fish", "spawnEggDefault.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package baguchan.better_with_aquatic.entity;

import net.minecraft.core.world.World;

public class EntityAnglerFish extends EntityBaseFish {
public EntityAnglerFish(World world) {
super(world);
this.highestSkinVariant = -1;
this.setSize(0.5F, 0.45F);
this.setPos(this.x, this.y, this.z);

this.skinName = "angler_fish";
}

@Override
public String getEntityTexture() {
return "/assets/better_with_aquatic/entity/angler_fish.png";
}

@Override
public String getDefaultEntityTexture() {
return "/assets/better_with_aquatic/entity/angler_fish.png";
}


@Override
protected float getBlockPathWeight(int x, int y, int z) {
return 0.5f - this.world.getLightBrightness(x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.animal.EntityWaterAnimal;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.MathHelper;
import net.minecraft.core.util.phys.Vec3d;
import net.minecraft.core.world.World;

public class EntityBaseFish extends EntityWaterAnimal implements IPathGetter {
public abstract class EntityBaseFish extends EntityWaterAnimal implements IPathGetter {
public BetterSwimPathFinder betterSwimPathFinder;
private Entity currentTarget;

Expand All @@ -24,25 +22,12 @@ public EntityBaseFish(World world) {
this.heightOffset = 0.2F;
this.footSize = 0.5F;
this.moveSpeed = 0.1F;
this.highestSkinVariant = -1;
this.setSize(0.45F, 0.45F);
this.setPos(this.x, this.y, this.z);
this.skinName = "fish";
this.betterSwimPathFinder = new BetterSwimPathFinder(world);
this.setPathFinder(this, this.betterSwimPathFinder);
this.setPathfindingMalus(this, BlockPath.WATER, 0.0F);
this.setPathfindingMalus(this, BlockPath.OPEN, -1.0F);
}

@Override
public String getEntityTexture() {
return "/assets/better_with_aquatic/entity/fish.png";
}

@Override
public String getDefaultEntityTexture() {
return "/assets/better_with_aquatic/entity/fish.png";
}

@Override
protected String getLivingSound() {
Expand Down Expand Up @@ -238,11 +223,6 @@ public void moveEntityWithHeading(float moveStrafing, float moveForward) {
}
}

@Override
protected void dropFewItems() {
this.spawnAtLocation(new ItemStack(Item.foodFishRaw, 1, 0), 0.0f);
}

@Override
public boolean canMoveIt(BlockPath blockPath) {
return blockPath == BlockPath.WATER;
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/baguchan/better_with_aquatic/entity/EntityFish.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package baguchan.better_with_aquatic.entity;

import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.world.World;

public class EntityFish extends EntityBaseFish {
public EntityFish(World world) {
super(world);
this.highestSkinVariant = -1;
this.setSize(0.45F, 0.45F);
this.setPos(this.x, this.y, this.z);

this.skinName = "fish";
}

@Override
public String getEntityTexture() {
return "/assets/better_with_aquatic/entity/fish.png";
}

@Override
public String getDefaultEntityTexture() {
return "/assets/better_with_aquatic/entity/fish.png";
}

@Override
protected void dropFewItems() {
this.spawnAtLocation(new ItemStack(Item.foodFishRaw, 1, 0), 0.0f);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package baguchan.better_with_aquatic.entity.render;// Made with Blockbench 4.8.3
// Exported for Minecraft version 1.7 - 1.12
// Paste this class into your mod and generate all required imports


import net.minecraft.client.render.model.Cube;
import net.minecraft.client.render.model.ModelBase;
import net.minecraft.core.util.helper.MathHelper;

public class AnglerFishModel extends ModelBase {
private Cube fish;
private Cube tail;
private Cube fin_r;
private Cube fin_l;
private Cube mouth_down;
private Cube mouth_up;
private Cube things;
private Cube orb;

public AnglerFishModel() {
fish = new Cube(0, 0);
fish.setRotationPoint(0.0F, 22.0F, 6.0F);
fish.addBox(-3.0F, -5.0F, -9.0F, 6, 7, 9, 0.0F, false);

tail = new Cube(10, 23);
tail.setRotationPoint(0.0F, 22.0F, 6.0F);
tail.addBox(-1.0F, -3.0F, 0.0F, 2, 5, 4, 0.0F, false);

fin_r = new Cube(0, 25);
fin_r.setRotationPoint(-3.0F, 22.5F, -3.0F);
fin_r.addBox(-1.0F, -1.5F, 0.0F, 1, 3, 4, 0.0F, false);

fin_l = new Cube(0, 25);
fin_l.setRotationPoint(3.0F, 22.5F, -1.0F);
fin_l.addBox(0.0F, -1.5F, 0.0F, 1, 3, 4, 0.0F, true);

mouth_down = new Cube(30, 9);
mouth_down.setRotationPoint(0.0F, 22.0F, -3.0F);
mouth_down.addBox(-3.5F, 0.0F, -4.0F, 7, 2, 4, 0.0F, false);

mouth_up = new Cube(21, 0);
mouth_up.setRotationPoint(0.0F, 22.0F, -3.0F);
mouth_up.addBox(-3.0F, -5.0F, -4.0F, 6, 5, 4, 0.0F, false);

things = new Cube(41, 1);
things.setRotationPoint(0.0F, 22.0F, -3.0F);

things.setRotationPoint(0.0F, 22.0F, -3.0F);
setRotationAngle(things, -0.48F, 0.0F, 0.0F);
things.addBox(-0.5F, -1.0F, -6.0F, 1, 1, 5, 0.0F, false);

orb = new Cube(48, 2);
orb.setRotationPoint(0.0F, 22.0F, -3.0F);
setRotationAngle(orb, -0.48F, 0.0F, 0.0F);
orb.addBox(-1.0F, -1.0F, -8.0F, 2, 2, 2, 0.0F, false);
}

@Override
public void render(float limbSwing, float limbYaw, float ticksExisted, float headYaw, float headPitch, float scale) {
this.setRotationAngles(limbSwing, limbYaw, ticksExisted, headYaw, headPitch, scale);
fish.render(scale);
tail.render(scale);
fin_r.render(scale);
fin_l.render(scale);
mouth_down.render(scale);
mouth_up.render(scale);
things.render(scale);
orb.render(scale);
}

public void setRotationAngles(float limbSwing, float limbYaw, float ticksExisted, float headYaw, float headPitch, float scale) {
this.fin_r.rotateAngleY = -0.6F + MathHelper.cos(ticksExisted * 0.5F) * -0.15F;
this.fin_l.rotateAngleY = 0.6F + MathHelper.cos(ticksExisted * 0.5F) * 0.15F;
this.tail.rotateAngleY = MathHelper.cos(ticksExisted * 0.5F) * -0.3F;
}

public void setRotationAngle(Cube 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
@@ -0,0 +1,37 @@
package baguchan.better_with_aquatic.entity.render;

import baguchan.better_with_aquatic.entity.EntityAnglerFish;
import net.minecraft.client.Minecraft;
import net.minecraft.client.render.entity.LivingRenderer;
import net.minecraft.client.render.model.ModelBase;
import org.lwjgl.opengl.GL11;

public class RenderAnglerFish extends LivingRenderer<EntityAnglerFish> {
public RenderAnglerFish(ModelBase modelbase, float shadowSize) {
super(modelbase, shadowSize);
this.setRenderPassModel(new AnglerFishModel());
}


protected boolean setAnglerBrightness(EntityAnglerFish spider, int i, float f) {
if (i == 0) {
this.loadTexture("/assets/better_with_aquatic/entity/angler_fish_overlay.png");
float brightness = spider.getBrightness(1.0f);
if (Minecraft.getMinecraft((Object) this).fullbright) {
brightness = 1.0f;
}
float f1 = (1.0f - brightness) * 0.5f;
GL11.glEnable(3042);
GL11.glDisable(3008);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(1.0f, 1.0f, 1.0f, f1);
return true;
}
return false;
}

@Override
protected boolean shouldRenderPass(EntityAnglerFish entity, int renderPass, float renderPartialTicks) {
return this.setAnglerBrightness(entity, renderPass, renderPartialTicks);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/lang/better_with_aquatic/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ tile.better_with_aquatic.coral_purple.desc=A purple bioluminescent bone like blo

tile.better_with_aquatic.coral_pink.name=Carnation Coral
tile.better_with_aquatic.coral_pink.desc=A pink bioluminescent bone like block found in oceans.

item.better_with_aquatic.spawnegg.fish.name=Fish
item.better_with_aquatic.spawnegg.angler_fish.name=Angler Fish

0 comments on commit 86aac4d

Please sign in to comment.