修改ntw渲染
This commit is contained in:
parent
07792d6e37
commit
1395e4e047
4 changed files with 70 additions and 54 deletions
|
@ -5,7 +5,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.heavy.Ntw20Item;
|
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -14,11 +13,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 Ntw20Model extends GeoModel<Ntw20Item> {
|
public class Ntw20Model extends CustomGunModel<Ntw20Item> {
|
||||||
|
|
||||||
public static float fireRotY = 0f;
|
public static float fireRotY = 0f;
|
||||||
public static float fireRotZ = 0f;
|
public static float fireRotZ = 0f;
|
||||||
|
@ -40,7 +38,12 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(Ntw20Item animatable, long instanceId, AnimationState animationState) {
|
public void setCustomAnimations(Ntw20Item animatable, long instanceId, AnimationState<Ntw20Item> 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 action = getAnimationProcessor().getBone("action");
|
GeoBone action = getAnimationProcessor().getBone("action");
|
||||||
GeoBone lh = getAnimationProcessor().getBone("lh");
|
GeoBone lh = getAnimationProcessor().getBone("lh");
|
||||||
|
@ -48,11 +51,6 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
|
||||||
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
||||||
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
||||||
|
|
||||||
Player player = Minecraft.getInstance().player;
|
|
||||||
if (player == null) return;
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
if (!(stack.getItem() instanceof GunItem)) return;
|
|
||||||
|
|
||||||
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;
|
||||||
double zp = ClientEventHandler.zoomPos;
|
double zp = ClientEventHandler.zoomPos;
|
||||||
|
|
|
@ -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 Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
public class Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
||||||
|
@ -38,39 +40,43 @@ public class Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
||||||
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("ironSight")) {
|
||||||
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) != 0);
|
||||||
|
}
|
||||||
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2
|
||||||
|
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("hidden"))) {
|
||||||
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
|
}
|
||||||
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3
|
||||||
|
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("jing") || name.equals("rail") || name.equals("base2") || name.equals("guan7"))) {
|
||||||
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name.equals("ironSight")) {
|
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) != 0);
|
|
||||||
|
switch (scopeType) {
|
||||||
|
case 1 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.468755, 40, 1, 255, 0, 0, 255, "eotech", false);
|
||||||
|
case 2 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.48875, 9, 1, 255, 0, 0, 255, "acog", true);
|
||||||
|
case 3 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.46875, 30, (float) ClientEventHandler.customZoom, 255, 0, 0, 255, "lpvo", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 3.70229375, 0.8);
|
||||||
|
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||||
|
} else {
|
||||||
|
ItemModelHelper.hideAllAttachments(bone, name);
|
||||||
|
if (name.equals("hidden") || name.equals("jing") || name.equals("base2") || name.equals("guan7")) {
|
||||||
|
bone.setHidden(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2
|
|
||||||
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("hidden"))) {
|
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3
|
|
||||||
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("jing") || name.equals("rail") || name.equals("base2") || name.equals("guan7"))) {
|
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
|
||||||
|
|
||||||
switch (scopeType) {
|
|
||||||
case 1 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.468755, 40, 1, 255, 0, 0, 255, "eotech", false);
|
|
||||||
case 2 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.48875, 9, 1, 255, 0, 0, 255, "acog", true);
|
|
||||||
case 3 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.46875, 30, (float) ClientEventHandler.customZoom, 255, 0, 0, 255, "lpvo", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 3.70229375, 0.8);
|
|
||||||
|
|
||||||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
|
||||||
|
|
||||||
if (renderingArms) {
|
if (renderingArms) {
|
||||||
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, false);
|
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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.animatable.GeoItem;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
|
@ -59,24 +60,26 @@ public class TracheliumItemRenderer extends CustomGunRenderer<Trachelium> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("humu")) {
|
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 0 && GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
if (name.equals("humu")) {
|
||||||
}
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 0 && GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (name.equals("qianzhunxing1")) {
|
if (name.equals("qianzhunxing1")) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) > 0 || GunData.from(itemStack).attachment.get(AttachmentType.GRIP) > 0);
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) > 0 || GunData.from(itemStack).attachment.get(AttachmentType.GRIP) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("railup")) {
|
if (name.equals("railup")) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 0);
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("raildown")) {
|
if (name.equals("raildown")) {
|
||||||
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 && !NBTTool.getTag(itemStack).getBoolean("ScopeAlt") && (name.equals("hidden"))) {
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 && !NBTTool.getTag(itemStack).getBoolean("ScopeAlt") && (name.equals("hidden"))) {
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemModelHelper.hideAllAttachments(bone, name);
|
ItemModelHelper.hideAllAttachments(bone, name);
|
||||||
|
|
|
@ -16,8 +16,10 @@ import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
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 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 java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -44,8 +46,10 @@ public class Ntw20Item 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.ntw_20.idle"));
|
||||||
|
|
||||||
|
var data = GunData.from(stack);
|
||||||
if (data.bolt.actionTimer.get() > 0) {
|
if (data.bolt.actionTimer.get() > 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift"));
|
||||||
}
|
}
|
||||||
|
@ -66,8 +70,10 @@ public class Ntw20Item 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.ntw_20.idle"));
|
||||||
|
|
||||||
|
var data = GunData.from(stack);
|
||||||
if (player.isSprinting() && player.onGround()
|
if (player.isSprinting() && player.onGround()
|
||||||
&& ClientEventHandler.cantSprint == 0
|
&& ClientEventHandler.cantSprint == 0
|
||||||
&& !(data.reload.normal() || data.reload.empty())
|
&& !(data.reload.normal() || data.reload.empty())
|
||||||
|
@ -83,6 +89,9 @@ public class Ntw20Item extends GunItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState editPredicate(AnimationState<Ntw20Item> event) {
|
private PlayState editPredicate(AnimationState<Ntw20Item> event) {
|
||||||
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.idle"));
|
||||||
|
|
||||||
if (ClickHandler.isEditing) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue