优化实体查找方法
This commit is contained in:
parent
b18c68d581
commit
774722cb5a
17 changed files with 191 additions and 1791 deletions
|
@ -3,18 +3,19 @@ package net.mcreator.target.client.gui;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
import net.mcreator.target.network.MortarGUIButtonMessage;
|
import net.mcreator.target.network.MortarGUIButtonMessage;
|
||||||
import net.mcreator.target.procedures.MortarAngleProcedure;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.mcreator.target.procedures.MortarPitchProcedure;
|
|
||||||
import net.mcreator.target.world.inventory.MortarGUIMenu;
|
import net.mcreator.target.world.inventory.MortarGUIMenu;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class MortarGUIScreen extends AbstractContainerScreen<MortarGUIMenu> {
|
public class MortarGUIScreen extends AbstractContainerScreen<MortarGUIMenu> {
|
||||||
|
@ -72,12 +73,21 @@ public class MortarGUIScreen extends AbstractContainerScreen<MortarGUIMenu> {
|
||||||
super.containerTick();
|
super.containerTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAngleString(Entity entity) {
|
||||||
|
if (entity == null) return "";
|
||||||
|
Entity mortar = TraceTool.findLookingEntity(entity, 6);
|
||||||
|
if (mortar == null) return "";
|
||||||
|
return "Angle: " + new DecimalFormat("##.#").format(-mortar.getXRot());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||||
guiGraphics.drawString(this.font,
|
guiGraphics.drawString(this.font, getAngleString(entity), -18, 98, -1, false);
|
||||||
|
|
||||||
MortarAngleProcedure.execute(entity), -18, 98, -1, false);
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
guiGraphics.drawString(this.font, Component.literal("Range:" + (int) RangeHelper.getRange(MortarPitchProcedure.execute(entity))), -18, 108, -16711885, false);
|
var range = looking == null ? 0 : -looking.getXRot();
|
||||||
|
|
||||||
|
guiGraphics.drawString(this.font, Component.literal("Range:" + (int) RangeHelper.getRange(range)), -18, 108, -16711885, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +107,7 @@ public class MortarGUIScreen extends AbstractContainerScreen<MortarGUIMenu> {
|
||||||
button_empty = Button.builder(Component.translatable("gui.target.mortar_gui.button_empty"), e -> {
|
button_empty = Button.builder(Component.translatable("gui.target.mortar_gui.button_empty"), e -> {
|
||||||
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(1, x, y, z));
|
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(1, x, y, z));
|
||||||
MortarGUIButtonMessage.handleButtonAction(entity, 1, x, y, z);
|
MortarGUIButtonMessage.handleButtonAction(entity, 1, x, y, z);
|
||||||
}).bounds(this.leftPos + -73, this.topPos + 124, 30, 20).build();
|
}).bounds(this.leftPos - 73, this.topPos + 124, 30, 20).build();
|
||||||
guistate.put("button:button_empty", button_empty);
|
guistate.put("button:button_empty", button_empty);
|
||||||
this.addRenderableWidget(button_empty);
|
this.addRenderableWidget(button_empty);
|
||||||
button_10 = Button.builder(Component.translatable("gui.target.mortar_gui.button_10"), e -> {
|
button_10 = Button.builder(Component.translatable("gui.target.mortar_gui.button_10"), e -> {
|
||||||
|
@ -109,13 +119,13 @@ public class MortarGUIScreen extends AbstractContainerScreen<MortarGUIMenu> {
|
||||||
button_101 = Button.builder(Component.translatable("gui.target.mortar_gui.button_101"), e -> {
|
button_101 = Button.builder(Component.translatable("gui.target.mortar_gui.button_101"), e -> {
|
||||||
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(3, x, y, z));
|
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(3, x, y, z));
|
||||||
MortarGUIButtonMessage.handleButtonAction(entity, 3, x, y, z);
|
MortarGUIButtonMessage.handleButtonAction(entity, 3, x, y, z);
|
||||||
}).bounds(this.leftPos + -73, this.topPos + 151, 30, 20).build();
|
}).bounds(this.leftPos - 73, this.topPos + 151, 30, 20).build();
|
||||||
guistate.put("button:button_101", button_101);
|
guistate.put("button:button_101", button_101);
|
||||||
this.addRenderableWidget(button_101);
|
this.addRenderableWidget(button_101);
|
||||||
button_05 = Button.builder(Component.translatable("gui.target.mortar_gui.button_05"), e -> {
|
button_05 = Button.builder(Component.translatable("gui.target.mortar_gui.button_05"), e -> {
|
||||||
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(4, x, y, z));
|
TargetMod.PACKET_HANDLER.sendToServer(new MortarGUIButtonMessage(4, x, y, z));
|
||||||
MortarGUIButtonMessage.handleButtonAction(entity, 4, x, y, z);
|
MortarGUIButtonMessage.handleButtonAction(entity, 4, x, y, z);
|
||||||
}).bounds(this.leftPos + -73, this.topPos + 97, 30, 20).build();
|
}).bounds(this.leftPos - 73, this.topPos + 97, 30, 20).build();
|
||||||
guistate.put("button:button_05", button_05);
|
guistate.put("button:button_05", button_05);
|
||||||
this.addRenderableWidget(button_05);
|
this.addRenderableWidget(button_05);
|
||||||
button_051 = Button.builder(Component.translatable("gui.target.mortar_gui.button_051"), e -> {
|
button_051 = Button.builder(Component.translatable("gui.target.mortar_gui.button_051"), e -> {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.mcreator.target.client.screens;
|
package net.mcreator.target.client.screens;
|
||||||
|
|
||||||
import net.mcreator.target.procedures.EntityRangeProcedure;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -10,6 +12,8 @@ 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;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class SpyglassRangeOverlay {
|
public class SpyglassRangeOverlay {
|
||||||
|
|
||||||
|
@ -17,16 +21,24 @@ public class SpyglassRangeOverlay {
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
int h = event.getWindow().getGuiScaledHeight();
|
int h = event.getWindow().getGuiScaledHeight();
|
||||||
Player entity = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (entity != null && entity.getMainHandItem().getItem() == Items.SPYGLASS) {
|
if (player != null && player.getMainHandItem().getItem() == Items.SPYGLASS) {
|
||||||
event.getGuiGraphics().drawString(
|
event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
EntityRangeProcedure.execute(entity),
|
getDistanceString(player),
|
||||||
w / 2 + 19,
|
w / 2 + 19,
|
||||||
h / 2 + -23,
|
h / 2 - 23,
|
||||||
-1,
|
-1,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getDistanceString(Player entity) {
|
||||||
|
Entity looking = TraceTool.findLookingEntity(entity, 1024);
|
||||||
|
if (looking instanceof LivingEntity) {
|
||||||
|
return looking.getDisplayName().getString() + ":" + new DecimalFormat("##.#").format(entity.position().distanceTo(looking.position())) + "M";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,29 +59,14 @@ public class MortarGUIButtonMessage {
|
||||||
// security measure to prevent arbitrary chunk generation
|
// security measure to prevent arbitrary chunk generation
|
||||||
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
||||||
return;
|
return;
|
||||||
if (buttonID == 0) {
|
|
||||||
|
|
||||||
AngleAddProcedure.execute(entity);
|
switch (buttonID) {
|
||||||
}
|
case 0 -> AngleAddProcedure.execute(entity);
|
||||||
if (buttonID == 1) {
|
case 1 -> AngleReduceProcedure.execute(entity);
|
||||||
|
case 2 -> AngleAddPlusProcedure.execute(entity);
|
||||||
AngleReduceProcedure.execute(entity);
|
case 3 -> AngleReducePlusProcedure.execute(entity);
|
||||||
}
|
case 4 -> AngleReduceMiniProcedure.execute(entity);
|
||||||
if (buttonID == 2) {
|
case 5 -> AngleAddMiniProcedure.execute(entity);
|
||||||
|
|
||||||
AngleAddPlusProcedure.execute(entity);
|
|
||||||
}
|
|
||||||
if (buttonID == 3) {
|
|
||||||
|
|
||||||
AngleReducePlusProcedure.execute(entity);
|
|
||||||
}
|
|
||||||
if (buttonID == 4) {
|
|
||||||
|
|
||||||
AngleReduceMiniProcedure.execute(entity);
|
|
||||||
}
|
|
||||||
if (buttonID == 5) {
|
|
||||||
|
|
||||||
AngleAddMiniProcedure.execute(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,187 +1,23 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleAddMiniProcedure {
|
public class AngleAddMiniProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() <= -87.5) return;
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setYRot(looking.getYRot());
|
||||||
double distance = entityReach * entityReach;
|
looking.setXRot((float) (looking.getXRot() - 0.5));
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYBodyRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
looking.yRotO = looking.getYRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
looking.xRotO = looking.getXRot();
|
||||||
double blockReach = 5;
|
if (looking instanceof LivingEntity living) {
|
||||||
if (distance > blockReach * blockReach) {
|
living.yBodyRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
living.yHeadRotO = living.getYRot();
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() > -87.5) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((float) ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() - 0.5));
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,187 +1,23 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleAddPlusProcedure {
|
public class AngleAddPlusProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() <= -78) return;
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setYRot(looking.getYRot());
|
||||||
double distance = entityReach * entityReach;
|
looking.setXRot(looking.getXRot() - 10);
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYBodyRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
if (hitResult != null && hitResult.getType() != HitResult.Type.MISS) {
|
looking.yRotO = looking.getYRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
looking.xRotO = looking.getXRot();
|
||||||
double blockReach = 5;
|
if (looking instanceof LivingEntity living) {
|
||||||
if (distance > blockReach * blockReach) {
|
living.yBodyRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
living.yHeadRotO = living.getYRot();
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() > -78) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() - 10);
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,187 +1,23 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleAddProcedure {
|
public class AngleAddProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() <= -88) return;
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setYRot(looking.getYRot());
|
||||||
double distance = entityReach * entityReach;
|
looking.setXRot(looking.getXRot() - 1);
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYBodyRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
looking.yRotO = looking.getYRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
looking.xRotO = looking.getXRot();
|
||||||
double blockReach = 5;
|
if (looking instanceof LivingEntity living) {
|
||||||
if (distance > blockReach * blockReach) {
|
living.yBodyRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
living.yHeadRotO = living.getYRot();
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() > -88) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() - 1);
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,190 +1,23 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleReduceMiniProcedure {
|
public class AngleReduceMiniProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() >= -20.5) return;
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setYRot(looking.getYRot());
|
||||||
double distance = entityReach * entityReach;
|
looking.setXRot((float) (looking.getXRot() + 0.5));
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYBodyRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
looking.yRotO = looking.getYRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
looking.xRotO = looking.getXRot();
|
||||||
double blockReach = 5;
|
if (looking instanceof LivingEntity living) {
|
||||||
if (distance > blockReach * blockReach) {
|
living.yBodyRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
living.yHeadRotO = living.getYRot();
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() < -20.5) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((float) ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() + 0.5));
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,187 +1,23 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleReducePlusProcedure {
|
public class AngleReducePlusProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() >= -30) return;
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setYRot(looking.getYRot());
|
||||||
double distance = entityReach * entityReach;
|
looking.setXRot(looking.getXRot() + 10);
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYBodyRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
looking.yRotO = looking.getYRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
looking.xRotO = looking.getXRot();
|
||||||
double blockReach = 5;
|
if (looking instanceof LivingEntity living) {
|
||||||
if (distance > blockReach * blockReach) {
|
living.yBodyRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
living.yHeadRotO = living.getYRot();
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() < -30) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() + 10);
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,187 +1,22 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class AngleReduceProcedure {
|
public class AngleReduceProcedure {
|
||||||
public static void execute(Entity entity) {
|
public static void execute(Entity entity) {
|
||||||
if (entity == null)
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
return;
|
if (looking == null || looking.getXRot() >= -20) return;
|
||||||
if (!((new Object() {
|
looking.setYRot(looking.getYRot());
|
||||||
public Entity func(Entity player, double entityReach) {
|
looking.setXRot(looking.getXRot() + 1);
|
||||||
double distance = entityReach * entityReach;
|
looking.setYBodyRot(looking.getYRot());
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
looking.setYHeadRot(looking.getYRot());
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
looking.yRotO = looking.getYRot();
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
looking.xRotO = looking.getXRot();
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
if (looking instanceof LivingEntity living) {
|
||||||
double blockReach = 5;
|
living.yBodyRotO = living.getYRot();
|
||||||
if (distance > blockReach * blockReach) {
|
living.yHeadRotO = living.getYRot();
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if ((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() < -20) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot() + 1);
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class EntityRangeProcedure {
|
|
||||||
public static String execute(Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return "";
|
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 1024)) == null) && (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 1024)) instanceof LivingEntity) {
|
|
||||||
return (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 1024)).getDisplayName().getString() + ":" + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo(((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 1024)).position()))) + "M";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class MortarAngleProcedure {
|
|
||||||
public static String execute(Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return "";
|
|
||||||
Entity mortar = null;
|
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
mortar = new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6);
|
|
||||||
return "Angle: " + new java.text.DecimalFormat("##.#").format(-(mortar.getXRot()));
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,192 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModAttributes;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class MortarGUIGaiGUIDaKaiShiMeiKeFaShengProcedure {
|
|
||||||
public static void execute(Entity entity, HashMap guistate) {
|
|
||||||
if (entity == null || guistate == null)
|
|
||||||
return;
|
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if (20 <= new Object() {
|
|
||||||
double convert(String s) {
|
|
||||||
try {
|
|
||||||
return Double.parseDouble(s.trim());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") && new Object() {
|
|
||||||
double convert(String s) {
|
|
||||||
try {
|
|
||||||
return Double.parseDouble(s.trim());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") <= 90) {
|
|
||||||
{
|
|
||||||
Entity _ent = (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6));
|
|
||||||
_ent.setYRot((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getYRot());
|
|
||||||
_ent.setXRot((float) (-((LivingEntity) (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6))).getAttribute(TargetModAttributes.MOTARPITCH.get()).getBaseValue()));
|
|
||||||
_ent.setYBodyRot(_ent.getYRot());
|
|
||||||
_ent.setYHeadRot(_ent.getYRot());
|
|
||||||
_ent.yRotO = _ent.getYRot();
|
|
||||||
_ent.xRotO = _ent.getXRot();
|
|
||||||
if (_ent instanceof LivingEntity _entity) {
|
|
||||||
_entity.yBodyRotO = _entity.getYRot();
|
|
||||||
_entity.yHeadRotO = _entity.getYRot();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound minecraft:entity.arrow.hit_player player @s ~ ~ ~ 1 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
{
|
|
||||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
|
||||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
|
||||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound minecraft:block.note_block.bass player @s ~ ~ ~ 1 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class MortarGUIGaiGUIDaKaiShiProcedure {
|
|
||||||
public static void execute(Entity entity, HashMap guistate) {
|
|
||||||
if (entity == null || guistate == null)
|
|
||||||
return;
|
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
if (guistate.get("text:pitch") instanceof EditBox _tf)
|
|
||||||
_tf.setValue((new java.text.DecimalFormat("##").format(-((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> !p_234237_.isSpectator(), distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
package net.mcreator.target.procedures;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
public class MortarPitchProcedure {
|
|
||||||
public static double execute(Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return 0;
|
|
||||||
if (!((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult != null && hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)) == null)) {
|
|
||||||
return -((new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult != null && hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6)).getXRot());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +1,38 @@
|
||||||
package net.mcreator.target.procedures;
|
package net.mcreator.target.procedures;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModAttributes;
|
import net.mcreator.target.init.TargetModAttributes;
|
||||||
|
import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
|
||||||
import net.minecraft.world.phys.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class MotarGUITickProcedure {
|
public class MotarGUITickProcedure {
|
||||||
public static void execute(Entity entity, HashMap guistate) {
|
public static void execute(Entity entity, HashMap<String, Object> guistate) {
|
||||||
if (entity == null || guistate == null)
|
if (entity == null || guistate == null) return;
|
||||||
return;
|
|
||||||
if (!((new Object() {
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
public Entity func(Entity player, double entityReach) {
|
if (looking == null) return;
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
if (20 <= new Object() {
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
double convert(String s) {
|
||||||
if (hitResult != null && hitResult.getType() != HitResult.Type.MISS) {
|
try {
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
return Double.parseDouble(s.trim());
|
||||||
double blockReach = 5;
|
} catch (Exception ignored) {
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
return 0;
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}.func(entity, 6)) == null)) {
|
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") && new Object() {
|
||||||
if (20 <= new Object() {
|
double convert(String s) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(s.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") <= 90) {
|
||||||
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MOTARPITCH.get()).setBaseValue(new Object() {
|
||||||
double convert(String s) {
|
double convert(String s) {
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble(s.trim());
|
return Double.parseDouble(s.trim());
|
||||||
|
@ -58,59 +40,7 @@ public class MotarGUITickProcedure {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") && new Object() {
|
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : ""));
|
||||||
double convert(String s) {
|
|
||||||
try {
|
|
||||||
return Double.parseDouble(s.trim());
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "") <= 90) {
|
|
||||||
((LivingEntity) (new Object() {
|
|
||||||
public Entity func(Entity player, double entityReach) {
|
|
||||||
double distance = entityReach * entityReach;
|
|
||||||
Vec3 eyePos = player.getEyePosition(1.0f);
|
|
||||||
HitResult hitResult = entity.pick(entityReach, 1.0f, false);
|
|
||||||
if (hitResult != null && hitResult.getType() != HitResult.Type.MISS) {
|
|
||||||
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
|
||||||
double blockReach = 5;
|
|
||||||
if (distance > blockReach * blockReach) {
|
|
||||||
Vec3 pos = hitResult.getLocation();
|
|
||||||
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, (p_234237_) -> {
|
|
||||||
return !p_234237_.isSpectator();
|
|
||||||
}, distance);
|
|
||||||
if (entityhitresult != null) {
|
|
||||||
Entity entity1 = entityhitresult.getEntity();
|
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
|
||||||
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
|
||||||
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
|
||||||
} else if (distanceToTarget < distance) {
|
|
||||||
hitResult = entityhitresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
|
||||||
return ((EntityHitResult) hitResult).getEntity();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.func(entity, 6))).getAttribute(TargetModAttributes.MOTARPITCH.get()).setBaseValue(new Object() {
|
|
||||||
double convert(String s) {
|
|
||||||
try {
|
|
||||||
return Double.parseDouble(s.trim());
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
src/main/java/net/mcreator/target/tools/TraceTool.java
Normal file
40
src/main/java/net/mcreator/target/tools/TraceTool.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package net.mcreator.target.tools;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||||
|
import net.minecraft.world.phys.*;
|
||||||
|
|
||||||
|
public class TraceTool {
|
||||||
|
public static Entity findLookingEntity(Entity player, double entityReach) {
|
||||||
|
double distance = entityReach * entityReach;
|
||||||
|
Vec3 eyePos = player.getEyePosition(1.0f);
|
||||||
|
HitResult hitResult = player.pick(entityReach, 1.0f, false);
|
||||||
|
if (hitResult.getType() != HitResult.Type.MISS) {
|
||||||
|
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
||||||
|
double blockReach = 5;
|
||||||
|
if (distance > blockReach * blockReach) {
|
||||||
|
Vec3 pos = hitResult.getLocation();
|
||||||
|
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Vec3 viewVec = player.getViewVector(1.0F);
|
||||||
|
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
||||||
|
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
||||||
|
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator(), distance);
|
||||||
|
if (entityhitresult != null) {
|
||||||
|
Vec3 targetPos = entityhitresult.getLocation();
|
||||||
|
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
||||||
|
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
||||||
|
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
||||||
|
} else if (distanceToTarget < distance) {
|
||||||
|
hitResult = entityhitresult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
||||||
|
return ((EntityHitResult) hitResult).getEntity();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package net.mcreator.target.world.inventory;
|
package net.mcreator.target.world.inventory;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModMenus;
|
import net.mcreator.target.init.TargetModMenus;
|
||||||
import net.mcreator.target.procedures.MortarGUIGaiGUIDaKaiShiProcedure;
|
|
||||||
import net.mcreator.target.procedures.MotarGUITickProcedure;
|
import net.mcreator.target.procedures.MotarGUITickProcedure;
|
||||||
|
import net.mcreator.target.tools.TraceTool;
|
||||||
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -43,15 +44,18 @@ public class MortarGUIMenu extends AbstractContainerMenu implements Supplier<Map
|
||||||
this.entity = inv.player;
|
this.entity = inv.player;
|
||||||
this.world = inv.player.level();
|
this.world = inv.player.level();
|
||||||
this.internal = new ItemStackHandler(0);
|
this.internal = new ItemStackHandler(0);
|
||||||
BlockPos pos = null;
|
|
||||||
if (extraData != null) {
|
if (extraData != null) {
|
||||||
pos = extraData.readBlockPos();
|
BlockPos pos = extraData.readBlockPos();
|
||||||
this.x = pos.getX();
|
this.x = pos.getX();
|
||||||
this.y = pos.getY();
|
this.y = pos.getY();
|
||||||
this.z = pos.getZ();
|
this.z = pos.getZ();
|
||||||
access = ContainerLevelAccess.create(world, pos);
|
access = ContainerLevelAccess.create(world, pos);
|
||||||
}
|
}
|
||||||
MortarGUIGaiGUIDaKaiShiProcedure.execute(entity, guistate);
|
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||||
|
if (looking == null) return;
|
||||||
|
|
||||||
|
if (guistate.get("text:pitch") instanceof EditBox box)
|
||||||
|
box.setValue((new java.text.DecimalFormat("##").format(-looking.getXRot())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,10 +76,6 @@ public class MortarGUIMenu extends AbstractContainerMenu implements Supplier<Map
|
||||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||||
Player entity = event.player;
|
Player entity = event.player;
|
||||||
if (event.phase == TickEvent.Phase.END && entity.containerMenu instanceof MortarGUIMenu) {
|
if (event.phase == TickEvent.Phase.END && entity.containerMenu instanceof MortarGUIMenu) {
|
||||||
Level world = entity.level();
|
|
||||||
double x = entity.getX();
|
|
||||||
double y = entity.getY();
|
|
||||||
double z = entity.getZ();
|
|
||||||
MotarGUITickProcedure.execute(entity, guistate);
|
MotarGUITickProcedure.execute(entity, guistate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue