mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-25 06:26:56 +01:00
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:
parent
0bee531b7e
commit
0d616b7a21
24 changed files with 461 additions and 444 deletions
|
@ -23,7 +23,7 @@ cf9045eb16e5299a1d917c4cb536289f49411276 assets\create\blockstates\birch_window.
|
|||
94a1a91403eb4b035fec48071e7fcae57a8a6abd assets\create\blockstates\birch_window_pane.json
|
||||
8b1dd00adcc7e74c5a9feed069e2610b15a338cb assets\create\blockstates\brass_block.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
|
||||
0f01f813388d3e6907c1cfd992e4b21c914e267e assets\create\blockstates\chiseled_dolomite.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
|
||||
3a739f9d4276828d83f2d2750bf3227c87bcd438 assets\create\blockstates\pulley_magnet.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
|
||||
c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets\create\blockstates\redstone_link.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
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.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
|
||||
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.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
|
||||
a37be4a0ec9bf6c381527403c57ced4f81abd67c assets\create\models\item\brass_nugget.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
|
||||
83d3571eacde52568786802b268f24c6578c1e5d assets\create\models\item\chiseled_dolomite.json
|
||||
afd697168c9786eb80e54eccdc6a23afa6c7fb0e assets\create\models\item\chiseled_gabbro.json
|
||||
|
|
|
@ -1,73 +1,59 @@
|
|||
{
|
||||
"variants": {
|
||||
"powered=false,rail_type=0,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_none"
|
||||
"powered=false,rail_type=regular,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_regular"
|
||||
},
|
||||
"powered=true,rail_type=0,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_powered_none"
|
||||
"powered=true,rail_type=regular,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_regular_powered"
|
||||
},
|
||||
"powered=false,rail_type=1,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_rail_normal"
|
||||
"powered=false,rail_type=powered_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail"
|
||||
},
|
||||
"powered=true,rail_type=1,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": {
|
||||
"powered=true,rail_type=powered_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_powered"
|
||||
},
|
||||
"powered=false,rail_type=3,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_rail_detector"
|
||||
"powered=false,rail_type=detector_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_detector_rail"
|
||||
},
|
||||
"powered=true,rail_type=3,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_detector"
|
||||
"powered=true,rail_type=detector_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_detector_rail_powered"
|
||||
},
|
||||
"powered=false,rail_type=4,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_rail_activator"
|
||||
"powered=false,rail_type=activator_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_activator_rail"
|
||||
},
|
||||
"powered=true,rail_type=4,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_activator"
|
||||
"powered=true,rail_type=activator_rail,shape=north_south": {
|
||||
"model": "create:block/cart_assembler/block_activator_rail_powered"
|
||||
},
|
||||
"powered=false,rail_type=0,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_none",
|
||||
"powered=false,rail_type=regular,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_regular",
|
||||
"y": 90
|
||||
},
|
||||
"powered=true,rail_type=0,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_powered_none",
|
||||
"powered=true,rail_type=regular,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_regular_powered",
|
||||
"y": 90
|
||||
},
|
||||
"powered=false,rail_type=1,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_rail_normal",
|
||||
"powered=false,rail_type=powered_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail",
|
||||
"y": 90
|
||||
},
|
||||
"powered=true,rail_type=1,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": {
|
||||
"powered=true,rail_type=powered_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_powered",
|
||||
"y": 90
|
||||
},
|
||||
"powered=false,rail_type=3,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_rail_detector",
|
||||
"powered=false,rail_type=detector_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_detector_rail",
|
||||
"y": 90
|
||||
},
|
||||
"powered=true,rail_type=3,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_detector",
|
||||
"powered=true,rail_type=detector_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_detector_rail_powered",
|
||||
"y": 90
|
||||
},
|
||||
"powered=false,rail_type=4,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_rail_activator",
|
||||
"powered=false,rail_type=activator_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_activator_rail",
|
||||
"y": 90
|
||||
},
|
||||
"powered=true,rail_type=4,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_powered_rail_activator",
|
||||
"powered=true,rail_type=activator_rail,shape=east_west": {
|
||||
"model": "create:block/cart_assembler/block_activator_rail_powered",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,8 +89,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_west": "true"
|
||||
"sticky_west": "true",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
|
@ -99,8 +99,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_west": "true"
|
||||
"sticky_west": "true",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
|
@ -109,8 +109,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_west": "true"
|
||||
"sticky_west": "true",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z_sticky",
|
||||
|
@ -119,8 +119,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_west": "false"
|
||||
"sticky_west": "false",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
|
@ -129,8 +129,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_west": "false"
|
||||
"sticky_west": "false",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
|
@ -139,8 +139,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_west": "false"
|
||||
"sticky_west": "false",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z",
|
||||
|
@ -149,8 +149,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky"
|
||||
|
@ -158,8 +158,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
|
@ -168,8 +168,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
|
@ -178,8 +178,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x"
|
||||
|
@ -187,8 +187,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
|
@ -197,8 +197,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
|
@ -207,8 +207,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
|
@ -217,8 +217,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
|
@ -227,8 +227,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z_sticky"
|
||||
|
@ -236,8 +236,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
|
@ -246,8 +246,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
|
@ -256,8 +256,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z"
|
||||
|
|
|
@ -484,8 +484,7 @@
|
|||
"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.cart_assembler.invalid": "Can not place a Cart Assembler on this rail type",
|
||||
"create.block.cart_assembler.invalid_update": "Invalid rail to update this Cart Assembler",
|
||||
"create.block.cart_assembler.invalid": "Place your Cart Assembler on a rail block",
|
||||
|
||||
"create.recipe.crushing": "Crushing",
|
||||
"create.recipe.milling": "Milling",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "create:block/cart_assembler/block_none"
|
||||
"parent": "create:block/cart_assembler/item"
|
||||
}
|
|
@ -453,9 +453,7 @@ public class AllBlocks {
|
|||
.addLayer(() -> RenderType::getCutoutMipped)
|
||||
.tag(BlockTags.RAILS)
|
||||
.item(CartAssemblerBlockItem::new)
|
||||
.model((c, p) -> p.blockItem(() -> c.getEntry()
|
||||
.getBlock(), "/block_none"))
|
||||
.build()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<ReinforcedRailBlock> REINFORCED_RAIL =
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,12 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
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.ItemUseType;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
import net.minecraft.block.Block;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.IntegerProperty;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
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.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
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.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 int RAIL_NORMAL = 1;
|
||||
public static final int RAIL_POWERED = 2;
|
||||
public static final int RAIL_DETECTOR = 3;
|
||||
public static final int RAIL_ACTIVATOR = 4;
|
||||
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 final IProperty<RailShape> RAIL_SHAPE =
|
||||
EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
|
||||
public static final IProperty<CartAssembleRailType> RAIL_TYPE =
|
||||
EnumProperty.create("rail_type", CartAssembleRailType.class);
|
||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
|
||||
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) {
|
||||
super(true, properties);
|
||||
setDefaultState(getDefaultState().with(POWERED, false).with(RAIL_TYPE, RAIL_POWERED));
|
||||
}
|
||||
public static BlockState createAnchor(BlockState state) {
|
||||
Axis axis = state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X;
|
||||
return AllBlocks.MINECART_ANCHOR.getDefaultState()
|
||||
.with(BlockStateProperties.HORIZONTAL_AXIS, axis);
|
||||
}
|
||||
|
||||
public static BlockState createAnchor(BlockState state) {
|
||||
Axis axis = state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X;
|
||||
return AllBlocks.MINECART_ANCHOR.getDefaultState()
|
||||
.with(BlockStateProperties.HORIZONTAL_AXIS, axis);
|
||||
}
|
||||
private static Item getRailItem(BlockState state) {
|
||||
return state.get(RAIL_TYPE).railItem;
|
||||
}
|
||||
|
||||
private static Item getRailItem(BlockState state) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Items.RAIL;
|
||||
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 state) {
|
||||
AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).railBlock;
|
||||
return railBlock.getDefaultState()
|
||||
.with(railBlock.getShapeProperty(), state.get(RAIL_SHAPE));
|
||||
}
|
||||
|
||||
public static BlockState getRailBlock(BlockState assembler) {
|
||||
switch (assembler.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Blocks.RAIL.getDefaultState().with(RailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
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
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE);
|
||||
super.fillStateContainer(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE);
|
||||
super.fillStateContainer(builder);
|
||||
}
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return AllTileEntities.CART_ASSEMBLER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return AllTileEntities.CART_ASSEMBLER.create();
|
||||
}
|
||||
@Override
|
||||
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
|
||||
AbstractMinecartEntity cart) {
|
||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||
return;
|
||||
|
||||
@Override
|
||||
public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||
return;
|
||||
withTileEntityDo(world, pos, te -> {
|
||||
if (te.isMinecartUpdateValid()) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
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 -> {
|
||||
if (te.isMinecartUpdateValid()) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
case RAIL_POWERED:
|
||||
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
|
||||
@Nonnull
|
||||
public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
|
||||
PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
|
||||
PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) {
|
||||
ItemStack itemStack = player.getHeldItem(hand);
|
||||
Item previousItem = getRailItem(state);
|
||||
Item heldItem = itemStack.getItem();
|
||||
if (heldItem != previousItem) {
|
||||
|
||||
ItemStack itemStack = player.getHeldItem(hand);
|
||||
if (itemStack.getItem() != getRailItem(state)) {
|
||||
CartAssembleRailType newType = null;
|
||||
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, 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;
|
||||
}
|
||||
world.setBlockState(pos, state.with(RAIL_TYPE, newType));
|
||||
|
||||
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) {
|
||||
if (!cart.getPassengers()
|
||||
.isEmpty())
|
||||
return;
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
MountedContraption contraption = MountedContraption.assembleMinecart(world, pos);
|
||||
if (contraption == null)
|
||||
return;
|
||||
if (contraption.blocks.size() == 1)
|
||||
return;
|
||||
protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.getPassengers()
|
||||
.isEmpty())
|
||||
return;
|
||||
|
||||
Direction facing = cart.getAdjustedHorizontalFacing();
|
||||
float initialAngle = facing.getHorizontalAngle();
|
||||
MountedContraption contraption = MountedContraption.assembleMinecart(world, pos);
|
||||
if (contraption == null)
|
||||
return;
|
||||
if (contraption.blocks.size() == 1)
|
||||
return;
|
||||
|
||||
withTileEntityDo(world, pos, te -> contraption.rotationMode = CartMovementMode.values()[te.movementMode.value]);
|
||||
ContraptionEntity entity = ContraptionEntity.createMounted(world, contraption, initialAngle, facing);
|
||||
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
world.addEntity(entity);
|
||||
entity.startRiding(cart);
|
||||
Direction facing = cart.getAdjustedHorizontalFacing();
|
||||
float initialAngle = facing.getHorizontalAngle();
|
||||
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", 0);
|
||||
nbt.putDouble("PushX", 0);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
withTileEntityDo(world, pos, te -> contraption.rotationMode = CartMovementMode.values()[te.movementMode.value]);
|
||||
ContraptionEntity entity = ContraptionEntity.createMounted(world, contraption, initialAngle, facing);
|
||||
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
world.addEntity(entity);
|
||||
entity.startRiding(cart);
|
||||
|
||||
protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (cart.getPassengers()
|
||||
.isEmpty())
|
||||
return;
|
||||
if (!(cart.getPassengers()
|
||||
.get(0) instanceof ContraptionEntity))
|
||||
return;
|
||||
cart.removePassengers();
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", 0);
|
||||
nbt.putDouble("PushX", 0);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", cart.getMotion().x);
|
||||
nbt.putDouble("PushX", cart.getMotion().z);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (cart.getPassengers()
|
||||
.isEmpty())
|
||||
return;
|
||||
if (!(cart.getPassengers()
|
||||
.get(0) instanceof ContraptionEntity))
|
||||
return;
|
||||
cart.removePassengers();
|
||||
|
||||
@Override
|
||||
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);
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", cart.getMotion().x);
|
||||
nbt.putDouble("PushX", cart.getMotion().z);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
if (worldIn.isRemote)
|
||||
return;
|
||||
@Override
|
||||
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 (previouslyPowered != worldIn.isBlockPowered(pos)) {
|
||||
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
}
|
||||
}
|
||||
if (worldIn.isRemote)
|
||||
return;
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IProperty<RailShape> getShapeProperty() {
|
||||
return RAIL_SHAPE;
|
||||
}
|
||||
boolean previouslyPowered = state.get(POWERED);
|
||||
if (previouslyPowered != worldIn.isBlockPowered(pos)) {
|
||||
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) {
|
||||
return AllShapes.CART_ASSEMBLER
|
||||
.get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X);
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public IProperty<RailShape> getShapeProperty() {
|
||||
return RAIL_SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
if (context.getEntity() instanceof AbstractMinecartEntity)
|
||||
return VoxelShapes.empty();
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
|
||||
@Nonnull ISelectionContext context) {
|
||||
return AllShapes.CART_ASSEMBLER
|
||||
.get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public PushReaction getPushReaction(@Nonnull BlockState state) {
|
||||
return PushReaction.BLOCK;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
if (context.getEntity() instanceof AbstractMinecartEntity)
|
||||
return VoxelShapes.empty();
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public PushReaction getPushReaction(@Nonnull BlockState state) {
|
||||
return PushReaction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CartAssemblerTileEntity> getTileEntityClass() {
|
||||
return CartAssemblerTileEntity.class;
|
||||
}
|
||||
@Override
|
||||
public boolean isNormalCube(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public Class<CartAssemblerTileEntity> getTileEntityClass() {
|
||||
return CartAssemblerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nonnull
|
||||
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
|
||||
public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state) {
|
||||
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")
|
||||
@Nonnull
|
||||
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;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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_) {
|
||||
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_));
|
||||
}
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state) {
|
||||
ArrayList<ItemStack> reuiredItems = new ArrayList<ItemStack>();
|
||||
reuiredItems.add(new ItemStack(getRailItem(state)));
|
||||
reuiredItems.add(new ItemStack(asItem()));
|
||||
return new ItemRequirement(ItemUseType.CONSUME, reuiredItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (world instanceof ServerWorld) {
|
||||
if (player != null && !player.isCreative())
|
||||
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;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
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_) {
|
||||
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_));
|
||||
}
|
||||
|
||||
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_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
if (player != null && !player.isCreative())
|
||||
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
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(BlockStateProperties.HORIZONTAL_AXIS);
|
||||
super.fillStateContainer(builder);
|
||||
}
|
||||
public static class MinecartAnchorBlock extends Block {
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
public MinecartAnchorBlock(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +1,68 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
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.item.BlockItem;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CartAssemblerBlockItem extends BlockItem {
|
||||
|
||||
public CartAssemblerBlockItem(Block block, Properties properties) {
|
||||
super(block, properties);
|
||||
}
|
||||
public CartAssemblerBlockItem(Block block, Properties properties) {
|
||||
super(block, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
BlockPos pos = context.getPos();
|
||||
World world = context.getWorld();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
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));
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
if (tryPlaceAssembler(context))
|
||||
return ActionResultType.SUCCESS;
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
|
||||
} else if (block.getClass() == DetectorRailBlock.class) {
|
||||
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_DETECTOR));
|
||||
} else {
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true);
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
if (!player.isCreative())
|
||||
context.getItem().setCount(context.getItem().getCount() - 1);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true);
|
||||
}
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
public boolean tryPlaceAssembler(ItemUseContext context) {
|
||||
BlockPos pos = context.getPos();
|
||||
World world = context.getWorld();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
||||
if (player == null)
|
||||
return false;
|
||||
if (!(block instanceof AbstractRailBlock)) {
|
||||
Lang.sendStatus(player, "block.cart_assembler.invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -6,11 +6,14 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
|
@ -34,6 +37,10 @@ public class ReinforcedRailBlock extends AbstractRailBlock {
|
|||
super(true, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup p_149666_1_, NonNullList<ItemStack> p_149666_2_) {
|
||||
// TODO re-add when finished
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
|
|
|
@ -17,16 +17,14 @@ public class WrenchItem extends Item {
|
|||
PlayerEntity player = context.getPlayer();
|
||||
if (!player.isAllowEdit())
|
||||
return super.onItemUse(context);
|
||||
|
||||
|
||||
BlockState state = context.getWorld().getBlockState(context.getPos());
|
||||
if (!(state.getBlock() instanceof IWrenchable))
|
||||
return super.onItemUse(context);
|
||||
IWrenchable actor = (IWrenchable) state.getBlock();
|
||||
|
||||
if (player.isSneaking()) {
|
||||
if (player.isSneaking())
|
||||
return actor.onSneakWrenched(state, context);
|
||||
}
|
||||
return actor.onWrenched(state, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ public class ZapperInteractionHandler {
|
|||
newState = newState.with(BlockStateProperties.STAIRS_SHAPE, StairsShape.STRAIGHT);
|
||||
if (newState.has(BlockStateProperties.PERSISTENT))
|
||||
newState = newState.with(BlockStateProperties.PERSISTENT, true);
|
||||
if (newState.has(BlockStateProperties.WATERLOGGED))
|
||||
newState = newState.with(BlockStateProperties.WATERLOGGED, false);
|
||||
|
||||
CompoundNBT tag = stack.getOrCreateTag();
|
||||
if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag()
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.function.Function;
|
|||
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.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.tracks.ReinforcedRailBlock;
|
||||
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() {
|
||||
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())
|
||||
.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()
|
||||
.modelFile(p.models()
|
||||
.getExistingFile(p.modLoc("block/" + c.getName() + "/block"
|
||||
+ (state.get(CartAssemblerBlock.POWERED) ? "_powered" : "")
|
||||
+ railTypes.get(state.get(CartAssemblerBlock.RAIL_TYPE)))))
|
||||
.rotationY(state.get(CartAssemblerBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0)
|
||||
.getExistingFile(p
|
||||
.modLoc("block/" + c.getName() + "/block_" + type.getName() + (powered ? "_powered" : ""))))
|
||||
.rotationY(shape == RailShape.EAST_WEST ? 90 : 0)
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static NonNullBiConsumer<DataGenContext<Block, ReinforcedRailBlock>, RegistrateBlockstateProvider> reinforcedRail() {
|
||||
return (c, p) -> p.getVariantBuilder(c.get())
|
||||
.forAllStates(state -> {
|
||||
return ConfiguredModel.builder()
|
||||
.modelFile(p.models()
|
||||
.getExistingFile(p.modLoc("block/" + c.getName() + "/block"
|
||||
+ (state.get(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "")
|
||||
.getExistingFile(p.modLoc(
|
||||
"block/" + c.getName() + "/block" + (state.get(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "")
|
||||
+ (state.get(ReinforcedRailBlock.CONNECTS_N) ? "_n" : ""))))
|
||||
.rotationY(state.get(ReinforcedRailBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0)
|
||||
.build();
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
"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",
|
||||
"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_update": "Invalid rail to update this Cart Assembler",
|
||||
"create.block.cart_assembler.invalid": "Place your Cart Assembler on a rail block",
|
||||
|
||||
"create.recipe.crushing": "Crushing",
|
||||
"create.recipe.milling": "Milling",
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"parent": "create:block/cart_assembler/block_none",
|
||||
"textures": {
|
||||
"clutch_off": "create:block/clutch_on"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue