Refactor and Bugs

- Added missing recipe for Dark Scoria
- Refactored Cart Assembler
- Removed reinforced rails from creative tab
- Fixed blockzappers placing waterlogged blocks #350
This commit is contained in:
simibubi 2020-06-13 20:41:08 +02:00
parent 0bee531b7e
commit 0d616b7a21
24 changed files with 461 additions and 444 deletions

View File

@ -23,7 +23,7 @@ cf9045eb16e5299a1d917c4cb536289f49411276 assets\create\blockstates\birch_window.
94a1a91403eb4b035fec48071e7fcae57a8a6abd assets\create\blockstates\birch_window_pane.json 94a1a91403eb4b035fec48071e7fcae57a8a6abd assets\create\blockstates\birch_window_pane.json
8b1dd00adcc7e74c5a9feed069e2610b15a338cb assets\create\blockstates\brass_block.json 8b1dd00adcc7e74c5a9feed069e2610b15a338cb assets\create\blockstates\brass_block.json
b8dd6e505943e06706d0718ece620ab3cf943650 assets\create\blockstates\brass_casing.json b8dd6e505943e06706d0718ece620ab3cf943650 assets\create\blockstates\brass_casing.json
dd1e9a928702415722f99d165571c2d63d847987 assets\create\blockstates\cart_assembler.json 26f3b6a8f8249e4e622ab200057d75e228762817 assets\create\blockstates\cart_assembler.json
7299cea212d879d6d5611bd139b24768b9af236f assets\create\blockstates\chiseled_dark_scoria.json 7299cea212d879d6d5611bd139b24768b9af236f assets\create\blockstates\chiseled_dark_scoria.json
0f01f813388d3e6907c1cfd992e4b21c914e267e assets\create\blockstates\chiseled_dolomite.json 0f01f813388d3e6907c1cfd992e4b21c914e267e assets\create\blockstates\chiseled_dolomite.json
324488e0c228f38f2597b2f76849e962bc1a7d90 assets\create\blockstates\chiseled_gabbro.json 324488e0c228f38f2597b2f76849e962bc1a7d90 assets\create\blockstates\chiseled_gabbro.json
@ -273,7 +273,7 @@ b7829c2ef2c47188713f8cab21b2c9bc7f9c5b79 assets\create\blockstates\portable_stor
e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets\create\blockstates\powered_toggle_latch.json e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets\create\blockstates\powered_toggle_latch.json
3a739f9d4276828d83f2d2750bf3227c87bcd438 assets\create\blockstates\pulley_magnet.json 3a739f9d4276828d83f2d2750bf3227c87bcd438 assets\create\blockstates\pulley_magnet.json
469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets\create\blockstates\pulse_repeater.json 469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets\create\blockstates\pulse_repeater.json
5d1b30c2bab556f57c78e7780fd445b08f541a50 assets\create\blockstates\radial_chassis.json 4e1fb033316e9230d2f024d67c27940ea731643a assets\create\blockstates\radial_chassis.json
8929677f2cc5354aa19ef182af69f9f0b41eb242 assets\create\blockstates\redstone_contact.json 8929677f2cc5354aa19ef182af69f9f0b41eb242 assets\create\blockstates\redstone_contact.json
c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets\create\blockstates\redstone_link.json c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets\create\blockstates\redstone_link.json
1eac804cba08aebb5f4646758ae1ef9b32e01365 assets\create\blockstates\reinforced_rail.json 1eac804cba08aebb5f4646758ae1ef9b32e01365 assets\create\blockstates\reinforced_rail.json
@ -326,7 +326,7 @@ c77b46d8b459e5c7cc495393546f3fcca8a1fa1d assets\create\blockstates\weathered_lim
7f39521b211441f5c3e06d60c5978cebe16cacfb assets\create\blockstates\zinc_block.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets\create\blockstates\zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.json
6bf74a9e1f74b41f53399c1f817942b01a010bf0 assets\create\lang\en_ud.json 6bf74a9e1f74b41f53399c1f817942b01a010bf0 assets\create\lang\en_ud.json
fd0932555a5afde9c3c5f990f78de545814cc4ab assets\create\lang\en_us.json 966d4802e7f260d852e422c5f47b2a9389557373 assets\create\lang\en_us.json
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets\create\models\block\acacia_window.json 846200eb548d3bfa2e77b41039de159b4b6cfb45 assets\create\models\block\acacia_window.json
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.json 1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.json
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets\create\models\block\acacia_window_pane_noside_alt.json 1763ea2c9b981d187f5031ba608f3d5d3be3986a assets\create\models\block\acacia_window_pane_noside_alt.json
@ -925,7 +925,7 @@ f5a18f4279c2e845a5967b1c2f9e807c2bb77afb assets\create\models\item\brass_casing.
1786bdffa2ab5a07c88d2797db3d7b54461323c4 assets\create\models\item\brass_ingot.json 1786bdffa2ab5a07c88d2797db3d7b54461323c4 assets\create\models\item\brass_ingot.json
a37be4a0ec9bf6c381527403c57ced4f81abd67c assets\create\models\item\brass_nugget.json a37be4a0ec9bf6c381527403c57ced4f81abd67c assets\create\models\item\brass_nugget.json
14ea6ee4db6e7e76446e331a70b6b6bec31e8eb7 assets\create\models\item\brass_sheet.json 14ea6ee4db6e7e76446e331a70b6b6bec31e8eb7 assets\create\models\item\brass_sheet.json
b362b940fe9074f0a9b8d53d8a12b41f18c2c292 assets\create\models\item\cart_assembler.json 3e232a103f7f916fc11edb4d541ca99fe7b44181 assets\create\models\item\cart_assembler.json
99d64b76b3baa84c3bd4b96ccd3376ca12425950 assets\create\models\item\chiseled_dark_scoria.json 99d64b76b3baa84c3bd4b96ccd3376ca12425950 assets\create\models\item\chiseled_dark_scoria.json
83d3571eacde52568786802b268f24c6578c1e5d assets\create\models\item\chiseled_dolomite.json 83d3571eacde52568786802b268f24c6578c1e5d assets\create\models\item\chiseled_dolomite.json
afd697168c9786eb80e54eccdc6a23afa6c7fb0e assets\create\models\item\chiseled_gabbro.json afd697168c9786eb80e54eccdc6a23afa6c7fb0e assets\create\models\item\chiseled_gabbro.json

