Casing case closed, Part II

- Encasing fluid pipes now locks their configuration
- Encased fluid pipes now join textures with adjacent casing blocks
- Fixed windowed pipe not allowing to be encased
- Fixed wrapped models not passing down model data in multi layered situations
This commit is contained in:
simibubi 2020-12-03 23:49:12 +01:00
parent 16705c5cb5
commit 2a56bb76be
19 changed files with 361 additions and 67 deletions

View file

@ -103,7 +103,7 @@ f63a5816d4bfe643aa098d03c3b54462dd06fe19 assets/create/blockstates/dolomite_cobb
f179202e59e449157f89efc37229b03bbfd391d7 assets/create/blockstates/dolomite_pillar.json f179202e59e449157f89efc37229b03bbfd391d7 assets/create/blockstates/dolomite_pillar.json
7b1c40891b07c8f3238537625d9e25c8627e7333 assets/create/blockstates/encased_belt.json 7b1c40891b07c8f3238537625d9e25c8627e7333 assets/create/blockstates/encased_belt.json
7b2b836649e729feafa60972bf95e3afb2143131 assets/create/blockstates/encased_fan.json 7b2b836649e729feafa60972bf95e3afb2143131 assets/create/blockstates/encased_fan.json
656813b75dd3b901bf34f24df785e4b0fbe11aa6 assets/create/blockstates/encased_fluid_pipe.json d13940ed213d7acbc6ebe3bdd21175ef89e4d613 assets/create/blockstates/encased_fluid_pipe.json
a774e815376a67e2a2de44e39af0a1a0b4406932 assets/create/blockstates/fancy_andesite_bricks.json a774e815376a67e2a2de44e39af0a1a0b4406932 assets/create/blockstates/fancy_andesite_bricks.json
180be26a75834cf9cdb881f969f77906e91cc36a assets/create/blockstates/fancy_andesite_bricks_slab.json 180be26a75834cf9cdb881f969f77906e91cc36a assets/create/blockstates/fancy_andesite_bricks_slab.json
d5d7762b80952052d0a7adf3081967cac3f3ba6c assets/create/blockstates/fancy_andesite_bricks_stairs.json d5d7762b80952052d0a7adf3081967cac3f3ba6c assets/create/blockstates/fancy_andesite_bricks_stairs.json
@ -613,7 +613,6 @@ cc6d9300cd26f2323c653dbcc61b7a885be8fa3b assets/create/models/block/dolomite_cob
a101974d906487326dc38916f828d12a278a49ae assets/create/models/block/dolomite_cobblestone_wall_post.json a101974d906487326dc38916f828d12a278a49ae assets/create/models/block/dolomite_cobblestone_wall_post.json
9c497140dfe73abe1964479eaf1af8f1892de290 assets/create/models/block/dolomite_cobblestone_wall_side.json 9c497140dfe73abe1964479eaf1af8f1892de290 assets/create/models/block/dolomite_cobblestone_wall_side.json
999a7cd79a9dc80c47fd6103b65f006b55187402 assets/create/models/block/dolomite_pillar.json 999a7cd79a9dc80c47fd6103b65f006b55187402 assets/create/models/block/dolomite_pillar.json
1a8bac1e97a2a6c3cc362081568d2a7fce815ad5 assets/create/models/block/encased_fluid_pipe.json
17dae5fdc1a551d8ab1ab8a68cabf7a8c3848d86 assets/create/models/block/fancy_andesite_bricks.json 17dae5fdc1a551d8ab1ab8a68cabf7a8c3848d86 assets/create/models/block/fancy_andesite_bricks.json
cfb2cd84a1cbd9226a77ebc1f6c29e8eaa9c577f assets/create/models/block/fancy_andesite_bricks_slab.json cfb2cd84a1cbd9226a77ebc1f6c29e8eaa9c577f assets/create/models/block/fancy_andesite_bricks_slab.json
8ee27601996ab577991b6a0f7e9df27db0282cad assets/create/models/block/fancy_andesite_bricks_slab_top.json 8ee27601996ab577991b6a0f7e9df27db0282cad assets/create/models/block/fancy_andesite_bricks_slab_top.json

View file

@ -1,17 +1,110 @@
{ {
"variants": { "multipart": [
"axis=x": { {
"model": "create:block/encased_fluid_pipe", "when": {
"x": 90, "down": "false"
"y": 90
}, },
"axis=y": { "apply": {
"model": "create:block/encased_fluid_pipe" "model": "create:block/encased_fluid_pipe/block_flat",
"x": -90
}
}, },
"axis=z": { {
"model": "create:block/encased_fluid_pipe", "when": {
"x": 90, "up": "false"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_flat",
"x": 90
}
},
{
"when": {
"north": "false"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_flat",
"y": 180 "y": 180
} }
},
{
"when": {
"south": "false"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_flat"
} }
},
{
"when": {
"west": "false"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_flat",
"y": 90
}
},
{
"when": {
"east": "false"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_flat",
"y": 270
}
},
{
"when": {
"down": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open",
"x": -90
}
},
{
"when": {
"up": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open",
"x": 90
}
},
{
"when": {
"north": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open",
"y": 180
}
},
{
"when": {
"south": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open"
}
},
{
"when": {
"west": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open",
"y": 90
}
},
{
"when": {
"east": "true"
},
"apply": {
"model": "create:block/encased_fluid_pipe/block_open",
"y": 270
}
}
]
} }

View file

@ -1,7 +0,0 @@
{
"parent": "block/cube_column",
"textures": {
"side": "create:block/copper_casing",
"end": "create:block/encased_pipe"
}
}

View file

@ -519,8 +519,11 @@ public class AllBlocks {
public static final BlockEntry<EncasedPipeBlock> ENCASED_FLUID_PIPE = public static final BlockEntry<EncasedPipeBlock> ENCASED_FLUID_PIPE =
REGISTRATE.block("encased_fluid_pipe", EncasedPipeBlock::new) REGISTRATE.block("encased_fluid_pipe", EncasedPipeBlock::new)
.initialProperties(SharedProperties::softMetal) .initialProperties(SharedProperties::softMetal)
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, state -> p.models() .properties(Block.Properties::nonOpaque)
.cubeColumn(c.getName(), p.modLoc("block/copper_casing"), p.modLoc("block/encased_pipe")))) .blockstate(BlockStateGen.encasedPipe())
.onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.COPPER_CASING)))
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.COPPER_CASING,
(s, f) -> !s.get(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(f)))))
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new)) .onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new))
.loot((p, b) -> p.registerDropping(b, FLUID_PIPE.get())) .loot((p, b) -> p.registerDropping(b, FLUID_PIPE.get()))
.register(); .register();

View file

@ -219,8 +219,8 @@ public class AllTileEntities {
.validBlocks(AllBlocks.FLUID_PIPE) .validBlocks(AllBlocks.FLUID_PIPE)
.register(); .register();
public static final TileEntityEntry<StraightPipeTileEntity> ENCASED_FLUID_PIPE = Create.registrate() public static final TileEntityEntry<FluidPipeTileEntity> ENCASED_FLUID_PIPE = Create.registrate()
.tileEntity("encased_fluid_pipe", StraightPipeTileEntity::new) .tileEntity("encased_fluid_pipe", FluidPipeTileEntity::new)
.validBlocks(AllBlocks.ENCASED_FLUID_PIPE) .validBlocks(AllBlocks.ENCASED_FLUID_PIPE)
.register(); .register();

View file

@ -26,6 +26,10 @@ public class FluidPipeAttachmentBehaviour extends BracketedTileEntityBehaviour {
.getAxis() == direction.getAxis()) .getAxis() == direction.getAxis())
return AttachmentTypes.NONE; return AttachmentTypes.NONE;
if (AllBlocks.ENCASED_FLUID_PIPE.has(facingState)
&& facingState.get(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(direction.getOpposite())))
return AttachmentTypes.NONE;
if (FluidPropagator.hasFluidCapability(facingState, world, offsetPos, direction) if (FluidPropagator.hasFluidCapability(facingState, world, offsetPos, direction)
&& !AllBlocks.HOSE_PULLEY.has(facingState)) && !AllBlocks.HOSE_PULLEY.has(facingState))
return AttachmentTypes.DRAIN; return AttachmentTypes.DRAIN;

View file

