加了一个框
This commit is contained in:
parent
6745d17a44
commit
afa4d77d2e
7 changed files with 33 additions and 38 deletions
|
@ -5,10 +5,10 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.item.gun.GunItem;
|
import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||||
import net.mcreator.superbwarfare.tools.RenderTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||||
|
@ -17,10 +17,12 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static net.mcreator.superbwarfare.tools.RenderTool.preciseBlit;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class Mk42UIOverlay {
|
public class CannonHudOverlay {
|
||||||
public static final int TEXTURE_WIDTH = 771;
|
|
||||||
public static final int TEXTURE_HEIGHT = 1006;
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
|
@ -34,10 +36,23 @@ public class Mk42UIOverlay {
|
||||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
if (shouldRenderCrossHair(player)) {
|
if (shouldRenderCrossHair(player)) {
|
||||||
RenderTool.preciseBlit(event.getGuiGraphics(),
|
float yRotOffset = Mth.lerp(event.getPartialTick(), player.yRotO, player.getYRot());
|
||||||
new ResourceLocation(ModUtils.MODID, "textures/screens/mk_42_rex.png"),
|
float xRotOffset = Mth.lerp(event.getPartialTick(), player.xRotO, player.getXRot());
|
||||||
(float) w / 2 - (float) TEXTURE_WIDTH / 10f, (float) h / 2 - (float) TEXTURE_HEIGHT / 10f,
|
float diffY = 13 * (Objects.requireNonNull(player.getVehicle()).getViewYRot(event.getPartialTick()) - yRotOffset);
|
||||||
0, 0, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f);
|
float diffX = 13 * (Objects.requireNonNull(player.getVehicle()).getViewXRot(event.getPartialTick()) - xRotOffset + 1.3f);
|
||||||
|
if (diffY > 180.0f) {
|
||||||
|
diffY -= 360.0f;
|
||||||
|
} else if (diffY < -180.0f) {
|
||||||
|
diffY += 360.0f;
|
||||||
|
}
|
||||||
|
float f = (float)Math.min(w, h);
|
||||||
|
float f1 = Math.min((float)w / f, (float)h / f);
|
||||||
|
int i = Mth.floor(f * f1);
|
||||||
|
int j = Mth.floor(f * f1);
|
||||||
|
int k = (w - i) / 2;
|
||||||
|
int l = (h - j) / 2;
|
||||||
|
preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/cannon/cannon_crosshair.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
|
preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/cannon/indicator.png"), k + diffY, l + diffX, 0, 0.0F, i, j, i, j);
|
||||||
}
|
}
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
|
@ -311,7 +311,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
}
|
}
|
||||||
if (stack != null && this.isVehicle() && !stack.is(ModTags.Items.GUN)) {
|
if (stack != null && this.isVehicle() && !stack.is(ModTags.Items.GUN)) {
|
||||||
float diffY = entity.getYHeadRot() - this.getYRot();
|
float diffY = entity.getYHeadRot() - this.getYRot();
|
||||||
float diffX = entity.getXRot() - this.getXRot();
|
float diffX = entity.getXRot() - 1.3f - this.getXRot();
|
||||||
if (diffY > 180.0f) {
|
if (diffY > 180.0f) {
|
||||||
diffY -= 360.0f;
|
diffY -= 360.0f;
|
||||||
} else if (diffY < -180.0f) {
|
} else if (diffY < -180.0f) {
|
||||||
|
@ -319,10 +319,11 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
}
|
}
|
||||||
diffY = diffY * 0.15f;
|
diffY = diffY * 0.15f;
|
||||||
diffX = diffX * 0.15f;
|
diffX = diffX * 0.15f;
|
||||||
|
|
||||||
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
||||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f));
|
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f));
|
||||||
this.yRotO = this.getYRot();
|
this.yRotO = this.getYRot();
|
||||||
this.setXRot(Mth.clamp(this.getXRot() - 0.11f + Mth.clamp(diffX, -3f, 3f), -85, 15));
|
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 15));
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
||||||
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
|
@ -332,7 +333,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void travel(Vec3 dir) {
|
public void travel(@NotNull Vec3 dir) {
|
||||||
Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0);
|
Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0);
|
||||||
ItemStack stack = null;
|
ItemStack stack = null;
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
@ -340,7 +341,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
}
|
}
|
||||||
if (stack != null && this.isVehicle() && !stack.is(ModTags.Items.GUN)) {
|
if (stack != null && this.isVehicle() && !stack.is(ModTags.Items.GUN)) {
|
||||||
float diffY = entity.getYHeadRot() - this.getYRot();
|
float diffY = entity.getYHeadRot() - this.getYRot();
|
||||||
float diffX = entity.getXRot() - this.getXRot();
|
float diffX = entity.getXRot() - 1.3f - this.getXRot();
|
||||||
if (diffY > 180.0f) {
|
if (diffY > 180.0f) {
|
||||||
diffY -= 360.0f;
|
diffY -= 360.0f;
|
||||||
} else if (diffY < -180.0f) {
|
} else if (diffY < -180.0f) {
|
||||||
|
@ -349,23 +350,18 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
diffY = diffY * 0.15f;
|
diffY = diffY * 0.15f;
|
||||||
diffX = diffX * 0.15f;
|
diffX = diffX * 0.15f;
|
||||||
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
||||||
this.setYRot(this.getYRot() + Mth.clamp(diffY,-1.25f,1.25f));
|
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f));
|
||||||
this.yRotO = this.getYRot();
|
this.yRotO = this.getYRot();
|
||||||
this.setXRot(Mth.clamp(this.getXRot() - 0.1f + Mth.clamp(diffX,-2f,2f), -30, 4));
|
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4));
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
this.yBodyRot = this.getYRot() + Mth.clamp(diffY,-1.25f,1.25f);
|
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||||
this.yHeadRot = this.getYRot() + Mth.clamp(diffY,-1.25f,1.25f);
|
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.travel(dir);
|
super.travel(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityDimensions getDimensions(Pose p_33597_) {
|
|
||||||
return super.getDimensions(p_33597_).scale((float) 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void aiStep() {
|
public void aiStep() {
|
||||||
super.aiStep();
|
super.aiStep();
|
||||||
|
|
|
@ -87,7 +87,6 @@ public class PlayerEventHandler {
|
||||||
handlePlayerSprint(player);
|
handlePlayerSprint(player);
|
||||||
handleWeaponLevel(player);
|
handleWeaponLevel(player);
|
||||||
handleAmmoCount(player);
|
handleAmmoCount(player);
|
||||||
handlePrepareZoom(player);
|
|
||||||
handleSpecialWeaponAmmo(player);
|
handleSpecialWeaponAmmo(player);
|
||||||
handleChangeFireRate(player);
|
handleChangeFireRate(player);
|
||||||
handleBocekPulling(player);
|
handleBocekPulling(player);
|
||||||
|
@ -338,22 +337,6 @@ public class PlayerEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handlePrepareZoom(Player player) {
|
|
||||||
// ItemStack stack = player.getMainHandItem();
|
|
||||||
//
|
|
||||||
// if (stack.is(ModTags.Items.GUN) && !player.isSpectator()) {
|
|
||||||
// if (player.getMainHandItem().getItem() != ModItems.MINIGUN.get()) {
|
|
||||||
// if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
|
|
||||||
// player.setSprinting(false);
|
|
||||||
// player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
|
||||||
// capability.zooming = true;
|
|
||||||
// capability.syncPlayerVariables(player);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSpecialWeaponAmmo(Player player) {
|
private static void handleSpecialWeaponAmmo(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Loading…
Add table
Reference in a new issue