selective tnt texture & custom renderer
This commit is contained in:
parent
73acc066f2
commit
8db7889b22
@ -38,7 +38,7 @@ mod_name=Enhanced Explosives
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=All Rights Reserved
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=0.9.7
|
||||
mod_version=0.9.8
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
@ -30,9 +30,10 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
sideTopBottom(blocks.TNT_CLAYMORE);
|
||||
sideTopBottom(blocks.TNT_HOMING);
|
||||
SideTop(blocks.TNT_BLACK_HOLE);
|
||||
clusterTNT(blocks.TNT_CLUSTER_2);
|
||||
clusterTNT(blocks.TNT_CLUSTER_4);
|
||||
clusterTNT(blocks.TNT_CLUSTER_8);
|
||||
SideOnlyTNT(blocks.TNT_CLUSTER_2);
|
||||
SideOnlyTNT(blocks.TNT_CLUSTER_4);
|
||||
SideOnlyTNT(blocks.TNT_CLUSTER_8);
|
||||
SideOnlyTNT(blocks.TNT_SELECTIVE);
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||
@ -71,7 +72,7 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
simpleBlockItem(block, model);
|
||||
}
|
||||
|
||||
public void clusterTNT(RegistryObject<Block> blockRegistryObject) {
|
||||
public void SideOnlyTNT(RegistryObject<Block> blockRegistryObject) {
|
||||
Block block = blockRegistryObject.get();
|
||||
ModelFile model = models().cubeBottomTop(name(block), extend(blockTexture(block), "_side"), extend(blockTexture(Blocks.TNT), "_bottom"), extend(blockTexture(Blocks.TNT), "_top"));
|
||||
this.getVariantBuilder(block).forAllStates(blockState -> ConfiguredModel.builder().modelFile(model).build());
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.jenny.enhancedexplosives.entities.client;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.selectivePrimedTNT;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.TntMinecartRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SelectiveTNTRenderer<T extends selectivePrimedTNT> extends EntityRenderer<T> {
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
|
||||
public SelectiveTNTRenderer(EntityRendererProvider.Context pContext) {
|
||||
super(pContext);
|
||||
this.shadowRadius = 0.5F;
|
||||
this.blockRenderer = pContext.getBlockRenderDispatcher();
|
||||
}
|
||||
|
||||
public void render(T pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
|
||||
pPoseStack.pushPose();
|
||||
pPoseStack.translate(0.0F, 0.5F, 0.0F);
|
||||
int i = pEntity.getFuse();
|
||||
if ((float)i - pPartialTicks + 1.0F < 10.0F) {
|
||||
float f = 1.0F - ((float)i - pPartialTicks + 1.0F) / 10.0F;
|
||||
f = Mth.clamp(f, 0.0F, 1.0F);
|
||||
f *= f;
|
||||
f *= f;
|
||||
float f1 = 1.0F + f * 0.3F;
|
||||
pPoseStack.scale(f1, f1, f1);
|
||||
}
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
pPoseStack.translate(-0.5F, -0.5F, 0.5F);
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
||||
Block block = (i / 5 % 2 == 0) ? pEntity.renderBlockBeneath(): pEntity.renderBlock();
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, block.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, false);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResourceLocation getTextureLocation(@NotNull T pEntity) {
|
||||
return TextureAtlas.LOCATION_BLOCKS;
|
||||
}
|
||||
}
|
@ -84,8 +84,8 @@ public class entities {
|
||||
EntityRenderers.register(TNT_HOMING.get(), BaseTNTRenderer::new);
|
||||
EntityRenderers.register(TNT_BLACK_HOLE.get(), BaseTNTRenderer::new);
|
||||
EntityRenderers.register(TNT_CLAYMORE.get(), BaseTNTRenderer::new);
|
||||
EntityRenderers.register(TNT_SELECTIVE.get(), BaseTNTRenderer::new);
|
||||
EntityRenderers.register(TNT_ENDER.get(), BaseTNTRenderer::new);
|
||||
EntityRenderers.register(TNT_SELECTIVE.get(), SelectiveTNTRenderer::new);
|
||||
|
||||
EntityRenderers.register(TNT_CLUSTER.get(), clusterTNTRenderer::new);
|
||||
EntityRenderers.register(DYNAMITE.get(), clusterTNTRenderer::new);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@ -9,7 +10,6 @@ import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -43,11 +43,15 @@ public class selectivePrimedTNT extends basePrimedTNT {
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return renderBlock().toString();
|
||||
return renderBlockBeneath().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block renderBlock() {
|
||||
return blocks.TNT_SELECTIVE.get();
|
||||
}
|
||||
|
||||
public Block renderBlockBeneath() {
|
||||
return level().getBlockState(new BlockPos((int) Math.floor(getX()), (int) Math.floor(getY()) - 1, (int) Math.floor(getZ()))).getBlock();
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 679 B |
Loading…
x
Reference in New Issue
Block a user