优化pitch显示
This commit is contained in:
parent
774722cb5a
commit
f11a18faba
2 changed files with 15 additions and 48 deletions
|
@ -1,46 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModAttributes;
|
||||
import net.mcreator.target.tools.TraceTool;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MotarGUITickProcedure {
|
||||
public static void execute(Entity entity, HashMap<String, Object> guistate) {
|
||||
if (entity == null || guistate == null) return;
|
||||
|
||||
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||
if (looking == null) return;
|
||||
|
||||
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 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) {
|
||||
try {
|
||||
return Double.parseDouble(s.trim());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.convert(guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : ""));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
package net.mcreator.target.world.inventory;
|
||||
|
||||
import net.mcreator.target.init.TargetModAttributes;
|
||||
import net.mcreator.target.init.TargetModMenus;
|
||||
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.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
@ -76,7 +77,19 @@ public class MortarGUIMenu extends AbstractContainerMenu implements Supplier<Map
|
|||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
Player entity = event.player;
|
||||
if (event.phase == TickEvent.Phase.END && entity.containerMenu instanceof MortarGUIMenu) {
|
||||
MotarGUITickProcedure.execute(entity, guistate);
|
||||
Entity looking = TraceTool.findLookingEntity(entity, 6);
|
||||
if (looking == null) return;
|
||||
|
||||
String s = guistate.containsKey("text:pitch") ? ((EditBox) guistate.get("text:pitch")).getValue() : "0";
|
||||
double converted = 0;
|
||||
try {
|
||||
converted = Double.parseDouble(s);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (20 <= converted && converted <= 90) {
|
||||
((LivingEntity) looking).getAttribute(TargetModAttributes.MOTARPITCH.get()).setBaseValue(converted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue