-
Notifications
You must be signed in to change notification settings - Fork 0
自動車Entityの実装の続き #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c3c3384
68654be
bdf7c89
8880b7d
53aee86
1e6aac7
69c71e2
448548e
a8ef331
5df4fd7
26c9bc7
6bd6830
cd72fec
3f28e15
88620de
932bc59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,10 +16,10 @@ | |||||||||||
| import net.minecraft.world.phys.Vec3; | ||||||||||||
| import org.jetbrains.annotations.NotNull; | ||||||||||||
|
|
||||||||||||
| // Entityについて | ||||||||||||
| // Entityは、BlockやItemと異なり、1つの実体に対して必ず1つのインスタンスを持つ。それによって、より多くの状態と処理を実装できる。 | ||||||||||||
| /** | ||||||||||||
| * 自動車Entityクラス<br> | ||||||||||||
| * <strong>Entityについて</strong><br> | ||||||||||||
| * Entityは、BlockやItemと異なり、1つの実体に対して必ず1つのインスタンスを持つ。それによって、より多くの状態と処理を実装できる。 | ||||||||||||
| * 自動車Entityクラス | ||||||||||||
| */ | ||||||||||||
| public class CarEntity extends Entity { | ||||||||||||
| // private static final EntityDataAccessor<Float> DATA_SPEED = | ||||||||||||
|
|
@@ -74,10 +74,9 @@ public InteractionResult interact(Player player, InteractionHand hand) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * 操縦している乗客<br> | ||||||||||||
| * 本来は常にnullなので乗客がいた時にそれを返却するように更新 | ||||||||||||
| * 操縦しているLivingEntity | ||||||||||||
| * | ||||||||||||
| * @return 乗客 | ||||||||||||
| * @return あればそのLivingEntity、なければnull | ||||||||||||
| */ | ||||||||||||
| @Override | ||||||||||||
| public LivingEntity getControllingPassenger() { | ||||||||||||
|
|
@@ -118,7 +117,7 @@ public boolean isPushable() { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * クリック判定を発生させるかどうかのようだ | ||||||||||||
| * クリック判定を発生させるかどうかだと思われる | ||||||||||||
| * | ||||||||||||
| * @return もちろん発生させる じゃないと乗れない | ||||||||||||
| */ | ||||||||||||
|
|
@@ -241,24 +240,25 @@ private void handlePlayerInput(Player player) { | |||||||||||
| // 前後進 | ||||||||||||
| float forward = 0.0f; | ||||||||||||
| // 前進0.98, 後進-0.98 | ||||||||||||
| float W_S = player.zza; | ||||||||||||
| float wS = player.zza; | ||||||||||||
| // 左0.98, 右-0.98 | ||||||||||||
| float A_D = player.xxa; | ||||||||||||
| float aD = player.xxa; | ||||||||||||
|
|
||||||||||||
| // PolygonTrainMod.LOGGER.info(String.valueOf(W_S) + ',' + A_D); | ||||||||||||
| // 前進 | ||||||||||||
| if (W_S > 0) forward = 1.0f; | ||||||||||||
| if (wS > 0) forward = 1.0f; | ||||||||||||
| // 後進 | ||||||||||||
| if (W_S < 0) forward = -1.0f; | ||||||||||||
| if (wS < 0) forward = -1.0f; | ||||||||||||
|
|
||||||||||||
| float turn = 0.0f; | ||||||||||||
| // 左旋回 | ||||||||||||
| if (A_D > 0) turn = 1.0f; | ||||||||||||
| if (aD > 0) turn = 1.0f; | ||||||||||||
| // 右旋回 | ||||||||||||
| if (A_D < 0) turn = -1.0f; | ||||||||||||
| if (aD < 0) turn = -1.0f; | ||||||||||||
|
|
||||||||||||
| // それはそうと適当に操作を反映 | ||||||||||||
| this.setYRot(this.getYRot() + turn); | ||||||||||||
| this.setYRot(this.getYRot() - turn); | ||||||||||||
| // TODO: 旋回に対応 | ||||||||||||
| this.setDeltaMovement(this.getDeltaMovement().x, this.getDeltaMovement().y, -forward); | ||||||||||||
Builder256 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 現在の実装では、
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 対応不要 |
||||||||||||
|
|
||||||||||||
| // | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testNormalVectorは定数なので、renderメソッドが呼ばれるたびにインスタンス化と計算を行うのは非効率です。static finalなフィールドとしてクラスレベルで宣言することをお勧めします。例:
そして、
buildQuadメソッド内でこの定数を直接使用します。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