Skip to content

Commit

Permalink
Added spacecraftEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
JunePrimavera committed Aug 31, 2023
1 parent d4446bf commit 57d024f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.teampropulsive.space.rocket;

import io.github.teampropulsive.space.spacecraft.SpacecraftEntity;
import io.github.teampropulsive.types.Planet;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.attribute.EntityAttributes;
Expand All @@ -15,42 +16,27 @@
import static io.github.teampropulsive.Propulsive.SPACE;
import static io.github.teampropulsive.Propulsive.TICKABLE_PLANETS;

public class RocketEntity extends AbstractHorseEntity {
public class RocketEntity extends SpacecraftEntity {

public boolean hasWarpAbility = false;
public Vec3d velocity;
public Vec3d dockingPosition;
public float storedOxygen = 0;

public RocketEntity(EntityType<? extends PathAwareEntity> entityType, World world) {
super((EntityType<? extends AbstractHorseEntity>) entityType, world);
}
@Override
public boolean canBeSaddled() {
return false;
}
@Override
public boolean isSaddled() {
return true;
}
@Override
public EntityView method_48926() {
return null;
public float maxOxygen = 1000; // We can settle on a number here later
public RocketEntity(EntityType<? extends SpacecraftEntity> entityType, World world) {
super(entityType, world);
}

@Override
public boolean isAiDisabled() {
return true;
public boolean canJump() {
return hasWarpAbility;
}

@Override
public void tick() {
super.tick();
protected void jump(float strength, Vec3d movementInput) {
//super.jump(strength, movementInput);
}

@Override
public boolean isOnGround() { // it's on the ground I swear!
return true;
}
@Override
protected Vec3d getControlledMovementInput(PlayerEntity controllingPlayer, Vec3d movementInput) {
Vec3d a = controllingPlayer.getRotationVecClient();
Expand All @@ -59,41 +45,9 @@ protected Vec3d getControlledMovementInput(PlayerEntity controllingPlayer, Vec3d
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);
}

@Override
public boolean isTame() {
return true;
}

@Override
public boolean canJump() {
return hasWarpAbility;
}

@Override
protected void jump(float strength, Vec3d movementInput) {
//super.jump(strength, movementInput);
}


protected Vec3d calculateGravity() {
Vec3d velocity = Vec3d.ZERO;
if (this.getWorld().getRegistryKey() == SPACE) {
for (Planet planet : TICKABLE_PLANETS) {
Vec3d distanceDirection = planet.currentPos.subtract(this.getPos());
velocity.add(
new Vec3d(
distanceDirection.x * planet.planetSize,
distanceDirection.y * planet.planetSize,
distanceDirection.z * planet.planetSize
)
);
}
}
return velocity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package io.github.teampropulsive.space.spacecraft;

import io.github.teampropulsive.types.Planet;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EntityView;
import net.minecraft.world.World;

import static io.github.teampropulsive.Propulsive.SPACE;
import static io.github.teampropulsive.Propulsive.TICKABLE_PLANETS;

public class SpacecraftEntity extends AbstractHorseEntity {

protected SpacecraftEntity(EntityType<? extends AbstractHorseEntity> entityType, World world) {
super(entityType, world);
}
@Override
public boolean canBeSaddled() {
return false;
}
@Override
public boolean isSaddled() {
return true;
}
@Override
public EntityView method_48926() {
return null;
}

@Override
public boolean isAiDisabled() {
return true;
}

@Override
public void tick() {
super.tick();
}

@Override
public boolean isOnGround() { // it's on the ground I swear!
return true;
}



@Override
public boolean isTame() {
return true;
}

protected Vec3d calculateGravity() {
Vec3d velocity = Vec3d.ZERO;
if (this.getWorld().getRegistryKey() == SPACE) {
for (Planet planet : TICKABLE_PLANETS) {
Vec3d distanceDirection = planet.currentPos.subtract(this.getPos());
velocity.add(
new Vec3d(
distanceDirection.x * planet.planetSize,
distanceDirection.y * planet.planetSize,
distanceDirection.z * planet.planetSize
)
);
}
}
return velocity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package io.github.teampropulsive.space.station;

public class StationEntity {
}

0 comments on commit 57d024f

Please sign in to comment.