From 45914ef66151e8c21c9db210316125913e18302b Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 16 Mar 2022 21:11:22 +0100 Subject: [PATCH 1/7] Fixed propeller slowdown and misc stuff --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../propeller_bearing/PropellerBearingTileEntity.java | 10 ++++------ .../blocks/stirling_engine/StirlingEngineBlock.java | 4 ++++ .../stirling_engine/StirlingEngineTileEntity.java | 10 ++++++++++ .../contraptions/AirshipContraptionEntity.java | 3 ++- .../physics/SimulatedContraptionRigidbody.java | 4 ++-- 6 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..00e33ed 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java index cc42efe..614cc74 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java @@ -103,7 +103,7 @@ public float getAngularSpeed() { float speed = rotationSpeed; if (level.isClientSide) { speed *= ServerSpeedProvider.get(); - //speed += clientAngleDiff / 3f; + speed += clientAngleDiff / 3f; } return speed; } @@ -160,11 +160,9 @@ void updateSlowdownSpeed() // the closest grid-aligned angle to currentStoppingPoint float optimalStoppingPoint = 90f*Math.round(currentStoppingPoint/90f); - // Q is an inverse-lerp that solves this equation: - // optimalStoppingPoint = lerp(currentStoppingPoint,angle,Q) - float Q = (optimalStoppingPoint-currentStoppingPoint)/(angle-currentStoppingPoint); + float Q = (optimalStoppingPoint-currentStoppingPoint)/disassemblyTimer; - rotationSpeed *= (1f - 3f*Q/disassemblyTimer)*(1f - 1f/disassemblyTimer); + rotationSpeed = (rotationSpeed + 6f*Q/disassemblyTimer)*(1f - 1f/disassemblyTimer); } @Override public void attach(ControlledContraptionEntity contraption) @@ -208,7 +206,7 @@ void findSails() public void spawnParticles() { - if(getSpeed()!=0 && movedContraption!=null &&isRunning()) { + if(Math.abs(rotationSpeed)>0.01 && movedContraption!=null &&isRunning()) { World world = getLevel(); Direction direction = getBlockState().getValue(BlockStateProperties.FACING); Vector3f speed = new Vector3f(direction.getNormal().getX(), direction.getNormal().getY(), direction.getNormal().getZ()); diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java new file mode 100644 index 0000000..a7b0e38 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java @@ -0,0 +1,4 @@ +package com.eriksonn.createaeronautics.blocks.stirling_engine; + +public class StirlingEngineBlock { +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java new file mode 100644 index 0000000..551f3e1 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java @@ -0,0 +1,10 @@ +package com.eriksonn.createaeronautics.blocks.stirling_engine; + +import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; +import net.minecraft.tileentity.TileEntityType; + +public class StirlingEngineTileEntity extends GeneratingKineticTileEntity { + public StirlingEngineTileEntity(TileEntityType typeIn) { + super(typeIn); + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java b/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java index fa48f54..748f1e9 100644 --- a/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java @@ -126,11 +126,12 @@ public void tickContraption() { if (level.isClientSide) { profiler.startTick(); fakeClientWorld.tick(() -> true); - fakeClientWorld.tickEntities(); + for (ControlledContraptionEntity contraptionEntity : subContraptions.values()) { contraptionEntity.tick(); } + fakeClientWorld.tickEntities(); profiler.endTick(); diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java index 3b5fa81..2d45a1a 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java @@ -77,7 +77,7 @@ public SimulatedContraptionRigidbody(AirshipContraptionEntity entity) momentum=Vector3d.ZERO; principalRotation =Quaternion.ONE.copy(); - angularMomentum=new Vector3d(0,800,0); + //angularMomentum=new Vector3d(0,800,0); //principialRotation=new Quaternion(1,2,3,4); //principialRotation.normalize(); PhysicsUtils.generateLeviCivitaTensor(); @@ -337,7 +337,7 @@ void updateRotation() angularMomentum=angularMomentum.scale(momentumMag); } - //angularMomentum=angularMomentum.scale(0.995); + angularMomentum=angularMomentum.scale(0.995); Vector3d v = angularVelocity.scale(PhysicsUtils.deltaTime*0.5f); Quaternion q = new Quaternion((float)v.x,(float)v.y,(float)v.z, 1.0f); q.mul(orientation); From c87c4393d24d4410fff517daea32c9440720a617 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 16 Mar 2022 22:29:36 +0100 Subject: [PATCH 2/7] Stirling engine part 1 --- src/generated/resources/.cache/cache | 10 ++++-- .../assets/createaeronautics/lang/en_ud.json | 1 + .../assets/createaeronautics/lang/en_us.json | 1 + .../data/create/tags/blocks/safe_nbt.json | 29 +++------------ .../stirling_engine/StirlingEngineBlock.java | 36 ++++++++++++++++++- .../createaeronautics/index/CABlocks.java | 8 +++++ .../createaeronautics/index/CAItems.java | 10 +++--- .../index/CATileEntities.java | 5 +++ 8 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index fe88cea..b6bf646 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -2,19 +2,23 @@ a46ab507ff2143e0354586a09eb4a47a710df479 assets/createaeronautics/blockstates/ai 388cbfb2ec3b4b10e3c534a347f56ff799688525 assets/createaeronautics/blockstates/levitite_casing.json f03bd9993220fb1d344cec8604dbd88d3b7b1275 assets/createaeronautics/blockstates/propeller_bearing.json 1d6fcfae6cc5e594163e320cfc3d9c8b791a6e1c assets/createaeronautics/blockstates/stationary_potato_cannon.json +155ca4bb6230a8d066884fb36d705af9ca9fba1c assets/createaeronautics/blockstates/stirling_engine.json 56f827d9b1dcf205d37a6a9ee82019e2b9498330 assets/createaeronautics/blockstates/torsion_spring.json -f8f9af452f83ba240bc7f679dc21d5c0254f34b0 assets/createaeronautics/lang/en_ud.json -ff0b742606f77205d671e56ede60b68d31f79e60 assets/createaeronautics/lang/en_us.json +c6ebf0a9bbeb758fe073feafc9ca76cd0c7ce7d0 assets/createaeronautics/lang/en_ud.json +24dfe9eec5b6eb14059de0440eaa94bb8757979e assets/createaeronautics/lang/en_us.json dd3444734415a2561192315a438498716b0a325a assets/createaeronautics/models/block/levitite_casing.json +ba3e5b5596e58ed4bd49ebec835963b743f8487d assets/createaeronautics/models/block/stirling_engine.json 5eb012264762a5949ac970bebf2675d258e005ff assets/createaeronautics/models/item/airship_assembler.json 194aefcc12c8a23ac02b86462b1ec69f2584f8d6 assets/createaeronautics/models/item/endstone_powder.json 5871bf294c63708c0d684eb8f5193bdc1896a160 assets/createaeronautics/models/item/levitite_casing.json 6ae86017bfb5b00c38c693e7ed965b6214427d7e assets/createaeronautics/models/item/propeller_bearing.json 7fc727516fad944ede696160be5c0240585e4caa assets/createaeronautics/models/item/stationary_potato_cannon.json +43a71f91f857e9cc3f5196a9ddc97564a06893ad assets/createaeronautics/models/item/stirling_engine.json c60b75429af4cde62f0db4123de91fbf6eefd671 assets/createaeronautics/models/item/torsion_spring.json -0b930418659f22732e3572d9df032811d17f1145 data/create/tags/blocks/safe_nbt.json +ae6560f8e5bdc5f962bb8bac2a40990cee42cf02 data/create/tags/blocks/safe_nbt.json 8e6e31749755efef7f36fa96811f282486b456e9 data/createaeronautics/loot_tables/blocks/airship_assembler.json a9765079a36fd299ea7fab5eded12193136e58b1 data/createaeronautics/loot_tables/blocks/levitite_casing.json 22b3fd57ee0cd5a3d102aa8cb1f0d027e415917e data/createaeronautics/loot_tables/blocks/propeller_bearing.json 336e90a1ec314af4263c6edfc07ed621927b84ce data/createaeronautics/loot_tables/blocks/stationary_potato_cannon.json +b840398dec616621b541a1c69ca26b95b466d67e data/createaeronautics/loot_tables/blocks/stirling_engine.json bc745c27abcc4a469b11ff598af1af1ae6a4cc4c data/createaeronautics/loot_tables/blocks/torsion_spring.json diff --git a/src/generated/resources/assets/createaeronautics/lang/en_ud.json b/src/generated/resources/assets/createaeronautics/lang/en_ud.json index b79fd8b..d0f651b 100644 --- a/src/generated/resources/assets/createaeronautics/lang/en_ud.json +++ b/src/generated/resources/assets/createaeronautics/lang/en_ud.json @@ -3,6 +3,7 @@ "block.createaeronautics.levitite_casing": "bu\u0131s\u0250\u0186 \u01DD\u0287\u0131\u0287\u0131\u028C\u01DD\uA780", "block.createaeronautics.propeller_bearing": "bu\u0131\u0279\u0250\u01DD\u15FA \u0279\u01DD\u05DF\u05DF\u01DDdo\u0279\u0500", "block.createaeronautics.stationary_potato_cannon": "uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S", + "block.createaeronautics.stirling_engine": "\u01DDu\u0131bu\u018E bu\u0131\u05DF\u0279\u0131\u0287S", "block.createaeronautics.torsion_spring": "bu\u0131\u0279dS uo\u0131s\u0279o\u27D8", "death.attack.createaeronautics.stationary_potato_cannon": "uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S \u0250 \u028Eq \u0287o\u0265s s\u0250\u028D %1$s", "death.attack.createaeronautics.stationary_potato_cannon.item": "%2$s bu\u0131sn uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S \u0250 \u028Eq \u0287o\u0265s s\u0250\u028D %1$s", diff --git a/src/generated/resources/assets/createaeronautics/lang/en_us.json b/src/generated/resources/assets/createaeronautics/lang/en_us.json index b6b5d9f..70a6e70 100644 --- a/src/generated/resources/assets/createaeronautics/lang/en_us.json +++ b/src/generated/resources/assets/createaeronautics/lang/en_us.json @@ -3,6 +3,7 @@ "block.createaeronautics.levitite_casing": "Levitite Casing", "block.createaeronautics.propeller_bearing": "Propeller Bearing", "block.createaeronautics.stationary_potato_cannon": "Stationary Potato Cannon", + "block.createaeronautics.stirling_engine": "Stirling Engine", "block.createaeronautics.torsion_spring": "Torsion Spring", "death.attack.createaeronautics.stationary_potato_cannon": "%1$s was shot by a Stationary Potato Cannon", "death.attack.createaeronautics.stationary_potato_cannon.item": "%1$s was shot by a Stationary Potato Cannon using %2$s", diff --git a/src/generated/resources/data/create/tags/blocks/safe_nbt.json b/src/generated/resources/data/create/tags/blocks/safe_nbt.json index d834c9f..8612bbf 100644 --- a/src/generated/resources/data/create/tags/blocks/safe_nbt.json +++ b/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -1,29 +1,10 @@ { "replace": false, "values": [ - "create:creative_motor", - "create:creative_fluid_tank", - "create:mechanical_piston", - "create:sticky_mechanical_piston", - "create:windmill_bearing", - "create:mechanical_bearing", - "create:clockwork_bearing", - "create:rope_pulley", - "create:cart_assembler", - "create:linear_chassis", - "create:secondary_linear_chassis", - "create:radial_chassis", - "create:sequenced_gearshift", - "create:rotation_speed_controller", - "create:andesite_funnel", - "create:andesite_belt_funnel", - "create:brass_funnel", - "create:brass_belt_funnel", - "create:creative_crate", - "create:redstone_link", - "create:analog_lever", - "create:adjustable_repeater", - "create:adjustable_pulse_repeater", - "#minecraft:signs" + "createaeronautics:torsion_spring", + "createaeronautics:airship_assembler", + "createaeronautics:propeller_bearing", + "createaeronautics:stationary_potato_cannon", + "createaeronautics:stirling_engine" ] } \ No newline at end of file diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java index a7b0e38..4f2574c 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java @@ -1,4 +1,38 @@ package com.eriksonn.createaeronautics.blocks.stirling_engine; -public class StirlingEngineBlock { + +import com.eriksonn.createaeronautics.index.CATileEntities; +import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; + +public class StirlingEngineBlock extends HorizontalKineticBlock { + public StirlingEngineBlock(Properties properties) { + super(properties); + } + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return CATileEntities.STIRLING_ENGINE.create(); + } + @Override + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + return face == state.getValue(HORIZONTAL_FACING).getOpposite(); + } + @Override + public Direction.Axis getRotationAxis(BlockState state) { + return state.getValue(HORIZONTAL_FACING).getAxis(); + } + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + Direction preferred = getPreferredHorizontalFacing(context); + if (preferred != null) + return defaultBlockState().setValue(HORIZONTAL_FACING, preferred.getOpposite()); + return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection()); + } } diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java index 57d7f9d..37b20a0 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java @@ -4,6 +4,7 @@ import com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerBlock; import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingBlock; import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonBlock; +import com.eriksonn.createaeronautics.blocks.stirling_engine.StirlingEngineBlock; import com.eriksonn.createaeronautics.blocks.torsion_spring.TorsionSpringBlock; import com.eriksonn.createaeronautics.groups.CAItemGroups; @@ -75,6 +76,13 @@ public class CABlocks { .item() .transform(customItemModel()) .register(); + public static final BlockEntry STIRLING_ENGINE = REGISTRATE.block("stirling_engine", StirlingEngineBlock::new) + .initialProperties(SharedProperties::stone) + .properties(AbstractBlock.Properties::noOcclusion) + .tag(AllTags.AllBlockTags.SAFE_NBT.tag) //Dono what this tag means (contraption safe?). + .item() + .transform(customItemModel()) + .register(); public static void register() { //CreateAeronautics.registrate().addToSection(TORSION_SPRING, AllSections.KINETICS); diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CAItems.java b/src/main/java/com/eriksonn/createaeronautics/index/CAItems.java index 5d161b4..c1d812c 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CAItems.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CAItems.java @@ -16,11 +16,11 @@ public class CAItems { .item("endstone_powder", Item::new) .register(); - public static final ItemEntry GOGGLES = REGISTRATE.item("aviator_goggles", GogglesItem::new) - .properties(p -> p.stacksTo(1)) - .onRegister(REGISTRATE.itemModel(() -> GogglesModel::new)) - .lang("Aviator's Goggles") - .register(); + //public static final ItemEntry GOGGLES = REGISTRATE.item("aviator_goggles", GogglesItem::new) + // .properties(p -> p.stacksTo(1)) + // .onRegister(REGISTRATE.itemModel(() -> GogglesModel::new)) + // .lang("Aviator's Goggles") + // .register(); public static void register(){} } diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java b/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java index 9f0a4ac..82448a0 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java @@ -4,6 +4,7 @@ import com.eriksonn.createaeronautics.CreateAeronautics; import com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity; import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingTileEntity; +import com.eriksonn.createaeronautics.blocks.stirling_engine.StirlingEngineTileEntity; import com.eriksonn.createaeronautics.blocks.torsion_spring.TorsionSpringTileEntity; import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonInstance; import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonRenderer; @@ -39,5 +40,9 @@ public class CATileEntities { .validBlocks(CABlocks.PROPELLER_BEARING) .renderer(() -> BearingRenderer::new) .register(); + public static final TileEntityEntry STIRLING_ENGINE = CreateAeronautics.registrate() + .tileEntity("stirling_engine", StirlingEngineTileEntity::new) + .validBlocks(CABlocks.STIRLING_ENGINE) + .register(); public static void register() {} } From fa63a564b99d28511018cb5e069e6cd733e6ae92 Mon Sep 17 00:00:00 2001 From: FortressNebula Date: Wed, 16 Mar 2022 21:31:03 +0000 Subject: [PATCH 3/7] bunch of fixes - Added (remap = false) to necessary mixins - Renamed some interfaces - Added Propeller Bearing gui info - Updated forge to 28 --- gradle.properties | 2 +- .../PropellerBearingBlock.java | 6 +-- .../PropellerBearingTileEntity.java | 8 +++- .../StationaryPotatoCannonTileEntity.java | 3 +- .../connected/CTSpriteShifter.java | 48 ------------------- .../createaeronautics/index/CABlocks.java | 3 +- .../index/CASpriteShifts.java | 9 ++-- .../mixins/BearingContraptionMixin.java | 46 ++++++++++++++++++ .../mixins/ContraptionMatriciesMixin.java | 2 +- .../mixins/ContraptionRenderInfoMixin.java | 2 +- .../ControlledContraptionEntityMixin.java | 2 +- .../mixins/Matrix3dAccessor.java | 18 +++---- .../MechanicalBearingTileEntityAccessor.java | 15 ------ .../MechanicalBearingTileEntityMixin.java | 24 ++++++++++ .../mixins/PotatoProjectileEntityMixin.java | 4 +- .../SimulatedContraptionRigidbody.java | 1 + .../utils/BearingContraptionExtension.java | 7 +++ .../PotatoProjectileEntityExtension.java} | 4 +- .../resources/createaeronautics.mixins.json | 3 +- 19 files changed, 114 insertions(+), 93 deletions(-) delete mode 100644 src/main/java/com/eriksonn/createaeronautics/connected/CTSpriteShifter.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/mixins/BearingContraptionMixin.java delete mode 100644 src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityAccessor.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/utils/BearingContraptionExtension.java rename src/main/java/com/eriksonn/createaeronautics/{blocks/stationary_potato_cannon/PotatoProjectileEntityFix.java => utils/PotatoProjectileEntityExtension.java} (59%) diff --git a/gradle.properties b/gradle.properties index ed5041f..2fd87f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false minecraft_version=1.16.5 jei_version=7.7.0.106 -forge_version=36.2.20 +forge_version=36.2.28 modid="createaeronautics" forgegradle_version=5.1+ diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingBlock.java b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingBlock.java index 54bf07c..09d46ef 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingBlock.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingBlock.java @@ -1,16 +1,12 @@ package com.eriksonn.createaeronautics.blocks.propeller_bearing; import com.eriksonn.createaeronautics.index.CATileEntities; -import com.eriksonn.createaeronautics.mixins.MechanicalBearingTileEntityAccessor; -import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingBlock; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.BooleanProperty; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; @@ -63,7 +59,7 @@ public ActionResultType use(BlockState state, World worldIn, BlockPos pos, Playe te.startDisassemblySlowdown(); return; } - ((MechanicalBearingTileEntityAccessor) te).setAssembleNextTick(true); + te.setAssembleNextTick(true); //te.assembleNextTick }); return ActionResultType.SUCCESS; diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java index cc42efe..be305cf 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java @@ -40,6 +40,7 @@ public class PropellerBearingTileEntity extends MechanicalBearingTileEntity{ float rotationSpeed=0; float disassemblyTimer; boolean disassemblySlowdown=false; + public PropellerBearingTileEntity(TileEntityType type) { super(type); sailPositions=new ArrayList<>(); @@ -180,12 +181,17 @@ public void assemble() super.assemble(); findSails(); } + @Override public void disassemble() { - super.disassemble(); } + + public void setAssembleNextTick(boolean value) { + assembleNextTick = value; + } + public void startDisassemblySlowdown() { if(!disassemblySlowdown) { diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/StationaryPotatoCannonTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/StationaryPotatoCannonTileEntity.java index 76a76c1..7152465 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/StationaryPotatoCannonTileEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/StationaryPotatoCannonTileEntity.java @@ -1,6 +1,7 @@ package com.eriksonn.createaeronautics.blocks.stationary_potato_cannon; import com.eriksonn.createaeronautics.index.CABlocks; +import com.eriksonn.createaeronautics.utils.PotatoProjectileEntityExtension; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; @@ -180,7 +181,7 @@ void Shoot() for(int i = 0; i < projectileType.getSplit(); ++i) { PotatoProjectileEntity projectile = AllEntityTypes.POTATO_PROJECTILE.create(this.level); // == This is the new code that fixes the death message. == - ((PotatoProjectileEntityFix) projectile).setIsFromStationaryPotatoCannon(true); + ((PotatoProjectileEntityExtension) projectile).setIsFromStationaryPotatoCannon(true); // ======================================================== projectile.setItem(currentStack); diff --git a/src/main/java/com/eriksonn/createaeronautics/connected/CTSpriteShifter.java b/src/main/java/com/eriksonn/createaeronautics/connected/CTSpriteShifter.java deleted file mode 100644 index 7b089e7..0000000 --- a/src/main/java/com/eriksonn/createaeronautics/connected/CTSpriteShifter.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.eriksonn.createaeronautics.connected; - - -import com.eriksonn.createaeronautics.CreateAeronautics; -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.render.SpriteShifter; -import net.minecraft.util.ResourceLocation; - -public class CTSpriteShifter extends SpriteShifter { - public static CTSpriteShiftEntry getCT(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type, ResourceLocation blockTexture, ResourceLocation connectedTexture) { - String key = type.name() + ":" + blockTexture + "->" + connectedTexture; - if (ENTRY_CACHE.containsKey(key)) - return (CTSpriteShiftEntry) ENTRY_CACHE.get(key); - - CTSpriteShiftEntry entry = create(type); - entry.set(blockTexture, connectedTexture); - ENTRY_CACHE.put(key, entry); - return entry; - } - - public static CTSpriteShiftEntry getCT(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type, String blockTextureName, String connectedTextureName) { - return getCT(type, CreateAeronautics.asResource("block/" + blockTextureName), CreateAeronautics.asResource("block/" + connectedTextureName + "_connected")); - } - - public static CTSpriteShiftEntry getCT(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type, String blockTextureName) { - return getCT(type, blockTextureName, blockTextureName); - } - - private static CTSpriteShiftEntry create(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type) { - switch (type) { - case HORIZONTAL: - return new CTSpriteShiftEntry.Horizontal(); - case OMNIDIRECTIONAL: - return new CTSpriteShiftEntry.Omnidirectional(); - case VERTICAL: - return new CTSpriteShiftEntry.Vertical(); - case CROSS: - return new CTSpriteShiftEntry.Cross(); - default: - return null; - } - } - - public enum CTType { - OMNIDIRECTIONAL, HORIZONTAL, VERTICAL, CROSS; - } - -} diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java index 57d7f9d..a682a10 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java @@ -19,6 +19,7 @@ import com.simibubi.create.foundation.data.SharedProperties; import com.simibubi.create.repack.registrate.util.entry.BlockEntry; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import static com.simibubi.create.foundation.data.ModelGen.customItemModel; @@ -72,8 +73,6 @@ public class CABlocks { public static final BlockEntry LEVITITE_CASING = REGISTRATE.block("levitite_casing", CasingBlock::new) .transform(BuilderTransformers.casing(CASpriteShifts.LEVITITE_CASING)) - .item() - .transform(customItemModel()) .register(); public static void register() { diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CASpriteShifts.java b/src/main/java/com/eriksonn/createaeronautics/index/CASpriteShifts.java index e0374af..5ba7f43 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CASpriteShifts.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CASpriteShifts.java @@ -1,16 +1,19 @@ package com.eriksonn.createaeronautics.index; +import com.eriksonn.createaeronautics.CreateAeronautics; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; +import com.simibubi.create.foundation.block.connected.CTSpriteShifter; import static com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType.OMNIDIRECTIONAL; -import static com.eriksonn.createaeronautics.connected.CTSpriteShifter.getCT; public class CASpriteShifts { - public static final CTSpriteShiftEntry LEVITITE_CASING = omni("levitite_casing"); + public static final CTSpriteShiftEntry LEVITITE_CASING = omni("block/levitite_casing"); static CTSpriteShiftEntry omni(String name) { - return getCT(OMNIDIRECTIONAL, name); + return CTSpriteShifter.getCT(OMNIDIRECTIONAL, + CreateAeronautics.asResource(name), + CreateAeronautics.asResource(name + "_connected")); } } diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/BearingContraptionMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/BearingContraptionMixin.java new file mode 100644 index 0000000..b46dbdf --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/BearingContraptionMixin.java @@ -0,0 +1,46 @@ +package com.eriksonn.createaeronautics.mixins; + +import com.eriksonn.createaeronautics.utils.BearingContraptionExtension; +import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BearingContraption.class) +public class BearingContraptionMixin implements BearingContraptionExtension { + private boolean isPropeller = false; + + @Shadow(remap = false) protected int sailBlocks; + + @Inject( + method = "assemble(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z", + at = @At(value = "RETURN", ordinal = 1), + remap = false) + private void onBlocksEmpty(World world, BlockPos pos, CallbackInfoReturnable cir) throws AssemblyException { + tryFailAssembly(); + } + + @Inject( + method = "assemble(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z", + at = @At(value = "RETURN", ordinal = 2), + remap = false) + private void onSucceededAssemble(World world, BlockPos pos, CallbackInfoReturnable cir) throws AssemblyException { + tryFailAssembly(); + } + + @Override + public void setPropeller() { + isPropeller = true; + } + + private void tryFailAssembly() throws AssemblyException { + if (isPropeller && sailBlocks < 2) { + throw new AssemblyException("not_enough_sails", sailBlocks, 2); + } + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionMatriciesMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionMatriciesMixin.java index 6108a78..bd2a9c7 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionMatriciesMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionMatriciesMixin.java @@ -31,7 +31,7 @@ @Mixin(value= ContraptionMatrices.class) public class ContraptionMatriciesMixin { - @Shadow @Final + @Shadow(remap = false) @Final private MatrixStack model; @Inject(locals = LocalCapture.CAPTURE_FAILHARD,remap=false,method = "setup", at = @At(remap=false,value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity;doLocalTransforms(F[Lcom/mojang/blaze3d/matrix/MatrixStack;)V")) diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionRenderInfoMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionRenderInfoMixin.java index fec6268..3b7fdcb 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionRenderInfoMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/ContraptionRenderInfoMixin.java @@ -56,7 +56,7 @@ public void onSetupMatrices(MatrixStack viewProjection, double camX, double camY // this.matrices=matrices; //} @Mutable - @Shadow + @Shadow(remap = false) private boolean visible; ///** // * @author Eriksonn diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java index 4f94118..956ea2e 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java @@ -8,6 +8,6 @@ @Mixin(ControlledContraptionEntity.class) public interface ControlledContraptionEntityMixin { - @Invoker("makeStructureTransform") + @Invoker(value = "makeStructureTransform", remap = false) public StructureTransform invokeMakeStructureTransform(); } diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/Matrix3dAccessor.java b/src/main/java/com/eriksonn/createaeronautics/mixins/Matrix3dAccessor.java index 461b156..26c6cc3 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/Matrix3dAccessor.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/Matrix3dAccessor.java @@ -8,15 +8,15 @@ @Mixin(Matrix3d.class) public abstract class Matrix3dAccessor implements Matrix3dExtension { - @Shadow private double m00; - @Shadow private double m01; - @Shadow private double m02; - @Shadow private double m10; - @Shadow private double m11; - @Shadow private double m12; - @Shadow private double m20; - @Shadow private double m21; - @Shadow private double m22; + @Shadow(remap = false) double m00; + @Shadow(remap = false) double m01; + @Shadow(remap = false) double m02; + @Shadow(remap = false) double m10; + @Shadow(remap = false) double m11; + @Shadow(remap = false) double m12; + @Shadow(remap = false) double m20; + @Shadow(remap = false) double m21; + @Shadow(remap = false) double m22; public void createaeronautics$set(Vector3d I, Vector3d J, Vector3d K) { diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityAccessor.java b/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityAccessor.java deleted file mode 100644 index 06c91ac..0000000 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityAccessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.eriksonn.createaeronautics.mixins; - -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -/** - * Much neater way to access the assembleNextTick variable. - * (Compared to the old way of placing a class into the same package) - * @author FortressNebula - */ -@Mixin(MechanicalBearingTileEntity.class) -public interface MechanicalBearingTileEntityAccessor { - @Accessor(remap = false) void setAssembleNextTick(boolean val); -} diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java new file mode 100644 index 0000000..5f0edb5 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java @@ -0,0 +1,24 @@ +package com.eriksonn.createaeronautics.mixins; + +import com.eriksonn.createaeronautics.utils.BearingContraptionExtension; +import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(MechanicalBearingTileEntity.class) +public class MechanicalBearingTileEntityMixin { + @Redirect( + method = "assemble()V", + at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption;assemble(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z", remap = false), + remap = false + ) + private boolean onTryAssemble(BearingContraption contraption, World world, BlockPos pos) throws AssemblyException { + ((BearingContraptionExtension) contraption).setPropeller(); + return contraption.assemble(world, pos); + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/PotatoProjectileEntityMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/PotatoProjectileEntityMixin.java index 8a54cf8..688315b 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/PotatoProjectileEntityMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/PotatoProjectileEntityMixin.java @@ -1,6 +1,6 @@ package com.eriksonn.createaeronautics.mixins; -import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.PotatoProjectileEntityFix; +import com.eriksonn.createaeronautics.utils.PotatoProjectileEntityExtension; import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonProjectileEntity; import com.simibubi.create.content.curiosities.weapons.PotatoProjectileEntity; import net.minecraft.util.DamageSource; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PotatoProjectileEntity.class) -public class PotatoProjectileEntityMixin implements PotatoProjectileEntityFix { +public class PotatoProjectileEntityMixin implements PotatoProjectileEntityExtension { public boolean isFromStationaryPotatoCannon = false; /** diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java index 3b5fa81..ab448ad 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java @@ -146,6 +146,7 @@ public void tick() entity.setDeltaMovement(globalVelocity.scale(PhysicsUtils.deltaTime)); entity.move(globalVelocity.x*PhysicsUtils.deltaTime,globalVelocity.y*PhysicsUtils.deltaTime,globalVelocity.z*PhysicsUtils.deltaTime); } + public void readAdditional(CompoundNBT compound, boolean spawnPacket) { orientation = readQuaternion(compound.getCompound("Orientation")); diff --git a/src/main/java/com/eriksonn/createaeronautics/utils/BearingContraptionExtension.java b/src/main/java/com/eriksonn/createaeronautics/utils/BearingContraptionExtension.java new file mode 100644 index 0000000..680fa0a --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/utils/BearingContraptionExtension.java @@ -0,0 +1,7 @@ +package com.eriksonn.createaeronautics.utils; + +public interface BearingContraptionExtension { + boolean isPropeller = false; + + void setPropeller(); +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/PotatoProjectileEntityFix.java b/src/main/java/com/eriksonn/createaeronautics/utils/PotatoProjectileEntityExtension.java similarity index 59% rename from src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/PotatoProjectileEntityFix.java rename to src/main/java/com/eriksonn/createaeronautics/utils/PotatoProjectileEntityExtension.java index 1a13f5f..a2cfe55 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stationary_potato_cannon/PotatoProjectileEntityFix.java +++ b/src/main/java/com/eriksonn/createaeronautics/utils/PotatoProjectileEntityExtension.java @@ -1,9 +1,9 @@ -package com.eriksonn.createaeronautics.blocks.stationary_potato_cannon; +package com.eriksonn.createaeronautics.utils; /** * This is needed to add a custom function to the PotatoProjectileEntity class. * @author FortressNebula */ -public interface PotatoProjectileEntityFix { +public interface PotatoProjectileEntityExtension { void setIsFromStationaryPotatoCannon(boolean value); } diff --git a/src/main/resources/createaeronautics.mixins.json b/src/main/resources/createaeronautics.mixins.json index 4872ce8..7d6e09f 100644 --- a/src/main/resources/createaeronautics.mixins.json +++ b/src/main/resources/createaeronautics.mixins.json @@ -5,6 +5,7 @@ "refmap": "createaeronautics.refmap.json", "mixins": [ "AbstractContraptionEntityMixin", + "BearingContraptionMixin", "ClientWorldAccessorMixin", "ContraptionColliderMixin", "ContraptionHolderAccessor", @@ -15,7 +16,7 @@ "ControlledContraptionEntityMixin", "DimensionTypeMixin", "Matrix3dAccessor", - "MechanicalBearingTileEntityAccessor", + "MechanicalBearingTileEntityMixin", "PotatoProjectileEntityMixin", "RedstoneLinkNetworkMixin", "RotationPropagatorMixin", From c036e977baf380f81cc8d7dd359b4962f917e6ab Mon Sep 17 00:00:00 2001 From: FortressNebula Date: Wed, 16 Mar 2022 22:10:32 +0000 Subject: [PATCH 4/7] fixed stirling engine blockstate --- .../eriksonn/createaeronautics/index/CABlocks.java | 5 +++-- .../createaeronautics/utils/BlockStateUtils.java | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java index 37b20a0..38e16fc 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CABlocks.java @@ -76,12 +76,13 @@ public class CABlocks { .item() .transform(customItemModel()) .register(); + public static final BlockEntry STIRLING_ENGINE = REGISTRATE.block("stirling_engine", StirlingEngineBlock::new) .initialProperties(SharedProperties::stone) .properties(AbstractBlock.Properties::noOcclusion) + .blockstate(BlockStateUtils::horizontalFacingLitBlockstate) .tag(AllTags.AllBlockTags.SAFE_NBT.tag) //Dono what this tag means (contraption safe?). - .item() - .transform(customItemModel()) + .item().transform(customItemModel()) .register(); public static void register() { diff --git a/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java b/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java index 6893216..bd13b16 100644 --- a/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java +++ b/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java @@ -2,10 +2,9 @@ import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingBlock; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; -import com.simibubi.create.repack.registrate.builders.BlockBuilder; +import com.simibubi.create.foundation.data.BlockStateGen; import com.simibubi.create.repack.registrate.providers.DataGenContext; import com.simibubi.create.repack.registrate.providers.RegistrateBlockstateProvider; -import com.simibubi.create.repack.registrate.util.nullness.NonNullUnaryOperator; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.state.properties.BlockStateProperties; @@ -15,8 +14,6 @@ import java.util.function.Function; -import static com.simibubi.create.foundation.data.BlockStateGen.directionalAxisBlock; - /** * Useful functions for auto-generating blockstates. * @author FortressNebula @@ -24,10 +21,15 @@ public class BlockStateUtils { public static void directionalPoweredAxisBlockstate(DataGenContext ctx, RegistrateBlockstateProvider prov) { - directionalAxisBlock(ctx, prov, (blockState, vertical) -> prov.models() + BlockStateGen.directionalAxisBlock(ctx, prov, (blockState, vertical) -> prov.models() .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/" + (vertical ? "vertical" : "horizontal") + (blockState.getValue(BlockStateProperties.POWERED) ? "_powered" : "")))); } + public static void horizontalFacingLitBlockstate(DataGenContext ctx, RegistrateBlockstateProvider prov) { + prov.horizontalBlock(ctx.get(), blockState -> prov.models() + .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/block" /*+ (blockState.getValue(BlockStateProperties.LIT) ? "_lit" : "")*/))); + } + public static void torsionSpringBlockstate(DataGenContext ctx, RegistrateBlockstateProvider prov, Function modelFunc, boolean uvLock) { prov.getVariantBuilder(ctx.getEntry()) From 85b78ca02075ee3b6ca09109559c5d60b8154121 Mon Sep 17 00:00:00 2001 From: FortressNebula Date: Thu, 17 Mar 2022 22:07:33 +0000 Subject: [PATCH 5/7] fixed slightly concerning bearing issue --- .../MecanicalBearingTileEntityExtension.java | 5 +++++ .../propeller_bearing/PropellerBearingTileEntity.java | 11 ++++++----- .../mixins/MechanicalBearingTileEntityMixin.java | 10 ++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/MecanicalBearingTileEntityExtension.java diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/MecanicalBearingTileEntityExtension.java b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/MecanicalBearingTileEntityExtension.java new file mode 100644 index 0000000..636b3d3 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/MecanicalBearingTileEntityExtension.java @@ -0,0 +1,5 @@ +package com.eriksonn.createaeronautics.blocks.propeller_bearing; + +public interface MecanicalBearingTileEntityExtension { + boolean isPropeller(); +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java index b75315e..7ebeaf1 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/propeller_bearing/PropellerBearingTileEntity.java @@ -1,14 +1,11 @@ package com.eriksonn.createaeronautics.blocks.propeller_bearing; -import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonTileEntity; import com.eriksonn.createaeronautics.particle.PropellerAirParticleData; import com.simibubi.create.AllTags; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; - -import com.simibubi.create.content.contraptions.particle.AirParticleData; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; @@ -17,7 +14,6 @@ import com.simibubi.create.foundation.utility.ServerSpeedProvider; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntityType; @@ -33,7 +29,7 @@ import java.util.List; import java.util.Map; -public class PropellerBearingTileEntity extends MechanicalBearingTileEntity{ +public class PropellerBearingTileEntity extends MechanicalBearingTileEntity implements MecanicalBearingTileEntityExtension{ public ScrollOptionBehaviour movementDirection; protected float lastGeneratedSpeed; public List sailPositions; @@ -258,6 +254,11 @@ protected void setBlockDirection(PropellerBearingBlock.Direction direction) { notifyUpdate(); } + @Override + public boolean isPropeller() { + return true; + } + static enum RotationDirection implements INamedIconOptions { CLOCKWISE(AllIcons.I_REFRESH), COUNTER_CLOCKWISE(AllIcons.I_ROTATE_CCW), diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java index 5f0edb5..10435d4 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/MechanicalBearingTileEntityMixin.java @@ -1,5 +1,6 @@ package com.eriksonn.createaeronautics.mixins; +import com.eriksonn.createaeronautics.blocks.propeller_bearing.MecanicalBearingTileEntityExtension; import com.eriksonn.createaeronautics.utils.BearingContraptionExtension; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; @@ -11,14 +12,19 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(MechanicalBearingTileEntity.class) -public class MechanicalBearingTileEntityMixin { +public class MechanicalBearingTileEntityMixin implements MecanicalBearingTileEntityExtension { @Redirect( method = "assemble()V", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption;assemble(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z", remap = false), remap = false ) private boolean onTryAssemble(BearingContraption contraption, World world, BlockPos pos) throws AssemblyException { - ((BearingContraptionExtension) contraption).setPropeller(); + if (isPropeller()) ((BearingContraptionExtension) contraption).setPropeller(); return contraption.assemble(world, pos); } + + @Override + public boolean isPropeller() { + return false; + } } From a02d40e57a1f1a1caf6c316dafb22ba173f1b8e5 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 25 Mar 2022 21:03:32 +0100 Subject: [PATCH 6/7] Added Stirling engine --- src/generated/resources/.cache/cache | 9 +- .../assets/createaeronautics/lang/en_ud.json | 4 + .../assets/createaeronautics/lang/en_us.json | 4 + .../models/item/levitite_casing.json | 2 +- .../CreateAeronauticsClient.java | 6 + .../stirling_engine/StirlingEngineBlock.java | 108 ++++++++- .../StirlingEngineInstance.java | 112 +++++++++ .../StirlingEngineItemHandler.java | 117 ++++++++++ .../StirlingEngineRenderer.java | 77 +++++++ .../StirlingEngineTileEntity.java | 214 ++++++++++++++++++ .../createaeronautics/events/DataEvents.java | 4 + .../index/CABlockPartials.java | 3 +- .../createaeronautics/index/CAShapes.java | 5 +- .../index/CATileEntities.java | 4 + .../SimulatedContraptionRigidbody.java | 2 +- .../ponder/CAPonderIndex.java | 15 ++ .../ponder/KineticScenes.java | 94 ++++++++ .../utils/BlockStateUtils.java | 3 +- .../recipes/crafting/stirling_engine.json | 29 +++ 19 files changed, 798 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineInstance.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineItemHandler.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineRenderer.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/ponder/CAPonderIndex.java create mode 100644 src/main/java/com/eriksonn/createaeronautics/ponder/KineticScenes.java create mode 100644 src/main/resources/data/createaeronautics/recipes/crafting/stirling_engine.json diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index b6bf646..62d94a8 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -2,15 +2,14 @@ a46ab507ff2143e0354586a09eb4a47a710df479 assets/createaeronautics/blockstates/ai 388cbfb2ec3b4b10e3c534a347f56ff799688525 assets/createaeronautics/blockstates/levitite_casing.json f03bd9993220fb1d344cec8604dbd88d3b7b1275 assets/createaeronautics/blockstates/propeller_bearing.json 1d6fcfae6cc5e594163e320cfc3d9c8b791a6e1c assets/createaeronautics/blockstates/stationary_potato_cannon.json -155ca4bb6230a8d066884fb36d705af9ca9fba1c assets/createaeronautics/blockstates/stirling_engine.json +ec6500ca9e9055d656869cd2ff306d420eb8bd1b assets/createaeronautics/blockstates/stirling_engine.json 56f827d9b1dcf205d37a6a9ee82019e2b9498330 assets/createaeronautics/blockstates/torsion_spring.json -c6ebf0a9bbeb758fe073feafc9ca76cd0c7ce7d0 assets/createaeronautics/lang/en_ud.json -24dfe9eec5b6eb14059de0440eaa94bb8757979e assets/createaeronautics/lang/en_us.json +d12e1d568d692a8d3b41e6b87cfd2478d4f5a82e assets/createaeronautics/lang/en_ud.json +cf023ab6131053f637e08900a750be2bda1e17f4 assets/createaeronautics/lang/en_us.json dd3444734415a2561192315a438498716b0a325a assets/createaeronautics/models/block/levitite_casing.json -ba3e5b5596e58ed4bd49ebec835963b743f8487d assets/createaeronautics/models/block/stirling_engine.json 5eb012264762a5949ac970bebf2675d258e005ff assets/createaeronautics/models/item/airship_assembler.json 194aefcc12c8a23ac02b86462b1ec69f2584f8d6 assets/createaeronautics/models/item/endstone_powder.json -5871bf294c63708c0d684eb8f5193bdc1896a160 assets/createaeronautics/models/item/levitite_casing.json +63155e7cee935a962fb05bd7ac7e6d612c8e0f76 assets/createaeronautics/models/item/levitite_casing.json 6ae86017bfb5b00c38c693e7ed965b6214427d7e assets/createaeronautics/models/item/propeller_bearing.json 7fc727516fad944ede696160be5c0240585e4caa assets/createaeronautics/models/item/stationary_potato_cannon.json 43a71f91f857e9cc3f5196a9ddc97564a06893ad assets/createaeronautics/models/item/stirling_engine.json diff --git a/src/generated/resources/assets/createaeronautics/lang/en_ud.json b/src/generated/resources/assets/createaeronautics/lang/en_ud.json index d0f651b..b5cf74d 100644 --- a/src/generated/resources/assets/createaeronautics/lang/en_ud.json +++ b/src/generated/resources/assets/createaeronautics/lang/en_ud.json @@ -5,6 +5,10 @@ "block.createaeronautics.stationary_potato_cannon": "uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S", "block.createaeronautics.stirling_engine": "\u01DDu\u0131bu\u018E bu\u0131\u05DF\u0279\u0131\u0287S", "block.createaeronautics.torsion_spring": "bu\u0131\u0279dS uo\u0131s\u0279o\u27D8", + "createaeronautics.ponder.stirling_engine.header": "\u01DDu\u0131bu\u018E bu\u0131\u05DF\u0279\u0131\u0287S \u01DD\u0265\u0287 bu\u0131sn \u01DD\u0254\u0279o\u2132 \u05DF\u0250uo\u0131\u0287\u0250\u0287o\u1D1A bu\u0131\u0287\u0250\u0279\u01DDu\u01DD\u2141", + "createaeronautics.ponder.stirling_engine.text_1": "\u05DF\u01DDn\u025F bu\u0131u\u0279nq \u028Eq \u01DD\u0254\u0279o\u025F \u05DF\u0250uo\u0131\u0287\u0250\u0287o\u0279 s\u01DD\u0287\u0250\u0279\u01DDu\u01DDb \u01DDu\u0131bu\u018E bu\u0131\u05DF\u0279\u0131\u0287S \u01DD\u0265\u27D8", + "createaeronautics.ponder.stirling_engine.text_2": "\u028E\u0287\u0131\u0254\u0250d\u0250\u0254 ss\u01DD\u0279\u0287s \u025Fo \u0287uno\u026F\u0250 \u01DD\u0287\u0250\u0279\u01DDpo\u026F \u0250 s\u01DDp\u0131\u028Co\u0279d \u01DDu\u0131bu\u01DD \u01DD\u0265\u27D8", + "createaeronautics.ponder.stirling_engine.text_3": "su\u0250\u01DD\u026F \u0254\u0131\u0287\u0250\u026Fo\u0287n\u0250 \u028Eq p\u01DD\u0287\u0279\u01DDsu\u0131 \u01DDq u\u0250\u0254 \u05DF\u01DDn\u2132", "death.attack.createaeronautics.stationary_potato_cannon": "uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S \u0250 \u028Eq \u0287o\u0265s s\u0250\u028D %1$s", "death.attack.createaeronautics.stationary_potato_cannon.item": "%2$s bu\u0131sn uouu\u0250\u0186 o\u0287\u0250\u0287o\u0500 \u028E\u0279\u0250uo\u0131\u0287\u0250\u0287S \u0250 \u028Eq \u0287o\u0265s s\u0250\u028D %1$s", "entity.createaeronautics.airship_contraption": "uo\u0131\u0287d\u0250\u0279\u0287uo\u0186 d\u0131\u0265s\u0279\u0131\u2C6F", diff --git a/src/generated/resources/assets/createaeronautics/lang/en_us.json b/src/generated/resources/assets/createaeronautics/lang/en_us.json index 70a6e70..956abb2 100644 --- a/src/generated/resources/assets/createaeronautics/lang/en_us.json +++ b/src/generated/resources/assets/createaeronautics/lang/en_us.json @@ -5,6 +5,10 @@ "block.createaeronautics.stationary_potato_cannon": "Stationary Potato Cannon", "block.createaeronautics.stirling_engine": "Stirling Engine", "block.createaeronautics.torsion_spring": "Torsion Spring", + "createaeronautics.ponder.stirling_engine.header": "Generating Rotational Force using the Stirling Engine", + "createaeronautics.ponder.stirling_engine.text_1": "The Stirling Engine generates rotational force by burning fuel", + "createaeronautics.ponder.stirling_engine.text_2": "The engine provides a moderate amount of stress capacity", + "createaeronautics.ponder.stirling_engine.text_3": "Fuel can be inserted by automatic means", "death.attack.createaeronautics.stationary_potato_cannon": "%1$s was shot by a Stationary Potato Cannon", "death.attack.createaeronautics.stationary_potato_cannon.item": "%1$s was shot by a Stationary Potato Cannon using %2$s", "entity.createaeronautics.airship_contraption": "Airship Contraption", diff --git a/src/generated/resources/assets/createaeronautics/models/item/levitite_casing.json b/src/generated/resources/assets/createaeronautics/models/item/levitite_casing.json index 87dc9a8..008f70f 100644 --- a/src/generated/resources/assets/createaeronautics/models/item/levitite_casing.json +++ b/src/generated/resources/assets/createaeronautics/models/item/levitite_casing.json @@ -1,3 +1,3 @@ { - "parent": "createaeronautics:block/levitite_casing/item" + "parent": "createaeronautics:block/levitite_casing" } \ No newline at end of file diff --git a/src/main/java/com/eriksonn/createaeronautics/CreateAeronauticsClient.java b/src/main/java/com/eriksonn/createaeronautics/CreateAeronauticsClient.java index de3522c..4fcb575 100644 --- a/src/main/java/com/eriksonn/createaeronautics/CreateAeronauticsClient.java +++ b/src/main/java/com/eriksonn/createaeronautics/CreateAeronauticsClient.java @@ -1,11 +1,17 @@ package com.eriksonn.createaeronautics; import com.eriksonn.createaeronautics.index.CAParticleTypes; +import com.eriksonn.createaeronautics.ponder.CAPonderIndex; import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateAeronauticsClient { public static void onCtorClient(IEventBus modEventBus, IEventBus forgeEventBus) { modEventBus.addListener(CAParticleTypes::registerFactories); + modEventBus.addListener(CreateAeronauticsClient::clientInit); } + public static void clientInit(final FMLClientSetupEvent event) { + CAPonderIndex.register(); + } } diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java index 4f2574c..d375877 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java @@ -1,28 +1,65 @@ package com.eriksonn.createaeronautics.blocks.stirling_engine; +import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingBlock; +import com.eriksonn.createaeronautics.index.CAShapes; import com.eriksonn.createaeronautics.index.CATileEntities; +import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; +import com.simibubi.create.foundation.item.ItemHelper; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; +import net.minecraftforge.items.ItemHandlerHelper; + +import java.util.function.Consumer; + +import static net.minecraft.block.AbstractFurnaceBlock.LIT; public class StirlingEngineBlock extends HorizontalKineticBlock { public StirlingEngineBlock(Properties properties) { super(properties); + this.registerDefaultState(this.defaultBlockState().setValue(LIT, false)); } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return CATileEntities.STIRLING_ENGINE.create(); + + } + @Override + protected void createBlockStateDefinition(StateContainer.Builder builder) { + builder.add(LIT); + super.createBlockStateDefinition(builder); + } + @Override + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { + StirlingEngineTileEntity te = (StirlingEngineTileEntity) worldIn.getBlockEntity(pos); + if (!te.currentStack.isEmpty()) + InventoryHelper.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), te.currentStack); + worldIn.removeBlockEntity(pos); + } } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face == state.getValue(HORIZONTAL_FACING).getOpposite(); + return face == state.getValue(HORIZONTAL_FACING); } @Override public Direction.Axis getRotationAxis(BlockState state) { @@ -31,8 +68,71 @@ public Direction.Axis getRotationAxis(BlockState state) { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredHorizontalFacing(context); - if (preferred != null) - return defaultBlockState().setValue(HORIZONTAL_FACING, preferred.getOpposite()); - return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection()); + if (preferred == null || (context.getPlayer() != null && context.getPlayer().isShiftKeyDown())) { + Direction horizontalDirection = context.getHorizontalDirection(); + return defaultBlockState().setValue(HORIZONTAL_FACING, (context.getPlayer() != null && context.getPlayer() + .isShiftKeyDown()) ? horizontalDirection.getOpposite():horizontalDirection); + } + return defaultBlockState().setValue(HORIZONTAL_FACING, preferred); + + } + @Override + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + BlockRayTraceResult hit) { + ItemStack heldByPlayer = player.getItemInHand(handIn) + .copy(); + if (AllItems.WRENCH.isIn(heldByPlayer)) + return ActionResultType.PASS; + + + if (worldIn.isClientSide) + return ActionResultType.SUCCESS; + StirlingEngineTileEntity te = (StirlingEngineTileEntity)worldIn.getBlockEntity(pos); + + ItemStack cannonItem = te.currentStack.copy(); + if (cannonItem.isEmpty() && heldByPlayer.isEmpty()) + return ActionResultType.SUCCESS; + if((!heldByPlayer.isEmpty() && !te.invHandler.orElse(null).isItemValid(0,heldByPlayer))) + return ActionResultType.PASS; + if(cannonItem.isEmpty()) + { + te.currentStack =heldByPlayer; + player.setItemInHand(handIn,ItemStack.EMPTY); + + }else + if(!heldByPlayer.isEmpty()) + { + if(!ItemHandlerHelper.canItemStacksStack(cannonItem, heldByPlayer)) + { + return ActionResultType.SUCCESS; + }else + { + int TargetAmount=cannonItem.getCount()+heldByPlayer.getCount(); + int TransferAmount = Math.min(TargetAmount-cannonItem.getCount(),heldByPlayer.getCount()); + if(TransferAmount==0) + return ActionResultType.SUCCESS; + te.currentStack.shrink(-TransferAmount); + heldByPlayer.shrink(TransferAmount); + player.setItemInHand(handIn,heldByPlayer); + } + }else + { + te.currentStack=ItemStack.EMPTY; + player.setItemInHand(handIn,cannonItem); + } + + te.sendData(); + + return ActionResultType.SUCCESS; + } + @Override + public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) + { + return CAShapes.STIRLING_ENGINE.get(state.getValue(HORIZONTAL_FACING)); + + } + + public static boolean isLitState(BlockState blockState) { + return blockState.getValue(LIT); } } diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineInstance.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineInstance.java new file mode 100644 index 0000000..756a185 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineInstance.java @@ -0,0 +1,112 @@ +package com.eriksonn.createaeronautics.blocks.stirling_engine; + +import com.eriksonn.createaeronautics.index.CABlockPartials; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.Instancer; +import com.jozufozu.flywheel.backend.material.InstanceMaterial; +import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.jozufozu.flywheel.core.materials.ModelData; +import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.KineticTileInstance; +import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.utility.AngleHelper; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import net.minecraft.util.Direction; +import net.minecraft.util.math.vector.Vector3d; + +import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; + + +public class StirlingEngineInstance extends KineticTileInstance implements IDynamicInstance { + + protected final Direction facing; + protected final RotatingData shaft; + protected ModelData[] pistons=new ModelData[4]; + public StirlingEngineInstance(MaterialManager modelManager, StirlingEngineTileEntity tile) { + super(modelManager, tile); + + facing = blockState.getValue(HORIZONTAL_FACING); + shaft = setup(shaftModel().createInstance()); + for (int i =0;i<4;i++) + { + InstanceMaterial mat = getTransformMaterial(); + pistons[i]=mat.getModel(CABlockPartials.ENGINE_PISTON, blockState).createInstance(); + } + } + + @Override + public void beginFrame() { + float partialTicks = AnimationTickHolder.getPartialTicks(); + float speed = tile.visualSpeed.get(partialTicks) * 3 / 10f; + float angle = tile.angle + speed * partialTicks; + + animate(angle); + } + private void animate(float angle) { + MatrixStack ms = new MatrixStack(); + MatrixTransformStack msr = MatrixTransformStack.of(ms); + + msr.translate(getInstancePosition()); + + float rotation = + facing .getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle + : angle; + ms.pushPose(); + rotateToFacing(msr,facing); + for (int i =0;i<4;i++) { + ms.pushPose(); + int y = i/2; + int x = i%2; + + double shift = Math.sin((rotation- i*90+45) * Math.PI / 180.0)*1.5f; + + msr.centre(); + msr.rotate(Direction.SOUTH,(float)(Math.PI*0.25 * (x*2-1))); + msr.translate(0,1.5/16.0,0); + msr.unCentre(); + msr.translate(0,(6.5 + shift) / 16.0,(7.5+y*4)/16.0); + + pistons[i].setTransform(ms); + ms.popPose(); + } + ms.popPose(); + msr.centre() + .rotate(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)) + .unCentre(); + } + + @Override + public void remove() { + shaft.delete(); + for (int i =0;i<4;i++) + { + pistons[i].delete(); + } + } + @Override + public void update() { + updateRotation(shaft); + } + + @Override + public void updateLight() { + relight(pos, shaft); + relight(pos,pistons); + //if (connection != null) { + // relight(this.pos.relative(connection), connectors.stream()); + //} + } + protected Instancer shaftModel() { + Direction opposite = facing; + return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite); + } + protected void rotateToFacing(MatrixTransformStack buffer, Direction facing) { + buffer.centre() + .rotate(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing))) + .unCentre(); + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineItemHandler.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineItemHandler.java new file mode 100644 index 0000000..d3b5b41 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineItemHandler.java @@ -0,0 +1,117 @@ +package com.eriksonn.createaeronautics.blocks.stirling_engine; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.ItemHandlerHelper; + +import javax.annotation.Nonnull; + +public class StirlingEngineItemHandler implements IItemHandlerModifiable { + private StirlingEngineTileEntity te; + public StirlingEngineItemHandler(StirlingEngineTileEntity te) + { + this.te=te; + } + @Override + public void setStackInSlot(int slot, ItemStack stack) { + set(stack); + } + public void set(ItemStack stack) { + if (this.te.currentStack != null) { + if (!this.te.getLevel().isClientSide) { + this.te.currentStack=stack; + this.te.setChanged(); + this.te.sendData(); + } + } + } + @Override + public int getSlots() { + return 1; + } + public ItemStack getHeld() { + return this.te.currentStack == null ? ItemStack.EMPTY : this.te.currentStack; + } + @Nonnull + @Override + public ItemStack getStackInSlot(int slot) { + return this.te.currentStack; + } + + @Nonnull + @Override + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + ItemStack held = this.getHeld(); + if (!this.isItemValid(slot, stack)) { + return stack; + } + if (held.isEmpty()) { + if (!simulate) { + this.set(stack); + } + return ItemStack.EMPTY; + } + if (!ItemHandlerHelper.canItemStacksStack(held, stack)) + return stack; + int space = held.getMaxStackSize() - held.getCount(); + ItemStack remainder = stack.copy(); + ItemStack split = remainder.split(space); + if (space == 0) { + return stack; + } else { + if (!simulate) { + held = held.copy(); + held.setCount(held.getCount() + split.getCount()); + this.set(held); + } + + return remainder; + } + + } + + @Nonnull + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + + if (amount == 0) { + return ItemStack.EMPTY; + } + ItemStack extractedFromOverflow = ItemStack.EMPTY; + ItemStack returnToOverflow = ItemStack.EMPTY; + //Iterator iterator = this.te.overflowItems.iterator(); + ItemStack toReturn; + + if (!extractedFromOverflow.isEmpty()) { + return extractedFromOverflow; + } else { + ItemStack held = this.getHeld(); + if (!held.isEmpty()) { + + if (simulate) { + return held.copy().split(amount); + } else { + toReturn = held.split(amount); + this.te.setChanged(); + this.te.sendData(); + return toReturn; + } + } else { + return ItemStack.EMPTY; + } + } + + } + + @Override + public int getSlotLimit(int slot) { + if(!this.te.currentStack.isEmpty()) + return this.getHeld().getMaxStackSize(); + return 64; + } + + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return net.minecraftforge.common.ForgeHooks.getBurnTime(stack, null)>0; + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineRenderer.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineRenderer.java new file mode 100644 index 0000000..e74e2c0 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineRenderer.java @@ -0,0 +1,77 @@ +package com.eriksonn.createaeronautics.blocks.stirling_engine; + +import com.eriksonn.createaeronautics.index.CABlockPartials; +import com.jozufozu.flywheel.backend.Backend; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; +import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; +import com.simibubi.create.foundation.utility.AngleHelper; +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3i; + +public class StirlingEngineRenderer extends KineticTileEntityRenderer { + + public StirlingEngineRenderer(TileEntityRendererDispatcher dispatcher) { + super(dispatcher); + }@Override + protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + int light, int overlay) { + super.renderSafe(te, partialTicks, ms, buffer, light, overlay); + FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + + Direction direction = te.getBlockState() + .getValue(BlockStateProperties.HORIZONTAL_FACING); + BlockState blockState = te.getBlockState(); + + StirlingEngineTileEntity wte = (StirlingEngineTileEntity)te; + + float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f; + float angle = wte.angle + speed * partialTicks; + + float rotation = + direction .getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle + : angle; + + for (int i =0;i<4;i++) { + + int y = i/2; + int x = i%2; + + double shift = Math.sin((rotation- i*90+45) * Math.PI / 180.0)*1.5f; + + SuperByteBuffer buf = PartialBufferer.get(CABlockPartials.ENGINE_PISTON, blockState); + + buf.rotateCentered(direction, (float) (Math.PI * 0.25 * (x*2-1))); + buf.translate(rotateY(new Vector3d(0, (8.0 + shift) / 16.0, (7.5+y*4) / 16.0), direction)); + + rotateToFacing(buf, direction).light(light).renderInto(ms, vb); + } + } + @Override + protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { + return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() + .getValue(BlockStateProperties.HORIZONTAL_FACING)); + } + protected SuperByteBuffer rotateToFacing(SuperByteBuffer buffer, Direction facing) { + buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing))); + return buffer; + } + Vector3d rotateY(Vector3d v,Direction facing) + { + Vector3i N= facing.getNormal(); + return new Vector3d(v.x*N.getZ() + v.z*N.getX(),v.y,v.z*N.getZ() - v.x*N.getX()); + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java index 551f3e1..2e52153 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineTileEntity.java @@ -1,10 +1,224 @@ package com.eriksonn.createaeronautics.blocks.stirling_engine; +import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingBlock; +import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.CannonItemHandler; +import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; +import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock; +import com.simibubi.create.content.curiosities.weapons.PotatoCannonProjectileType; +import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.Direction; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.ItemStackHandler; + +import java.util.List; + +import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; +import static net.minecraft.block.AbstractFurnaceBlock.LIT; public class StirlingEngineTileEntity extends GeneratingKineticTileEntity { + + int burnTime=0; + float generatedSpeed; + float generatedCapacity = 32; + protected ItemStack currentStack; + public LazyOptional invHandler; + // Client + InterpolatedChasingValue visualSpeed = new InterpolatedChasingValue(); + float angle; + public StirlingEngineTileEntity(TileEntityType typeIn) { super(typeIn); + this.currentStack = ItemStack.EMPTY; + } + public void initialize() { + super.initialize(); + this.invHandler = LazyOptional.of(this::createHandler); + + } + public LazyOptional getCapability(Capability cap, Direction side) { + return this.isItemHandlerCap(cap) && this.invHandler != null ? this.invHandler.cast() : super.getCapability(cap, side); + } + @Override + public float getGeneratedSpeed() { + return convertToDirection(generatedSpeed, getBlockState().getValue(HORIZONTAL_FACING)); + } + + @Override + public float calculateAddedStressCapacity() { + return lastCapacityProvided = generatedCapacity; } + + @Override + public void tick() { + super.tick(); + + if (level.isClientSide) { + float targetSpeed = isVirtual() ? speed : getGeneratedSpeed(); + visualSpeed.target(targetSpeed); + visualSpeed.tick(); + angle += visualSpeed.value * 3 / 10f; + angle %= 360; + + } + if(isVirtual()) + { + return; + } + + if (getGeneratedSpeed() != 0 && getSpeed() == 0) + updateGeneratedRotation(); + if (getGeneratedSpeed() == 0 && getSpeed() != 0) + updateGeneratedRotation(); + if(burnTime>0) burnTime--; + if(burnTime<=0&&!currentStack.isEmpty()) + { + burnTime = net.minecraftforge.common.ForgeHooks.getBurnTime(currentStack, null); + if(burnTime>0) { + if (currentStack.getCount() == 1 && currentStack.hasContainerItem()) + currentStack = currentStack.getContainerItem(); + else + currentStack.shrink(1); + } + + } + + boolean isLit = burnTime>0; + + if(isLit && level.isClientSide) + { + spawnParticles(); + } + + boolean isLitState = StirlingEngineBlock.isLitState(this.getBlockState()); + generatedSpeed = isLit?32:0; + + if(isLitState && !isLit) + { + level.setBlock(getBlockPos(), this.getBlockState().setValue(LIT,false), 2); + } + if(!isLitState && isLit) + { + level.setBlock(getBlockPos(), this.getBlockState().setValue(LIT,true), 2); + } + } + void spawnParticles() + { + if(Create.RANDOM.nextFloat()<0.12) { + Vector3d pos = VecHelper.getCenterOf(this.worldPosition); + + Direction direction = getBlockState() + .getValue(BlockStateProperties.HORIZONTAL_FACING); + Vector3i N = direction.getNormal(); + Vector3d N2 = new Vector3d(N.getX(),N.getY(),N.getZ()); + pos = pos.add(-N.getX() * 0.53, -0.1, -N.getZ() * 0.53); + + Vector3d random = VecHelper.offsetRandomly(Vector3d.ZERO,Create.RANDOM,0.15f); + random = random.subtract(N2.scale(random.dot(N2))); + pos=pos.add(random); + + Vector3d speed = VecHelper.offsetRandomly(Vector3d.ZERO,Create.RANDOM,0.01f); + + level.addParticle(ParticleTypes.SMOKE, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); + } + } + public void write(CompoundNBT compound, boolean clientPacket) { + super.write(compound, clientPacket); + compound.putFloat("GeneratedSpeed", generatedSpeed); + compound.put("CurrentStack", this.currentStack.serializeNBT()); + compound.putInt("BurnTime",burnTime); + } + protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + super.fromTag(blockState, compound, clientPacket); + this.currentStack = ItemStack.of(compound.getCompound("CurrentStack")); + burnTime=compound.getInt("BurnTime"); + generatedSpeed = compound.getFloat("GeneratedSpeed"); + + if (clientPacket) + visualSpeed.withSpeed(1 / 8f) + .target(getGeneratedSpeed()); + } + private IItemHandlerModifiable createHandler() { + return new StirlingEngineItemHandler(this); + } + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + super.addToGoggleTooltip(tooltip, isPlayerSneaking); + tooltip.add(componentSpacing.plainCopy() + .append("")); + tooltip.add(componentSpacing.plainCopy() + .append("Stirling engine:")); + boolean hasByproduct = net.minecraftforge.common.ForgeHooks.getBurnTime(currentStack, null)==0; + if(currentStack.isEmpty()) + { + tooltip.add(componentSpacing.plainCopy().plainCopy() + .append(" Fuel: ") + .withStyle(TextFormatting.GRAY).append("None").withStyle(TextFormatting.RED)); + + }else { + if(!hasByproduct) { + tooltip.add(componentSpacing.plainCopy().plainCopy() + .append(" Fuel: " + new TranslationTextComponent(currentStack.getItem() + .getDescriptionId(currentStack)).getString() + " x" + currentStack.getCount()) + .withStyle(TextFormatting.GREEN)); + }else + { + tooltip.add(componentSpacing.plainCopy().plainCopy() + .append(" Byproduct: ") + .withStyle(TextFormatting.GRAY).append(new TranslationTextComponent(currentStack.getItem() + .getDescriptionId(currentStack)).getString() + " x" + currentStack.getCount()) + .withStyle(TextFormatting.YELLOW)); + } + + } + if(burnTime>0) + { + int sec = burnTime/20; + + tooltip.add(componentSpacing.plainCopy().plainCopy() + .append(new StringTextComponent(" Burn time: ").withStyle(TextFormatting.GRAY)) + .append(new StringTextComponent(getTime(sec)).withStyle(TextFormatting.AQUA))); + if(!currentStack.isEmpty() && !hasByproduct) { + int totalSec = sec; + totalSec+=currentStack.getCount()*net.minecraftforge.common.ForgeHooks.getBurnTime(currentStack, null)/20; + tooltip.add(componentSpacing.plainCopy() + .append(new StringTextComponent(" Burn time total: ").withStyle(TextFormatting.GRAY)) + .append(new StringTextComponent(getTime(totalSec)).withStyle(TextFormatting.AQUA))); + } + } + return true; + } + String getTime(int sec) + { + String s=""; + int min = sec/60; + int hour = min/60; + sec=Math.floorMod(sec,60); + min=Math.floorMod(min,60); + if(hour>0) + s += hour+"h "; + if(min<10&&hour>0) + s+=0; + if(min>0||hour>0) + s += min+"m "; + if(sec<10&&min>0) + s+=0; + s+=sec+"s"; + return s; + } + } diff --git a/src/main/java/com/eriksonn/createaeronautics/events/DataEvents.java b/src/main/java/com/eriksonn/createaeronautics/events/DataEvents.java index d6e9254..66c2672 100644 --- a/src/main/java/com/eriksonn/createaeronautics/events/DataEvents.java +++ b/src/main/java/com/eriksonn/createaeronautics/events/DataEvents.java @@ -1,6 +1,8 @@ package com.eriksonn.createaeronautics.events; import com.eriksonn.createaeronautics.CreateAeronautics; +import com.eriksonn.createaeronautics.ponder.CAPonderIndex; +import com.simibubi.create.foundation.ponder.PonderLocalization; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -26,5 +28,7 @@ public static void gatherData(GatherDataEvent event) { "item", "%1$s was shot by a Stationary Potato Cannon using %2$s" ); + CAPonderIndex.register(); + PonderLocalization.provideRegistrateLang(CreateAeronautics.registrate()); } } diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CABlockPartials.java b/src/main/java/com/eriksonn/createaeronautics/index/CABlockPartials.java index bc022e8..541a85f 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CABlockPartials.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CABlockPartials.java @@ -8,7 +8,8 @@ public class CABlockPartials { public static final PartialModel CANNON_BARREL = get("stationary_potato_cannon/barrel"), - CANNON_BELLOW = get("stationary_potato_cannon/bellow"); + CANNON_BELLOW = get("stationary_potato_cannon/bellow"), + ENGINE_PISTON = get("stirling_engine/piston"); private static PartialModel get(String path) { ResourceLocation L = new ResourceLocation(CreateAeronautics.MODID, "block/" + path); diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CAShapes.java b/src/main/java/com/eriksonn/createaeronautics/index/CAShapes.java index ffa8c34..6c00ffd 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CAShapes.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CAShapes.java @@ -29,7 +29,10 @@ public class CAShapes { .add(2, 4, 2, 14, 12, 14) .add(4, 12, 4, 12, 13, 12) .add(6, 13, 6,10, 16, 10) - .forAxis(); + .forAxis(), + STIRLING_ENGINE = shape(0,0,0,16,2,16) + .add(3,2,0,13,12,16) + .forDirectional(Direction.NORTH); private static CAShapes.Builder shape(VoxelShape shape) { return new CAShapes.Builder(shape); } diff --git a/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java b/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java index 82448a0..178842b 100644 --- a/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java +++ b/src/main/java/com/eriksonn/createaeronautics/index/CATileEntities.java @@ -4,6 +4,8 @@ import com.eriksonn.createaeronautics.CreateAeronautics; import com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity; import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingTileEntity; +import com.eriksonn.createaeronautics.blocks.stirling_engine.StirlingEngineInstance; +import com.eriksonn.createaeronautics.blocks.stirling_engine.StirlingEngineRenderer; import com.eriksonn.createaeronautics.blocks.stirling_engine.StirlingEngineTileEntity; import com.eriksonn.createaeronautics.blocks.torsion_spring.TorsionSpringTileEntity; import com.eriksonn.createaeronautics.blocks.stationary_potato_cannon.StationaryPotatoCannonInstance; @@ -42,7 +44,9 @@ public class CATileEntities { .register(); public static final TileEntityEntry STIRLING_ENGINE = CreateAeronautics.registrate() .tileEntity("stirling_engine", StirlingEngineTileEntity::new) + .instance(() -> StirlingEngineInstance::new) .validBlocks(CABlocks.STIRLING_ENGINE) + .renderer(() -> StirlingEngineRenderer::new) .register(); public static void register() {} } diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java index c033661..dc9518d 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java @@ -617,7 +617,7 @@ public Vector3d getVelocity() { } public Vector3d getVelocityAtPoint(Vector3d pos) { - return globalVelocity.add(pos.cross(angularVelocity)); + return globalVelocity.add(rotate(pos.cross(angularVelocity))); } public Vector3d getAngularVelocity() { diff --git a/src/main/java/com/eriksonn/createaeronautics/ponder/CAPonderIndex.java b/src/main/java/com/eriksonn/createaeronautics/ponder/CAPonderIndex.java new file mode 100644 index 0000000..963a377 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/ponder/CAPonderIndex.java @@ -0,0 +1,15 @@ +package com.eriksonn.createaeronautics.ponder; + +import com.eriksonn.createaeronautics.CreateAeronautics; +import com.eriksonn.createaeronautics.index.CABlocks; +import com.eriksonn.createaeronautics.ponder.KineticScenes; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.ponder.PonderRegistrationHelper; + +public class CAPonderIndex { + static final PonderRegistrationHelper HELPER = new PonderRegistrationHelper(CreateAeronautics.MODID); + public static void register() { + HELPER.forComponents(CABlocks.STIRLING_ENGINE).addStoryBoard("stirling_engine",KineticScenes::stirlingEngine); + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/ponder/KineticScenes.java b/src/main/java/com/eriksonn/createaeronautics/ponder/KineticScenes.java new file mode 100644 index 0000000..965b186 --- /dev/null +++ b/src/main/java/com/eriksonn/createaeronautics/ponder/KineticScenes.java @@ -0,0 +1,94 @@ +package com.eriksonn.createaeronautics.ponder; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; +import com.simibubi.create.foundation.ponder.ElementLink; +import com.simibubi.create.foundation.ponder.SceneBuilder; +import com.simibubi.create.foundation.ponder.SceneBuildingUtil; +import com.simibubi.create.foundation.ponder.elements.EntityElement; +import com.simibubi.create.foundation.ponder.elements.InputWindowElement; +import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstruction; +import com.simibubi.create.foundation.utility.Pointing; +import net.minecraft.block.AbstractFurnaceBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.FurnaceBlock; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; + +public class KineticScenes { + public static void stirlingEngine(SceneBuilder scene, SceneBuildingUtil util) + { + scene.title("stirling_engine", "Generating Rotational Force using the Stirling Engine"); + scene.configureBasePlate(0, 0, 5); + scene.world.showSection(util.select.layer(0), Direction.UP); + scene.idle(10); + + + scene.world.showSection(util.select.fromTo(2, 1, 1, 2, 2, 3), Direction.DOWN); + + BlockPos enginePos = util.grid.at(2, 2, 1); + BlockPos shaftPos = util.grid.at(2, 2, 2); + scene.idle(10); + scene.overlay.showText(80) + .attachKeyFrame() + .placeNearTarget() + .pointAt(util.vector.topOf(enginePos)) + .text("The Stirling Engine generates rotational force by burning fuel"); + scene.idle(20); + scene.overlay.showControls( + new InputWindowElement(util.vector.topOf(enginePos), Pointing.DOWN).withItem(new ItemStack(Items.COAL)), + 30); + scene.world.cycleBlockProperty(enginePos, AbstractFurnaceBlock.LIT); + scene.world.setKineticSpeed(util.select.fromTo(2, 2, 1, 2, 2, 3), 32); + scene.effects.emitParticles(util.vector.of(2.5, 2.2, 0.9), EmitParticlesInstruction.Emitter.simple(ParticleTypes.LAVA, Vector3d.ZERO), 3, + 1); + + scene.idle(80); + + scene.overlay.showText(80) + .attachKeyFrame() + .placeNearTarget() + .pointAt(util.vector.topOf(enginePos.south(2))) + .text("The engine provides a moderate amount of stress capacity"); + + scene.idle(90); + + scene.world.hideSection(util.select.position(shaftPos), Direction.DOWN); + scene.idle(15); + BlockState cogState = AllBlocks.COGWHEEL.getDefaultState(); + scene.world.setBlock(shaftPos,cogState.setValue(CogWheelBlock.AXIS, Direction.Axis.Z),false); + + scene.world.showSection(util.select.position(shaftPos).add(util.select.fromTo(0, 1, 1, 1, 2, 2)), Direction.DOWN); + scene.world.setKineticSpeed(util.select.fromTo(0, 1, 1, 1, 2, 2), -16); + + scene.idle(20); + + scene.overlay.showText(80) + .attachKeyFrame() + .placeNearTarget() + .pointAt(util.vector.topOf(new BlockPos(0,1,1))) + .text("Fuel can be inserted by automatic means"); + + ItemStack stack = Items.CHARCOAL.getDefaultInstance(); + scene.world.createItemOnBelt(new BlockPos(0,1,1), Direction.WEST, stack); + scene.idle(10); + for (int i =0;i<4;i++) { + scene.idle(24); + if(i<3) { + scene.world.createItemOnBelt(new BlockPos(0, 1, 1), Direction.WEST, stack); + } + if(i==1) + { + scene.markAsFinished(); + } + scene.idle(10); + scene.world.removeItemsFromBelt(util.grid.at(1, 1, 1)); + scene.world.flapFunnel(util.grid.at(1, 2, 1), false); + } + } +} diff --git a/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java b/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java index bd13b16..48ec572 100644 --- a/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java +++ b/src/main/java/com/eriksonn/createaeronautics/utils/BlockStateUtils.java @@ -5,6 +5,7 @@ import com.simibubi.create.foundation.data.BlockStateGen; import com.simibubi.create.repack.registrate.providers.DataGenContext; import com.simibubi.create.repack.registrate.providers.RegistrateBlockstateProvider; +import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.state.properties.BlockStateProperties; @@ -27,7 +28,7 @@ public static void directionalPoweredAxi public static void horizontalFacingLitBlockstate(DataGenContext ctx, RegistrateBlockstateProvider prov) { prov.horizontalBlock(ctx.get(), blockState -> prov.models() - .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/block" /*+ (blockState.getValue(BlockStateProperties.LIT) ? "_lit" : "")*/))); + .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/block" + (blockState.getValue(AbstractFurnaceBlock.LIT) ? "_lit" : "")))); } public static void torsionSpringBlockstate(DataGenContext ctx, RegistrateBlockstateProvider prov, diff --git a/src/main/resources/data/createaeronautics/recipes/crafting/stirling_engine.json b/src/main/resources/data/createaeronautics/recipes/crafting/stirling_engine.json new file mode 100644 index 0000000..0bc4b58 --- /dev/null +++ b/src/main/resources/data/createaeronautics/recipes/crafting/stirling_engine.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " N ", + "PCP", + "AFA" + ], + "key": { + "F": { + "item": "minecraft:blast_furnace" + }, + "A": { + "tag": "minecraft:planks" + }, + "C": { + "item": "create:brass_casing" + }, + "N": { + "item": "create:shaft" + }, + "P": { + "tag": "forge:plates/brass" + } + }, + "result": { + "item": "createaeronautics:stirling_engine", + "count": 1 + } +} \ No newline at end of file From 811dfadbe751f032464d185972bf76c5e67cb10b Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 1 Apr 2022 21:29:08 +0200 Subject: [PATCH 7/7] Fixed wings --- .../blockstates/stirling_engine.json | 34 +++ .../models/item/stirling_engine.json | 3 + .../loot_tables/blocks/stirling_engine.json | 19 ++ .../stirling_engine/StirlingEngineBlock.java | 2 +- .../connected/CTSpriteShifter.java | 48 ++++ .../AirshipContraptionEntity.java | 3 +- .../ControlledContraptionEntityMixin.java | 5 + .../physics/AbstractContraptionRigidbody.java | 13 ++ .../SimulatedContraptionRigidbody.java | 82 +++++-- .../physics/SubcontraptionRigidbody.java | 20 +- .../models/block/stirling_engine/block.json | 180 +++++++++++++++ .../block/stirling_engine/block_lit.json | 180 +++++++++++++++ .../block/stirling_engine/block_static.json | 216 ++++++++++++++++++ .../models/block/stirling_engine/item.json | 35 +++ .../models/block/stirling_engine/piston.json | 19 ++ .../block/stirling_engine/piston_left.json | 0 .../block/stirling_engine/piston_right.json | 0 .../ponder/stirling_engine.nbt | Bin 0 -> 802 bytes .../textures/block/stirling_engine.png | Bin 0 -> 1800 bytes 19 files changed, 825 insertions(+), 34 deletions(-) create mode 100644 src/generated/resources/assets/createaeronautics/blockstates/stirling_engine.json create mode 100644 src/generated/resources/assets/createaeronautics/models/item/stirling_engine.json create mode 100644 src/generated/resources/data/createaeronautics/loot_tables/blocks/stirling_engine.json create mode 100644 src/main/java/com/eriksonn/createaeronautics/connected/CTSpriteShifter.java create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/block.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_lit.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_static.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/item.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_left.json create mode 100644 src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_right.json create mode 100644 src/main/resources/assets/createaeronautics/ponder/stirling_engine.nbt create mode 100644 src/main/resources/assets/createaeronautics/textures/block/stirling_engine.png diff --git a/src/generated/resources/assets/createaeronautics/blockstates/stirling_engine.json b/src/generated/resources/assets/createaeronautics/blockstates/stirling_engine.json new file mode 100644 index 0000000..6bcde0f --- /dev/null +++ b/src/generated/resources/assets/createaeronautics/blockstates/stirling_engine.json @@ -0,0 +1,34 @@ +{ + "variants": { + "facing=north,lit=false": { + "model": "createaeronautics:block/stirling_engine/block" + }, + "facing=south,lit=false": { + "model": "createaeronautics:block/stirling_engine/block", + "y": 180 + }, + "facing=west,lit=false": { + "model": "createaeronautics:block/stirling_engine/block", + "y": 270 + }, + "facing=east,lit=false": { + "model": "createaeronautics:block/stirling_engine/block", + "y": 90 + }, + "facing=north,lit=true": { + "model": "createaeronautics:block/stirling_engine/block_lit" + }, + "facing=south,lit=true": { + "model": "createaeronautics:block/stirling_engine/block_lit", + "y": 180 + }, + "facing=west,lit=true": { + "model": "createaeronautics:block/stirling_engine/block_lit", + "y": 270 + }, + "facing=east,lit=true": { + "model": "createaeronautics:block/stirling_engine/block_lit", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/createaeronautics/models/item/stirling_engine.json b/src/generated/resources/assets/createaeronautics/models/item/stirling_engine.json new file mode 100644 index 0000000..ec57900 --- /dev/null +++ b/src/generated/resources/assets/createaeronautics/models/item/stirling_engine.json @@ -0,0 +1,3 @@ +{ + "parent": "createaeronautics:block/stirling_engine/item" +} \ No newline at end of file diff --git a/src/generated/resources/data/createaeronautics/loot_tables/blocks/stirling_engine.json b/src/generated/resources/data/createaeronautics/loot_tables/blocks/stirling_engine.json new file mode 100644 index 0000000..b721492 --- /dev/null +++ b/src/generated/resources/data/createaeronautics/loot_tables/blocks/stirling_engine.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "createaeronautics:stirling_engine" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java index d375877..b6c82f3 100644 --- a/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java +++ b/src/main/java/com/eriksonn/createaeronautics/blocks/stirling_engine/StirlingEngineBlock.java @@ -52,7 +52,7 @@ protected void createBlockStateDefinition(StateContainer.Builder" + connectedTexture; + if (ENTRY_CACHE.containsKey(key)) + return (CTSpriteShiftEntry) ENTRY_CACHE.get(key); + + CTSpriteShiftEntry entry = create(type); + entry.set(blockTexture, connectedTexture); + ENTRY_CACHE.put(key, entry); + return entry; + } + + public static CTSpriteShiftEntry getCT(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type, String blockTextureName, String connectedTextureName) { + return getCT(type, CreateAeronautics.asResource("block/" + blockTextureName), CreateAeronautics.asResource("block/" + connectedTextureName + "_connected")); + } + + public static CTSpriteShiftEntry getCT(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type, String blockTextureName) { + return getCT(type, blockTextureName, blockTextureName); + } + + private static CTSpriteShiftEntry create(com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType type) { + switch (type) { + case HORIZONTAL: + return new CTSpriteShiftEntry.Horizontal(); + case OMNIDIRECTIONAL: + return new CTSpriteShiftEntry.Omnidirectional(); + case VERTICAL: + return new CTSpriteShiftEntry.Vertical(); + case CROSS: + return new CTSpriteShiftEntry.Cross(); + default: + return null; + } + } + + public enum CTType { + OMNIDIRECTIONAL, HORIZONTAL, VERTICAL, CROSS; + } + +} diff --git a/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java b/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java index 748f1e9..34e3b24 100644 --- a/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java +++ b/src/main/java/com/eriksonn/createaeronautics/contraptions/AirshipContraptionEntity.java @@ -72,7 +72,7 @@ public class AirshipContraptionEntity extends AbstractContraptionEntity { public AirshipContraption airshipContraption; public int plotId = 0; public SimulatedContraptionRigidbody simulatedRigidbody; - public Map sails; + public Map subContraptions = new HashMap<>(); public Vector3d centerOfMassOffset = Vector3d.ZERO; public static final DataParameter physicsDataAccessor = EntityDataManager.defineId(AirshipContraptionEntity.class, DataSerializers.COMPOUND_TAG); @@ -85,7 +85,6 @@ protected void defineSynchedData() { public AirshipContraptionEntity(EntityType type, World world) { super(type, world); - sails = new HashMap<>(); simulatedRigidbody = new SimulatedContraptionRigidbody(this); System.out.println("New airship entity"); } diff --git a/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java b/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java index 956ea2e..1fb0cd4 100644 --- a/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java +++ b/src/main/java/com/eriksonn/createaeronautics/mixins/ControlledContraptionEntityMixin.java @@ -2,7 +2,9 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; +import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(ControlledContraptionEntity.class) @@ -10,4 +12,7 @@ public interface ControlledContraptionEntityMixin { @Invoker(value = "makeStructureTransform", remap = false) public StructureTransform invokeMakeStructureTransform(); + + @Accessor(remap = false) + BlockPos getControllerPos(); } diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/AbstractContraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/AbstractContraptionRigidbody.java index 49b344f..fab966d 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/AbstractContraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/AbstractContraptionRigidbody.java @@ -1,10 +1,13 @@ package com.eriksonn.createaeronautics.physics; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock; +import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.gen.feature.template.Template; +import java.util.HashMap; import java.util.Map; public abstract class AbstractContraptionRigidbody implements IRigidbody{ @@ -12,6 +15,7 @@ public abstract class AbstractContraptionRigidbody implements IRigidbody{ public Vector3d localCenterOfMass=Vector3d.ZERO; public double[][] localInertiaTensor=new double[3][3]; public double localMass; + public Map sails = new HashMap<>(); public void generateMassDependentParameters(Contraption contraption,Vector3d offset) { localMass=0; @@ -43,6 +47,15 @@ public void generateMassDependentParameters(Contraption contraption,Vector3d off } } } + public void findSails(Contraption contraption) + { + sails.clear(); + for (Map.Entry entry : contraption.getBlocks().entrySet()) { + if(entry.getValue().state.getBlock() instanceof SailBlock) { + sails.put(entry.getKey(),entry.getValue().state); + } + } + } public double getLocalMass() { return localMass; } public Vector3d getLocalCenterOfMass(){ return localCenterOfMass; } } diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java index dc9518d..ab22e67 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/SimulatedContraptionRigidbody.java @@ -7,6 +7,7 @@ import com.eriksonn.createaeronautics.blocks.propeller_bearing.PropellerBearingTileEntity; import com.eriksonn.createaeronautics.index.CABlocks; import com.eriksonn.createaeronautics.index.CATileEntities; +import com.eriksonn.createaeronautics.mixins.ControlledContraptionEntityMixin; import com.eriksonn.createaeronautics.particle.PropellerAirParticleData; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity; @@ -70,7 +71,7 @@ public class SimulatedContraptionRigidbody extends AbstractContraptionRigidbody public SimulatedContraptionRigidbody(AirshipContraptionEntity entity) { orientation=Quaternion.ONE.copy(); - //orientation=new Quaternion(1,0,0,1); + //orientation=new Quaternion(0,1,0,1); //orientation.normalize(); this.entity=entity; @@ -87,9 +88,16 @@ public void tryInit() { if(!isInitialized) { contraption=entity.airshipContraption; - //updateCenterOfMass(); + + generateMassDependentParameters(contraption,Vector3d.ZERO); + mergeMassFromSubContraptions(); + updateLevititeBuoyancy(); isInitialized=true; + updateRotation(); + //applyImpulse(new Vector3d(0,0,1),new Vector3d(0,7,0)); + Vector3d V = getVelocityAtPoint(new Vector3d(0,0,1)); + Vector3d V2 = V.cross(V); } } public void tick() @@ -110,21 +118,31 @@ public void tick() - //updateWings(); + updateWings(); //updateInertia(); updateTileEntityInteractions(); - centerOfMass=Vector3d.ZERO; + //centerOfMass=Vector3d.ZERO; totalAccumulatedBuoyancy =0; totalAccumulatedBuoyancy += levititeBuoyancyController.apply(orientation,entity.position()); updateRotation(); globalForce=globalForce.add(0,-totalAccumulatedBuoyancy,0); + //globalForce=globalForce.add(0,-PhysicsUtils.gravity*mass,0); momentum = momentum.add(rotateQuat(localForce.scale(PhysicsUtils.deltaTime),orientation)).add(globalForce.scale(PhysicsUtils.deltaTime)); globalForce = Vector3d.ZERO; localForce = Vector3d.ZERO; + if(entity.position().y<75) + { + entity.move(0,75-entity.position().y,0); + if(momentum.y<0) + { + momentum=momentum.multiply(1,-0.5,1); + } + } + momentum=momentum.scale(0.995); globalVelocity=momentum.scale(1.0/mass); localVelocity = rotateQuatReverse(globalVelocity,orientation); @@ -514,37 +532,49 @@ Vector3d multiplyMatrixArray(double[][] M,Vector3d v) } void updateWings() { - for (Map.Entry entry : entity.sails.entrySet()) + findSails(this.contraption); + + for (Map.Entry entry : sails.entrySet()) { Vector3d pos = getLocalCoordinate(entry.getKey()); Vector3d vel = getLocalVelocityAtPosition(pos); Vector3d normal = getFacingVector(entry.getValue()); - Vector3d force = normal.scale(-0.8f*normal.dot(vel)); + Vector3d force = normal.scale(-3.0f*normal.dot(vel)); addForce(force,pos); } - for (Map.Entry contraptionEntityEntry : entity.subContraptions.entrySet()) + + for (Map.Entry entry : subcontraptionRigidbodyMap.entrySet()) { - // TODO: make propellers not provide lift - if(contraptionEntityEntry.getValue() != null) + AbstractContraptionEntity entity = entry.getValue().entity; + Contraption subContraption = entity.getContraption(); + + entry.getValue().findSails(subContraption); + + if(entity instanceof ControlledContraptionEntity) { + ControlledContraptionEntity controlledEntity = (ControlledContraptionEntity)entity; + TileEntity te = entity.level.getBlockEntity(((ControlledContraptionEntityMixin)controlledEntity).getControllerPos()); + if (te instanceof PropellerBearingTileEntity) { + continue; + } + } + + for (Map.Entry blockStateEntry : subContraption.getBlocks().entrySet()) { - Contraption subContraption = contraptionEntityEntry.getValue().getContraption(); + if(blockStateEntry.getValue().state.getBlock() instanceof SailBlock) { - for (Map.Entry blockStateEntry : subContraption.getBlocks().entrySet()) - { - if(blockStateEntry.getValue().state.getBlock() instanceof SailBlock) { + Vector3d pos = VecHelper.getCenterOf(blockStateEntry.getKey()); + pos=entry.getValue().toParent(pos); - Vector3d pos = contraptionEntityEntry.getValue().applyRotation(VecHelper.getCenterOf(blockStateEntry.getKey()),0); - pos.subtract(centerOfMass); - Vector3d vel = getLocalVelocityAtPosition(pos); - Vector3d normal = getFacingVector(blockStateEntry.getValue().state); - normal = contraptionEntityEntry.getValue().applyRotation(normal,0); - Vector3d force = normal.scale(-0.8f*normal.dot(vel)); - addForce(force,pos); + Vector3d vel = getLocalVelocityAtPosition(pos); + Vector3d normal = getFacingVector(blockStateEntry.getValue().state); + normal = entity.applyRotation(normal,1); + Vector3d force = normal.scale(-3.0f*normal.dot(vel)); + addForce(force,pos); - } } } } + } public Vector3d getPlotOffset() { @@ -649,6 +679,16 @@ Vector3d getLocalVelocityAtPosition(Vector3d pos) { return localVelocity.add(pos.cross(angularVelocity)); } + public void applyImpulse(Vector3d pos, Vector3d impulse) { + momentum = momentum.add(impulse); + globalVelocity = momentum.scale(1.0 / getMass()); + + // if(Math.abs(impulse.scale(1.0 / getMass()).lengthSqr()) < 0.05) return; + + Vector3d additionalAngularMomentum = rotateInverse(impulse).cross(pos); + angularMomentum = angularMomentum.add(additionalAngularMomentum); + updateRotation(); + } Vector3d getForcePropellerBearing(BlockPos pos,PropellerBearingTileEntity te) { if(!te.isRunning()) diff --git a/src/main/java/com/eriksonn/createaeronautics/physics/SubcontraptionRigidbody.java b/src/main/java/com/eriksonn/createaeronautics/physics/SubcontraptionRigidbody.java index 34604c9..78f143e 100644 --- a/src/main/java/com/eriksonn/createaeronautics/physics/SubcontraptionRigidbody.java +++ b/src/main/java/com/eriksonn/createaeronautics/physics/SubcontraptionRigidbody.java @@ -34,18 +34,18 @@ public Vector3d multiplyInertiaInverse(Vector3d v) { public Vector3d rotate(Vector3d point) { - return parentRigidbody.rotate(entity.applyRotation(point,0)); + return parentRigidbody.rotate(entity.applyRotation(point,1)); } public Vector3d rotateInverse(Vector3d point) { - return entity.reverseRotation(parentRigidbody.rotateInverse(point),0); + return entity.reverseRotation(parentRigidbody.rotateInverse(point),1); } public Vector3d rotateLocal(Vector3d point) { - return entity.applyRotation(point,0); + return entity.applyRotation(point,1); } public Vector3d rotateLocalInverse(Vector3d point) { - return entity.reverseRotation(point,0); + return entity.reverseRotation(point,1); } public Vector3d toLocal(Vector3d globalPoint) { @@ -77,7 +77,7 @@ public Vector3d getAngularVelocity() { public void addForce(Vector3d pos, Vector3d force) { - parentRigidbody.addForce(toParent(pos),entity.applyRotation(force,0)); + parentRigidbody.addForce(toParent(pos),entity.applyRotation(force,1)); } @@ -87,21 +87,21 @@ public void addGlobalForce(Vector3d pos, Vector3d force) { public void addVelocity(Vector3d pos, Vector3d velocity) { - parentRigidbody.addVelocity(toParent(pos),entity.applyRotation(velocity,0)); + parentRigidbody.addVelocity(toParent(pos),entity.applyRotation(velocity,1)); } public void addGlobalVelocity(Vector3d pos, Vector3d velocity) { parentRigidbody.addGlobalVelocity(toParent(pos),velocity); } - Vector3d toParent(Vector3d point) + public Vector3d toParent(Vector3d point) { Vector3d entityOffsetPosition = entity.position().subtract(parentRigidbody.getPlotOffset()); - return entity.applyRotation(point,0).add(entityOffsetPosition); + return entity.applyRotation(point,1).add(entityOffsetPosition); } - Vector3d fromParent(Vector3d point) + public Vector3d fromParent(Vector3d point) { Vector3d entityOffsetPosition = entity.position().subtract(parentRigidbody.getPlotOffset()); - return entity.reverseRotation(point.subtract(entityOffsetPosition),0); + return entity.reverseRotation(point.subtract(entityOffsetPosition),1); } } diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block.json new file mode 100644 index 0000000..74c69e9 --- /dev/null +++ b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block.json @@ -0,0 +1,180 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [48, 32], + "textures": { + "0": "createaeronautics:block/stirling_engine", + "particle": "createaeronautics:block/stirling_engine" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 2, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "east": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "south": {"uv": [0, 13, 5.33333, 14], "texture": "#0"}, + "west": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "up": {"uv": [0, 5, 5.33333, 13], "texture": "#0"}, + "down": {"uv": [0, 5, 5.33333, 13], "texture": "#0"} + } + }, + { + "from": [4, 2, 1], + "to": [12, 12, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 0, 2.66667, 5], "texture": "#0"}, + "east": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "south": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "west": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "up": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#0"} + } + }, + { + "from": [3, 2, 11], + "to": [13, 12, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [12, 0, 15.33333, 5], "texture": "#0"}, + "east": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "south": {"uv": [8.66667, 0, 12, 5], "texture": "#0"}, + "west": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "up": {"uv": [12.33333, 5, 15.66667, 7.5], "texture": "#0"} + } + }, + { + "from": [3.84315, 8.65685, 2], + "to": [4.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "texture": "#0"} + } + }, + { + "from": [-0.15685, 8.65685, 2], + "to": [0.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 2], + "to": [3.84315, 13.65685, 3], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 10], + "to": [3.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 6], + "to": [3.84315, 13.65685, 7], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [11.15685, 8.65685, 2], + "to": [12.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15.15685, 8.65685, 2], + "to": [16.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 10], + "to": [15.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 2], + "to": [15.15685, 13.65685, 3], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 6], + "to": [15.15685, 13.65685, 7], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [2, 2, 0], + "to": [4, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [12, 2, 0], + "to": [14, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_lit.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_lit.json new file mode 100644 index 0000000..9a93e4f --- /dev/null +++ b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_lit.json @@ -0,0 +1,180 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [48, 32], + "textures": { + "0": "createaeronautics:block/stirling_engine", + "particle": "createaeronautics:block/stirling_engine" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 2, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "east": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "south": {"uv": [0, 13, 5.33333, 14], "texture": "#0"}, + "west": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "up": {"uv": [0, 5, 5.33333, 13], "texture": "#0"}, + "down": {"uv": [0, 5, 5.33333, 13], "texture": "#0"} + } + }, + { + "from": [4, 2, 1], + "to": [12, 12, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 0, 2.66667, 5], "texture": "#0"}, + "east": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "south": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "west": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "up": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#0"} + } + }, + { + "from": [3, 2, 11], + "to": [13, 12, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [12, 0, 15.33333, 5], "texture": "#0"}, + "east": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "south": {"uv": [8.66667, 10.5, 12, 15.5], "texture": "#0"}, + "west": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "up": {"uv": [12.33333, 5, 15.66667, 7.5], "texture": "#0"} + } + }, + { + "from": [3.84315, 8.65685, 2], + "to": [4.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "texture": "#0"} + } + }, + { + "from": [-0.15685, 8.65685, 2], + "to": [0.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 2], + "to": [3.84315, 13.65685, 3], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 10], + "to": [3.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 6], + "to": [3.84315, 13.65685, 7], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [11.15685, 8.65685, 2], + "to": [12.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15.15685, 8.65685, 2], + "to": [16.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 10], + "to": [15.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 2], + "to": [15.15685, 13.65685, 3], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 6], + "to": [15.15685, 13.65685, 7], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [2, 2, 0], + "to": [4, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [12, 2, 0], + "to": [14, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_static.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_static.json new file mode 100644 index 0000000..22c7cde --- /dev/null +++ b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/block_static.json @@ -0,0 +1,216 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [48, 32], + "textures": { + "0": "createaeronautics:block/stirling_engine", + "particle": "createaeronautics:block/stirling_engine" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 2, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "east": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "south": {"uv": [0, 13, 5.33333, 14], "texture": "#0"}, + "west": {"uv": [0, 5, 5.33333, 6], "texture": "#0"}, + "up": {"uv": [0, 5, 5.33333, 13], "texture": "#0"}, + "down": {"uv": [0, 5, 5.33333, 13], "texture": "#0"} + } + }, + { + "from": [4, 2, 1], + "to": [12, 12, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 0, 2.66667, 5], "texture": "#0"}, + "east": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "south": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "west": {"uv": [5.33333, 0, 8.66667, 5], "texture": "#0"}, + "up": {"uv": [2.66667, 0, 5.33333, 5], "texture": "#0"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#0"} + } + }, + { + "from": [3, 2, 11], + "to": [13, 12, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [12, 0, 15.33333, 5], "texture": "#0"}, + "east": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "south": {"uv": [8.66667, 0, 12, 5], "texture": "#0"}, + "west": {"uv": [12.33333, 7.5, 14, 12.5], "texture": "#0"}, + "up": {"uv": [12.33333, 5, 15.66667, 7.5], "texture": "#0"} + } + }, + { + "from": [3.84315, 8.65685, 2], + "to": [4.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "texture": "#0"} + } + }, + { + "from": [-0.15685, 8.65685, 2], + "to": [0.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 2], + "to": [3.84315, 13.65685, 3], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "name": "piston", + "from": [0.84315, 11.65685, 3], + "to": [3.84315, 12.65685, 6], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [7, 13, 8, 14.5], "texture": "#0"} + } + }, + { + "name": "piston", + "from": [0.84315, 11.65685, 7], + "to": [3.84315, 12.65685, 10], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [7, 13, 8, 14.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 10], + "to": [3.84315, 13.65685, 11], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [0.84315, 8.65685, 6], + "to": [3.84315, 13.65685, 7], + "rotation": {"angle": -45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "texture": "#0"} + } + }, + { + "from": [11.15685, 8.65685, 2], + "to": [12.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [6.66667, 5, 7, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15.15685, 8.65685, 2], + "to": [16.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7, 10.5, 7.33333, 13], "texture": "#0"}, + "east": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "south": {"uv": [8.33333, 10.5, 8.66667, 13], "texture": "#0"}, + "west": {"uv": [7, 8, 10, 10.5], "texture": "#0"}, + "up": {"uv": [5.33333, 5, 5.66667, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 10], + "to": [15.15685, 13.65685, 11], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "piston", + "from": [12.15685, 11.65685, 7], + "to": [15.15685, 12.65685, 10], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [7, 13, 8, 14.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "piston", + "from": [12.15685, 11.65685, 3], + "to": [15.15685, 12.65685, 6], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "up": {"uv": [7, 13, 8, 14.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 2], + "to": [15.15685, 13.65685, 3], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [12.15685, 8.65685, 6], + "to": [15.15685, 13.65685, 7], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "south": {"uv": [7.33333, 10.5, 8.33333, 13], "texture": "#0"}, + "up": {"uv": [5.66667, 5, 6.66667, 5.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [2, 2, 0], + "to": [4, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [12, 2, 0], + "to": [14, 8, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 15, 2, 14], "rotation": 90, "texture": "#0"}, + "east": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "south": {"uv": [0, 14, 2, 15], "rotation": 90, "texture": "#0"}, + "west": {"uv": [7, 5, 12.33333, 8], "texture": "#0"}, + "up": {"uv": [0, 14, 5.33333, 15], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/item.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/item.json new file mode 100644 index 0000000..727bd01 --- /dev/null +++ b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/item.json @@ -0,0 +1,35 @@ +{ + "parent": "createaeronautics:block/stirling_engine/block_static", + "display": { + "gui": { + "rotation": [ 30, 45, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.625, 0.625, 0.625 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 45, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 225, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston.json new file mode 100644 index 0000000..92103e7 --- /dev/null +++ b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston.json @@ -0,0 +1,19 @@ +{ + "textures": { + "0": "createaeronautics:block/stirling_engine" + }, + "elements": [ + { + "name": "piston", + "from": [6.5, 5, -1.5], + "to": [9.5, 8, 1.5], + "faces": { + "up": {"uv": [7, 13, 8, 14.5], "texture": "#0"}, + "north": {"uv": [7, 13, 8, 14.5], "texture": "#0"}, + "south": {"uv": [7, 13, 8, 14.5], "texture": "#0"}, + "east": {"uv": [7, 13, 8, 14.5], "texture": "#0"}, + "west": {"uv": [7, 13, 8, 14.5], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_left.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_left.json new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_right.json b/src/main/resources/assets/createaeronautics/models/block/stirling_engine/piston_right.json new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/assets/createaeronautics/ponder/stirling_engine.nbt b/src/main/resources/assets/createaeronautics/ponder/stirling_engine.nbt new file mode 100644 index 0000000000000000000000000000000000000000..28d6fca7bc09f2a57355bd718c54de3fcba8a7b1 GIT binary patch literal 802 zcmV+-1Ks=|iwFP!000000IgPCZ`v>vy&;4qDVwT&NYnPT{RQ6o*0B#&n%YY3s%KUN$udh2V3~x%c>9D=9z%UBmA%1c34zxqAXJO3N)r1Lc)K z?@Flb+NAXGE`cyt#s$?^2$8YOVimCs6Kr6D9hgoFp0EW^*TWNR$+^knFhL8RP79u} z1y9$*(`n(e!}xr57@yA$~|LvP3o zms9AToSuB#GSbcR!oQ~;{7dTaNU5ig9LpOzJ(d0yz>_m&=or1hQ#~dx6VkIdH&sm! z4}oTt-K|wVtZJ3~%PM)p=efYqHJ504wnJvKFQZB(g#ITkEb61VDx_Ua!NG-Q(o9ef zl@epMkZZS|RDzR2N)##dR?*esob)rzCiakV9Y8cJIfHFwcN%5)s(e!D4-2iy&2!7L zYaee}gx{kGo_67=EohTR)H@`^=V0IhoC^i`O!jOccv1+DSfhlI4n;qb-}9%oIw)U@+LBy?J~j^x4aqKx?slGe~2a z0Y*-~T5r)}#x0IAB}t8f9OA_qVWe7&maiA}>T@@Rni(_7R^vtEc&1g3x_m96sjL2u zCQKNl$ed{lA<8kWO<1;^$ORf3Q^JDcAe|}A?`Wc#sFgP7y`4f?y|#~~vA>`dE!1>M z+f@s(TW%n@s~KE(2&Si{nbXA#Q8c;sa7)z8OMLKp557*uI;rEyYVK}p~$w<_|S?rC29-G0T3uY1cWS*ETM=)0zzs~Q?3z* zN|7Uh6sdv(pi-Ikzzu;&TPGk|MY3F}GHHSx5ykmf#~ZxawRh*sYcGfK`}&>P+0D8= z^1tlP^E@;2f8KpQS35s7-URTR1}Y3w=aHi^U^e+Q`l#K+nO{>}DRS@bJr)-i$z(Fr zYBe&M3@1*Ukh&vBj&x;r=FAxlKnFPeqhp-BxI%etjlTYVG)?0d-?5mPSwQFomdj;^ z2M1X$mmjMan3-8%Zf=fuFJ0o$v!mR&zJz6^0I+SJ{rmSz9dmSNw*%dC8hr2dCH}Rr zKyhUSfWpuaKifFWm$SPkyKw!MylL*%L(*0cx;Xwre*WQ$N_wV25(6giD`U(^Z zCHhR0b;lu_4ePqKlMVowrpaolB!$J56^^{{0ae9HM-FJ^q0`T%z zUsm2#q*|#0Fh4&}CX?Ym*O$5BEn(X}MW9f~QK?j@R4UlE&!MM%d4D37MGQ)78dKCfyv29X5XJ>a&l7IO;1lVKR?gd*cbp46BBg8($dnd1BR)yTrTt4ghAac$(N?B zJP?#YwW93mld*c$Mzvd9Tm<0Y@Ij2UA@v&@8+fiqKA)F10G{iG?1ap59adL&b5oZu zb$#l7gC|ltb-zLXzHFFOmwJJyUA0n?1fmeKYNZk)`ZzlP?fleubM;Y^R60JN2h1j) zMK7?dA7*qXL;%dR86pL+r2GPp!`tt?qe%xKzSG9ZRh@upW0Pd|qdRPFHA(hpY;Fae zTKz5%)dOs9HTlZ7e;_N8dfEW}*{rNW7cN}TWGDVKI5&Nn{D8(QKmEFty?*iUBzqF{ zT0Qg{IuF-9^rVKKNZ@)~^gofJ?r+lAY?3y5F!Ua(bzjPpn}I{0T)RffFtAKh)_;J? zjzfpX$AO(r4DiRlT-_7-7mo(vpmt(WGPMNs8af+Z11$l1B0;aA<85wXnLPlkZ}}k` zRi4RYBw^q4u$ zwh`;FW%jV{1SA{&wv>xsBMKp})oKhMJlK*4mT6*{LGs_fcdylfPUKa69Mmpdcekj! zwoKAHt95C&{9hXglD7EB3CTqwPfblxTq#l*DzuExQMCL5g1k6s5!b>Qab0~7t`4FP z`0h5}|Jsv4=L+`ox30w!0+^edYrcEw61MG=9q8ptPY<^<4LY$3K~#`mcU*b${rj@G zw;sk4ilS3xJ2!o~tqy{*Ih)O5+a-L@3yse$4yYG`c>lgEtG6D8$mgH>JgX7%0?{t) zISrP}Wmc8FL4@JR;V(S4=>ZIVF~|M`2iQ*f++M!jodZ$wfK1$|Ln=P`_il`f$|N9& zL+2b)QLEKhzI|JU(8$P0dj~wH!SLW9AI6Y}AQ#k;IBg|E`nXs=KQ-R`{ck^xKk2J0 zT{)qKkUBoMIH1OGC-Tu69}H=C+CDfxpy4^ey@sjt(y8Bsmi1R({bsY>vOYF8#^~to z-m8w!Ee=El>d!35r>$h{3hBGsEiwT$iO)@6?tZB!7`@eTda=Whr;CJx)>9T}CvOMw z%<6**rL_%G>BOFv^=hSpli%$T(Sa`HfcPS2n`nKH&i#8qv_p5Z)T?k@M~>a?pxY$n z|2t8rArhC6?aHBH>O_-RBx2)t$Iwq+q4CRO&<}iThLNj3=H}5ii6WppFX(D z+y8j8?e?T@N&RA*`nCXQokn$ qKEAWwb;5jB2%>6riF4@x3jYJk8C4w+Y3)t`0000