View File

@ -1,73 +1,59 @@
{ {
"variants": { "variants": {
"powered=false,rail_type=0,shape=north_south": { "powered=false,rail_type=regular,shape=north_south": {
"model": "create:block/cart_assembler/block_none" "model": "create:block/cart_assembler/block_regular"
}, },
"powered=true,rail_type=0,shape=north_south": { "powered=true,rail_type=regular,shape=north_south": {
"model": "create:block/cart_assembler/block_powered_none" "model": "create:block/cart_assembler/block_regular_powered"
}, },
"powered=false,rail_type=1,shape=north_south": { "powered=false,rail_type=powered_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_rail_normal" "model": "create:block/cart_assembler/block_powered_rail"
}, },
"powered=true,rail_type=1,shape=north_south": { "powered=true,rail_type=powered_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_powered_rail_normal"
},
"powered=false,rail_type=2,shape=north_south": {
"model": "create:block/cart_assembler/block_rail_powered"
},
"powered=true,rail_type=2,shape=north_south": {
"model": "create:block/cart_assembler/block_powered_rail_powered" "model": "create:block/cart_assembler/block_powered_rail_powered"
}, },
"powered=false,rail_type=3,shape=north_south": { "powered=false,rail_type=detector_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_rail_detector" "model": "create:block/cart_assembler/block_detector_rail"
}, },
"powered=true,rail_type=3,shape=north_south": { "powered=true,rail_type=detector_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_powered_rail_detector" "model": "create:block/cart_assembler/block_detector_rail_powered"
}, },
"powered=false,rail_type=4,shape=north_south": { "powered=false,rail_type=activator_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_rail_activator" "model": "create:block/cart_assembler/block_activator_rail"
}, },
"powered=true,rail_type=4,shape=north_south": { "powered=true,rail_type=activator_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_powered_rail_activator" "model": "create:block/cart_assembler/block_activator_rail_powered"
}, },
"powered=false,rail_type=0,shape=east_west": { "powered=false,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_none", "model": "create:block/cart_assembler/block_regular",
"y": 90 "y": 90
}, },
"powered=true,rail_type=0,shape=east_west": { "powered=true,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_none", "model": "create:block/cart_assembler/block_regular_powered",
"y": 90 "y": 90
}, },
"powered=false,rail_type=1,shape=east_west": { "powered=false,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_rail_normal", "model": "create:block/cart_assembler/block_powered_rail",
"y": 90 "y": 90
}, },
"powered=true,rail_type=1,shape=east_west": { "powered=true,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_normal",
"y": 90
},
"powered=false,rail_type=2,shape=east_west": {
"model": "create:block/cart_assembler/block_rail_powered",
"y": 90
},
"powered=true,rail_type=2,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_powered", "model": "create:block/cart_assembler/block_powered_rail_powered",
"y": 90 "y": 90
}, },
"powered=false,rail_type=3,shape=east_west": { "powered=false,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_rail_detector", "model": "create:block/cart_assembler/block_detector_rail",
"y": 90 "y": 90
}, },
"powered=true,rail_type=3,shape=east_west": { "powered=true,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_detector", "model": "create:block/cart_assembler/block_detector_rail_powered",
"y": 90 "y": 90
}, },
"powered=false,rail_type=4,shape=east_west": { "powered=false,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_rail_activator", "model": "create:block/cart_assembler/block_activator_rail",
"y": 90 "y": 90
}, },
"powered=true,rail_type=4,shape=east_west": { "powered=true,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_activator", "model": "create:block/cart_assembler/block_activator_rail_powered",
"y": 90 "y": 90
} }
} }

View File

@ -89,8 +89,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_west": "true",
"sticky_west": "true" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -99,8 +99,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_west": "true",
"sticky_west": "true" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -109,8 +109,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_west": "true",
"sticky_west": "true" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z_sticky", "model": "create:block/radial_chassis_side_z_sticky",
@ -119,8 +119,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_west": "false",
"sticky_west": "false" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -129,8 +129,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_west": "false",
"sticky_west": "false" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -139,8 +139,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_west": "false",
"sticky_west": "false" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z", "model": "create:block/radial_chassis_side_z",
@ -149,8 +149,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_north": "true",
"sticky_north": "true" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky" "model": "create:block/radial_chassis_side_x_sticky"
@ -158,8 +158,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_north": "true",
"sticky_north": "true" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -168,8 +168,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_north": "true",
"sticky_north": "true" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -178,8 +178,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_north": "false",
"sticky_north": "false" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x" "model": "create:block/radial_chassis_side_x"
@ -187,8 +187,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_north": "false",
"sticky_north": "false" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -197,8 +197,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_north": "false",
"sticky_north": "false" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -207,8 +207,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "x",
"axis": "x" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -217,8 +217,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "y",
"axis": "y" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -227,8 +227,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "z",
"axis": "z" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z_sticky" "model": "create:block/radial_chassis_side_z_sticky"
@ -236,8 +236,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "x",
"axis": "x" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -246,8 +246,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "y",
"axis": "y" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -256,8 +256,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "z",
"axis": "z" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z" "model": "create:block/radial_chassis_side_z"

View File

@ -484,8 +484,7 @@
"death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock", "death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock",
"create.block.deployer.damage_source_name": "a rogue Deployer", "create.block.deployer.damage_source_name": "a rogue Deployer",
"create.block.cart_assembler.invalid": "Can not place a Cart Assembler on this rail type", "create.block.cart_assembler.invalid": "Place your Cart Assembler on a rail block",
"create.block.cart_assembler.invalid_update": "Invalid rail to update this Cart Assembler",
"create.recipe.crushing": "Crushing", "create.recipe.crushing": "Crushing",
"create.recipe.milling": "Milling", "create.recipe.milling": "Milling",

View File

@ -1,3 +1,3 @@
{ {
"parent": "create:block/cart_assembler/block_none" "parent": "create:block/cart_assembler/item"
} }

View File

@ -453,9 +453,7 @@ public class AllBlocks {
.addLayer(() -> RenderType::getCutoutMipped) .addLayer(() -> RenderType::getCutoutMipped)
.tag(BlockTags.RAILS) .tag(BlockTags.RAILS)
.item(CartAssemblerBlockItem::new) .item(CartAssemblerBlockItem::new)
.model((c, p) -> p.blockItem(() -> c.getEntry() .transform(customItemModel())
.getBlock(), "/block_none"))
.build()
.register(); .register();
public static final BlockEntry<ReinforcedRailBlock> REINFORCED_RAIL = public static final BlockEntry<ReinforcedRailBlock> REINFORCED_RAIL =

View File

@ -0,0 +1,32 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.IStringSerializable;
public enum CartAssembleRailType implements IStringSerializable {
REGULAR(Blocks.RAIL),
POWERED_RAIL(Blocks.POWERED_RAIL),
DETECTOR_RAIL(Blocks.DETECTOR_RAIL),
ACTIVATOR_RAIL(Blocks.ACTIVATOR_RAIL),
;
public Block railBlock;
public Item railItem;
private CartAssembleRailType(Block block) {
this.railBlock = block;
this.railItem = block.asItem();
}
@Override
public String getName() {
return Lang.asId(name());
}
}

View File

@ -1,14 +1,12 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted; package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
@ -18,31 +16,23 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.DetectorRailBlock;
import net.minecraft.block.PoweredRailBlock;
import net.minecraft.block.RailBlock;
import net.minecraft.block.material.PushReaction; import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty; import net.minecraft.state.EnumProperty;
import net.minecraft.state.IProperty; import net.minecraft.state.IProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
@ -57,7 +47,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -65,322 +54,308 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters; import net.minecraft.world.storage.loot.LootParameters;
public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAssemblerTileEntity>, IWrenchable, ISpecialBlockItemRequirement { public class CartAssemblerBlock extends AbstractRailBlock
implements ITE<CartAssemblerTileEntity>, IWrenchable, ISpecialBlockItemRequirement {
public static final int RAIL_NONE = 0; public static final IProperty<RailShape> RAIL_SHAPE =
public static final int RAIL_NORMAL = 1; EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
public static final int RAIL_POWERED = 2; public static final IProperty<CartAssembleRailType> RAIL_TYPE =
public static final int RAIL_DETECTOR = 3; EnumProperty.create("rail_type", CartAssembleRailType.class);
public static final int RAIL_ACTIVATOR = 4; public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
public static IProperty<RailShape> RAIL_SHAPE =
EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
public static IProperty<Integer> RAIL_TYPE = IntegerProperty.create("rail_type", 0, 4);
public static BooleanProperty POWERED = BlockStateProperties.POWERED; public CartAssemblerBlock(Properties properties) {
super(true, properties);
setDefaultState(getDefaultState().with(POWERED, false)
.with(RAIL_TYPE, CartAssembleRailType.POWERED_RAIL));
}
public CartAssemblerBlock(Properties properties) { public static BlockState createAnchor(BlockState state) {
super(true, properties); Axis axis = state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X;
setDefaultState(getDefaultState().with(POWERED, false).with(RAIL_TYPE, RAIL_POWERED)); return AllBlocks.MINECART_ANCHOR.getDefaultState()
} .with(BlockStateProperties.HORIZONTAL_AXIS, axis);
}
public static BlockState createAnchor(BlockState state) { private static Item getRailItem(BlockState state) {
Axis axis = state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X; return state.get(RAIL_TYPE).railItem;
return AllBlocks.MINECART_ANCHOR.getDefaultState() }
.with(BlockStateProperties.HORIZONTAL_AXIS, axis);
}
private static Item getRailItem(BlockState state) { public static BlockState getRailBlock(BlockState state) {
switch (state.get(RAIL_TYPE)) { AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).railBlock;
case RAIL_NORMAL: return railBlock.getDefaultState()
return Items.RAIL; .with(railBlock.getShapeProperty(), state.get(RAIL_SHAPE));
case RAIL_DETECTOR: }
return Items.DETECTOR_RAIL;
case RAIL_POWERED:
return Items.POWERED_RAIL;
case RAIL_ACTIVATOR:
return Items.ACTIVATOR_RAIL;
default:
return Items.AIR;
}
}
public static BlockState getRailBlock(BlockState assembler) { @Override
switch (assembler.get(RAIL_TYPE)) { protected void fillStateContainer(Builder<Block, BlockState> builder) {
case RAIL_NORMAL: builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE);
return Blocks.RAIL.getDefaultState().with(RailBlock.SHAPE, assembler.get(RAIL_SHAPE)); super.fillStateContainer(builder);
case RAIL_DETECTOR: }
return Blocks.DETECTOR_RAIL.getDefaultState().with(DetectorRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
case RAIL_POWERED:
return Blocks.POWERED_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
case RAIL_ACTIVATOR:
return Blocks.ACTIVATOR_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
default:
return Blocks.AIR.getDefaultState();
}
}
@Override @Override
protected void fillStateContainer(Builder<Block, BlockState> builder) { public boolean hasTileEntity(BlockState state) {
builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE); return true;
super.fillStateContainer(builder); }
}
@Override @Override
public boolean hasTileEntity(BlockState state) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return true; return AllTileEntities.CART_ASSEMBLER.create();
} }
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) {
return AllTileEntities.CART_ASSEMBLER.create(); return false;
} }
@Override @Override
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) { public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
return false; AbstractMinecartEntity cart) {
} if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
return;
@Override withTileEntityDo(world, pos, te -> {
public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, AbstractMinecartEntity cart) { if (te.isMinecartUpdateValid()) {
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity)) switch (state.get(RAIL_TYPE)) {
return; case POWERED_RAIL:
if (state.get(POWERED)) {
assemble(world, pos, cart);
Direction facing = cart.getAdjustedHorizontalFacing();
float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed,
facing.getZOffset() * speed);
} else {
disassemble(world, pos, cart);
Vec3d diff = VecHelper.getCenterOf(pos)
.subtract(cart.getPositionVec());
cart.setMotion(diff.x / 16f, 0, diff.z / 16f);
}
break;
case REGULAR:
if (state.get(POWERED)) {
assemble(world, pos, cart);
} else {
disassemble(world, pos, cart);
}
break;
case ACTIVATOR_RAIL:
if (state.get(POWERED)) {
disassemble(world, pos, cart);
}
break;
case DETECTOR_RAIL:
if (cart.getPassengers()
.isEmpty()) {
assemble(world, pos, cart);
Direction facing = cart.getAdjustedHorizontalFacing();
float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed,
facing.getZOffset() * speed);
} else {
disassemble(world, pos, cart);
}
break;
default:
break;
}
te.resetTicksSinceMinecartUpdate();
}
});
}
withTileEntityDo(world, pos, te -> { @Override
if (te.isMinecartUpdateValid()) { @Nonnull
switch (state.get(RAIL_TYPE)) { public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
case RAIL_POWERED: PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) {
if (state.get(POWERED)) {
assemble(world, pos, cart);
Direction facing = cart.getAdjustedHorizontalFacing();
float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed);
} else {
disassemble(world, pos, cart);
Vec3d diff = VecHelper.getCenterOf(pos)
.subtract(cart.getPositionVec());
cart.setMotion(diff.x / 16f, 0, diff.z / 16f);
}
break;
case RAIL_NORMAL:
if (state.get(POWERED)) {
assemble(world, pos, cart);
} else {
disassemble(world, pos, cart);
}
break;
case RAIL_ACTIVATOR:
if (state.get(POWERED)) {
disassemble(world, pos, cart);
}
break;
case RAIL_DETECTOR:
if (cart.getPassengers().isEmpty()) {
assemble(world, pos, cart);
Direction facing = cart.getAdjustedHorizontalFacing();
float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed);
} else {
disassemble(world, pos, cart);
}
break;
default:
break;
}
te.resetTicksSinceMinecartUpdate();
}
});
}
@Override ItemStack itemStack = player.getHeldItem(hand);
@Nonnull Item previousItem = getRailItem(state);
public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, Item heldItem = itemStack.getItem();
PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) { if (heldItem != previousItem) {
ItemStack itemStack = player.getHeldItem(hand); CartAssembleRailType newType = null;
if (itemStack.getItem() != getRailItem(state)) { for (CartAssembleRailType type : CartAssembleRailType.values())
if (heldItem == type.railItem)
newType = type;
if (newType == null)
return ActionResultType.PASS;
if (itemStack.getItem() == Items.RAIL) { world.setBlockState(pos, state.with(RAIL_TYPE, newType));
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_NORMAL));
} else if (itemStack.getItem() == Items.POWERED_RAIL) {
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_POWERED));
} else if (itemStack.getItem() == Items.ACTIVATOR_RAIL) {
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_ACTIVATOR));
} else if (itemStack.getItem() == Items.DETECTOR_RAIL) {
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_DETECTOR));
} else {
if(itemStack.getItem() instanceof BlockItem && ((BlockItem) itemStack.getItem()).getBlock() instanceof AbstractRailBlock) {
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid_update")), true);
}
return ActionResultType.PASS;
}
if (!player.isCreative()) {
itemStack.setCount(itemStack.getCount() - 1);
player.inventory.placeItemBackInInventory(world, new ItemStack(getRailItem(state)));
}
return ActionResultType.SUCCESS;
}
return ActionResultType.PASS; if (!player.isCreative()) {
} itemStack.shrink(1);
player.inventory.placeItemBackInInventory(world, new ItemStack(previousItem));
}
return ActionResultType.SUCCESS;
}
protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) { return ActionResultType.PASS;
if (!cart.getPassengers() }
.isEmpty())
return;
MountedContraption contraption = MountedContraption.assembleMinecart(world, pos); protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
if (contraption == null) if (!cart.getPassengers()
return; .isEmpty())
if (contraption.blocks.size() == 1) return;
return;
Direction facing = cart.getAdjustedHorizontalFacing(); MountedContraption contraption = MountedContraption.assembleMinecart(world, pos);
float initialAngle = facing.getHorizontalAngle(); if (contraption == null)
return;
if (contraption.blocks.size() == 1)
return;
withTileEntityDo(world, pos, te -> contraption.rotationMode = CartMovementMode.values()[te.movementMode.value]); Direction facing = cart.getAdjustedHorizontalFacing();
ContraptionEntity entity = ContraptionEntity.createMounted(world, contraption, initialAngle, facing); float initialAngle = facing.getHorizontalAngle();
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
world.addEntity(entity);
entity.startRiding(cart);
if (cart instanceof FurnaceMinecartEntity) { withTileEntityDo(world, pos, te -> contraption.rotationMode = CartMovementMode.values()[te.movementMode.value]);
CompoundNBT nbt = cart.serializeNBT(); ContraptionEntity entity = ContraptionEntity.createMounted(world, contraption, initialAngle, facing);
nbt.putDouble("PushZ", 0); entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
nbt.putDouble("PushX", 0); world.addEntity(entity);
cart.deserializeNBT(nbt); entity.startRiding(cart);
}
}
protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) { if (cart instanceof FurnaceMinecartEntity) {
if (cart.getPassengers() CompoundNBT nbt = cart.serializeNBT();
.isEmpty()) nbt.putDouble("PushZ", 0);
return; nbt.putDouble("PushX", 0);
if (!(cart.getPassengers() cart.deserializeNBT(nbt);
.get(0) instanceof ContraptionEntity)) }
return; }
cart.removePassengers();
if (cart instanceof FurnaceMinecartEntity) { protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
CompoundNBT nbt = cart.serializeNBT(); if (cart.getPassengers()
nbt.putDouble("PushZ", cart.getMotion().x); .isEmpty())
nbt.putDouble("PushX", cart.getMotion().z); return;
cart.deserializeNBT(nbt); if (!(cart.getPassengers()
} .get(0) instanceof ContraptionEntity))
} return;
cart.removePassengers();
@Override if (cart instanceof FurnaceMinecartEntity) {
public void neighborChanged(@Nonnull BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull Block blockIn, @Nonnull BlockPos fromPos, CompoundNBT nbt = cart.serializeNBT();
boolean isMoving) { nbt.putDouble("PushZ", cart.getMotion().x);
super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); nbt.putDouble("PushX", cart.getMotion().z);
cart.deserializeNBT(nbt);
}
}
if (worldIn.isRemote) @Override
return; public void neighborChanged(@Nonnull BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos,
@Nonnull Block blockIn, @Nonnull BlockPos fromPos, boolean isMoving) {
super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving);
boolean previouslyPowered = state.get(POWERED); if (worldIn.isRemote)
if (previouslyPowered != worldIn.isBlockPowered(pos)) { return;
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
}
}
@Override boolean previouslyPowered = state.get(POWERED);
@Nonnull if (previouslyPowered != worldIn.isBlockPowered(pos)) {
public IProperty<RailShape> getShapeProperty() { worldIn.setBlockState(pos, state.cycle(POWERED), 2);
return RAIL_SHAPE; }
} }
@Override @Override
@Nonnull @Nonnull
public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) { public IProperty<RailShape> getShapeProperty() {
return AllShapes.CART_ASSEMBLER return RAIL_SHAPE;
.get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X); }
}
@Override @Override
@Nonnull @Nonnull
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
ISelectionContext context) { @Nonnull ISelectionContext context) {
if (context.getEntity() instanceof AbstractMinecartEntity) return AllShapes.CART_ASSEMBLER
return VoxelShapes.empty(); .get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X);
return VoxelShapes.fullCube(); }
}
@Override @Override
@Nonnull @Nonnull
public PushReaction getPushReaction(@Nonnull BlockState state) { public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
return PushReaction.BLOCK; ISelectionContext context) {
} if (context.getEntity() instanceof AbstractMinecartEntity)
return VoxelShapes.empty();
return VoxelShapes.fullCube();
}
@Override @Override
public boolean isNormalCube(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) { @Nonnull
return false; public PushReaction getPushReaction(@Nonnull BlockState state) {
} return PushReaction.BLOCK;
}
@Override @Override
public Class<CartAssemblerTileEntity> getTileEntityClass() { public boolean isNormalCube(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) {
return CartAssemblerTileEntity.class; return false;
} }
@Override @Override
public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) { public Class<CartAssemblerTileEntity> getTileEntityClass() {
return false; return CartAssemblerTileEntity.class;
} }
@Override @Override
@SuppressWarnings("deprecation") public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) {
@Nonnull return false;
public List<ItemStack> getDrops(@Nonnull BlockState state, @Nonnull net.minecraft.world.storage.loot.LootContext.Builder builder) { }
List<ItemStack> drops = super.getDrops(state, builder);
drops.addAll(getRailBlock(state).getDrops(builder));
return drops;
}
@Override @Override
public ItemRequirement getRequiredItems(BlockState state) { @SuppressWarnings("deprecation")
ArrayList<ItemStack> reuiredItems = new ArrayList<ItemStack>(); @Nonnull
reuiredItems.add(new ItemStack(getRailItem(state))); public List<ItemStack> getDrops(@Nonnull BlockState state,
reuiredItems.add(new ItemStack(asItem())); @Nonnull net.minecraft.world.storage.loot.LootContext.Builder builder) {
return new ItemRequirement(ItemUseType.CONSUME, reuiredItems); List<ItemStack> drops = super.getDrops(state, builder);
} drops.addAll(getRailBlock(state).getDrops(builder));
return drops;
}
@SuppressWarnings("deprecation") @Override
public List<ItemStack> getDropedAssembler(BlockState p_220077_0_, ServerWorld p_220077_1_, BlockPos p_220077_2_, @Nullable TileEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) { public ItemRequirement getRequiredItems(BlockState state) {
return super.getDrops(p_220077_0_, (new LootContext.Builder(p_220077_1_)).withRandom(p_220077_1_.rand).withParameter(LootParameters.POSITION, p_220077_2_).withParameter(LootParameters.TOOL, p_220077_5_).withNullableParameter(LootParameters.THIS_ENTITY, p_220077_4_).withNullableParameter(LootParameters.BLOCK_ENTITY, p_220077_3_)); ArrayList<ItemStack> reuiredItems = new ArrayList<ItemStack>();
} reuiredItems.add(new ItemStack(getRailItem(state)));
reuiredItems.add(new ItemStack(asItem()));
return new ItemRequirement(ItemUseType.CONSUME, reuiredItems);
}
@Override @SuppressWarnings("deprecation")
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { public List<ItemStack> getDropedAssembler(BlockState p_220077_0_, ServerWorld p_220077_1_, BlockPos p_220077_2_,
World world = context.getWorld(); @Nullable TileEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) {
BlockPos pos = context.getPos(); return super.getDrops(p_220077_0_, (new LootContext.Builder(p_220077_1_)).withRandom(p_220077_1_.rand)
PlayerEntity player = context.getPlayer(); .withParameter(LootParameters.POSITION, p_220077_2_)
if (world instanceof ServerWorld) { .withParameter(LootParameters.TOOL, p_220077_5_)
if (player != null && !player.isCreative()) .withNullableParameter(LootParameters.THIS_ENTITY, p_220077_4_)
getDropedAssembler(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem()) .withNullableParameter(LootParameters.BLOCK_ENTITY, p_220077_3_));
.forEach(itemStack -> { }
player.inventory.placeItemBackInInventory(world, itemStack);
});
state.spawnAdditionalDrops(world, pos, ItemStack.EMPTY);
world.setBlockState(pos, getRailBlock(state));
}
return ActionResultType.SUCCESS;
}
public static class MinecartAnchorBlock extends Block { @Override
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) {
World world = context.getWorld();
BlockPos pos = context.getPos();
PlayerEntity player = context.getPlayer();
if (world.isRemote)
return ActionResultType.SUCCESS;
public MinecartAnchorBlock(Properties p_i48440_1_) { if (player != null && !player.isCreative())
super(p_i48440_1_); getDropedAssembler(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem())
} .forEach(itemStack -> {
player.inventory.placeItemBackInInventory(world, itemStack);
});
state.spawnAdditionalDrops(world, pos, ItemStack.EMPTY);
world.setBlockState(pos, getRailBlock(state));
return ActionResultType.SUCCESS;
}
@Override public static class MinecartAnchorBlock extends Block {
protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.HORIZONTAL_AXIS);
super.fillStateContainer(builder);
}
@Override public MinecartAnchorBlock(Properties p_i48440_1_) {
@Nonnull super(p_i48440_1_);
public VoxelShape getShape(@Nonnull BlockState p_220053_1_, @Nonnull IBlockReader p_220053_2_, @Nonnull BlockPos p_220053_3_, }
@Nonnull ISelectionContext p_220053_4_) {
return VoxelShapes.empty(); @Override
} protected void fillStateContainer(Builder<Block, BlockState> builder) {
} builder.add(BlockStateProperties.HORIZONTAL_AXIS);
super.fillStateContainer(builder);
}
@Override
@Nonnull
public VoxelShape getShape(@Nonnull BlockState p_220053_1_, @Nonnull IBlockReader p_220053_2_,
@Nonnull BlockPos p_220053_3_, @Nonnull ISelectionContext p_220053_4_) {
return VoxelShapes.empty();
}
}
} }

View File

@ -1,58 +1,68 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted; package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
import javax.annotation.Nonnull;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.*;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class CartAssemblerBlockItem extends BlockItem { public class CartAssemblerBlockItem extends BlockItem {
public CartAssemblerBlockItem(Block block, Properties properties) { public CartAssemblerBlockItem(Block block, Properties properties) {
super(block, properties); super(block, properties);
} }
@Override @Override
@Nonnull @Nonnull
public ActionResultType onItemUse(ItemUseContext context) { public ActionResultType onItemUse(ItemUseContext context) {
BlockPos pos = context.getPos(); if (tryPlaceAssembler(context))
World world = context.getWorld(); return ActionResultType.SUCCESS;
BlockState state = world.getBlockState(pos); return super.onItemUse(context);
Block block = state.getBlock(); }
PlayerEntity player = context.getPlayer();
if (block instanceof AbstractRailBlock && player != null) {
RailShape shape = state.get(((AbstractRailBlock) block).getShapeProperty());
if (shape == RailShape.EAST_WEST || shape == RailShape.NORTH_SOUTH) {
BlockState defaultState = AllBlocks.CART_ASSEMBLER.getDefaultState().with(CartAssemblerBlock.RAIL_SHAPE, shape);
if (block.getClass() == RailBlock.class) {
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_NORMAL));
} else if (block.getClass() == PoweredRailBlock.class) {
if (((PoweredRailBlock) block).isActivatorRail()) {
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_ACTIVATOR));
} else {
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_POWERED));
}
} else if (block.getClass() == DetectorRailBlock.class) { public boolean tryPlaceAssembler(ItemUseContext context) {
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_DETECTOR)); BlockPos pos = context.getPos();
} else { World world = context.getWorld();
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true); BlockState state = world.getBlockState(pos);
return super.onItemUse(context); Block block = state.getBlock();
} PlayerEntity player = context.getPlayer();
if (!player.isCreative())
context.getItem().setCount(context.getItem().getCount() - 1); if (player == null)
return ActionResultType.SUCCESS; return false;
} if (!(block instanceof AbstractRailBlock)) {
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true); Lang.sendStatus(player, "block.cart_assembler.invalid");
} return false;
return super.onItemUse(context); }
}
RailShape shape = state.get(((AbstractRailBlock) block).getShapeProperty());
if (shape != RailShape.EAST_WEST && shape != RailShape.NORTH_SOUTH)
return false;
BlockState newState = AllBlocks.CART_ASSEMBLER.getDefaultState()
.with(CartAssemblerBlock.RAIL_SHAPE, shape);
CartAssembleRailType newType = null;
for (CartAssembleRailType type : CartAssembleRailType.values())
if (block == type.railBlock)
newType = type;
if (newType == null)
return false;
if (world.isRemote)
return true;
newState = newState.with(CartAssemblerBlock.RAIL_TYPE, newType);
world.setBlockState(pos, newState);
if (!player.isCreative())
context.getItem().shrink(1);
return true;
}
} }

View File

@ -6,11 +6,14 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.material.PushReaction; import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty; import net.minecraft.state.EnumProperty;
import net.minecraft.state.IProperty; import net.minecraft.state.IProperty;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
import net.minecraft.util.NonNullList;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
@ -34,6 +37,10 @@ public class ReinforcedRailBlock extends AbstractRailBlock {
super(true, properties); super(true, properties);
} }
@Override
public void fillItemGroup(ItemGroup p_149666_1_, NonNullList<ItemStack> p_149666_2_) {
// TODO re-add when finished
}
@Nonnull @Nonnull
@Override @Override

View File

@ -17,16 +17,14 @@ public class WrenchItem extends Item {
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
if (!player.isAllowEdit()) if (!player.isAllowEdit())
return super.onItemUse(context); return super.onItemUse(context);
BlockState state = context.getWorld().getBlockState(context.getPos()); BlockState state = context.getWorld().getBlockState(context.getPos());
if (!(state.getBlock() instanceof IWrenchable)) if (!(state.getBlock() instanceof IWrenchable))
return super.onItemUse(context); return super.onItemUse(context);
IWrenchable actor = (IWrenchable) state.getBlock(); IWrenchable actor = (IWrenchable) state.getBlock();
if (player.isSneaking()) { if (player.isSneaking())
return actor.onSneakWrenched(state, context); return actor.onSneakWrenched(state, context);
}
return actor.onWrenched(state, context); return actor.onWrenched(state, context);
} }
} }

