Skip to content

Commit

Permalink
Added docking keybind
Browse files Browse the repository at this point in the history
  • Loading branch information
JunePrimavera committed Sep 1, 2023
1 parent c209b85 commit da96926
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/io/github/teampropulsive/PropulsiveClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;

import static io.github.teampropulsive.Propulsive.*;
import static io.github.teampropulsive.keybind.DockShipKeybind.DockKeybindRegister;
import static io.github.teampropulsive.keybind.MapScreenKeybind.MapScreenKeybindRegister;

@Environment(EnvType.CLIENT)
Expand All @@ -52,7 +53,7 @@ public void onInitializeClient() {
EARTH.render();
// Key binds
MapScreenKeybindRegister();

DockKeybindRegister();
// Rocket go space c:
EntityRendererRegistry.register(TEST_ROCKET, RocketEntityRenderer::new);
EntityModelLayerRegistry.registerModelLayer(MODEL_CUBE_LAYER, RocketEntityModel::getTexturedModelData);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.teampropulsive.keybind;

import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

public class DockShipKeybind {
public static KeyBinding dockShipKey;
public static void DockKeybindRegister() {
dockShipKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.propulsive.dock",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_V,
"category.propulsive.keys"
));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.teampropulsive.space.rocket;

import io.github.teampropulsive.screen.MapScreen;
import io.github.teampropulsive.space.spacecraft.SpacecraftEntity;
import io.github.teampropulsive.types.Planet;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.mob.PathAwareEntity;
Expand All @@ -16,9 +18,9 @@

import static io.github.teampropulsive.Propulsive.SPACE;
import static io.github.teampropulsive.Propulsive.TICKABLE_PLANETS;
import static io.github.teampropulsive.keybind.DockShipKeybind.dockShipKey;

public class RocketEntity extends SpacecraftEntity {

public boolean hasWarpAbility = false;

public RocketEntity(EntityType<? extends SpacecraftEntity> entityType, World world) {
Expand All @@ -38,12 +40,14 @@ protected void jump(float strength, Vec3d movementInput) {
@Override
protected Vec3d getControlledMovementInput(PlayerEntity controllingPlayer, Vec3d movementInput) {
Vec3d a = controllingPlayer.getRotationVecClient();

float x = (float) a.x;
float y = (float) a.y;
float z = (float) a.z;
return new Vec3d(x, y, z);
}


@Override
protected float getSaddledSpeed(PlayerEntity controllingPlayer) {
return (float)this.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.teampropulsive.space.spacecraft;

import io.github.teampropulsive.types.Planet;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.AbstractHorseEntity;
Expand All @@ -10,12 +11,12 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EntityView;
import net.minecraft.world.World;
import qouteall.q_misc_util.my_util.Vec2d;

import java.util.ArrayList;

import static io.github.teampropulsive.Propulsive.SPACE;
import static io.github.teampropulsive.Propulsive.TICKABLE_PLANETS;
import static io.github.teampropulsive.keybind.DockShipKeybind.dockShipKey;

public class SpacecraftEntity extends AbstractHorseEntity {

Expand All @@ -33,6 +34,11 @@ protected SpacecraftEntity(EntityType<? extends AbstractHorseEntity> entityType,
playerPositionOffsets.add(new Vec3d(0.0, 0.0, 0.0));
playerYawOffsets.add(0.0F);
}
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (dockShipKey.wasPressed()) {
onDockingTrigger();
}
});
}
@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
Expand All @@ -48,7 +54,11 @@ protected void updatePassengerPosition(Entity passenger, Entity.PositionUpdater
passenger.setPosition(this.getPos().add(this.playerPositionOffsets.get(i)));
passenger.setYaw((this.getYaw() + this.playerYawOffsets.get(i)));
positionUpdater.accept(passenger, passenger.getX(), passenger.getY(), passenger.getZ());
}


public void onDockingTrigger() {
System.out.println("AAAAAAAAAAAAAAAAAAAaa");
}
@Override
public boolean canBeSaddled() {
Expand Down

0 comments on commit da96926

Please sign in to comment.