Skip to content

Commit

Permalink
fixed server side
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed May 29, 2024
1 parent 6ebc7d4 commit ec8fed3
Show file tree
Hide file tree
Showing 46 changed files with 210 additions and 91 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ loom {
customMinecraftManifest.set("https://github.com/Turnip-Labs/bta-manifest-repo/releases/download/v${project.bta_version}/${project.bta_version}.json")
}


repositories {
mavenCentral()
maven { url = "https://jitpack.io" }
Expand Down Expand Up @@ -103,7 +102,7 @@ dependencies {
modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}"
modImplementation "DragonFly:dragonfly:${project.dragonfly_version}"

modImplementation "BetterAI-BTA:better_ai:2.0.1"
modImplementation "BetterAI-BTA:better_ai:3.0.0"
modImplementation "ModMenu:ModMenu:2.0.5"

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
org.gradle.jvmargs=-Xmx2G

# BTA
bta_version=7.1
bta_version=7.2-pre1

# Loader
loader_version=0.15.6-babric.4-bta
loader_version=0.15.6-babric.6-bta

# HalpLibe
halplibe_version=3.5.2
dragonfly_version=1.4.7-7.1
terrain_api_version=1.4.4-7.1
halplibe_version=4.0.6
dragonfly_version=1.5.0-7.2-pre1
terrain_api_version=1.4.4-7.2-pre1
# Mod
mod_version=3.3.0
mod_group=baguchan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import baguchan.better_with_aquatic.entity.EntityDrowned;
import baguchan.better_with_aquatic.entity.EntityFish;
import baguchan.better_with_aquatic.entity.EntityFrog;
import baguchan.better_with_aquatic.entity.render.*;
import baguchan.better_with_aquatic.item.ModItems;
import baguchan.better_with_aquatic.packet.SwimPacket;
import net.fabricmc.api.ModInitializer;
Expand Down Expand Up @@ -54,10 +55,10 @@ public void beforeGameStart() {
Block.lightBlock[Block.fluidWaterStill.id] = 1;
ModBlocks.createBlocks();
ModItems.onInitialize();
EntityHelper.Core.createEntity(EntityFish.class, entityID, "Fish");
EntityHelper.Core.createEntity(EntityAnglerFish.class, entityID + 1, "AnglerFish");
EntityHelper.Core.createEntity(EntityDrowned.class, entityID + 2, "Drowned");
EntityHelper.Core.createEntity(EntityFrog.class, entityID + 3, "Frog");
EntityHelper.createEntity(EntityFish.class, entityID, "Fish", () -> new RenderFish(new FishModel(), 0.3F));
EntityHelper.createEntity(EntityAnglerFish.class, entityID + 1, "AnglerFish", () -> new RenderAnglerFish(new FishModel(), 0.4F));
EntityHelper.createEntity(EntityDrowned.class, entityID + 2, "Drowned", () -> new DrownedRenderer(BetterWithAquaticClient.modelDrowned, 0.5F));
EntityHelper.createEntity(EntityFrog.class, entityID + 3, "Frog", () -> new FrogRenderer(BetterWithAquaticClient.modelFrog, 0.3f));

MobInfoRegistry.register(EntityFish.class, "section.better_with_aquatic.fish.name", "section.better_with_aquatic.fish.desc", 3, 20, new MobInfoRegistry.MobDrop[]{new MobInfoRegistry.MobDrop(Item.foodFishRaw.getDefaultStack(), 1.0f, 1, 1)});
MobInfoRegistry.register(EntityAnglerFish.class, "section.better_with_aquatic.angler_fish.name", "section.better_with_aquatic.angler_fish.desc", 3, 20, new MobInfoRegistry.MobDrop[]{new MobInfoRegistry.MobDrop(ModItems.small_bulb.getDefaultStack(), 1.0f, 1, 1)});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package baguchan.better_with_aquatic;

import baguchan.better_with_aquatic.block.ModBlocks;
import baguchan.better_with_aquatic.entity.EntityAnglerFish;
import baguchan.better_with_aquatic.entity.EntityDrowned;
import baguchan.better_with_aquatic.entity.EntityFish;
import baguchan.better_with_aquatic.entity.EntityFrog;
import baguchan.better_with_aquatic.entity.render.*;
import net.minecraft.client.render.block.model.BlockModelDispatcher;
import net.minecraft.client.render.block.model.BlockModelRenderBlocks;
import turniplabs.halplibe.helper.EntityHelper;
import baguchan.better_with_aquatic.entity.render.DrownedModel;
import baguchan.better_with_aquatic.entity.render.FrogModel;
import net.minecraft.client.render.block.color.BlockColorCustom;
import net.minecraft.client.render.block.color.BlockColorDispatcher;
import net.minecraft.client.render.colorizer.Colorizers;
import org.useless.dragonfly.helper.ModelHelper;
import org.useless.dragonfly.model.entity.BenchEntityModel;
import turniplabs.halplibe.helper.SoundHelper;
import turniplabs.halplibe.util.ClientStartEntrypoint;
import useless.dragonfly.helper.ModelHelper;
import useless.dragonfly.model.entity.BenchEntityModel;

import static baguchan.better_with_aquatic.BetterWithAquatic.MOD_ID;

Expand All @@ -26,20 +23,16 @@ public class BetterWithAquaticClient implements ClientStartEntrypoint {

@Override
public void beforeClientStart() {
EntityHelper.Client.assignEntityRenderer(EntityFish.class, new RenderFish(new FishModel(), 0.3F));
EntityHelper.Client.assignEntityRenderer(EntityAnglerFish.class, new RenderAnglerFish(new AnglerFishModel(), 0.4F));
EntityHelper.Client.assignEntityRenderer(EntityDrowned.class, new DrownedRenderer(modelDrowned, 0.5f));
EntityHelper.Client.assignEntityRenderer(EntityFrog.class, new FrogRenderer(modelFrog, 0.3f));
SoundHelper.Client.addSound(MOD_ID, "mob/drowned/drowned_idle.wav");
SoundHelper.Client.addSound(MOD_ID, "mob/drowned/drowned_death.wav");
SoundHelper.Client.addSound(MOD_ID, "mob/drowned/drowned_hurt.wav");
SoundHelper.Client.addSound(MOD_ID, "mob/drowned/drowned_hurt_extra.wav");
SoundHelper.addSound(MOD_ID, "mob/drowned/drowned_idle.wav");
SoundHelper.addSound(MOD_ID, "mob/drowned/drowned_death.wav");
SoundHelper.addSound(MOD_ID, "mob/drowned/drowned_hurt.wav");
SoundHelper.addSound(MOD_ID, "mob/drowned/drowned_hurt_extra.wav");

}

@Override
public void afterClientStart() {
BlockModelDispatcher dispatcher = BlockModelDispatcher.getInstance();
dispatcher.addDispatch(ModBlocks.sea_grass, new BlockModelRenderBlocks(6));
dispatcher.addDispatch(ModBlocks.sea_grass_flow, new BlockModelRenderBlocks(6));
BlockColorDispatcher.getInstance().addDispatch(ModBlocks.sea_grass, new BlockColorCustom(Colorizers.water));
BlockColorDispatcher.getInstance().addDispatch(ModBlocks.sea_grass_flow, new BlockColorCustom(Colorizers.water));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,6 @@ public boolean isCollidable() {
return super.isCollidable();
}

@Override
public int getRenderBlockPass() {
return 0;
}


@Override
public ItemStack[] getBreakResult(World world, EnumDropCause dropCause, int x, int y, int z, int meta, TileEntity tileEntity) {
switch (dropCause) {
Expand All @@ -251,4 +245,9 @@ public ItemStack[] getBreakResult(World world, EnumDropCause dropCause, int x, i
public boolean canBlockStay(World world, int x, int y, int z) {
return (this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z))) && world.getBlock(x, y, z) != null && world.getBlock(x, y, z).blockMaterial == Material.water;
}

@Override
public int getRenderBlockPass() {
return 0;
}
}
32 changes: 22 additions & 10 deletions src/main/java/baguchan/better_with_aquatic/block/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package baguchan.better_with_aquatic.block;

import baguchan.better_with_aquatic.BetterWithAquatic;
import baguchan.better_with_aquatic.client.render.model.BlockModelSeaGrass;
import baguchan.better_with_aquatic.client.render.model.SeaGrassItemModel;
import baguchan.better_with_aquatic.util.IDUtils;
import net.minecraft.core.block.Block;
import net.minecraft.core.block.material.Material;
Expand All @@ -15,15 +17,25 @@ public class ModBlocks {
.setHardness(0.0f)
.setResistance(100F)
.setLightOpacity(1)
.setTextures("sea_grass.png")
.setTags(BlockTags.IS_WATER, BlockTags.PLACE_OVERWRITES, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.setBlockModel(block -> {
return new BlockModelSeaGrass<>(block).withTextures("better_with_aquatic:block/sea_grass");
})
.setItemModel(itemBlock -> {
return new SeaGrassItemModel(itemBlock);
})
.build(new BlockWaterPlantStill("sea_grass", IDUtils.getCurrBlockId(), Material.water).withLitInteriorSurface(true));
public static final Block sea_grass_flow = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.0f)
.setResistance(100F)
.setLightOpacity(1)
.setTextures("sea_grass.png")
.setBlockModel(block -> {
return new BlockModelSeaGrass<>(block).withTextures("better_with_aquatic:block/sea_grass");
})
.setItemModel(itemBlock -> {
return new SeaGrassItemModel(itemBlock);
})
.setBlockDrop(sea_grass)
.setTags(BlockTags.IS_WATER, BlockTags.PLACE_OVERWRITES, BlockTags.SHEARS_DO_SILK_TOUCH, BlockTags.NOT_IN_CREATIVE_MENU)
.setBlockSound(BlockSounds.GRASS)
Expand All @@ -32,58 +44,58 @@ public class ModBlocks {
public static final Block coral_blue = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_blue.png")
.setTextures("better_with_aquatic:block/coral_blue")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_blue", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block coral_cyan = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_cyan.png")
.setTextures("better_with_aquatic:block/coral_cyan")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_cyan", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block coral_green = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_green.png")
.setTextures("better_with_aquatic:block/coral_green")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_green", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block coral_pink = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_pink.png")
.setTextures("better_with_aquatic:block/coral_pink")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_pink", IDUtils.getCurrBlockId(), Material.vegetable));

public static final Block coral_purple = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_purple.png")
.setTextures("better_with_aquatic:block/coral_purple")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_purple", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block coral_red = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_red.png")
.setTextures("better_with_aquatic:block/coral_red")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_red", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block coral_yellow = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.6f)
.setResistance(0.65F)
.setTextures("coral_yellow.png")
.setTextures("better_with_aquatic:block/coral_yellow")
.setTags(BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH)
.setBlockSound(BlockSounds.GRASS)
.build(new CoralBlock("coral_yellow", IDUtils.getCurrBlockId(), Material.vegetable));
public static final Block light_blub = new BlockBuilder(BetterWithAquatic.MOD_ID)
.setHardness(0.5f)
.setResistance(1.5F)
.setLuminance(13)
.setTextures("light_bulb.png")
.setTextures("better_with_aquatic:block/light_bulb")
.setTags(BlockTags.MINEABLE_BY_PICKAXE)
.setBlockSound(BlockSounds.METAL)
.build(new Block("light_bulb", IDUtils.getCurrBlockId(), Material.metal));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package baguchan.better_with_aquatic.client.render.model;

import net.minecraft.client.render.LightmapHelper;
import net.minecraft.client.render.block.model.BlockModelStandard;
import net.minecraft.client.render.stitcher.IconCoordinate;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.core.block.Block;
import net.minecraft.core.util.helper.Side;
import net.minecraft.core.world.WorldSource;

public class BlockModelSeaGrass<T extends Block>
extends BlockModelStandard<T> {

public BlockModelSeaGrass(Block block) {
super(block);
}

@Override
public boolean render(Tessellator tessellator, int x, int y, int z) {
this.block.setBlockBoundsBasedOnState(BlockModelSeaGrass.renderBlocks.blockAccess, x, y, z);
float brightness = 1.0f;
if (LightmapHelper.isLightmapEnabled()) {
tessellator.setLightmapCoord(this.block.getLightmapCoord(BlockModelSeaGrass.renderBlocks.blockAccess, x, y, z));
} else {
brightness = this.getBlockBrightness(BlockModelSeaGrass.renderBlocks.blockAccess, x, y, z);
}
tessellator.setColorOpaque_F(brightness, brightness, brightness);
IconCoordinate texture = this.getBlockTextureFromSideAndMetadata(Side.BOTTOM, BlockModelSeaGrass.renderBlocks.blockAccess.getBlockMetadata(x, y, z));
if (BlockModelSeaGrass.renderBlocks.overrideBlockTexture != null) {
texture = BlockModelSeaGrass.renderBlocks.overrideBlockTexture;
}
double uMin = texture.getIconUMin();
double uMax = texture.getIconUMax();
double vMin = texture.getIconVMin();
double vMax = texture.getIconVMax();
double xMin = (double) x + 0.5 - 0.25;
double xMax = (double) x + 0.5 + 0.25;
double zMin = (double) z + 0.5 - 0.5;
double zMax = (double) z + 0.5 + 0.5;
double yd = (float) y - 0.0625f;
tessellator.addVertexWithUV(xMin, yd + 1.0, zMin, uMin, vMin);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMin, uMin, vMax);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMax, uMax, vMax);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMax, uMax, vMin);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMax, uMin, vMin);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMax, uMin, vMax);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMin, uMax, vMax);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMin, uMax, vMin);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMax, uMin, vMin);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMax, uMin, vMax);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMin, uMax, vMax);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMin, uMax, vMin);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMin, uMin, vMin);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMin, uMin, vMax);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMax, uMax, vMax);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMax, uMax, vMin);
xMin = (double) x + 0.5 - 0.5;
xMax = (double) x + 0.5 + 0.5;
zMin = (double) z + 0.5 - 0.25;
zMax = (double) z + 0.5 + 0.25;
tessellator.addVertexWithUV(xMin, yd + 1.0, zMin, uMin, vMin);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMin, uMin, vMax);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMin, uMax, vMax);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMin, uMax, vMin);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMin, uMin, vMin);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMin, uMin, vMax);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMin, uMax, vMax);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMin, uMax, vMin);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMax, uMin, vMin);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMax, uMin, vMax);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMax, uMax, vMax);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMax, uMax, vMin);
tessellator.addVertexWithUV(xMin, yd + 1.0, zMax, uMin, vMin);
tessellator.addVertexWithUV(xMin, yd + 0.0, zMax, uMin, vMax);
tessellator.addVertexWithUV(xMax, yd + 0.0, zMax, uMax, vMax);
tessellator.addVertexWithUV(xMax, yd + 1.0, zMax, uMax, vMin);
return true;
}

@Override
public boolean shouldItemRender3d() {
return false;
}

@Override
public boolean shouldSideBeRendered(WorldSource blockAccess, int x, int y, int z, int side) {
return super.shouldSideBeRendered(blockAccess, x, y, z, side);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package baguchan.better_with_aquatic.client.render.model;

import net.minecraft.client.render.item.model.ItemModelBlock;
import net.minecraft.client.render.stitcher.IconCoordinate;
import net.minecraft.client.render.stitcher.TextureRegistry;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.item.block.ItemBlock;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class SeaGrassItemModel extends ItemModelBlock {
public SeaGrassItemModel(ItemBlock itemBlock) {
super(itemBlock);
}

@Override
public @NotNull IconCoordinate getIcon(@Nullable Entity entity, ItemStack itemStack) {
return TextureRegistry.getTexture("better_with_aquatic:block/sea_grass");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void onRecipesReady() {

@Override
public void initNamespaces() {
RecipeEntrypoint.super.initNamespaces();
RecipeBuilder.initNameSpace(MOD_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public EntityAnglerFish(World world) {
super(world);
this.setSize(0.5F, 0.45F);
this.setPos(this.x, this.y, this.z);
this.skinName = "angler_fish";
}

@Override
Expand All @@ -24,12 +23,12 @@ public int getMaxHealth() {

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

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


Expand Down
Loading

0 comments on commit ec8fed3

Please sign in to comment.