Block Placer placement context issue fix. Fixed compatibility to Forge >=37.0.82. Update lang ru_ru (PR#191, Smollet777).
This commit is contained in:
parent
80abccc6cc
commit
8a26de7c2b
11 changed files with 58 additions and 47 deletions
|
@ -90,7 +90,6 @@ public class ModContent
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// Blocks
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -461,14 +461,11 @@ public class EdPlacer
|
|||
if(((BlockItem)item).place(use_context) != InteractionResult.FAIL) {
|
||||
SoundType stype = block.getSoundType(placement_state, level, worldPosition, null);
|
||||
if(stype != null) level.playSound(null, placement_pos, stype.getPlaceSound(), SoundSource.BLOCKS, stype.getVolume()*0.6f, stype.getPitch());
|
||||
} else if(block instanceof IPlantable) {
|
||||
} else {
|
||||
if(level.setBlock(placement_pos, placement_state, 1|2|8)) {
|
||||
SoundType stype = block.getSoundType(placement_state, level, worldPosition, null);
|
||||
if(stype != null) level.playSound(null, placement_pos, stype.getPlaceSound(), SoundSource.BLOCKS, stype.getVolume()*0.6f, stype.getPitch());
|
||||
}
|
||||
} else {
|
||||
Auxiliaries.logDebug("Placer spit: try-place and planting failed for item " + item.getRegistryName().toString());
|
||||
return spit_out(facing);
|
||||
}
|
||||
} else {
|
||||
if(level.setBlock(placement_pos, placement_state, 1|2|8)) {
|
||||
|
@ -484,7 +481,11 @@ public class EdPlacer
|
|||
// A hard crash should not be fired here, instead spit out the item to indicated that this
|
||||
// block is not compatible.
|
||||
ModEngineersDecor.logger().error("Exception while trying to place " + ((block==null)?(""):(""+block)) + ", spitting out. Exception is: " + e);
|
||||
level.removeBlock(placement_pos, false);
|
||||
try {
|
||||
level.removeBlock(placement_pos, false);
|
||||
} catch(Throwable e1) {
|
||||
ModEngineersDecor.logger().error("Exception while removing failed block placement " + ((block==null)?(""):(""+block)) + ", spitting out. Exception is: " + e1);
|
||||
}
|
||||
return spit_out(facing, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* @file BlockDecorHalfSlab.java
|
||||
* @file SlabSliceBlock.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2020 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Half slab ("slab slices") characteristics class. Actually
|
||||
* it's now a quater slab, but who cares.
|
||||
* it's now a quarter slab, but who cares.
|
||||
*/
|
||||
package wile.engineersdecor.libmc.blocks;
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ public class StandardBlocks
|
|||
protected final Map<BlockState, VoxelShape> shapes;
|
||||
protected final Map<BlockState, VoxelShape> collision_shapes;
|
||||
|
||||
public HorizontalFourWayWaterLoggable(long config, BlockBehaviour.Properties properties, AABB base_aabb, final AABB side_aabb, int railing_height_extension)
|
||||
public HorizontalFourWayWaterLoggable(long config, BlockBehaviour.Properties properties, AABB base_aabb, final AABB side_aabb[], int railing_height_extension)
|
||||
{
|
||||
super(config, properties, base_aabb);
|
||||
Map<BlockState, VoxelShape> build_shapes = new HashMap<>();
|
||||
|
@ -473,10 +473,10 @@ public class StandardBlocks
|
|||
for(BlockState state:getStateDefinition().getPossibleStates()) {
|
||||
{
|
||||
VoxelShape shape = ((base_aabb.getXsize()==0) || (base_aabb.getYsize()==0) || (base_aabb.getZsize()==0)) ? Shapes.empty() : Shapes.create(base_aabb);
|
||||
if(state.getValue(NORTH)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.NORTH, true)), BooleanOp.OR);
|
||||
if(state.getValue(EAST)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.EAST, true)), BooleanOp.OR);
|
||||
if(state.getValue(SOUTH)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.SOUTH, true)), BooleanOp.OR);
|
||||
if(state.getValue(WEST)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.WEST, true)), BooleanOp.OR);
|
||||
if(state.getValue(NORTH)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(side_aabb, Direction.NORTH, true)), BooleanOp.OR);
|
||||
if(state.getValue(EAST)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(side_aabb, Direction.EAST, true)), BooleanOp.OR);
|
||||
if(state.getValue(SOUTH)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(side_aabb, Direction.SOUTH, true)), BooleanOp.OR);
|
||||
if(state.getValue(WEST)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(side_aabb, Direction.WEST, true)), BooleanOp.OR);
|
||||
if(shape.isEmpty()) shape = Shapes.block();
|
||||
build_shapes.put(state.setValue(WATERLOGGED, false), shape);
|
||||
build_shapes.put(state.setValue(WATERLOGGED, true), shape);
|
||||
|
@ -484,10 +484,14 @@ public class StandardBlocks
|
|||
{
|
||||
// how the hack to extend a shape, these are the above with y+4px.
|
||||
VoxelShape shape = ((base_aabb.getXsize()==0) || (base_aabb.getYsize()==0) || (base_aabb.getZsize()==0)) ? Shapes.empty() : Shapes.create(base_aabb);
|
||||
if(state.getValue(NORTH)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.NORTH, true).expandTowards(0, railing_height_extension, 0)), BooleanOp.OR);
|
||||
if(state.getValue(EAST)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.EAST, true).expandTowards(0, railing_height_extension, 0)), BooleanOp.OR);
|
||||
if(state.getValue(SOUTH)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.SOUTH, true).expandTowards(0, railing_height_extension, 0)), BooleanOp.OR);
|
||||
if(state.getValue(WEST)) shape = Shapes.joinUnoptimized(shape,Shapes.create(Auxiliaries.getRotatedAABB(side_aabb, Direction.WEST, true).expandTowards(0, railing_height_extension, 0)), BooleanOp.OR);
|
||||
if(state.getValue(NORTH)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getMappedAABB(Auxiliaries.getRotatedAABB(side_aabb,
|
||||
Direction.NORTH, true), bb->bb.expandTowards(0, railing_height_extension, 0))), BooleanOp.OR);
|
||||
if(state.getValue(EAST)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getMappedAABB(Auxiliaries.getRotatedAABB(side_aabb,
|
||||
Direction.EAST, true), bb->bb.expandTowards(0, railing_height_extension, 0))), BooleanOp.OR);
|
||||
if(state.getValue(SOUTH)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getMappedAABB(Auxiliaries.getRotatedAABB(side_aabb,
|
||||
Direction.SOUTH, true), bb->bb.expandTowards(0, railing_height_extension, 0))), BooleanOp.OR);
|
||||
if(state.getValue(WEST)) shape = Shapes.joinUnoptimized(shape,Auxiliaries.getUnionShape(Auxiliaries.getMappedAABB(Auxiliaries.getRotatedAABB(side_aabb,
|
||||
Direction.WEST, true), bb->bb.expandTowards(0, railing_height_extension, 0))), BooleanOp.OR);
|
||||
if(shape.isEmpty()) shape = Shapes.block();
|
||||
build_collision_shapes.put(state.setValue(WATERLOGGED, false), shape);
|
||||
build_collision_shapes.put(state.setValue(WATERLOGGED, true), shape);
|
||||
|
@ -498,6 +502,9 @@ public class StandardBlocks
|
|||
registerDefaultState(super.defaultBlockState().setValue(NORTH, false).setValue(EAST, false).setValue(SOUTH, false).setValue(WEST, false).setValue(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
public HorizontalFourWayWaterLoggable(long config, BlockBehaviour.Properties properties, AABB base_aabb, final AABB side_aabb, int railing_height_extension)
|
||||
{ this(config, properties, base_aabb, new AABB[]{side_aabb}, railing_height_extension); }
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder)
|
||||
{ super.createBlockStateDefinition(builder); builder.add(NORTH,EAST,SOUTH,WEST); }
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -373,6 +374,12 @@ public class Auxiliaries
|
|||
return shape;
|
||||
}
|
||||
|
||||
public static final AABB[] getMappedAABB(AABB[] bbs, Function<AABB,AABB> mapper) {
|
||||
final AABB[] transformed = new AABB[bbs.length];
|
||||
for(int i=0; i<bbs.length; ++i) transformed[i] = mapper.apply(bbs[i]);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static final class BlockPosRange implements Iterable<BlockPos>
|
||||
{
|
||||
private final int x0, x1, y0, y1, z0, z1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue