diff --git a/Translators-Changes.md b/Translators-Changes.md index 6e28aa0e3..2c5fad74c 100644 --- a/Translators-Changes.md +++ b/Translators-Changes.md @@ -9,6 +9,9 @@ Note: Changes to en_us.json before Create Big Cannons 0.5.3.b => 0.5.4 will not ## 5.7.2 → 5.8.0 Additions: \ + `"block.createbigcannons.cannon_mount_extension": "Cannon Mount Extension"` \ ++ `"block.createbigcannons.fixed_cannon_mount": "Fixed Cannon Mount"` \ ++ `"createbigcannons.fixed_cannon_mount.angle_pitch": "Pitch Adjustment"` \ ++ `"createbigcannons.fixed_cannon_mount.angle_yaw": "Yaw Adjustment"` \ + `"createbigcannons.ponder.cannon_mount/upside_down_cannon_mounts.header": "Placing Cannon Mounts upside down"` \ + `"createbigcannons.ponder.cannon_mount/upside_down_cannon_mounts.text_1": "Cannon Mounts can be rotated to face downwards by clicking their sides with a wrench."` \ + `"createbigcannons.ponder.cannon_mount/upside_down_cannon_mounts.text_2": "Cannon Mounts can also be placed upside-down on the bottom of blocks."` \ diff --git a/fabric/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json b/fabric/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json new file mode 100644 index 000000000..483a2bbae --- /dev/null +++ b/fabric/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json @@ -0,0 +1,420 @@ +{ + "variants": { + "assembly_powered=false,facing=down,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/createbigcannons/lang/en_ud.json b/fabric/src/generated/resources/assets/createbigcannons/lang/en_ud.json index df4cbdddd..47c69ca06 100644 --- a/fabric/src/generated/resources/assets/createbigcannons/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/createbigcannons/lang/en_ud.json @@ -93,6 +93,7 @@ "block.createbigcannons.drop_mortar_shell.tooltip.condition1": "uoıʇɐuoʇǝᗡ uO", "block.createbigcannons.drop_mortar_shell.tooltip.summary": "‾˙pǝɹıɟ ʎןןɐuoıʇuǝʌuoɔ‾ ǝq osןɐ uɐɔ ʇı ɥbnoɥʇןɐ 'uouuɐɔ bıq ‾ǝdʎʇ-ɹɐʇɹoɯ doɹp ɐ oʇuı buıddoɹp‾ ʎq pǝɹıℲ ˙ǝbɐɯɐp ןɐɹnʇɔnɹʇs ɟo ʇıq ɐ sןɐǝp ʇɐɥʇ ןןǝɥs ‾ǝʌısoןdxǝ‾ ʎʇıʇuǝ-ıʇuɐ ʇɥbıꞀ", "block.createbigcannons.finished_cannon_cast": "ʇsɐƆ uouuɐƆ pǝɥsıuıℲ", + "block.createbigcannons.fixed_cannon_mount": "ʇunoW uouuɐƆ pǝxıℲ", "block.createbigcannons.fluid_shell": "ןןǝɥS pınןℲ", "block.createbigcannons.fluid_shell.tooltip": "ꞀꞀƎHS ᗡI∩ꞀℲ", "block.createbigcannons.fluid_shell.tooltip.behaviour1": "˙sʇuǝʇuoɔ sʇı sǝsɐǝןǝᴚ", @@ -246,6 +247,8 @@ "createbigcannons.display_source.cannon_mount.pitch": "ɥɔʇıԀ uouuɐƆ", "createbigcannons.display_source.cannon_mount.yaw": "ʍɐʎ uouuɐƆ", "createbigcannons.display_source.cannon_mount_source": "ʇunoW uouuɐƆ ɯoɹℲ", + "createbigcannons.fixed_cannon_mount.angle_pitch": "ʇuǝɯʇsnظpⱯ ɥɔʇıԀ", + "createbigcannons.fixed_cannon_mount.angle_yaw": "ʇuǝɯʇsnظpⱯ ʍɐʎ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire": " :ǝɹıℲ ɟo ǝʇɐᴚ uouuɐɔoʇnⱯ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire.value": "WԀᴚ %s", "createbigcannons.goggles.cannon_mount.cannon_strength": " :ɥʇbuǝɹʇS uouuɐƆ", diff --git a/fabric/src/generated/resources/assets/createbigcannons/lang/en_us.json b/fabric/src/generated/resources/assets/createbigcannons/lang/en_us.json index beb2dc851..4094db056 100644 --- a/fabric/src/generated/resources/assets/createbigcannons/lang/en_us.json +++ b/fabric/src/generated/resources/assets/createbigcannons/lang/en_us.json @@ -93,6 +93,7 @@ "block.createbigcannons.drop_mortar_shell.tooltip.condition1": "On Detonation", "block.createbigcannons.drop_mortar_shell.tooltip.summary": "Light anti-entity _explosive_ shell that deals a bit of structural damage. Fired by _dropping into a drop mortar-type_ big cannon, although it can also be _conventionally fired._", "block.createbigcannons.finished_cannon_cast": "Finished Cannon Cast", + "block.createbigcannons.fixed_cannon_mount": "Fixed Cannon Mount", "block.createbigcannons.fluid_shell": "Fluid Shell", "block.createbigcannons.fluid_shell.tooltip": "FLUID SHELL", "block.createbigcannons.fluid_shell.tooltip.behaviour1": "Releases its contents.", @@ -246,6 +247,8 @@ "createbigcannons.display_source.cannon_mount.pitch": "Cannon Pitch", "createbigcannons.display_source.cannon_mount.yaw": "Cannon Yaw", "createbigcannons.display_source.cannon_mount_source": "From Cannon Mount", + "createbigcannons.fixed_cannon_mount.angle_pitch": "Pitch Adjustment", + "createbigcannons.fixed_cannon_mount.angle_yaw": "Yaw Adjustment", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire": "Autocannon Rate of Fire: ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire.value": "%s RPM", "createbigcannons.goggles.cannon_mount.cannon_strength": "Cannon Strength: ", diff --git a/fabric/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json b/fabric/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json new file mode 100644 index 000000000..f9c628b3e --- /dev/null +++ b/fabric/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json @@ -0,0 +1,3 @@ +{ + "parent": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/create/tags/blocks/safe_nbt.json b/fabric/src/generated/resources/data/create/tags/blocks/safe_nbt.json index a8a619f76..d8dc2e2c9 100644 --- a/fabric/src/generated/resources/data/create/tags/blocks/safe_nbt.json +++ b/fabric/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -92,6 +92,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_carriage", "createbigcannons:cannon_drill", "createbigcannons:cannon_builder", diff --git a/fabric/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json b/fabric/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json new file mode 100644 index 000000000..6b8a6cd07 --- /dev/null +++ b/fabric/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "createbigcannons:fixed_cannon_mount" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "createbigcannons:blocks/fixed_cannon_mount" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index 8b56b7364..f7e83edc5 100644 --- a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -9,6 +9,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_carriage", "createbigcannons:cannon_drill", "createbigcannons:cannon_drill_bit", diff --git a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index d53541971..bc0ffc372 100644 --- a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -92,6 +92,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_drill", "createbigcannons:cannon_drill_bit", "createbigcannons:cannon_builder", diff --git a/fabric/src/main/java/rbasamoyai/createbigcannons/datagen/assets/fabric/CBCBuilderTransformersImpl.java b/fabric/src/main/java/rbasamoyai/createbigcannons/datagen/assets/fabric/CBCBuilderTransformersImpl.java index 2526d4e37..a31293c91 100644 --- a/fabric/src/main/java/rbasamoyai/createbigcannons/datagen/assets/fabric/CBCBuilderTransformersImpl.java +++ b/fabric/src/main/java/rbasamoyai/createbigcannons/datagen/assets/fabric/CBCBuilderTransformersImpl.java @@ -40,6 +40,7 @@ import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlock; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlock; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlockItem; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlock; import rbasamoyai.createbigcannons.cannon_loading.CannonLoaderGen; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBarrelBlock; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBlock; @@ -577,6 +578,21 @@ public static NonNullUnaryOperator> cann .build(); } + public static NonNullUnaryOperator> fixedCannonMount() { + String key = "block/cannon_mount/fixed_cannon_mount_"; + return b -> b.properties(p -> p.noOcclusion()) + .addLayer(() -> RenderType::cutoutMipped) + .blockstate((c, p) -> p.directionalBlock(c.get(), state -> { + Direction rotation = state.getValue(FixedCannonMountBlock.ROTATION); + ResourceLocation loc = CreateBigCannons.resource(key + rotation.getName()); + return p.models().getExistingFile(loc); + })) + .tag(AllTags.AllBlockTags.SAFE_NBT.tag) + .item() + .model((c, p) -> p.withExistingParent(c.getName(), CreateBigCannons.resource(key + "north"))) + .build(); + } + public static NonNullUnaryOperator> cannonCarriage() { ResourceLocation blockLoc = CreateBigCannons.resource("block/cannon_carriage/block"); ResourceLocation saddleLoc = CreateBigCannons.resource("block/cannon_carriage/block_saddle"); diff --git a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/client/ValueSettingsClientMixin.java b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/client/ValueSettingsClientMixin.java new file mode 100644 index 000000000..70609aa4f --- /dev/null +++ b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/client/ValueSettingsClientMixin.java @@ -0,0 +1,41 @@ +package rbasamoyai.createbigcannons.fabric.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.AllKeys; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsClient; + +import me.pepperbell.simplenetworking.C2SPacket; +import me.pepperbell.simplenetworking.SimpleChannel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity; +import rbasamoyai.createbigcannons.multiloader.NetworkPlatform; +import rbasamoyai.createbigcannons.network.ServerboundSetFixedCannonMountValuePacket; + +@Mixin(ValueSettingsClient.class) +public class ValueSettingsClientMixin { + + @Shadow public BlockPos interactHeldPos; + @Shadow public InteractionHand interactHeldHand; + @Shadow public Direction interactHeldFace; + + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lme/pepperbell/simplenetworking/SimpleChannel;sendToServer(Lme/pepperbell/simplenetworking/C2SPacket;)V"), remap = false) + private void createbigcannons$tick$cancelPacket(SimpleChannel instance, C2SPacket packet, Operation original, + @Local ValueSettingsBehaviour valueSettingBehaviour) { + if (valueSettingBehaviour instanceof FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour fixedMountBehaviour) { + NetworkPlatform.sendToServer(new ServerboundSetFixedCannonMountValuePacket(this.interactHeldPos, 0, 0, + this.interactHeldHand, this.interactHeldFace, AllKeys.ctrlDown(), fixedMountBehaviour.setsPitch())); + return; + } + original.call(instance, packet); + } + +} diff --git a/fabric/src/main/resources/createbigcannons.mixins.json b/fabric/src/main/resources/createbigcannons.mixins.json index 91eaf0cf4..ae9d8b3c6 100644 --- a/fabric/src/main/resources/createbigcannons.mixins.json +++ b/fabric/src/main/resources/createbigcannons.mixins.json @@ -10,7 +10,8 @@ "client.GuiMixin", "client.KeyboardHandlerMixin", "client.KeyMappingAccessor", - "client.MouseHandlerMixin" + "client.MouseHandlerMixin", + "client.ValueSettingsClientMixin" ], "mixins": [ "AbstractCannonProjectileMixin", diff --git a/forge/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json b/forge/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json new file mode 100644 index 000000000..483a2bbae --- /dev/null +++ b/forge/src/generated/resources/assets/createbigcannons/blockstates/fixed_cannon_mount.json @@ -0,0 +1,420 @@ +{ + "variants": { + "assembly_powered=false,facing=down,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=false,facing=down,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=east,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=false,facing=north,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=south,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=false,facing=up,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=false,facing=up,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=false,facing=west,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 180 + }, + "assembly_powered=true,facing=down,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 180 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=east,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90 + }, + "assembly_powered=true,facing=north,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=south,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 180 + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=true,facing=up,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south" + }, + "assembly_powered=true,facing=up,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west" + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=false,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=east": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_east", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=north": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=south": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_south", + "x": 90, + "y": 270 + }, + "assembly_powered=true,facing=west,fire_powered=true,rotation=west": { + "model": "createbigcannons:block/cannon_mount/fixed_cannon_mount_west", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/createbigcannons/lang/en_ud.json b/forge/src/generated/resources/assets/createbigcannons/lang/en_ud.json index df4cbdddd..47c69ca06 100644 --- a/forge/src/generated/resources/assets/createbigcannons/lang/en_ud.json +++ b/forge/src/generated/resources/assets/createbigcannons/lang/en_ud.json @@ -93,6 +93,7 @@ "block.createbigcannons.drop_mortar_shell.tooltip.condition1": "uoıʇɐuoʇǝᗡ uO", "block.createbigcannons.drop_mortar_shell.tooltip.summary": "‾˙pǝɹıɟ ʎןןɐuoıʇuǝʌuoɔ‾ ǝq osןɐ uɐɔ ʇı ɥbnoɥʇןɐ 'uouuɐɔ bıq ‾ǝdʎʇ-ɹɐʇɹoɯ doɹp ɐ oʇuı buıddoɹp‾ ʎq pǝɹıℲ ˙ǝbɐɯɐp ןɐɹnʇɔnɹʇs ɟo ʇıq ɐ sןɐǝp ʇɐɥʇ ןןǝɥs ‾ǝʌısoןdxǝ‾ ʎʇıʇuǝ-ıʇuɐ ʇɥbıꞀ", "block.createbigcannons.finished_cannon_cast": "ʇsɐƆ uouuɐƆ pǝɥsıuıℲ", + "block.createbigcannons.fixed_cannon_mount": "ʇunoW uouuɐƆ pǝxıℲ", "block.createbigcannons.fluid_shell": "ןןǝɥS pınןℲ", "block.createbigcannons.fluid_shell.tooltip": "ꞀꞀƎHS ᗡI∩ꞀℲ", "block.createbigcannons.fluid_shell.tooltip.behaviour1": "˙sʇuǝʇuoɔ sʇı sǝsɐǝןǝᴚ", @@ -246,6 +247,8 @@ "createbigcannons.display_source.cannon_mount.pitch": "ɥɔʇıԀ uouuɐƆ", "createbigcannons.display_source.cannon_mount.yaw": "ʍɐʎ uouuɐƆ", "createbigcannons.display_source.cannon_mount_source": "ʇunoW uouuɐƆ ɯoɹℲ", + "createbigcannons.fixed_cannon_mount.angle_pitch": "ʇuǝɯʇsnظpⱯ ɥɔʇıԀ", + "createbigcannons.fixed_cannon_mount.angle_yaw": "ʇuǝɯʇsnظpⱯ ʍɐʎ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire": " :ǝɹıℲ ɟo ǝʇɐᴚ uouuɐɔoʇnⱯ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire.value": "WԀᴚ %s", "createbigcannons.goggles.cannon_mount.cannon_strength": " :ɥʇbuǝɹʇS uouuɐƆ", diff --git a/forge/src/generated/resources/assets/createbigcannons/lang/en_us.json b/forge/src/generated/resources/assets/createbigcannons/lang/en_us.json index beb2dc851..4094db056 100644 --- a/forge/src/generated/resources/assets/createbigcannons/lang/en_us.json +++ b/forge/src/generated/resources/assets/createbigcannons/lang/en_us.json @@ -93,6 +93,7 @@ "block.createbigcannons.drop_mortar_shell.tooltip.condition1": "On Detonation", "block.createbigcannons.drop_mortar_shell.tooltip.summary": "Light anti-entity _explosive_ shell that deals a bit of structural damage. Fired by _dropping into a drop mortar-type_ big cannon, although it can also be _conventionally fired._", "block.createbigcannons.finished_cannon_cast": "Finished Cannon Cast", + "block.createbigcannons.fixed_cannon_mount": "Fixed Cannon Mount", "block.createbigcannons.fluid_shell": "Fluid Shell", "block.createbigcannons.fluid_shell.tooltip": "FLUID SHELL", "block.createbigcannons.fluid_shell.tooltip.behaviour1": "Releases its contents.", @@ -246,6 +247,8 @@ "createbigcannons.display_source.cannon_mount.pitch": "Cannon Pitch", "createbigcannons.display_source.cannon_mount.yaw": "Cannon Yaw", "createbigcannons.display_source.cannon_mount_source": "From Cannon Mount", + "createbigcannons.fixed_cannon_mount.angle_pitch": "Pitch Adjustment", + "createbigcannons.fixed_cannon_mount.angle_yaw": "Yaw Adjustment", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire": "Autocannon Rate of Fire: ", "createbigcannons.goggles.cannon_mount.autocannon_rate_of_fire.value": "%s RPM", "createbigcannons.goggles.cannon_mount.cannon_strength": "Cannon Strength: ", diff --git a/forge/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json b/forge/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json new file mode 100644 index 000000000..f9c628b3e --- /dev/null +++ b/forge/src/generated/resources/assets/createbigcannons/models/item/fixed_cannon_mount.json @@ -0,0 +1,3 @@ +{ + "parent": "createbigcannons:block/cannon_mount/fixed_cannon_mount_north" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/create/tags/blocks/safe_nbt.json b/forge/src/generated/resources/data/create/tags/blocks/safe_nbt.json index a8a619f76..d8dc2e2c9 100644 --- a/forge/src/generated/resources/data/create/tags/blocks/safe_nbt.json +++ b/forge/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -92,6 +92,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_carriage", "createbigcannons:cannon_drill", "createbigcannons:cannon_builder", diff --git a/forge/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json b/forge/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json new file mode 100644 index 000000000..6b8a6cd07 --- /dev/null +++ b/forge/src/generated/resources/data/createbigcannons/loot_tables/blocks/fixed_cannon_mount.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "createbigcannons:fixed_cannon_mount" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "createbigcannons:blocks/fixed_cannon_mount" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index 8b56b7364..f7e83edc5 100644 --- a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -9,6 +9,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_carriage", "createbigcannons:cannon_drill", "createbigcannons:cannon_drill_bit", diff --git a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index d53541971..bc0ffc372 100644 --- a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -92,6 +92,7 @@ "createbigcannons:cannon_mount", "createbigcannons:yaw_controller", "createbigcannons:cannon_mount_extension", + "createbigcannons:fixed_cannon_mount", "createbigcannons:cannon_drill", "createbigcannons:cannon_drill_bit", "createbigcannons:cannon_builder", diff --git a/forge/src/main/java/rbasamoyai/createbigcannons/datagen/assets/forge/CBCBuilderTransformersImpl.java b/forge/src/main/java/rbasamoyai/createbigcannons/datagen/assets/forge/CBCBuilderTransformersImpl.java index a2ab8c014..c136805df 100644 --- a/forge/src/main/java/rbasamoyai/createbigcannons/datagen/assets/forge/CBCBuilderTransformersImpl.java +++ b/forge/src/main/java/rbasamoyai/createbigcannons/datagen/assets/forge/CBCBuilderTransformersImpl.java @@ -41,6 +41,7 @@ import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlock; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlock; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlockItem; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlock; import rbasamoyai.createbigcannons.cannon_loading.CannonLoaderGen; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBarrelBlock; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBlock; @@ -578,6 +579,21 @@ public static NonNullUnaryOperator> cann .build(); } + public static NonNullUnaryOperator> fixedCannonMount() { + String key = "block/cannon_mount/fixed_cannon_mount_"; + return b -> b.properties(p -> p.noOcclusion()) + .addLayer(() -> RenderType::cutoutMipped) + .blockstate((c, p) -> p.directionalBlock(c.get(), state -> { + Direction rotation = state.getValue(FixedCannonMountBlock.ROTATION); + ResourceLocation loc = CreateBigCannons.resource(key + rotation.getName()); + return p.models().getExistingFile(loc); + })) + .tag(AllBlockTags.SAFE_NBT.tag) + .item() + .model((c, p) -> p.withExistingParent(c.getName(), CreateBigCannons.resource(key + "north"))) + .build(); + } + public static NonNullUnaryOperator> cannonCarriage() { ResourceLocation blockLoc = CreateBigCannons.resource("block/cannon_carriage/block"); ResourceLocation saddleLoc = CreateBigCannons.resource("block/cannon_carriage/block_saddle"); diff --git a/forge/src/main/java/rbasamoyai/createbigcannons/forge/mixin/client/ValueSettingsClientMixin.java b/forge/src/main/java/rbasamoyai/createbigcannons/forge/mixin/client/ValueSettingsClientMixin.java new file mode 100644 index 000000000..88660b7e8 --- /dev/null +++ b/forge/src/main/java/rbasamoyai/createbigcannons/forge/mixin/client/ValueSettingsClientMixin.java @@ -0,0 +1,39 @@ +package rbasamoyai.createbigcannons.forge.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.AllKeys; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsClient; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraftforge.network.simple.SimpleChannel; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity; +import rbasamoyai.createbigcannons.multiloader.NetworkPlatform; +import rbasamoyai.createbigcannons.network.ServerboundSetFixedCannonMountValuePacket; + +@Mixin(ValueSettingsClient.class) +public class ValueSettingsClientMixin { + + @Shadow public BlockPos interactHeldPos; + @Shadow public InteractionHand interactHeldHand; + @Shadow public Direction interactHeldFace; + + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/network/simple/SimpleChannel;sendToServer(Ljava/lang/Object;)V"), remap = false) + private void createbigcannons$tick$cancelPacket(SimpleChannel instance, Object message, Operation original, @Local ValueSettingsBehaviour valueSettingBehaviour) { + if (valueSettingBehaviour instanceof FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour fixedMountBehaviour) { + NetworkPlatform.sendToServer(new ServerboundSetFixedCannonMountValuePacket(this.interactHeldPos, 0, 0, + this.interactHeldHand, this.interactHeldFace, AllKeys.ctrlDown(), fixedMountBehaviour.setsPitch())); + return; + } + original.call(instance, message); + } + +} diff --git a/forge/src/main/resources/createbigcannons.mixins.json b/forge/src/main/resources/createbigcannons.mixins.json index 334b40a00..6ad30f66f 100644 --- a/forge/src/main/resources/createbigcannons.mixins.json +++ b/forge/src/main/resources/createbigcannons.mixins.json @@ -5,7 +5,8 @@ "compatibilityLevel": "JAVA_17", "client": [ "client.GasMaskModelMixin", - "client.GoggleOverlayRendererMixin" + "client.GoggleOverlayRendererMixin", + "client.ValueSettingsClientMixin" ], "mixins": [ "AbstractCannonProjectileMixin", diff --git a/src/main/java/rbasamoyai/createbigcannons/CBCClientCommon.java b/src/main/java/rbasamoyai/createbigcannons/CBCClientCommon.java index 783916c31..2047b78a6 100644 --- a/src/main/java/rbasamoyai/createbigcannons/CBCClientCommon.java +++ b/src/main/java/rbasamoyai/createbigcannons/CBCClientCommon.java @@ -53,6 +53,7 @@ import rbasamoyai.createbigcannons.block_hit_effects.ProjectileHitEffectsHandler; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageEntity; import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBoxRenderer; import rbasamoyai.createbigcannons.cannons.big_cannons.BigCannonBlock; import rbasamoyai.createbigcannons.cannons.big_cannons.breeches.quickfiring_breech.QuickfiringBreechBlock; import rbasamoyai.createbigcannons.crafting.welding.CannonWelderSelectionHandler; @@ -228,6 +229,7 @@ public static void onClientGameTick(Minecraft mc) { CANNON_WELDER_HANDLER.tick(); FUZE_GUIDE_HANDLER.tick(); ParticleWindHandler.updateWind(); + FixedCannonMountBoxRenderer.tick(); } public static boolean onClickMouse(KeyMapping mapping) { diff --git a/src/main/java/rbasamoyai/createbigcannons/ModGroup.java b/src/main/java/rbasamoyai/createbigcannons/ModGroup.java index 289b437f6..41b84fb40 100644 --- a/src/main/java/rbasamoyai/createbigcannons/ModGroup.java +++ b/src/main/java/rbasamoyai/createbigcannons/ModGroup.java @@ -28,6 +28,7 @@ public class ModGroup { output.acceptAll(Arrays.asList( CBCBlocks.CANNON_MOUNT.asStack(), CBCBlocks.CANNON_MOUNT_EXTENSION.asStack(), + CBCBlocks.FIXED_CANNON_MOUNT.asStack(), CBCBlocks.LOG_CANNON_END.asStack(), CBCBlocks.LOG_CANNON_CHAMBER.asStack(), diff --git a/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java b/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java index 42c0d1a6c..c076d355f 100644 --- a/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java +++ b/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java @@ -42,6 +42,7 @@ import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity; import rbasamoyai.createbigcannons.cannon_control.cannon_types.CBCCannonContraptionTypes; import rbasamoyai.createbigcannons.cannon_control.cannon_types.ICannonContraptionType; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity; import rbasamoyai.createbigcannons.cannons.ItemCannonBehavior; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBarrelBlock; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBlock; @@ -451,6 +452,8 @@ public boolean canBeTurnedByController(ControlPitchContraption control) { @Override public boolean canBeTurnedByPassenger(Entity entity) { + if (this.entity instanceof PitchOrientedContraptionEntity poce && poce.getController() instanceof FixedCannonMountBlockEntity) + return false; return this.isHandle && entity instanceof Player; } diff --git a/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlock.java b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlock.java new file mode 100644 index 000000000..dcc604904 --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlock.java @@ -0,0 +1,161 @@ +package rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount; + +import javax.annotation.Nullable; + +import com.simibubi.create.content.equipment.wrench.IWrenchable; +import com.simibubi.create.foundation.block.IBE; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlock; +import rbasamoyai.createbigcannons.index.CBCBlockEntities; + +public class FixedCannonMountBlock extends DirectionalBlock implements IBE, IWrenchable { + + public static final BooleanProperty ASSEMBLY_POWERED = CannonMountBlock.ASSEMBLY_POWERED; + public static final BooleanProperty FIRE_POWERED = CannonMountBlock.FIRE_POWERED; + public static final DirectionProperty ROTATION = DirectionProperty.create("rotation", Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST); + + public FixedCannonMountBlock(Properties properties) { + super(properties); + this.registerDefaultState(this.getStateDefinition().any() + .setValue(FACING, Direction.NORTH) + .setValue(ROTATION, Direction.NORTH) + .setValue(ASSEMBLY_POWERED, false) + .setValue(FIRE_POWERED, false)); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(FACING, ROTATION, ASSEMBLY_POWERED, FIRE_POWERED); + super.createBlockStateDefinition(builder); + } + + @Nullable + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + Direction dir = context.getNearestLookingDirection(); + boolean flag = context.getPlayer() != null && context.getPlayer().isShiftKeyDown(); + BlockState state = this.defaultBlockState().setValue(FACING, flag ? dir : dir.getOpposite()); + if (dir.getAxis().isVertical()) { + Direction facing = context.getHorizontalDirection(); + state = state.setValue(ROTATION, dir == Direction.UP ? facing : facing.getOpposite()); + } + return state; + } + + @Override + public void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean isMoving) { + if (!level.isClientSide) { + if (!level.getBlockTicks().willTickThisTick(pos, this)) { + level.scheduleTick(pos, this, 0); + } + } + } + + public Direction getAssemblyFace(BlockState state) { + Direction facing = state.getValue(FACING); + Direction rotation = state.getValue(ROTATION); + if (facing.getAxis().isVertical()) + return facing == Direction.UP || rotation.getAxis() == Direction.Axis.X ? rotation : rotation.getOpposite(); + Direction dir1 = rotation.getAxis() == Direction.Axis.X ? rotation + : rotation.getClockWise(Direction.Axis.X); + if (dir1.getAxis().isVertical()) + return dir1; + int rot = facing.get2DDataValue(); + Direction dir2 = dir1; + for (int i = 0; i < rot; ++i) + dir2 = dir2.getCounterClockWise(); + return facing.getAxis() == Direction.Axis.Z && rotation.getAxis() == Direction.Axis.X ? dir2.getOpposite() : dir2; + } + + public Direction getFiringFace(BlockState state) { + return this.getAssemblyFace(state).getOpposite(); + } + + @Override + public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource rand) { + boolean prevAssemblyPowered = state.getValue(ASSEMBLY_POWERED); + boolean prevFirePowered = state.getValue(FIRE_POWERED); + boolean assemblyPowered = this.hasNeighborSignal(level, state, pos, ASSEMBLY_POWERED); + boolean firePowered = this.hasNeighborSignal(level, state, pos, FIRE_POWERED); + Direction fireDirection = this.getFiringFace(state); + int firePower = level.getSignal(pos.relative(fireDirection), fireDirection); + this.withBlockEntityDo(level, pos, mount -> mount.onRedstoneUpdate(assemblyPowered, prevAssemblyPowered, firePowered, prevFirePowered, firePower)); + } + + private boolean hasNeighborSignal(Level level, BlockState state, BlockPos pos, BooleanProperty property) { + if (property == FIRE_POWERED) { + Direction fireDirection = this.getFiringFace(state); + return level.getSignal(pos.relative(fireDirection), fireDirection) > 0; + } + if (property == ASSEMBLY_POWERED) { + Direction assemblyDirection = this.getAssemblyFace(state); + return level.getSignal(pos.relative(assemblyDirection), assemblyDirection) > 0; + } + return false; + } + + @Override + public BlockState rotate(BlockState state, Rotation rotation) { + if (state.getValue(FACING).getAxis().isVertical()) { + return state.setValue(ROTATION, rotation.rotate(state.getValue(ROTATION))); + } else { + return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); + } + } + + @Override + public BlockState mirror(BlockState state, Mirror mirror) { + if (state.getValue(FACING).getAxis().isVertical()) { + return state.setValue(ROTATION, mirror.mirror(state.getValue(ROTATION))); + } else { + return state.setValue(FACING, mirror.mirror(state.getValue(FACING))); + } + } + + @Override + public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) { + Direction facing = originalState.getValue(FACING); + if (targetedFace.getAxis() == facing.getAxis()) { + return originalState.setValue(ROTATION, originalState.getValue(ROTATION).getClockWise()); + } else { + Direction facing1 = facing.getClockWise(targetedFace.getAxis()); + BlockState newState = originalState.setValue(FACING, facing1); + if (targetedFace.getAxis() == Direction.Axis.X && (facing == Direction.DOWN || facing1 == Direction.UP)) + newState = newState.setValue(ROTATION, newState.getValue(ROTATION).getOpposite()); + if (targetedFace.getAxis() == Direction.Axis.Z) + newState = newState.setValue(ROTATION, newState.getValue(ROTATION).getCounterClockWise()); + return newState; + } + } + + @Override + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + InteractionResult resultType = IWrenchable.super.onWrenched(state, context); + if (!context.getLevel().isClientSide && resultType.consumesAction() + && context.getLevel().getBlockEntity(context.getClickedPos()) instanceof FixedCannonMountBlockEntity mount) { + mount.disassemble(); + } + return resultType; + } + + @Override public Class getBlockEntityClass() { return FixedCannonMountBlockEntity.class; } + @Override public BlockEntityType getBlockEntityType() { return CBCBlockEntities.FIXED_CANNON_MOUNT.get(); } + +} diff --git a/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlockEntity.java b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlockEntity.java new file mode 100644 index 000000000..4644f55cf --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBlockEntity.java @@ -0,0 +1,343 @@ +package rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount; + +import static rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity.cannonBlockOutsideOfWorld; + +import java.util.List; + +import com.google.common.collect.ImmutableList; +import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.AssemblyException; +import com.simibubi.create.content.contraptions.IDisplayAssemblyExceptions; +import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation; +import com.simibubi.create.content.kinetics.crank.ValveHandleBlockEntity; +import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; +import com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.CenteredSideValueBoxTransform; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBoard; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatter; +import com.simibubi.create.foundation.utility.Components; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.foundation.utility.VecHelper; + +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import rbasamoyai.createbigcannons.CreateBigCannons; +import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption; +import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption; +import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity; +import rbasamoyai.createbigcannons.cannons.CannonContraptionProviderBlock; +import rbasamoyai.createbigcannons.index.CBCBlocks; + +public class FixedCannonMountBlockEntity extends SmartBlockEntity implements IDisplayAssemblyExceptions, ControlPitchContraption.Block, IHaveGoggleInformation { + + private AssemblyException lastException = null; + protected PitchOrientedContraptionEntity mountedContraption; + private boolean running; + + private float cannonYaw; + private float cannonPitch; + + private FixedCannonMountScrollValueBehaviour pitchSlot; + private FixedCannonMountScrollValueBehaviour yawSlot; + + public FixedCannonMountBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { + super(type, pos, state); + if (CBCBlocks.FIXED_CANNON_MOUNT.has(state)) + this.cannonYaw = state.getValue(FixedCannonMountBlock.FACING).toYRot(); + this.setLazyTickRate(3); + } + + @Override + public void addBehaviours(List behaviours) { + behaviours.add(this.pitchSlot = new FixedCannonMountScrollValueBehaviour(this, true)); + behaviours.add(this.yawSlot = new FixedCannonMountScrollValueBehaviour(this, false)); + } + + public void onRedstoneUpdate(boolean assemblyPowered, boolean prevAssemblyPowered, boolean firePowered, boolean prevFirePowered, int firePower) { + if (assemblyPowered != prevAssemblyPowered) { + this.getLevel().setBlock(this.worldPosition, this.getBlockState().setValue(FixedCannonMountBlock.ASSEMBLY_POWERED, assemblyPowered), 3); + if (assemblyPowered) { + try { + this.assemble(); + this.lastException = null; + } catch (AssemblyException e) { + this.lastException = e; + this.sendData(); + } + } else { + this.disassemble(); + this.sendData(); + } + } + if (firePowered != prevFirePowered) { + this.getLevel().setBlock(this.worldPosition, this.getBlockState().setValue(FixedCannonMountBlock.FIRE_POWERED, firePowered), 3); + } + if (this.running && this.mountedContraption != null && this.getLevel() instanceof ServerLevel slevel) { + ((AbstractMountedCannonContraption) this.mountedContraption.getContraption()).onRedstoneUpdate(slevel, this.mountedContraption, firePowered != prevFirePowered, firePower, this); + } + } + + @Override + public void tick() { + super.tick(); + + if (this.mountedContraption != null && !this.mountedContraption.isAlive()) + this.mountedContraption = null; + this.applyRotation(); + } + + protected void applyRotation() { + if (this.mountedContraption == null) + return; + Direction dir = this.mountedContraption.getInitialOrientation(); + boolean flag = (dir.getAxisDirection() == Direction.AxisDirection.POSITIVE) == (dir.getAxis() == Direction.Axis.X); + float sgn = flag ? 1 : -1; + + float pitchAdjust = this.pitchSlot == null ? 0 : this.pitchSlot.getValue(); + this.mountedContraption.pitch = (this.cannonPitch + pitchAdjust) * sgn; + float yawAdjust = this.yawSlot == null ? 0 : this.yawSlot.getValue(); + this.mountedContraption.yaw = this.cannonYaw + yawAdjust; + } + + @Override + public void lazyTick() { + super.lazyTick(); + if (this.running && this.mountedContraption != null) { + this.sendData(); + } + } + + protected void assemble() throws AssemblyException { + if (!CBCBlocks.FIXED_CANNON_MOUNT.has(this.getBlockState())) + return; + Direction facing = this.getBlockState().getValue(BlockStateProperties.FACING); + BlockPos assemblyPos = this.worldPosition.relative(facing); + if (this.getLevel().isOutsideBuildHeight(assemblyPos)) + throw cannonBlockOutsideOfWorld(assemblyPos); + + AbstractMountedCannonContraption mountedCannon = this.getContraption(assemblyPos); + if (mountedCannon == null || !mountedCannon.assemble(this.getLevel(), assemblyPos)) + return; + Direction facing1 = mountedCannon.initialOrientation(); + this.running = true; + + mountedCannon.removeBlocksFromWorld(this.getLevel(), BlockPos.ZERO); + PitchOrientedContraptionEntity contraptionEntity = PitchOrientedContraptionEntity.create(this.getLevel(), mountedCannon, facing1, this); + this.mountedContraption = contraptionEntity; + this.resetContraptionToOffset(); + this.getLevel().addFreshEntity(contraptionEntity); + + this.sendData(); + + AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(this.getLevel(), this.worldPosition); + } + + private AbstractMountedCannonContraption getContraption(BlockPos pos) { + return this.level.getBlockState(pos).getBlock() instanceof CannonContraptionProviderBlock provBlock ? provBlock.getCannonContraption() : null; + } + + protected void resetContraptionToOffset() { + if (this.mountedContraption == null) + return; + this.cannonPitch = 0; + this.cannonYaw = this.getContraptionDirection().toYRot(); + + this.mountedContraption.pitch = this.cannonPitch; + this.mountedContraption.yaw = this.cannonYaw; + this.mountedContraption.prevPitch = this.mountedContraption.pitch; + this.mountedContraption.prevYaw = this.mountedContraption.yaw; + + this.mountedContraption.setXRot(this.cannonPitch); + this.mountedContraption.setYRot(this.cannonYaw); + this.mountedContraption.xRotO = this.mountedContraption.getXRot(); + this.mountedContraption.yRotO = this.mountedContraption.getYRot(); + + Direction facing = this.getBlockState().getValue(BlockStateProperties.FACING); + Vec3 vec = Vec3.atBottomCenterOf((this.worldPosition.relative(facing))); + this.mountedContraption.setPos(vec); + } + + public Direction getContraptionDirection() { + return this.mountedContraption == null ? Direction.NORTH + : ((AbstractMountedCannonContraption) this.mountedContraption.getContraption()).initialOrientation(); + } + + @Override + public void disassemble() { + if (!this.running && this.mountedContraption == null) + return; + if (this.mountedContraption != null) { + this.resetContraptionToOffset(); + this.mountedContraption.save(new CompoundTag()); // Crude refresh of block data + this.mountedContraption.disassemble(); + AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(this.getLevel(), this.worldPosition); + } + + this.running = false; + } + + @Override public AssemblyException getLastAssemblyException() { return this.lastException; } + + @Override public boolean isAttachedTo(AbstractContraptionEntity entity) { return this.mountedContraption == entity; } + + @Override + public void attach(PitchOrientedContraptionEntity contraption) { + if (!(contraption.getContraption() instanceof AbstractMountedCannonContraption)) + return; + this.mountedContraption = contraption; + if (!this.level.isClientSide) { + this.running = true; + this.sendData(); + } + } + + @Override + public void onStall() { + if (!this.level.isClientSide) + this.sendData(); + } + + @Override + public BlockPos getDismountPositionForContraption(PitchOrientedContraptionEntity poce) { + Direction facing = this.getBlockState().getValue(BlockStateProperties.FACING); + return this.worldPosition.relative(this.mountedContraption.getInitialOrientation().getOpposite()).relative(facing); + } + + @Override public BlockState getControllerState() { return this.getBlockState(); } + + @Override public BlockPos getControllerBlockPos() { return this.worldPosition; } + + @Override + public void remove() { + this.remove = true; + if (!this.level.isClientSide) + this.disassemble(); + super.remove(); + } + + @Override + protected void write(CompoundTag tag, boolean clientPacket) { + super.write(tag, clientPacket); + tag.putBoolean("Running", this.running); + tag.putFloat("CannonYaw", this.cannonYaw); + tag.putFloat("CannonPitch", this.cannonPitch); + AssemblyException.write(tag, this.lastException); + } + + @Override + protected void read(CompoundTag tag, boolean clientPacket) { + super.read(tag, clientPacket); + this.running = tag.getBoolean("Running"); + this.cannonYaw = tag.getFloat("CannonYaw"); + this.cannonPitch = tag.getFloat("CannonPitch"); + this.lastException = AssemblyException.read(tag); + + if (!clientPacket) return; + + if (!this.running) + this.mountedContraption = null; + } + + public static class FixedCannonMountScrollValueBehaviour extends ValveHandleBlockEntity.ValveHandleScrollValueBehaviour { + public static final BehaviourType PITCH_TYPE = new BehaviourType<>(); + public static final BehaviourType YAW_TYPE = new BehaviourType<>(); + + private final boolean pitch; + private final ValueBoxTransform newSlotPositioning; + + public FixedCannonMountScrollValueBehaviour(SmartBlockEntity be, boolean pitch) { + super(be); + String suffix = pitch ? "pitch" : "yaw"; + this.setLabel(Lang.builder(CreateBigCannons.MOD_ID).translate("fixed_cannon_mount.angle_" + suffix).component()); + this.newSlotPositioning = new FixedCannonMountValueBox(pitch); + this.pitch = pitch; + this.between(-45, 45); + this.withFormatter(v -> { + return String.format("%s%d", v < 0 ? "-" : v > 0 ? "+" : "", Math.abs(v)) + Lang.translateDirect("generic.unit.degrees").getString(); + }); + } + + @Override + public boolean testHit(Vec3 hit) { + BlockState state = this.blockEntity.getBlockState(); + Vec3 localHit = hit.subtract(Vec3.atLowerCornerOf(this.blockEntity.getBlockPos())); + return this.newSlotPositioning.testHit(state, localHit); + } + + @Override + public MutableComponent formatValue(ValueSettings settings) { + int sgn = settings.row() == 0 ? -1 : 1; + return Lang.number(settings.value() * sgn) + .add(Lang.translateDirect("generic.unit.degrees")) + .component(); + } + + @Override public void onShortInteract(Player player, InteractionHand hand, Direction side) {} + + @Override + public void setValueSettings(Player player, ValueSettings valueSetting, boolean ctrlHeld) { + int value = valueSetting.value(); + if (!valueSetting.equals(this.getValueSettings())) + this.playFeedbackSound(this); + this.setValue(valueSetting.row() == 0 ? -value : value); + } + + @Override + public ValueSettingsBoard createBoard(Player player, BlockHitResult hitResult) { + ImmutableList rows = ImmutableList.of(Components.literal("-") + .withStyle(ChatFormatting.BOLD), + Components.literal("+") + .withStyle(ChatFormatting.BOLD)); + return new ValueSettingsBoard(this.label, 45, 15, rows, new ValueSettingsFormatter(this::formatValue)); + } + + @Override public ValueBoxTransform getSlotPositioning() { return this.newSlotPositioning; } + + @Override public BehaviourType getType() { return this.pitch ? PITCH_TYPE : YAW_TYPE; } + + public boolean setsPitch() { return this.pitch; } + + @Override + public void write(CompoundTag nbt, boolean clientPacket) { + nbt.putInt(this.pitch ? "PitchAdjustment" : "YawAdjustment", this.value); + } + + @Override + public void read(CompoundTag nbt, boolean clientPacket) { + this.value = nbt.getInt(this.pitch ? "PitchAdjustment" : "YawAdjustment"); + } + } + + public static class FixedCannonMountValueBox extends CenteredSideValueBoxTransform { + private final boolean pitch; + + public FixedCannonMountValueBox(boolean pitch) { + super((state, dir) -> { + return state.getValue(BlockStateProperties.FACING) != dir; + }); + this.pitch = pitch; + } + + @Override + protected Vec3 getSouthLocation() { + double xOffset = this.pitch ? -4 : 4; + return VecHelper.voxelSpace(8 + xOffset, 8, 15.5); + } + } + +} diff --git a/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBoxRenderer.java b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBoxRenderer.java new file mode 100644 index 000000000..dad940d17 --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountBoxRenderer.java @@ -0,0 +1,90 @@ +package rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount; + +import java.util.ArrayList; +import java.util.List; + +import com.mojang.datafixers.util.Pair; +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; +import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; +import com.simibubi.create.foundation.utility.Components; +import com.simibubi.create.foundation.utility.Iterate; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import rbasamoyai.createbigcannons.CreateBigCannons; + +public class FixedCannonMountBoxRenderer { + + /** + * Adpated from {@link com.simibubi.create.content.redstone.link.LinkRenderer} + */ + public static void tick() { + Minecraft mc = Minecraft.getInstance(); + HitResult target = mc.hitResult; + if (target == null || !(target instanceof BlockHitResult)) + return; + + BlockHitResult result = (BlockHitResult) target; + ClientLevel level = mc.level; + BlockPos pos = result.getBlockPos(); + Direction face = result.getDirection(); + + Component anglePitch = Lang.builder(CreateBigCannons.MOD_ID).translate("fixed_cannon_mount.angle_pitch").component(); + Component angleYaw = Lang.builder(CreateBigCannons.MOD_ID).translate("fixed_cannon_mount.angle_yaw").component(); + + for (boolean pitch : Iterate.trueAndFalse) { + BehaviourType type = pitch ? FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour.PITCH_TYPE : FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour.YAW_TYPE; + FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour behaviour = BlockEntityBehaviour.get(level, pos, type); + if (behaviour == null) + continue; + Pair, BlockPos> slot = Pair.of(type, pos); + if (!behaviour.isActive()) { + CreateClient.OUTLINER.remove(slot); + continue; + } + + Component label = pitch ? anglePitch : angleYaw; + boolean hit = behaviour.testHit(target.getLocation()); + addBox(level, pos, face, behaviour, hit, slot); + + if (!hit) + continue; + + List tip = new ArrayList<>(); + tip.add(label.copy()); + tip.add(Lang.translateDirect("gui.value_settings.hold_to_edit")); + CreateClient.VALUE_SETTINGS_HANDLER.showHoverTip(tip); + } + } + + /** + * Copied from {@link com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueRenderer} + */ + protected static void addBox(ClientLevel level, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, + boolean highlight, Object slot) { + AABB bb = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.5f) + .contract(0, 0, -.5f) + .move(0, 0, -.125f); + Component label = behaviour.label; + ValueBox box = new ValueBox.TextValueBox(label, bb, pos, Components.literal(behaviour.formatValue())); + + box.passive(!highlight) + .wideOutline(); + + CreateClient.OUTLINER.showValueBox(slot, box.transform(behaviour.getSlotPositioning())) + .highlightFace(face); + } + +} diff --git a/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountValueScreen.java b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountValueScreen.java new file mode 100644 index 000000000..7c1c7da84 --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/cannon_control/fixed_cannon_mount/FixedCannonMountValueScreen.java @@ -0,0 +1,36 @@ +package rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount; + +import java.util.function.Consumer; + +import com.simibubi.create.AllKeys; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour.ValueSettings; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBoard; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsScreen; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import rbasamoyai.createbigcannons.multiloader.NetworkPlatform; +import rbasamoyai.createbigcannons.network.ServerboundSetFixedCannonMountValuePacket; + +public class FixedCannonMountValueScreen extends ValueSettingsScreen { + + private final boolean pitch; + private final BlockPos posCopy; + + public FixedCannonMountValueScreen(BlockPos pos, ValueSettingsBoard board, ValueSettings valueSettings, + Consumer onHover, boolean pitch) { + super(pos, board, valueSettings, onHover); + this.pitch = pitch; + this.posCopy = pos; + } + + @Override + protected void saveAndClose(double pMouseX, double pMouseY) { + ValueSettings closest = getClosestCoordinate((int) pMouseX, (int) pMouseY); + // FIXME: value settings may be face-sensitive on future components - taken from ValueSettingsScreen#saveAndClose + NetworkPlatform.sendToServer(new ServerboundSetFixedCannonMountValuePacket(this.posCopy, closest.row(), closest.value(), + null, Direction.UP, AllKeys.ctrlDown(), this.pitch)); + this.onClose(); + } + +} diff --git a/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCBuilderTransformers.java b/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCBuilderTransformers.java index 845c568cf..552dacbe3 100644 --- a/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCBuilderTransformers.java +++ b/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCBuilderTransformers.java @@ -86,6 +86,7 @@ public class CBCBuilderTransformers { @ExpectPlatform public static NonNullUnaryOperator> cannonMount() { throw new AssertionError(); } @ExpectPlatform public static NonNullUnaryOperator> yawController() { throw new AssertionError(); } @ExpectPlatform public static NonNullUnaryOperator> cannonMountExtension() { throw new AssertionError(); } + @ExpectPlatform public static NonNullUnaryOperator> fixedCannonMount() { throw new AssertionError(); } @ExpectPlatform public static NonNullUnaryOperator> cannonCarriage() { throw new AssertionError(); } @ExpectPlatform public static NonNullUnaryOperator> invisibleWithParticle(String path) { throw new AssertionError(); } @ExpectPlatform public static NonNullUnaryOperator> slidingBreechblock(String pathAndMaterial) { throw new AssertionError(); } diff --git a/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCLangGen.java b/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCLangGen.java index 5b8213753..1cd919b84 100644 --- a/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCLangGen.java +++ b/src/main/java/rbasamoyai/createbigcannons/datagen/assets/CBCLangGen.java @@ -35,6 +35,8 @@ public static void prepare() { REGISTRATE.addLang("exception", CreateBigCannons.resource("cannon_mount"), "hasIncompleteCannonBlocks", "Cannon block at [%s, %s, %s] has not finished the crafting process"); REGISTRATE.addLang("exception", CreateBigCannons.resource("cannon_mount"), "noAutocannonBreech", "This cannon requires an autocannon breech to fire"); REGISTRATE.addLang("exception", CreateBigCannons.resource("cannon_mount"), "incorrectBreechDirection", "Cannon block at [%s, %s, %s] should be reversed"); + REGISTRATE.addRawLang(CreateBigCannons.MOD_ID + ".fixed_cannon_mount.angle_pitch", "Pitch Adjustment"); + REGISTRATE.addRawLang(CreateBigCannons.MOD_ID + ".fixed_cannon_mount.angle_yaw", "Yaw Adjustment"); REGISTRATE.addLang("exception", CreateBigCannons.resource("casting"), "Cannon cast at [%s, %s, %s] does not have a valid recipe for fluid %s and shape %s"); REGISTRATE.addLang("death.attack", CreateBigCannons.resource("shrapnel"), "%s was ripped up by shrapnel"); REGISTRATE.addLang("death.attack", CreateBigCannons.resource("grapeshot"), "%s was blown out by grapeshot"); diff --git a/src/main/java/rbasamoyai/createbigcannons/index/CBCBlockEntities.java b/src/main/java/rbasamoyai/createbigcannons/index/CBCBlockEntities.java index 137111dda..d2f0c6974 100644 --- a/src/main/java/rbasamoyai/createbigcannons/index/CBCBlockEntities.java +++ b/src/main/java/rbasamoyai/createbigcannons/index/CBCBlockEntities.java @@ -12,6 +12,7 @@ import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountInstance; import rbasamoyai.createbigcannons.cannon_control.cannon_mount.YawControllerBlockEntity; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlockEntity; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity; import rbasamoyai.createbigcannons.cannon_loading.CannonLoaderBlockEntity; import rbasamoyai.createbigcannons.cannons.autocannon.AutocannonBlockEntity; import rbasamoyai.createbigcannons.cannons.autocannon.breech.AbstractAutocannonBreechBlockEntity; @@ -228,6 +229,11 @@ public class CBCBlockEntities { .validBlocks(CBCBlocks.AUTOCANNON_AMMO_CONTAINER, CBCBlocks.CREATIVE_AUTOCANNON_AMMO_CONTAINER) .register(); + public static final BlockEntityEntry FIXED_CANNON_MOUNT = REGISTRATE + .blockEntity("fixed_cannon_mount", FixedCannonMountBlockEntity::new) + .validBlock(CBCBlocks.FIXED_CANNON_MOUNT) + .register(); + public static void register() { } diff --git a/src/main/java/rbasamoyai/createbigcannons/index/CBCBlocks.java b/src/main/java/rbasamoyai/createbigcannons/index/CBCBlocks.java index c0e22dd54..6ac0f6a6e 100644 --- a/src/main/java/rbasamoyai/createbigcannons/index/CBCBlocks.java +++ b/src/main/java/rbasamoyai/createbigcannons/index/CBCBlocks.java @@ -35,6 +35,7 @@ import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountExtensionBlock; import rbasamoyai.createbigcannons.cannon_control.cannon_mount.YawControllerBlock; import rbasamoyai.createbigcannons.cannon_control.carriage.CannonCarriageBlock; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlock; import rbasamoyai.createbigcannons.cannon_loading.CannonLoaderBlock; import rbasamoyai.createbigcannons.cannon_loading.RamHeadBlock; import rbasamoyai.createbigcannons.cannon_loading.WormHeadBlock; @@ -873,6 +874,14 @@ private static NonNullSupplier steelSlidingBreech() { .onRegister(AllDisplayBehaviours.assignDataBehaviour(new CannonMountDisplaySource())) .register(); + public static final BlockEntry FIXED_CANNON_MOUNT = REGISTRATE + .block("fixed_cannon_mount", FixedCannonMountBlock::new) + .transform(cbcMachine()) + .transform(axeOrPickaxe()) + .transform(CBCBuilderTransformers.fixedCannonMount()) + .onRegister(AllDisplayBehaviours.assignDataBehaviour(new CannonMountDisplaySource())) + .register(); + public static final BlockEntry CANNON_CARRIAGE = REGISTRATE .block("cannon_carriage", CannonCarriageBlock::new) .initialProperties(() -> Blocks.OAK_PLANKS) diff --git a/src/main/java/rbasamoyai/createbigcannons/mixin/client/ValueSettingsClientMixin.java b/src/main/java/rbasamoyai/createbigcannons/mixin/client/ValueSettingsClientMixin.java new file mode 100644 index 000000000..76598d6c8 --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/mixin/client/ValueSettingsClientMixin.java @@ -0,0 +1,36 @@ +package rbasamoyai.createbigcannons.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsClient; + +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.BlockHitResult; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountValueScreen; + +@Mixin(ValueSettingsClient.class) +public class ValueSettingsClientMixin { + + @Shadow public BlockPos interactHeldPos; + + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/gui/ScreenOpener;open(Lnet/minecraft/client/gui/screens/Screen;)V"), remap = false) + private void createbigcannons$tick$openScreen(Screen screen, Operation original, @Local ValueSettingsBehaviour valueSettingBehaviour, + @Local Player player, @Local BlockHitResult blockHitResult) { + if (valueSettingBehaviour instanceof FixedCannonMountScrollValueBehaviour fixedMountBehaviour) { + original.call(new FixedCannonMountValueScreen(this.interactHeldPos, valueSettingBehaviour.createBoard(player, blockHitResult), + valueSettingBehaviour.getValueSettings(), valueSettingBehaviour::newSettingHovered, fixedMountBehaviour.setsPitch())); + return; + } + original.call(screen); + } + +} diff --git a/src/main/java/rbasamoyai/createbigcannons/network/CBCRootNetwork.java b/src/main/java/rbasamoyai/createbigcannons/network/CBCRootNetwork.java index 9729cb858..c263ec947 100644 --- a/src/main/java/rbasamoyai/createbigcannons/network/CBCRootNetwork.java +++ b/src/main/java/rbasamoyai/createbigcannons/network/CBCRootNetwork.java @@ -26,7 +26,7 @@ public class CBCRootNetwork { private static final Int2ObjectMap> ID_TO_CONSTRUCTOR = new Int2ObjectOpenHashMap<>(); private static final Object2IntMap> TYPE_TO_ID = new Object2IntOpenHashMap<>(); - public static final String VERSION = "13.0.0"; + public static final String VERSION = "14.0.0"; public static void init() { int id = 0; @@ -58,6 +58,7 @@ public static void init() { addMsg(id++, ClientboundSendCustomBreakProgressPacket.class, ClientboundSendCustomBreakProgressPacket::new); addMsg(id++, ClientboundFluidDragPacket.class, ClientboundFluidDragPacket::copyOf); addMsg(id++, ClientboundBlastSoundPacket.class, ClientboundBlastSoundPacket::new); + addMsg(id++, ServerboundSetFixedCannonMountValuePacket.class, ServerboundSetFixedCannonMountValuePacket::new); } private static void addMsg(int id, Class clazz, Function decoder) { diff --git a/src/main/java/rbasamoyai/createbigcannons/network/ServerboundSetFixedCannonMountValuePacket.java b/src/main/java/rbasamoyai/createbigcannons/network/ServerboundSetFixedCannonMountValuePacket.java new file mode 100644 index 000000000..aba2dc93b --- /dev/null +++ b/src/main/java/rbasamoyai/createbigcannons/network/ServerboundSetFixedCannonMountValuePacket.java @@ -0,0 +1,83 @@ +package rbasamoyai.createbigcannons.network; + +import java.util.concurrent.Executor; + +import javax.annotation.Nullable; + +import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; +import com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsPacket; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.PacketListener; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity; +import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity.FixedCannonMountScrollValueBehaviour; + +/** + * Adapted from {@link ValueSettingsPacket} + */ +public record ServerboundSetFixedCannonMountValuePacket(BlockPos pos, int row, int value, @Nullable InteractionHand interactHand, + Direction side, boolean ctrlDown, boolean pitch) implements RootPacket { + + public ServerboundSetFixedCannonMountValuePacket(FriendlyByteBuf buf) { + this(buf.readBlockPos(), buf.readVarInt(), buf.readVarInt(), + buf.readBoolean() ? + buf.readBoolean() ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND + : null, Direction.values()[buf.readVarInt()], buf.readBoolean(), buf.readBoolean()); + } + + @Override + public void rootEncode(FriendlyByteBuf buf) { + buf.writeBlockPos(this.pos) + .writeVarInt(this.row) + .writeVarInt(this.value) + .writeBoolean(this.interactHand != null); + if (this.interactHand != null) + buf.writeBoolean(this.interactHand == InteractionHand.MAIN_HAND); + buf.writeVarInt(this.side.ordinal()) + .writeBoolean(this.ctrlDown) + .writeBoolean(this.pitch); + } + + @Override + public void handle(Executor exec, PacketListener listener, @Nullable ServerPlayer sender) { + // Adapted from BlockEntityConfigurationPacket#handle + exec.execute(() -> { + if (sender == null) + return; + Level level = sender.level(); + if (level == null || !level.isLoaded(this.pos)) + return; + if (!this.pos.closerThan(sender.blockPosition(), 20)) + return; + BlockEntity blockEntity = level.getBlockEntity(this.pos); + if (!(blockEntity instanceof FixedCannonMountBlockEntity mount)) + return; + this.applySettings(sender, mount); + mount.sendData(); + blockEntity.setChanged(); + }); + } + + private void applySettings(ServerPlayer player, SmartBlockEntity be) { + // Adapted from ValueSettingsPacket#applySettings + BehaviourType type = this.pitch ? FixedCannonMountScrollValueBehaviour.PITCH_TYPE : FixedCannonMountScrollValueBehaviour.YAW_TYPE; + BlockEntityBehaviour behaviour = be.getBehaviour(type); + if (!(behaviour instanceof FixedCannonMountScrollValueBehaviour angleBehaviour) || !angleBehaviour.acceptsValueSettings()) + return; + if (this.interactHand != null) { + angleBehaviour.onShortInteract(player, this.interactHand, this.side); + return; + } + angleBehaviour.setValueSettings(player, new ValueSettingsBehaviour.ValueSettings(this.row, this.value), this.ctrlDown); + } + +} diff --git a/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_east.json b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_east.json new file mode 100644 index 000000000..0581f9176 --- /dev/null +++ b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_east.json @@ -0,0 +1,26 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "createbigcannons:block/cannon_mount/cannon_loader_nook", + "1": "createbigcannons:block/cannon_mount/cannon_mount_firing", + "2": "createbigcannons:block/cannon_mount/cannon_mount_toggle", + "3": "createbigcannons:block/cannon_mount/rotating_mount_plate", + "particle": "createbigcannons:block/cannon_mount/cannon_loader_nook" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "east": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "up": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_north.json b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_north.json new file mode 100644 index 000000000..b269e9124 --- /dev/null +++ b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_north.json @@ -0,0 +1,25 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "createbigcannons:block/cannon_mount/cannon_loader_nook", + "1": "createbigcannons:block/cannon_mount/cannon_mount_firing", + "2": "createbigcannons:block/cannon_mount/cannon_mount_toggle", + "3": "createbigcannons:block/cannon_mount/rotating_mount_plate", + "particle": "createbigcannons:block/cannon_mount/cannon_loader_nook" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "east": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#3"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_south.json b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_south.json new file mode 100644 index 000000000..7751fadbb --- /dev/null +++ b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_south.json @@ -0,0 +1,26 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "createbigcannons:block/cannon_mount/cannon_loader_nook", + "1": "createbigcannons:block/cannon_mount/cannon_mount_firing", + "2": "createbigcannons:block/cannon_mount/cannon_mount_toggle", + "3": "createbigcannons:block/cannon_mount/rotating_mount_plate", + "particle": "createbigcannons:block/cannon_mount/cannon_loader_nook" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "east": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#3"}, + "down": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_west.json b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_west.json new file mode 100644 index 000000000..ee3d815fb --- /dev/null +++ b/src/main/resources/assets/createbigcannons/models/block/cannon_mount/fixed_cannon_mount_west.json @@ -0,0 +1,25 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "createbigcannons:block/cannon_mount/cannon_loader_nook", + "1": "createbigcannons:block/cannon_mount/cannon_mount_firing", + "2": "createbigcannons:block/cannon_mount/cannon_mount_toggle", + "3": "createbigcannons:block/cannon_mount/rotating_mount_plate", + "particle": "createbigcannons:block/cannon_mount/cannon_loader_nook" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "east": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#3"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/createbigcannons-common.mixins.json b/src/main/resources/createbigcannons-common.mixins.json index 0d6c5b722..04a2f48aa 100644 --- a/src/main/resources/createbigcannons-common.mixins.json +++ b/src/main/resources/createbigcannons-common.mixins.json @@ -19,7 +19,8 @@ "client.PoleContraptionMixin", "client.PonderRegistryMixin", "client.RPLClientHandlersMixin", - "client.SoundEngineMixin" + "client.SoundEngineMixin", + "client.ValueSettingsClientMixin" ], "mixins": [ "ArmorStandMixin", diff --git a/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/autocannon.json b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/autocannon.json new file mode 100644 index 000000000..ac5863834 --- /dev/null +++ b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/autocannon.json @@ -0,0 +1,6 @@ +{ + "pitch_range": { + "maximum_depression": 90, + "maximum_elevation": 90 + } +} diff --git a/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/big_cannon.json b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/big_cannon.json new file mode 100644 index 000000000..ac5863834 --- /dev/null +++ b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/big_cannon.json @@ -0,0 +1,6 @@ +{ + "pitch_range": { + "maximum_depression": 90, + "maximum_elevation": 90 + } +} diff --git a/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/drop_mortar.json b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/drop_mortar.json new file mode 100644 index 000000000..ac5863834 --- /dev/null +++ b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/drop_mortar.json @@ -0,0 +1,6 @@ +{ + "pitch_range": { + "maximum_depression": 90, + "maximum_elevation": 90 + } +} diff --git a/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/handle_autocannon.json b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/handle_autocannon.json new file mode 100644 index 000000000..ac5863834 --- /dev/null +++ b/src/main/resources/data/createbigcannons/cannon_mounts/block_entities/fixed_cannon_mount/createbigcannons/handle_autocannon.json @@ -0,0 +1,6 @@ +{ + "pitch_range": { + "maximum_depression": 90, + "maximum_elevation": 90 + } +}