@ -8,7 +8,7 @@ import java.util.Random;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.fluids.FluidPipeAttachmentBehaviour.AttachmentTypes; import com.simibubi.create.content.contraptions.fluids.FluidPipeAttachmentBehaviour.AttachmentTypes;
import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock; import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock;
import com.simibubi.create.foundation.block.render.WrappedBakedModel; import com.simibubi.create.foundation.block.connected.BakedModelWrapperWithData;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
@ -21,9 +21,10 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader; import net.minecraft.world.ILightReader;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelDataMap.Builder;
import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.client.model.data.ModelProperty;
public class PipeAttachmentModel extends WrappedBakedModel { public class PipeAttachmentModel extends BakedModelWrapperWithData {
private static ModelProperty<PipeModelData> PIPE_PROPERTY = new ModelProperty<>(); private static ModelProperty<PipeModelData> PIPE_PROPERTY = new ModelProperty<>();
@ -32,7 +33,7 @@ public class PipeAttachmentModel extends WrappedBakedModel {
} }
@Override @Override
public IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) { protected Builder gatherModelData(Builder builder, ILightReader world, BlockPos pos, BlockState state) {
PipeModelData data = new PipeModelData(); PipeModelData data = new PipeModelData();
FluidPipeAttachmentBehaviour attachmentBehaviour = FluidPipeAttachmentBehaviour attachmentBehaviour =
TileEntityBehaviour.get(world, pos, FluidPipeAttachmentBehaviour.TYPE); TileEntityBehaviour.get(world, pos, FluidPipeAttachmentBehaviour.TYPE);
@ -44,8 +45,7 @@ public class PipeAttachmentModel extends WrappedBakedModel {
} }
data.setEncased(FluidPipeBlock.shouldDrawCasing(world, pos, state)); data.setEncased(FluidPipeBlock.shouldDrawCasing(world, pos, state));
return new ModelDataMap.Builder().withInitial(PIPE_PROPERTY, data) return builder.withInitial(PIPE_PROPERTY, data);
.build();
} }
@Override @Override

View file

