尝试实现glock渲染分离
This commit is contained in:
parent
92851546ea
commit
09ce92ec61
6 changed files with 36 additions and 28 deletions
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
|||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -14,9 +13,8 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
||||
public class Glock17ItemModel extends CustomGunModel<Glock17Item> {
|
||||
|
||||
public static float fireRotY = 0f;
|
||||
public static float fireRotZ = 0f;
|
||||
|
@ -37,15 +35,15 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(Glock17Item animatable, long instanceId, AnimationState animationState) {
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone slide = getAnimationProcessor().getBone("huatao");
|
||||
GeoBone bullet = getAnimationProcessor().getBone("bullet");
|
||||
|
||||
public void setCustomAnimations(Glock17Item animatable, long instanceId, AnimationState<Glock17Item> animationState) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player == null) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return;
|
||||
if (shouldCancelRender(stack, animationState)) return;
|
||||
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone slide = getAnimationProcessor().getBone("huatao");
|
||||
GeoBone bullet = getAnimationProcessor().getBone("bullet");
|
||||
|
||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
double zt = ClientEventHandler.zoomTime;
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.data.gun.FireMode;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -15,9 +14,8 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
||||
public class Glock18ItemModel extends CustomGunModel<Glock18Item> {
|
||||
|
||||
public static float fireRotY = 0f;
|
||||
public static float fireRotZ = 0f;
|
||||
|
@ -38,17 +36,17 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(Glock18Item animatable, long instanceId, AnimationState animationState) {
|
||||
public void setCustomAnimations(Glock18Item animatable, long instanceId, AnimationState<Glock18Item> 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 slide = getAnimationProcessor().getBone("huatao");
|
||||
GeoBone bullet = getAnimationProcessor().getBone("bullet");
|
||||
GeoBone switch_ = getAnimationProcessor().getBone("kuaimanji");
|
||||
|
||||
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 mode = data.fireMode.get();
|
||||
if (mode == FireMode.SEMI) {
|
||||
|
@ -102,7 +100,6 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
|||
GeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
GeoBone main = getAnimationProcessor().getBone("0");
|
||||
|
||||
|
||||
float numR = (float) (1 - 0.12 * zt);
|
||||
float numP = (float) (1 - 0.68 * zt);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Glock17ItemRenderer extends CustomGunRenderer<Glock17Item> {
|
||||
|
@ -34,12 +35,12 @@ public class Glock17ItemRenderer extends CustomGunRenderer<Glock17Item> {
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Glock18ItemRenderer extends CustomGunRenderer<Glock18Item> {
|
||||
|
@ -34,12 +35,12 @@ public class Glock18ItemRenderer extends CustomGunRenderer<Glock18Item> {
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,11 @@ import net.minecraft.client.player.LocalPlayer;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -37,6 +39,8 @@ public class Glock17Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.glock_17.idle"));
|
||||
|
||||
if (GunData.from(stack).reload.empty()) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock_17.reload_empty"));
|
||||
|
@ -46,7 +50,6 @@ public class Glock17Item extends GunItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock_17.reload_normal"));
|
||||
}
|
||||
|
||||
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock_17.idle"));
|
||||
}
|
||||
|
||||
|
@ -55,6 +58,8 @@ public class Glock17Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.glock_17.idle"));
|
||||
|
||||
if (player.isSprinting() && player.onGround()
|
||||
&& ClientEventHandler.cantSprint == 0
|
||||
|
|
|
@ -11,9 +11,11 @@ import net.minecraft.client.player.LocalPlayer;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -37,6 +39,8 @@ public class Glock18Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.glock_17.idle"));
|
||||
|
||||
if (GunData.from(stack).reload.empty()) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock_17.reload_empty"));
|
||||
|
@ -54,6 +58,8 @@ public class Glock18Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.glock_17.idle"));
|
||||
|
||||
if (player.isSprinting() && player.onGround()
|
||||
&& ClientEventHandler.cantSprint == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue