diff --git a/build.gradle b/build.gradle index 98df937..fbdd1aa 100644 --- a/build.gradle +++ b/build.gradle @@ -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}" @@ -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" diff --git a/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java b/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java index 5a23735..1dc66f9 100644 --- a/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java +++ b/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java @@ -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; @@ -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; @@ -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(); @@ -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); } diff --git a/src/main/java/baguchan/better_with_aquatic/compat/SpawnEggCompat.java b/src/main/java/baguchan/better_with_aquatic/compat/SpawnEggCompat.java new file mode 100644 index 0000000..efa74a4 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/compat/SpawnEggCompat.java @@ -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"); + } +} diff --git a/src/main/java/baguchan/better_with_aquatic/entity/EntityAnglerFish.java b/src/main/java/baguchan/better_with_aquatic/entity/EntityAnglerFish.java new file mode 100644 index 0000000..ecb1f24 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/entity/EntityAnglerFish.java @@ -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); + } +} diff --git a/src/main/java/baguchan/better_with_aquatic/entity/EntityBaseFish.java b/src/main/java/baguchan/better_with_aquatic/entity/EntityBaseFish.java index 7d3da84..72a3bfa 100644 --- a/src/main/java/baguchan/better_with_aquatic/entity/EntityBaseFish.java +++ b/src/main/java/baguchan/better_with_aquatic/entity/EntityBaseFish.java @@ -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; @@ -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() { @@ -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; diff --git a/src/main/java/baguchan/better_with_aquatic/entity/EntityFish.java b/src/main/java/baguchan/better_with_aquatic/entity/EntityFish.java new file mode 100644 index 0000000..b8a7d36 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/entity/EntityFish.java @@ -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); + } + +} diff --git a/src/main/java/baguchan/better_with_aquatic/entity/render/AnglerFishModel.java b/src/main/java/baguchan/better_with_aquatic/entity/render/AnglerFishModel.java new file mode 100644 index 0000000..fce0249 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/entity/render/AnglerFishModel.java @@ -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; + } +} diff --git a/src/main/java/baguchan/better_with_aquatic/entity/render/RenderAnglerFish.java b/src/main/java/baguchan/better_with_aquatic/entity/render/RenderAnglerFish.java new file mode 100644 index 0000000..1012790 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/entity/render/RenderAnglerFish.java @@ -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 { + 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); + } +} diff --git a/src/main/resources/assets/better_with_aquatic/entity/angler_fish.png b/src/main/resources/assets/better_with_aquatic/entity/angler_fish.png new file mode 100644 index 0000000..34c24c1 Binary files /dev/null and b/src/main/resources/assets/better_with_aquatic/entity/angler_fish.png differ diff --git a/src/main/resources/assets/better_with_aquatic/entity/angler_fish_overlay.png b/src/main/resources/assets/better_with_aquatic/entity/angler_fish_overlay.png new file mode 100644 index 0000000..4884e91 Binary files /dev/null and b/src/main/resources/assets/better_with_aquatic/entity/angler_fish_overlay.png differ diff --git a/src/main/resources/assets/better_with_aquatic/item/spawnEggDefault.png b/src/main/resources/assets/better_with_aquatic/item/spawnEggDefault.png new file mode 100644 index 0000000..9919575 Binary files /dev/null and b/src/main/resources/assets/better_with_aquatic/item/spawnEggDefault.png differ diff --git a/src/main/resources/lang/better_with_aquatic/en_US.lang b/src/main/resources/lang/better_with_aquatic/en_US.lang index 3b196c4..7846263 100644 --- a/src/main/resources/lang/better_with_aquatic/en_US.lang +++ b/src/main/resources/lang/better_with_aquatic/en_US.lang @@ -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