@ -10,6 +10,7 @@ import com.simibubi.create.content.contraptions.fluids.FluidPipeAttachmentBehavi
import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.fluids.FluidPropagator;
import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket; import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -19,10 +20,13 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.DebugPacketSender; import net.minecraft.network.DebugPacketSender;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
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;
@ -49,6 +53,20 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith
world.removeTileEntity(pos); world.removeTileEntity(pos);
} }
@Override
public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockRayTraceResult hit) {
if (!AllBlocks.COPPER_CASING.isIn(player.getHeldItem(hand)))
return ActionResultType.PASS;
if (!world.isRemote) {
BlockState newState = AllBlocks.ENCASED_FLUID_PIPE.getDefaultState();
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
newState = newState.with(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
world.setBlockState(pos, newState);
}
return ActionResultType.SUCCESS;
}
@Override @Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) {
if (world.isRemote) if (world.isRemote)

View file

@ -1,22 +1,58 @@
package com.simibubi.create.content.contraptions.fluids.pipes; package com.simibubi.create.content.contraptions.fluids.pipes;
import com.simibubi.create.AllTileEntities; import static net.minecraft.state.properties.BlockStateProperties.DOWN;
import static net.minecraft.state.properties.BlockStateProperties.EAST;
import static net.minecraft.state.properties.BlockStateProperties.NORTH;
import static net.minecraft.state.properties.BlockStateProperties.SOUTH;
import static net.minecraft.state.properties.BlockStateProperties.UP;
import static net.minecraft.state.properties.BlockStateProperties.WEST;
import java.util.Map;
import java.util.Random;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.fluids.FluidPropagator;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SixWayBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.network.DebugPacketSender;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.TickPriority;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class EncasedPipeBlock extends AxisPipeBlock { public class EncasedPipeBlock extends Block implements IWrenchable {
public static final Map<Direction, BooleanProperty> FACING_TO_PROPERTY_MAP = SixWayBlock.FACING_TO_PROPERTY_MAP;
public EncasedPipeBlock(Properties p_i48339_1_) { public EncasedPipeBlock(Properties p_i48339_1_) {
super(p_i48339_1_); super(p_i48339_1_);
setDefaultState(getDefaultState().with(NORTH, false)
.with(SOUTH, false)
.with(DOWN, false)
.with(UP, false)
.with(WEST, false)
.with(EAST, false));
}
@Override
protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN);
super.fillStateContainer(builder);
} }
@Override @Override
@ -25,22 +61,80 @@ public class EncasedPipeBlock extends AxisPipeBlock {
} }
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
return AllTileEntities.ENCASED_FLUID_PIPE.create(); boolean blockTypeChanged = state.getBlock() != newState.getBlock();
if (blockTypeChanged && !world.isRemote)
FluidPropagator.propagateChangedPipe(world, pos, state);
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
world.removeTileEntity(pos);
} }
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) {
ISelectionContext p_220053_4_) { if (!world.isRemote && state != oldState)
return VoxelShapes.fullCube(); world.getPendingBlockTicks()
.scheduleTick(pos, this, 1, TickPriority.HIGH);
}
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
PlayerEntity player) {
return AllBlocks.FLUID_PIPE.asStack();
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos,
boolean isMoving) {
DebugPacketSender.func_218806_a(world, pos);
Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving);
if (d == null)
return;
if (!state.get(FACING_TO_PROPERTY_MAP.get(d)))
return;
world.getPendingBlockTicks()
.scheduleTick(pos, this, 1, TickPriority.HIGH);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) {
FluidPropagator.propagateChangedPipe(world, pos, state);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return AllTileEntities.ENCASED_FLUID_PIPE.create();
} }
@Override @Override
public ActionResultType onWrenched(BlockState state, ItemUseContext context) { public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
World world = context.getWorld(); World world = context.getWorld();
BlockPos pos = context.getPos(); BlockPos pos = context.getPos();
world.setBlockState(pos, toRegularPipe(world, pos, state), 3);
if (world.isRemote)
return ActionResultType.SUCCESS;
context.getWorld()
.playEvent(2001, context.getPos(), Block.getStateId(state));
BlockState equivalentPipe = transferSixWayProperties(state, AllBlocks.FLUID_PIPE.getDefaultState());
Direction firstFound = Direction.UP;
for (Direction d : Iterate.directions)
if (state.get(FACING_TO_PROPERTY_MAP.get(d))) {
firstFound = d;
break;
}
world.setBlockState(pos, AllBlocks.FLUID_PIPE.get()
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
public static BlockState transferSixWayProperties(BlockState from, BlockState to) {
for (Direction d : Iterate.directions) {
BooleanProperty property = FACING_TO_PROPERTY_MAP.get(d);
to = to.with(property, from.get(property));
}
return to;
}
} }

View file

