generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
210 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/baguchan/better_with_aquatic/client/render/model/BlockModelSeaGrass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/baguchan/better_with_aquatic/client/render/model/SeaGrassItemModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.