Skip to content
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

add auto gradle #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0

- name: Build with Gradle
run: ./gradlew build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
2 changes: 1 addition & 1 deletion src/generated/resources/.cache/cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
a46ab507ff2143e0354586a09eb4a47a710df479 assets/createaeronautics/blockstates/airship_assembler.json
388cbfb2ec3b4b10e3c534a347f56ff799688525 assets/createaeronautics/blockstates/levitite_casing.json
f03bd9993220fb1d344cec8604dbd88d3b7b1275 assets/createaeronautics/blockstates/propeller_bearing.json
8c8c860c6f25962e30b98f8aaf8df91ab5e4ba02 assets/createaeronautics/blockstates/propeller_bearing.json
1d6fcfae6cc5e594163e320cfc3d9c8b791a6e1c assets/createaeronautics/blockstates/stationary_potato_cannon.json
ec6500ca9e9055d656869cd2ff306d420eb8bd1b assets/createaeronautics/blockstates/stirling_engine.json
56f827d9b1dcf205d37a6a9ee82019e2b9498330 assets/createaeronautics/blockstates/torsion_spring.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
{
"variants": {
"direction=push,facing=down": {
"model": "createaeronautics:block/propeller_bearing/block_reverse",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 180
},
"direction=pull,facing=down": {
"model": "createaeronautics:block/propeller_bearing/block_forward",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 180
},
"direction=push,facing=up": {
"model": "createaeronautics:block/propeller_bearing/block_reverse"
"model": "createaeronautics:block/propeller_bearing/block"
},
"direction=pull,facing=up": {
"model": "createaeronautics:block/propeller_bearing/block_forward"
"model": "createaeronautics:block/propeller_bearing/block"
},
"direction=push,facing=north": {
"model": "createaeronautics:block/propeller_bearing/block_reverse",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90
},
"direction=pull,facing=north": {
"model": "createaeronautics:block/propeller_bearing/block_forward",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90
},
"direction=push,facing=south": {
"model": "createaeronautics:block/propeller_bearing/block_reverse",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 180
},
"direction=pull,facing=south": {
"model": "createaeronautics:block/propeller_bearing/block_forward",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 180
},
"direction=push,facing=west": {
"model": "createaeronautics:block/propeller_bearing/block_reverse",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 270
},
"direction=pull,facing=west": {
"model": "createaeronautics:block/propeller_bearing/block_forward",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 270
},
"direction=push,facing=east": {
"model": "createaeronautics:block/propeller_bearing/block_reverse",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 90
},
"direction=pull,facing=east": {
"model": "createaeronautics:block/propeller_bearing/block_forward",
"model": "createaeronautics:block/propeller_bearing/block",
"x": 90,
"y": 90
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.eriksonn.createaeronautics.blocks.airship_assembler;

import appeng.core.sync.network.ServerPacketHandler;
import com.eriksonn.createaeronautics.index.CAShapes;
import com.eriksonn.createaeronautics.index.CATileEntities;
import com.eriksonn.createaeronautics.inspect.InspectUI;
import com.eriksonn.createaeronautics.network.NetworkMain;
import com.eriksonn.createaeronautics.network.packet.InspectAirshipPacket;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.ponder.PonderUI;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
Expand All @@ -22,6 +29,7 @@
import net.minecraft.world.World;

import javax.annotation.Nullable;
import java.util.function.Function;

public class AirshipAssemblerBlock extends Block implements ITE<AirshipAssemblerTileEntity> {
public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
Expand Down Expand Up @@ -59,11 +67,22 @@ public Class<AirshipAssemblerTileEntity> getTileEntityClass() {
return AirshipAssemblerTileEntity.class;
}

public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {


@Override
public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) {

if (!player.mayBuild()) {
return ActionResultType.FAIL;
} else if (player.isShiftKeyDown()) {
return ActionResultType.FAIL;

this.withTileEntityDo(worldIn, pos, (te) -> {
if (te.running) {
NetworkMain.sendToPlayer((ServerPlayerEntity) player, new InspectAirshipPacket(te.movedContraption.plotId));
}
});
return ActionResultType.SUCCESS;
} else if (player.getItemInHand(handIn).isEmpty()) {
if (worldIn.isClientSide) {
return ActionResultType.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ public void assemble() {
contraption.removeBlocksFromWorld(this.level, BlockPos.ZERO);
this.movedContraption = AirshipContraptionEntity.create(this.level, contraption);
BlockPos anchor = this.worldPosition;
this.movedContraption.simulatedRigidbody.tryInit();

this.movedContraption.setPos(
(double)anchor.getX()+this.movedContraption.centerOfMassOffset.x,
(double)anchor.getY()+this.movedContraption.centerOfMassOffset.y,
(double)anchor.getZ()+this.movedContraption.centerOfMassOffset.z);
(double)anchor.getX()-this.movedContraption.centerOfMassOffset.x,
(double)anchor.getY()-this.movedContraption.centerOfMassOffset.y,
(double)anchor.getZ()-this.movedContraption.centerOfMassOffset.z);
this.level.addFreshEntity(this.movedContraption);
AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(this.level, this.worldPosition);
this.running = true;
Expand All @@ -90,7 +89,6 @@ public void tick() {
}
if(this.movedContraption!=null)
{

time++;
float angle=time*5.5f;
MatrixStack[] stack = new MatrixStack[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.eriksonn.createaeronautics.network.packet.*;
import com.eriksonn.createaeronautics.physics.SimulatedContraptionRigidbody;
import com.eriksonn.createaeronautics.physics.SubcontraptionRigidbody;
import com.eriksonn.createaeronautics.physics.api.ContraptionEntityPhysicsAdapter;
import com.eriksonn.createaeronautics.physics.collision.shape.ICollisionShape;
import com.eriksonn.createaeronautics.physics.collision.shape.MeshCollisionShape;
import com.eriksonn.createaeronautics.utils.AbstractContraptionEntityExtension;
Expand All @@ -19,6 +20,7 @@
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.*;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.content.curiosities.tools.ExtendoGripItem;
import com.simibubi.create.foundation.collision.Matrix3d;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.utility.AngleHelper;
Expand Down Expand Up @@ -69,6 +71,7 @@ public class AirshipContraptionEntity extends AbstractContraptionEntity {

float time = 0;

public boolean playPhysics = true;
public Quaternion quat = Quaternion.ONE;
public Vector3d velocity;
public AirshipContraption airshipContraption;
Expand All @@ -87,21 +90,22 @@ protected void defineSynchedData() {

public AirshipContraptionEntity(EntityType<?> type, World world) {
super(type, world);
simulatedRigidbody = new SimulatedContraptionRigidbody(this);

simulatedRigidbody = new SimulatedContraptionRigidbody((AirshipContraption) getContraption(), new ContraptionEntityPhysicsAdapter(this));
// testing
// this.simulatedRigidbody.angularMomentum = new Vector3d(0, 0, 40);

airshipContraption = (AirshipContraption) contraption;
System.out.println("New airship entity");
}

public static AirshipContraptionEntity create(World world, AirshipContraption contraption) {
AirshipContraptionEntity entity = new AirshipContraptionEntity((EntityType) CAEntityTypes.AIRSHIP_CONTRAPTION.get(), world);
entity.setContraption(contraption);

entity.airshipContraption = contraption;
entity.simulatedRigidbody = new SimulatedContraptionRigidbody((AirshipContraption) entity.airshipContraption, new ContraptionEntityPhysicsAdapter(entity));
AirshipManager.INSTANCE.tryAddEntity(AirshipManager.INSTANCE.getNextId(), entity);

entity.simulatedRigidbody.tryInit();
return entity;

}
Expand All @@ -116,13 +120,22 @@ public static AirshipContraptionEntity create(World world, AirshipContraption co

@Override
public void tickContraption() {
airshipContraption = (AirshipContraption) contraption;
simulatedRigidbody.contraption = airshipContraption;
AirshipAssemblerTileEntity controller = getController();
airshipContraption = (AirshipContraption) contraption;

if (controller != null)
controller.attach(this);

simulatedRigidbody.tick();
if(playPhysics) {
simulatedRigidbody.tick();
this.centerOfMassOffset = simulatedRigidbody.getCenterOfMass();
quat=simulatedRigidbody.orientation.copy();
double deltaTime = 0.05;
velocity=simulatedRigidbody.globalVelocity.scale(deltaTime);
move(simulatedRigidbody.globalVelocity.x* deltaTime,simulatedRigidbody.globalVelocity.y* deltaTime,simulatedRigidbody.globalVelocity.z* deltaTime);
}

if (!airshipInitialized) {
initFakeClientWorld();
Expand All @@ -135,7 +148,7 @@ public void tickContraption() {
for (ControlledContraptionEntity contraptionEntity : subContraptions.values()) {
contraptionEntity.tick();
}
fakeClientWorld.tickEntities();
// fakeClientWorld.tickEntities();

fakeClientWorld.tickBlockEntities();
profiler.endTick();
Expand Down Expand Up @@ -210,9 +223,11 @@ public void onSyncedDataUpdated(DataParameter<?> pKey) {
if (pKey.equals(physicsDataAccessor)) {
CompoundNBT tag = this.entityData.get((DataParameter<CompoundNBT>) pKey);

simulatedRigidbody.momentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "momentum"));
simulatedRigidbody.angularMomentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "angularMomentum"));
simulatedRigidbody.orientation = simulatedRigidbody.arrayToQuat(readDoubleArray(tag, "orientation"));
if(tag.contains("momentum")) {
simulatedRigidbody.momentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "momentum"));
simulatedRigidbody.angularMomentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "angularMomentum"));
simulatedRigidbody.orientation = simulatedRigidbody.arrayToQuat(readDoubleArray(tag, "orientation"));
}
}
}

Expand Down Expand Up @@ -469,6 +484,13 @@ public boolean handlePlayerInteraction2(PlayerEntity player, BlockPos localPos,

public boolean handlePlayerInteraction(PlayerEntity player, BlockPos localPos, Direction side,
Hand interactionHand) {


if(player.getItemInHand(interactionHand).getItem() instanceof ExtendoGripItem){
simulatedRigidbody.addGlobalForce(player.getLookAngle().scale(100.0), new Vector3d(localPos.getX(), localPos.getY(), localPos.getZ()));
return true;
}

int indexOfSeat = contraption.getSeats()
.indexOf(localPos);
if (indexOfSeat == -1 && player instanceof ServerPlayerEntity) {
Expand All @@ -479,7 +501,7 @@ public boolean handlePlayerInteraction(PlayerEntity player, BlockPos localPos, D
try {
state.getBlock().use(state, worldIn, dimensionPos, player, interactionHand, null);
} catch (Exception e) {

e.printStackTrace();
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public static void renderList(RenderWorldLastEvent event) {
ClientPlayerEntity player = mc.player;
if(player == null) return;

Vector3d origin = RaycastHelper.getTraceOrigin(mc.player);
Vector3d playerEye = RaycastHelper.getTraceOrigin(mc.player);

double reach = mc.gameMode.getPickRange();
if (mc.hitResult != null && mc.hitResult.getLocation() != null)
reach = Math.max(mc.hitResult.getLocation()
.distanceTo(origin), reach);
.distanceTo(playerEye), reach);

Vector3d target = RaycastHelper.getTraceTarget(mc.player, reach, origin);
Vector3d target = RaycastHelper.getTraceTarget(mc.player, reach, playerEye);
for (AirshipContraptionEntity contraptionEntity : mc.level
.getEntitiesOfClass(AirshipContraptionEntity.class, new AxisAlignedBB(origin, target))) {
.getEntitiesOfClass(AirshipContraptionEntity.class, new AxisAlignedBB(playerEye, target))) {

Vector3d localOrigin = contraptionEntity.toLocalVector(origin, 1);
Vector3d localOrigin = contraptionEntity.toLocalVector(playerEye, 1);
Vector3d localTarget = contraptionEntity.toLocalVector(target, 1);
Contraption contraption = contraptionEntity.getContraption();

Expand Down
Loading