@ -73,12 +73,9 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
BlockRayTraceResult hit) { BlockRayTraceResult hit) {
if (!AllBlocks.COPPER_CASING.isIn(player.getHeldItem(hand))) if (!AllBlocks.COPPER_CASING.isIn(player.getHeldItem(hand)))
return ActionResultType.PASS; return ActionResultType.PASS;
Axis axis = getAxis(world, pos, state);
if (axis == null)
return ActionResultType.PASS;
if (!world.isRemote) if (!world.isRemote)
world.setBlockState(pos, AllBlocks.ENCASED_FLUID_PIPE.getDefaultState() world.setBlockState(pos,
.with(EncasedPipeBlock.AXIS, axis)); EncasedPipeBlock.transferSixWayProperties(state, AllBlocks.ENCASED_FLUID_PIPE.getDefaultState()));
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
@ -149,7 +146,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
|| FluidPropagator.getStraightPipeAxis(neighbour) == blockFace.getAxis(); || FluidPropagator.getStraightPipeAxis(neighbour) == blockFace.getAxis();
if (attachmentBehaviour == null) if (attachmentBehaviour == null)
return false; return false;
return attachmentBehaviour.isPipeConnectedTowards(neighbour, blockFace); return attachmentBehaviour.isPipeConnectedTowards(neighbour, blockFace.getOpposite());
} }
public static boolean shouldDrawRim(ILightReader world, BlockPos pos, BlockState state, Direction direction) { public static boolean shouldDrawRim(ILightReader world, BlockPos pos, BlockState state, Direction direction) {

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.fluids.pipes;
import java.util.List; import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.fluids.FluidPipeAttachmentBehaviour; import com.simibubi.create.content.contraptions.fluids.FluidPipeAttachmentBehaviour;
import com.simibubi.create.content.contraptions.fluids.FluidPipeBehaviour; import com.simibubi.create.content.contraptions.fluids.FluidPipeBehaviour;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
@ -33,7 +34,8 @@ public class FluidPipeTileEntity extends SmartTileEntity {
@Override @Override
public boolean isConnectedTo(BlockState state, Direction direction) { public boolean isConnectedTo(BlockState state, Direction direction) {
return FluidPipeBlock.isPipe(state) && state.get(FluidPipeBlock.FACING_TO_PROPERTY_MAP.get(direction)); return (FluidPipeBlock.isPipe(state) || state.getBlock() instanceof EncasedPipeBlock)
&& state.get(FluidPipeBlock.FACING_TO_PROPERTY_MAP.get(direction));
} }
} }
@ -48,6 +50,9 @@ public class FluidPipeTileEntity extends SmartTileEntity {
public AttachmentTypes getAttachment(ILightReader world, BlockPos pos, BlockState state, Direction direction) { public AttachmentTypes getAttachment(ILightReader world, BlockPos pos, BlockState state, Direction direction) {
AttachmentTypes attachment = super.getAttachment(world, pos, state, direction); AttachmentTypes attachment = super.getAttachment(world, pos, state, direction);
if (attachment == AttachmentTypes.RIM && AllBlocks.ENCASED_FLUID_PIPE.has(state))
return AttachmentTypes.RIM;
BlockPos offsetPos = pos.offset(direction); BlockPos offsetPos = pos.offset(direction);
if (!FluidPipeBlock.isPipe(world.getBlockState(offsetPos))) { if (!FluidPipeBlock.isPipe(world.getBlockState(offsetPos))) {
FluidPipeAttachmentBehaviour attachmentBehaviour = FluidPipeAttachmentBehaviour attachmentBehaviour =

View file

@ -18,6 +18,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader; import net.minecraft.world.ILightReader;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap.Builder;
import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.client.model.data.ModelProperty;
public class FluidTankModel extends CTModel { public class FluidTankModel extends CTModel {
@ -37,12 +38,11 @@ public class FluidTankModel extends CTModel {
} }
@Override @Override
public IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) { protected Builder gatherModelData(Builder builder, ILightReader world, BlockPos pos, BlockState state) {
CullData cullData = new CullData(); CullData cullData = new CullData();
for (Direction d : Iterate.horizontalDirections) for (Direction d : Iterate.horizontalDirections)
cullData.setCulled(d, FluidTankConnectivityHandler.isConnected(world, pos, pos.offset(d))); cullData.setCulled(d, FluidTankConnectivityHandler.isConnected(world, pos, pos.offset(d)));
return getCTDataMapBuilder(world, pos, state).withInitial(CULL_PROPERTY, cullData) return super.gatherModelData(builder, world, pos, state).withInitial(CULL_PROPERTY, cullData);
.build();
} }
@Override @Override

View file

@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.base.CasingBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.entry.BlockEntry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -42,7 +43,7 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock {
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) {
if (context.getWorld().isRemote) if (context.getWorld().isRemote)
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
context.getWorld().playEvent(2001, context.getPos(), Block.getStateId(state));
KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), AllBlocks.SHAFT.getDefaultState().with(AXIS, state.get(AXIS))); KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), AllBlocks.SHAFT.getDefaultState().with(AXIS, state.get(AXIS)));
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }

View file

@ -0,0 +1,29 @@
package com.simibubi.create.foundation.block.connected;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader;
import net.minecraftforge.client.model.BakedModelWrapper;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelDataMap.Builder;
public abstract class BakedModelWrapperWithData extends BakedModelWrapper<IBakedModel> {
public BakedModelWrapperWithData(IBakedModel originalModel) {
super(originalModel);
}
@Override
public final IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) {
Builder builder = new ModelDataMap.Builder();
if (originalModel instanceof BakedModelWrapperWithData)
((BakedModelWrapperWithData) originalModel).gatherModelData(builder, world, pos, state);
return gatherModelData(builder, world, pos, state).build();
}
protected abstract ModelDataMap.Builder gatherModelData(ModelDataMap.Builder builder, ILightReader world,
BlockPos pos, BlockState state);
}

View file

@ -16,13 +16,11 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader; import net.minecraft.world.ILightReader;
import net.minecraftforge.client.model.BakedModelWrapper;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelDataMap.Builder; import net.minecraftforge.client.model.data.ModelDataMap.Builder;
import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.client.model.data.ModelProperty;
public class CTModel extends BakedModelWrapper<IBakedModel> { public class CTModel extends BakedModelWrapperWithData {
protected static ModelProperty<CTData> CT_PROPERTY = new ModelProperty<>(); protected static ModelProperty<CTData> CT_PROPERTY = new ModelProperty<>();
private ConnectedTextureBehaviour behaviour; private ConnectedTextureBehaviour behaviour;
@ -50,12 +48,8 @@ public class CTModel extends BakedModelWrapper<IBakedModel> {
} }
@Override @Override
public IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) { protected Builder gatherModelData(Builder builder, ILightReader world, BlockPos pos, BlockState state) {
return getCTDataMapBuilder(world, pos, state).build(); return builder.withInitial(CT_PROPERTY, createCTData(world, pos, state));
}
protected Builder getCTDataMapBuilder(ILightReader world, BlockPos pos, BlockState state) {
return new ModelDataMap.Builder().withInitial(CT_PROPERTY, createCTData(world, pos, state));
} }
protected CTData createCTData(ILightReader world, BlockPos pos, BlockState state) { protected CTData createCTData(ILightReader world, BlockPos pos, BlockState state) {

View file

@ -41,8 +41,19 @@ public class CustomBlockModels {
private void loadEntries() { private void loadEntries() {
customModels.clear(); customModels.clear();
registered.forEach(p -> customModels.put(p.getKey() registered.forEach(p -> {
.get(), p.getValue())); Block key = p.getKey()
.get();
NonNullFunction<IBakedModel, ? extends IBakedModel> existingModel = customModels.get(key);
if (existingModel != null) {
customModels.put(key, p.getValue()
.andThen(existingModel));
return;
}
customModels.put(key, p.getValue());
});
} }
} }

View file

@ -19,6 +19,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.cha
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType; 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.contraptions.fluids.pipes.EncasedPipeBlock;
import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock; import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.palettes.PavedBlock; import com.simibubi.create.content.palettes.PavedBlock;
@ -340,6 +341,26 @@ public class BlockStateGen {
}; };
} }
public static <P extends EncasedPipeBlock> NonNullBiConsumer<DataGenContext<Block, P>, RegistrateBlockstateProvider> encasedPipe() {
return (c, p) -> {
ModelFile open = AssetLookup.partialBaseModel(c, p, "open");
ModelFile flat = AssetLookup.partialBaseModel(c, p, "flat");
MultiPartBlockStateBuilder builder = p.getMultipartBuilder(c.get());
for (boolean flatPass : Iterate.trueAndFalse)
for (Direction d : Iterate.directions) {
int verticalAngle = d == Direction.UP ? 90 : d == Direction.DOWN ? -90 : 0;
builder.part()
.modelFile(flatPass ? flat : open)
.rotationX(verticalAngle)
.rotationY((int) (d.getHorizontalAngle() + (d.getAxis()
.isVertical() ? 90 : 0)) % 360)
.addModel()
.condition(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), !flatPass)
.end();
}
};
}
public static <P extends FluidPipeBlock> NonNullBiConsumer<DataGenContext<Block, P>, RegistrateBlockstateProvider> pipe() { public static <P extends FluidPipeBlock> NonNullBiConsumer<DataGenContext<Block, P>, RegistrateBlockstateProvider> pipe() {
return (c, p) -> { return (c, p) -> {
String path = "block/" + c.getName(); String path = "block/" + c.getName();

View file

@ -0,0 +1,16 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "create:block/copper_casing",
"particle": "create:block/copper_casing"
},
"elements": [
{
"from": [0, 0, 15],
"to": [16, 16, 16],
"faces": {
"south": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,16 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "create:block/encased_pipe",
"particle": "create:block/encased_pipe"
},
"elements": [
{
"from": [0, 0, 15],
"to": [16, 16, 16],
"faces": {
"south": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]
}