子弹改用geo模型
This commit is contained in:
parent
3ea791240e
commit
c593b8ffdf
9 changed files with 219 additions and 53 deletions
|
@ -0,0 +1,51 @@
|
|||
package net.mcreator.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.mcreator.superbwarfare.entity.ProjectileEntity;
|
||||
import net.mcreator.superbwarfare.entity.layer.ProjectileEntityLayer;
|
||||
import net.mcreator.superbwarfare.entity.model.ProjectileEntityModel;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class ProjectileEntityRenderer extends GeoEntityRenderer<ProjectileEntity> {
|
||||
public ProjectileEntityRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new ProjectileEntityModel());
|
||||
this.shadowRadius = 0f;
|
||||
this.addRenderLayer(new ProjectileEntityLayer(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(ProjectileEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, ProjectileEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green,
|
||||
float blue, float alpha) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ProjectileEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(ProjectileEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package net.mcreator.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.mcreator.superbwarfare.client.model.entity.ModelBullet;
|
||||
import net.mcreator.superbwarfare.entity.ProjectileEntity;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class ProjectileRenderer extends EntityRenderer<ProjectileEntity> {
|
||||
private static final ResourceLocation texture = new ResourceLocation("superbwarfare:textures/entity/bullet_tex.png");
|
||||
private static final ResourceLocation empty_texture = new ResourceLocation("superbwarfare:textures/entity/empty.png");
|
||||
private final ModelBullet<ProjectileEntity> model;
|
||||
|
||||
public ProjectileRenderer(EntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
model = new ModelBullet<>(context.bakeLayer(ModelBullet.LAYER_LOCATION));
|
||||
}
|
||||
|
||||
protected int getBlockLightLevel(ProjectileEntity pEntity, BlockPos pPos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ProjectileEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
VertexConsumer vb = bufferIn.getBuffer(RenderType.eyes(this.getTextureLocation(entityIn)));
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
model.renderToBuffer(poseStack, vb, packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 0.0625f);
|
||||
poseStack.popPose();
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureLocation(ProjectileEntity entity) {
|
||||
if (entity.tickCount > 1){
|
||||
return texture;
|
||||
}
|
||||
return empty_texture;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,10 @@ package net.mcreator.superbwarfare.entity;
|
|||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.block.BarbedWireBlock;
|
||||
import net.mcreator.superbwarfare.init.*;
|
||||
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
||||
import net.mcreator.superbwarfare.init.ModEntities;
|
||||
import net.mcreator.superbwarfare.init.ModParticleTypes;
|
||||
import net.mcreator.superbwarfare.init.ModSounds;
|
||||
import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage;
|
||||
import net.mcreator.superbwarfare.network.message.PlayerGunKillMessage;
|
||||
import net.mcreator.superbwarfare.tools.ExtendedEntityRayTraceResult;
|
||||
|
@ -16,6 +19,9 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
@ -39,6 +45,10 @@ import net.minecraftforge.entity.IEntityAdditionalSpawnData;
|
|||
import net.minecraftforge.entity.PartEntity;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
import software.bernie.geckolib.animatable.GeoEntity;
|
||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
@ -47,7 +57,12 @@ import java.util.function.BiFunction;
|
|||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData {
|
||||
public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData, GeoEntity, AnimatedEntity {
|
||||
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.STRING);
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public String animationProcedure = "empty";
|
||||
private static final Predicate<Entity> PROJECTILE_TARGETS = input -> input != null && input.isPickable() && !input.isSpectator() && input.isAlive();
|
||||
|
||||
private static final Predicate<BlockState> IGNORE_LEAVES = input -> input != null && (input.getBlock() instanceof LeavesBlock
|
||||
|
@ -587,4 +602,26 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
return this.legshot;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSyncedAnimation() {
|
||||
return this.entityData.get(ANIMATION);
|
||||
}
|
||||
|
||||
public void setAnimation(String animation) {
|
||||
this.entityData.set(ANIMATION, animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationProcedure(String procedure) {
|
||||
this.animationProcedure = procedure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import software.bernie.geckolib.core.animation.AnimatableManager;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity{
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.STRING);
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(RgoGrenadeEntity.class, EntityDataSerializers.STRING);
|
||||
private int fuse = 80;
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package net.mcreator.superbwarfare.entity.layer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.entity.ProjectileEntity;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoRenderer;
|
||||
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
||||
|
||||
public class ProjectileEntityLayer extends GeoRenderLayer<ProjectileEntity> {
|
||||
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entity/projectile_entity.png");
|
||||
|
||||
public ProjectileEntityLayer(GeoRenderer<ProjectileEntity> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, ProjectileEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
RenderType glowRenderType = RenderType.eyes(LAYER);
|
||||
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package net.mcreator.superbwarfare.entity.model;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.entity.ProjectileEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||
import software.bernie.geckolib.core.animation.AnimationState;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class ProjectileEntityModel extends GeoModel<ProjectileEntity> {
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(ProjectileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(ProjectileEntity entity) {
|
||||
return new ResourceLocation(ModUtils.MODID, "geo/projectile_entity.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(ProjectileEntity entity) {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/entity/empty.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(ProjectileEntity animatable, long instanceId, AnimationState animationState) {
|
||||
CoreGeoBone bone = getAnimationProcessor().getBone("bone");
|
||||
|
||||
bone.setHidden(animatable.tickCount <= 1);
|
||||
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ public class ModEntityRenderers {
|
|||
event.registerEntityRenderer(ModEntities.MORTAR_SHELL.get(), MortarShellRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.CANNON_SHELL.get(), CannonShellRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.BOCEK_ARROW.get(), BocekArrowRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.PROJECTILE.get(), ProjectileRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.PROJECTILE.get(), ProjectileEntityRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.FRAG.get(), FragRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.MK_42.get(), Mk42Renderer::new);
|
||||
event.registerEntityRenderer(ModEntities.DRONE.get(), DroneRenderer::new);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"format_version": "1.12.0",
|
||||
"minecraft:geometry": [
|
||||
{
|
||||
"description": {
|
||||
"identifier": "geometry.unknown",
|
||||
"texture_width": 32,
|
||||
"texture_height": 32,
|
||||
"visible_bounds_width": 4,
|
||||
"visible_bounds_height": 6,
|
||||
"visible_bounds_offset": [0, -1, 0]
|
||||
},
|
||||
"bones": [
|
||||
{
|
||||
"name": "bone",
|
||||
"pivot": [0, 0, 0]
|
||||
},
|
||||
{
|
||||
"name": "bone2",
|
||||
"parent": "bone",
|
||||
"pivot": [-0.16703, -30.85427, 0],
|
||||
"rotation": [-90, 0, -3.75],
|
||||
"cubes": [
|
||||
{
|
||||
"origin": [-1.34303, -32.03027, 10.5525],
|
||||
"size": [2.352, 2.352, 0],
|
||||
"uv": {
|
||||
"north": {"uv": [8, 0], "uv_size": [24, 24]},
|
||||
"south": {"uv": [8, 0], "uv_size": [24, 24]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.16703, -62.33427, -4.3575],
|
||||
"size": [0, 49.96, 1.68],
|
||||
"pivot": [-0.16703, -30.85427, -3.5175],
|
||||
"rotation": [-90, 0, 30],
|
||||
"uv": {
|
||||
"east": {"uv": [0, 0], "uv_size": [8, 32]},
|
||||
"west": {"uv": [0, 0], "uv_size": [8, 32]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.16703, -62.33427, -4.3575],
|
||||
"size": [0, 49.96, 1.68],
|
||||
"pivot": [-0.16703, -30.85427, -3.5175],
|
||||
"rotation": [-90, 0, -30],
|
||||
"uv": {
|
||||
"east": {"uv": [0, 0], "uv_size": [8, 32]},
|
||||
"west": {"uv": [0, 0], "uv_size": [8, 32]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.16703, -62.33427, -4.3575],
|
||||
"size": [0, 49.96, 1.68],
|
||||
"pivot": [-0.16703, -30.85427, -3.5175],
|
||||
"rotation": [-90, 0, -90],
|
||||
"uv": {
|
||||
"east": {"uv": [0, 0], "uv_size": [8, 32]},
|
||||
"west": {"uv": [0, 0], "uv_size": [8, 32]}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
Loading…
Add table
Reference in a new issue