View File

@ -82,6 +82,8 @@ public class ZapperInteractionHandler {
newState = newState.with(BlockStateProperties.STAIRS_SHAPE, StairsShape.STRAIGHT); newState = newState.with(BlockStateProperties.STAIRS_SHAPE, StairsShape.STRAIGHT);
if (newState.has(BlockStateProperties.PERSISTENT)) if (newState.has(BlockStateProperties.PERSISTENT))
newState = newState.with(BlockStateProperties.PERSISTENT, true); newState = newState.with(BlockStateProperties.PERSISTENT, true);
if (newState.has(BlockStateProperties.WATERLOGGED))
newState = newState.with(BlockStateProperties.WATERLOGGED, false);
CompoundNBT tag = stack.getOrCreateTag(); CompoundNBT tag = stack.getOrCreateTag();
if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag() if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag()

View File

@ -11,6 +11,7 @@ import java.util.function.Function;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock;
import com.simibubi.create.content.contraptions.components.tracks.ReinforcedRailBlock; import com.simibubi.create.content.contraptions.components.tracks.ReinforcedRailBlock;
import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverBlock; import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverBlock;
@ -166,32 +167,28 @@ public class BlockStateGen {
} }
public static NonNullBiConsumer<DataGenContext<Block, CartAssemblerBlock>, RegistrateBlockstateProvider> cartAssembler() { public static NonNullBiConsumer<DataGenContext<Block, CartAssemblerBlock>, RegistrateBlockstateProvider> cartAssembler() {
HashMap<Integer, String> railTypes = new HashMap<Integer, String>();
railTypes.put(CartAssemblerBlock.RAIL_NONE, "_none");
railTypes.put(CartAssemblerBlock.RAIL_NORMAL, "_rail_normal");
railTypes.put(CartAssemblerBlock.RAIL_POWERED, "_rail_powered");
railTypes.put(CartAssemblerBlock.RAIL_DETECTOR, "_rail_detector");
railTypes.put(CartAssemblerBlock.RAIL_ACTIVATOR, "_rail_activator");
return (c, p) -> p.getVariantBuilder(c.get()) return (c, p) -> p.getVariantBuilder(c.get())
.forAllStates(state -> { .forAllStates(state -> {
CartAssembleRailType type = state.get(CartAssemblerBlock.RAIL_TYPE);
Boolean powered = state.get(CartAssemblerBlock.POWERED);
RailShape shape = state.get(CartAssemblerBlock.RAIL_SHAPE);
return ConfiguredModel.builder() return ConfiguredModel.builder()
.modelFile(p.models() .modelFile(p.models()
.getExistingFile(p.modLoc("block/" + c.getName() + "/block" .getExistingFile(p
+ (state.get(CartAssemblerBlock.POWERED) ? "_powered" : "") .modLoc("block/" + c.getName() + "/block_" + type.getName() + (powered ? "_powered" : ""))))
+ railTypes.get(state.get(CartAssemblerBlock.RAIL_TYPE))))) .rotationY(shape == RailShape.EAST_WEST ? 90 : 0)
.rotationY(state.get(CartAssemblerBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0)
.build(); .build();
}); });
} }
public static NonNullBiConsumer<DataGenContext<Block, ReinforcedRailBlock>, RegistrateBlockstateProvider> reinforcedRail() { public static NonNullBiConsumer<DataGenContext<Block, ReinforcedRailBlock>, RegistrateBlockstateProvider> reinforcedRail() {
return (c, p) -> p.getVariantBuilder(c.get()) return (c, p) -> p.getVariantBuilder(c.get())
.forAllStates(state -> { .forAllStates(state -> {
return ConfiguredModel.builder() return ConfiguredModel.builder()
.modelFile(p.models() .modelFile(p.models()
.getExistingFile(p.modLoc("block/" + c.getName() + "/block" .getExistingFile(p.modLoc(
+ (state.get(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "") "block/" + c.getName() + "/block" + (state.get(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "")
+ (state.get(ReinforcedRailBlock.CONNECTS_N) ? "_n" : "")))) + (state.get(ReinforcedRailBlock.CONNECTS_N) ? "_n" : ""))))
.rotationY(state.get(ReinforcedRailBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0) .rotationY(state.get(ReinforcedRailBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0)
.build(); .build();

View File

@ -10,8 +10,7 @@
"death.attack.create.mechanical_saw": "%1$s got cut in half by Mechanical mechanical_saw", "death.attack.create.mechanical_saw": "%1$s got cut in half by Mechanical mechanical_saw",
"death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock", "death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock",
"create.block.deployer.damage_source_name": "a rogue Deployer", "create.block.deployer.damage_source_name": "a rogue Deployer",
"create.block.cart_assembler.invalid": "Can not place a Cart Assembler on this rail type", "create.block.cart_assembler.invalid": "Place your Cart Assembler on a rail block",
"create.block.cart_assembler.invalid_update": "Invalid rail to update this Cart Assembler",
"create.recipe.crushing": "Crushing", "create.recipe.crushing": "Crushing",
"create.recipe.milling": "Milling", "create.recipe.milling": "Milling",

View File

@ -1,6 +0,0 @@
{
"parent": "create:block/cart_assembler/block_none",
"textures": {
"clutch_off": "create:block/clutch_on"
}
}

View File

@ -0,0 +1,20 @@
{
"type": "crafting_shaped",
"pattern": [
"III",
"ISI",
"III"
],
"key": {
"I": {
"item": "create:scoria"
},
"S": {
"tag": "forge:dyes/black"
}
},
"result": {
"item": "create:dark_scoria",
"count": 8
}
}