修改smg的渲染
This commit is contained in:
parent
db9994f6ca
commit
545f47485d
6 changed files with 80 additions and 64 deletions
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.smg.Mp5Item;
|
import com.atsuishio.superbwarfare.item.gun.smg.Mp5Item;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -15,9 +14,8 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import software.bernie.geckolib.animation.AnimationState;
|
import software.bernie.geckolib.animation.AnimationState;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
import software.bernie.geckolib.model.GeoModel;
|
|
||||||
|
|
||||||
public class Mp5ItemModel extends GeoModel<Mp5Item> {
|
public class Mp5ItemModel extends CustomGunModel<Mp5Item> {
|
||||||
|
|
||||||
public static float fireRotY = 0f;
|
public static float fireRotY = 0f;
|
||||||
public static float fireRotZ = 0f;
|
public static float fireRotZ = 0f;
|
||||||
|
@ -38,14 +36,14 @@ public class Mp5ItemModel extends GeoModel<Mp5Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(Mp5Item animatable, long instanceId, AnimationState animationState) {
|
public void setCustomAnimations(Mp5Item animatable, long instanceId, AnimationState<Mp5Item> animationState) {
|
||||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
|
||||||
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
|
||||||
|
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return;
|
if (shouldCancelRender(stack, animationState)) return;
|
||||||
|
|
||||||
|
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||||
|
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
||||||
|
|
||||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||||
double zt = ClientEventHandler.zoomTime;
|
double zt = ClientEventHandler.zoomTime;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
|
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -15,11 +14,10 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import software.bernie.geckolib.animation.AnimationState;
|
import software.bernie.geckolib.animation.AnimationState;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
import software.bernie.geckolib.model.GeoModel;
|
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.event.ClientEventHandler.isProne;
|
import static com.atsuishio.superbwarfare.event.ClientEventHandler.isProne;
|
||||||
|
|
||||||
public class VectorItemModel extends GeoModel<VectorItem> {
|
public class VectorItemModel extends CustomGunModel<VectorItem> {
|
||||||
|
|
||||||
public static float fireRotY = 0f;
|
public static float fireRotY = 0f;
|
||||||
public static float fireRotZ = 0f;
|
public static float fireRotZ = 0f;
|
||||||
|
@ -42,18 +40,18 @@ public class VectorItemModel extends GeoModel<VectorItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(VectorItem animatable, long instanceId, AnimationState animationState) {
|
public void setCustomAnimations(VectorItem animatable, long instanceId, AnimationState<VectorItem> animationState) {
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
if (player == null) return;
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
if (shouldCancelRender(stack, animationState)) return;
|
||||||
|
|
||||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||||
GeoBone scope = getAnimationProcessor().getBone("Scope1");
|
GeoBone scope = getAnimationProcessor().getBone("Scope1");
|
||||||
GeoBone kmj = getAnimationProcessor().getBone("kuaimanji");
|
GeoBone kmj = getAnimationProcessor().getBone("kuaimanji");
|
||||||
GeoBone sight1fold = getAnimationProcessor().getBone("SightFold1");
|
GeoBone sight1fold = getAnimationProcessor().getBone("SightFold1");
|
||||||
GeoBone sight2fold = getAnimationProcessor().getBone("SightFold2");
|
GeoBone sight2fold = getAnimationProcessor().getBone("SightFold2");
|
||||||
|
|
||||||
Player player = Minecraft.getInstance().player;
|
|
||||||
if (player == null) return;
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
if (!(stack.getItem() instanceof GunItem)) return;
|
|
||||||
|
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
|
|
||||||
switch (data.fireMode.get()) {
|
switch (data.fireMode.get()) {
|
||||||
|
|
|
@ -14,7 +14,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import software.bernie.geckolib.animatable.GeoItem;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
|
|
||||||
public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
|
public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
|
||||||
|
@ -38,19 +40,18 @@ public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
|
||||||
var player = mc.player;
|
var player = mc.player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
ItemStack itemStack = player.getMainHandItem();
|
ItemStack itemStack = player.getMainHandItem();
|
||||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||||
|
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||||
if (name.equals("yugu")) {
|
if (name.equals("yugu")) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("bashou")) {
|
if (name.equals("bashou")) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) != 0);
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 && (bone.getName().endsWith("_hide2"))) {
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 && (bone.getName().endsWith("_hide2"))) {
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
||||||
switch (scopeType) {
|
switch (scopeType) {
|
||||||
|
@ -61,8 +62,13 @@ public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0.05, 1, 0.35);
|
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0.05, 1, 0.35);
|
||||||
|
|
||||||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||||
|
} else {
|
||||||
|
ItemModelHelper.hideAllAttachments(bone, name);
|
||||||
|
if (name.equals("yugu")) {
|
||||||
|
bone.setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (renderingArms) {
|
if (renderingArms) {
|
||||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||||
|
|
|
@ -13,8 +13,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import software.bernie.geckolib.animatable.GeoItem;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
|
|
||||||
public class VectorItemRenderer extends CustomGunRenderer<VectorItem> {
|
public class VectorItemRenderer extends CustomGunRenderer<VectorItem> {
|
||||||
|
@ -38,11 +39,12 @@ public class VectorItemRenderer extends CustomGunRenderer<VectorItem> {
|
||||||
var player = mc.player;
|
var player = mc.player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
ItemStack itemStack = player.getMainHandItem();
|
ItemStack itemStack = player.getMainHandItem();
|
||||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||||
|
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||||
if (name.equals("tuoxin")) {
|
if (name.equals("tuoxin")) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.STOCK) == 0);
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.STOCK) == 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
||||||
switch (scopeType) {
|
switch (scopeType) {
|
||||||
|
@ -53,18 +55,17 @@ public class VectorItemRenderer extends CustomGunRenderer<VectorItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.453125, 0.35);
|
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.453125, 0.35);
|
||||||
|
|
||||||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||||
|
} else {
|
||||||
|
ItemModelHelper.hideAllAttachments(bone, name);
|
||||||
|
if (name.equals("tuoxin")) {
|
||||||
|
bone.setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (renderingArms) {
|
if (renderingArms) {
|
||||||
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, true);
|
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, true);
|
||||||
}
|
}
|
||||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getTextureLocation(VectorItem instance) {
|
|
||||||
return super.getTextureLocation(instance);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import software.bernie.geckolib.animation.*;
|
import software.bernie.geckolib.animation.*;
|
||||||
|
import software.bernie.geckolib.constant.DataTickets;
|
||||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
@ -41,6 +43,9 @@ public class Mp5Item extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mp5.idle"));
|
||||||
|
|
||||||
boolean drum = GunData.from(stack).attachment.get(AttachmentType.MAGAZINE) == 2;
|
boolean drum = GunData.from(stack).attachment.get(AttachmentType.MAGAZINE) == 2;
|
||||||
|
|
||||||
if (GunData.from(stack).reload.empty()) {
|
if (GunData.from(stack).reload.empty()) {
|
||||||
|
@ -75,6 +80,8 @@ public class Mp5Item extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mp5.idle"));
|
||||||
|
|
||||||
if (ClickHandler.isEditing) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mp5.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mp5.edit"));
|
||||||
|
|
|
@ -14,10 +14,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import software.bernie.geckolib.animation.*;
|
import software.bernie.geckolib.animation.*;
|
||||||
|
import software.bernie.geckolib.constant.DataTickets;
|
||||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
@ -35,8 +37,10 @@ public class VectorItem extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
var data = GunData.from(stack);
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.vector.idle"));
|
||||||
|
|
||||||
|
var data = GunData.from(stack);
|
||||||
boolean drum = data.attachment.get(AttachmentType.MAGAZINE) == 2;
|
boolean drum = data.attachment.get(AttachmentType.MAGAZINE) == 2;
|
||||||
|
|
||||||
if (data.reload.empty()) {
|
if (data.reload.empty()) {
|
||||||
|
@ -71,6 +75,8 @@ public class VectorItem extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.vector.idle"));
|
||||||
|
|
||||||
if (ClickHandler.isEditing) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vector.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vector.edit"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue