优化代码
This commit is contained in:
parent
75ed202791
commit
4032d4537a
9 changed files with 34 additions and 56 deletions
|
@ -2,8 +2,7 @@ package net.mcreator.superbwarfare.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import net.mcreator.superbwarfare.entity.MortarEntity;
|
import net.mcreator.superbwarfare.entity.MortarEntity;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.init.ModMobEffects;
|
import net.mcreator.superbwarfare.init.ModMobEffects;
|
||||||
|
@ -76,7 +75,7 @@ public class ClickHandler {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new DroneFireMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new DroneFireMessage(0));
|
||||||
}
|
}
|
||||||
if (player.getVehicle() != null && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity)) {
|
if (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity)) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0));
|
||||||
return;
|
return;
|
||||||
|
@ -91,7 +90,7 @@ public class ClickHandler {
|
||||||
if (Minecraft.getInstance().player.hasEffect(ModMobEffects.SHOCK.get())) {
|
if (Minecraft.getInstance().player.hasEffect(ModMobEffects.SHOCK.get())) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.isPassenger() && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity))) {
|
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.isPassenger() && (player.getVehicle() instanceof ICannonEntity))) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package net.mcreator.superbwarfare.client.screens;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.minecraft.client.CameraType;
|
import net.minecraft.client.CameraType;
|
||||||
|
@ -17,8 +16,9 @@ import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber({Dist.CLIENT})
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class M79UIOverlay {
|
public class M79UIOverlay {
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
|
@ -44,7 +44,7 @@ public class M79UIOverlay {
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
return !player.isSpectator()
|
return !player.isSpectator()
|
||||||
&& player.getMainHandItem().getItem() == ModItems.M_79.get()
|
&& player.getMainHandItem().getItem() == ModItems.M_79.get()
|
||||||
&& (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || (player.isPassenger() && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity)))
|
&& (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || (player.isPassenger() && player.getVehicle() instanceof ICannonEntity))
|
||||||
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);
|
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,6 @@ public class M79UIOverlay {
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
return !player.isSpectator()
|
return !player.isSpectator()
|
||||||
&& !(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom
|
&& !(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom
|
||||||
&& player.isPassenger() && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity);
|
&& player.isPassenger() && player.getVehicle() instanceof ICannonEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package net.mcreator.superbwarfare.client.screens;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.item.gun.GunItem;
|
import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.tools.RenderTool;
|
import net.mcreator.superbwarfare.tools.RenderTool;
|
||||||
|
@ -35,9 +35,9 @@ public class Mk42UIOverlay {
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
if (shouldRenderCrossHair(player)) {
|
if (shouldRenderCrossHair(player)) {
|
||||||
RenderTool.preciseBlit(event.getGuiGraphics(),
|
RenderTool.preciseBlit(event.getGuiGraphics(),
|
||||||
new ResourceLocation("superbwarfare:textures/screens/mk_42_rex.png"),
|
new ResourceLocation(ModUtils.MODID, "textures/screens/mk_42_rex.png"),
|
||||||
(float) w / 2 - (float) TEXTURE_WIDTH / 10f, (float) h / 2 - (float) TEXTURE_HEIGHT / 10f,
|
(float) w / 2 - (float) TEXTURE_WIDTH / 10f, (float) h / 2 - (float) TEXTURE_HEIGHT / 10f,
|
||||||
0, 0, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f);
|
0, 0, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f);
|
||||||
}
|
}
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
|
@ -50,8 +50,7 @@ public class Mk42UIOverlay {
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
return !player.isSpectator()
|
return !player.isSpectator()
|
||||||
&& !(player.getMainHandItem().getItem() instanceof GunItem)
|
&& !(player.getMainHandItem().getItem() instanceof GunItem)
|
||||||
// && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON
|
&& (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))
|
||||||
&& (player.getVehicle() != null && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity))
|
|
||||||
&& (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom;
|
&& (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,7 @@ import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntity {
|
public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntity {
|
||||||
public static final EntityDataAccessor<Boolean> SHOOT = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.BOOLEAN);
|
|
||||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.STRING);
|
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.STRING);
|
||||||
public static final EntityDataAccessor<String> TEXTURE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.STRING);
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public String animationprocedure = "empty";
|
public String animationprocedure = "empty";
|
||||||
|
@ -67,9 +65,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
super.defineSynchedData();
|
super.defineSynchedData();
|
||||||
this.entityData.define(SHOOT, false);
|
|
||||||
this.entityData.define(ANIMATION, "undefined");
|
this.entityData.define(ANIMATION, "undefined");
|
||||||
this.entityData.define(TEXTURE, "sherman");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,14 +73,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
return 2.16F;
|
return 2.16F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTexture(String texture) {
|
|
||||||
this.entityData.set(TEXTURE, texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTexture() {
|
|
||||||
return this.entityData.get(TEXTURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCollideWith(Entity entity) {
|
public boolean canCollideWith(Entity entity) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -167,14 +155,11 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
compound.putString("Texture", this.getTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
if (compound.contains("Texture"))
|
|
||||||
this.setTexture(compound.getString("Texture"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -373,7 +358,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
.add(Attributes.KNOCKBACK_RESISTANCE, 1);
|
.add(Attributes.KNOCKBACK_RESISTANCE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState movementPredicate(AnimationState event) {
|
private PlayState movementPredicate(AnimationState<Mk42Entity> event) {
|
||||||
if (this.animationprocedure.equals("empty")) {
|
if (this.animationprocedure.equals("empty")) {
|
||||||
|
|
||||||
if (this.getFirstPassenger() != null) {
|
if (this.getFirstPassenger() != null) {
|
||||||
|
@ -393,7 +378,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
return PlayState.STOP;
|
return PlayState.STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState procedurePredicate(AnimationState event) {
|
private PlayState procedurePredicate(AnimationState<Mk42Entity> event) {
|
||||||
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
||||||
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
|
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
|
||||||
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
||||||
|
|
|
@ -210,16 +210,14 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
||||||
float BodyHeight = entity.getBbHeight();
|
float BodyHeight = entity.getBbHeight();
|
||||||
if ((eyeHeight - 0.35) < hitBoxPos.y && hitBoxPos.y < (eyeHeight + 0.4) && !(entity instanceof ClaymoreEntity
|
if ((eyeHeight - 0.35) < hitBoxPos.y && hitBoxPos.y < (eyeHeight + 0.4) && !(entity instanceof ClaymoreEntity
|
||||||
|| entity instanceof MortarEntity
|
|| entity instanceof MortarEntity
|
||||||
|| entity instanceof Mle1934Entity
|
|| entity instanceof ICannonEntity
|
||||||
|| entity instanceof Mk42Entity
|
|
||||||
|| entity instanceof DroneEntity
|
|| entity instanceof DroneEntity
|
||||||
)) {
|
)) {
|
||||||
headshot = true;
|
headshot = true;
|
||||||
}
|
}
|
||||||
if (hitBoxPos.y < (0.33 * BodyHeight) && !(entity instanceof ClaymoreEntity
|
if (hitBoxPos.y < (0.33 * BodyHeight) && !(entity instanceof ClaymoreEntity
|
||||||
|| entity instanceof MortarEntity
|
|| entity instanceof MortarEntity
|
||||||
|| entity instanceof Mle1934Entity
|
|| entity instanceof ICannonEntity
|
||||||
|| entity instanceof Mk42Entity
|
|
||||||
|| entity instanceof DroneEntity
|
|| entity instanceof DroneEntity
|
||||||
)) {
|
)) {
|
||||||
legshot = true;
|
legshot = true;
|
||||||
|
|
|
@ -41,7 +41,6 @@ import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
||||||
public static final EntityDataAccessor<Boolean> SHOOT = SynchedEntityData.defineId(SenpaiEntity.class, EntityDataSerializers.BOOLEAN);
|
|
||||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(SenpaiEntity.class, EntityDataSerializers.STRING);
|
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(SenpaiEntity.class, EntityDataSerializers.STRING);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
|
@ -60,7 +59,6 @@ public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
super.defineSynchedData();
|
super.defineSynchedData();
|
||||||
this.entityData.define(SHOOT, false);
|
|
||||||
this.entityData.define(ANIMATION, "undefined");
|
this.entityData.define(ANIMATION, "undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,11 +95,13 @@ public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
||||||
|
|
||||||
protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHitIn) {
|
protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHitIn) {
|
||||||
super.dropCustomDeathLoot(source, looting, recentlyHitIn);
|
super.dropCustomDeathLoot(source, looting, recentlyHitIn);
|
||||||
if (Math.random() < 0.01) {
|
|
||||||
|
double random = Math.random();
|
||||||
|
if (random < 0.01) {
|
||||||
this.spawnAtLocation(new ItemStack(Items.ENCHANTED_GOLDEN_APPLE));
|
this.spawnAtLocation(new ItemStack(Items.ENCHANTED_GOLDEN_APPLE));
|
||||||
} else if (0.01 <= Math.random() && Math.random() < 0.2) {
|
} else if (random < 0.2) {
|
||||||
this.spawnAtLocation(new ItemStack(Items.GOLDEN_APPLE));
|
this.spawnAtLocation(new ItemStack(Items.GOLDEN_APPLE));
|
||||||
} else if (Math.random() >= 0.2) {
|
} else {
|
||||||
this.spawnAtLocation(new ItemStack(Items.APPLE));
|
this.spawnAtLocation(new ItemStack(Items.APPLE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
||||||
|
|
||||||
if (distance < 32) {
|
if (distance < 32) {
|
||||||
return new ResourceLocation(ModUtils.MODID, "geo/sherman.geo.json");
|
return new ResourceLocation(ModUtils.MODID, "geo/sherman.geo.json");
|
||||||
} else if (distance < 64){
|
} else if (distance < 64) {
|
||||||
return new ResourceLocation(ModUtils.MODID, "geo/sherman_lod1.geo.json");
|
return new ResourceLocation(ModUtils.MODID, "geo/sherman_lod1.geo.json");
|
||||||
} else {
|
} else {
|
||||||
return new ResourceLocation(ModUtils.MODID, "geo/sherman_lod2.geo.json");
|
return new ResourceLocation(ModUtils.MODID, "geo/sherman_lod2.geo.json");
|
||||||
|
@ -45,9 +45,9 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(Mk42Entity animatable, long instanceId, AnimationState animationState) {
|
public void setCustomAnimations(Mk42Entity animatable, long instanceId, AnimationState animationState) {
|
||||||
CoreGeoBone barrle = getAnimationProcessor().getBone("maingun");
|
CoreGeoBone bone = getAnimationProcessor().getBone("maingun");
|
||||||
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
||||||
barrle.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
bone.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
||||||
|
|
||||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
||||||
|
|
||||||
|
@ -57,6 +57,5 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
||||||
gunner.getPersistentData().putDouble("cannon_camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
|
gunner.getPersistentData().putDouble("cannon_camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
|
||||||
gunner.getPersistentData().putDouble("cannon_camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
|
gunner.getPersistentData().putDouble("cannon_camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
|
||||||
gunner.getPersistentData().putDouble("cannon_camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
|
gunner.getPersistentData().putDouble("cannon_camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package net.mcreator.superbwarfare.event;
|
package net.mcreator.superbwarfare.event;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.entity.DroneEntity;
|
import net.mcreator.superbwarfare.entity.DroneEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.init.ModMobEffects;
|
import net.mcreator.superbwarfare.init.ModMobEffects;
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
|
@ -60,7 +59,7 @@ public class ClientEventHandler {
|
||||||
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
|
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
|
||||||
ClientLevel level = Minecraft.getInstance().level;
|
ClientLevel level = Minecraft.getInstance().level;
|
||||||
Entity entity = event.getCamera().getEntity();
|
Entity entity = event.getCamera().getEntity();
|
||||||
if (level != null && entity instanceof LivingEntity living && entity.isPassenger() && (entity.getVehicle() instanceof Mk42Entity || entity.getVehicle() instanceof Mle1934Entity)) {
|
if (level != null && entity instanceof LivingEntity living && entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
|
||||||
handleCannonCamera(event, living);
|
handleCannonCamera(event, living);
|
||||||
}
|
}
|
||||||
if (level != null && entity instanceof LivingEntity living
|
if (level != null && entity instanceof LivingEntity living
|
||||||
|
@ -470,7 +469,7 @@ public class ClientEventHandler {
|
||||||
player.getPersistentData().putDouble("fov", event.getFOV());
|
player.getPersistentData().putDouble("fov", event.getFOV());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.isPassenger() && (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity)) {
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
|
||||||
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
|
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
|
||||||
event.setFOV(event.getFOV() / 5);
|
event.setFOV(event.getFOV() / 5);
|
||||||
}
|
}
|
||||||
|
@ -492,7 +491,7 @@ public class ClientEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.player.getMainHandItem().is(ModTags.Items.GUN) || (mc.player.getVehicle() != null && (mc.player.getVehicle() instanceof Mk42Entity || mc.player.getVehicle() instanceof Mle1934Entity))) {
|
if (mc.player.getMainHandItem().is(ModTags.Items.GUN) || (mc.player.getVehicle() != null && mc.player.getVehicle() instanceof ICannonEntity)) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.mcreator.superbwarfare.network.message;
|
package net.mcreator.superbwarfare.network.message;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import net.mcreator.superbwarfare.init.ModSounds;
|
import net.mcreator.superbwarfare.init.ModSounds;
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.tools.SoundTool;
|
import net.mcreator.superbwarfare.tools.SoundTool;
|
||||||
|
@ -16,7 +15,6 @@ import java.util.function.Supplier;
|
||||||
public class ZoomMessage {
|
public class ZoomMessage {
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
|
|
||||||
public ZoomMessage(int type) {
|
public ZoomMessage(int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +50,13 @@ public class ZoomMessage {
|
||||||
capability.syncPlayerVariables(entity);
|
capability.syncPlayerVariables(entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (entity.isPassenger() && (entity.getVehicle() instanceof Mk42Entity || entity.getVehicle() instanceof Mle1934Entity)) {
|
if (entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
|
||||||
if (entity instanceof ServerPlayer serverPlayer) {
|
if (entity instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.zoom = false;
|
capability.zoom = false;
|
||||||
|
@ -68,7 +67,7 @@ public class ZoomMessage {
|
||||||
capability.syncPlayerVariables(entity);
|
capability.syncPlayerVariables(entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (entity.isPassenger() && (entity.getVehicle() instanceof Mk42Entity || entity.getVehicle() instanceof Mle1934Entity)) {
|
if (entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
|
||||||
if (entity instanceof ServerPlayer serverPlayer) {
|
if (entity instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue