Skip to content

Commit

Permalink
Add Carpet Support Check
Browse files Browse the repository at this point in the history
because carpet extra does not do anything to other facing blocks
  • Loading branch information
aria1th authored Aug 17, 2021
1 parent 73c4c90 commit f3f09ed
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.FurnaceBlock;
import net.minecraft.block.FluidBlock;
import net.minecraft.block.GlazedTerracottaBlock;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.LadderBlock;
import net.minecraft.block.LecternBlock;
Expand Down Expand Up @@ -764,7 +765,7 @@ else if (sBlock instanceof ObserverBlock || sBlock instanceof PistonBlock) {
Vec3d hitPos = new Vec3d(offX, offY, offZ);
// Carpet Accurate Placement protocol support, plus BlockSlab support
hitPos = applyHitVec(npos, stateSchematic, hitPos, side);
if(CanUseProtocol) {hitPos = applyCarpetProtocolHitVec(npos,stateSchematic,hitPos);} else {hitPos = applyHitVec(npos, stateSchematic, hitPos, side);}
if(CanUseProtocol && IsBlockSupportedCarpet(stateSchematic.getBlock())) {hitPos = applyCarpetProtocolHitVec(npos,stateSchematic,hitPos);} else {hitPos = applyHitVec(npos, stateSchematic, hitPos, side);}

// Mark that this position has been handled (use the non-offset position that is
// checked above)
Expand Down Expand Up @@ -1022,6 +1023,13 @@ public static Vec3d applyHitVec(BlockPos pos, BlockState state, Vec3d hitVecIn,
* Gets the direction necessary to build the block oriented correctly. TODO:
* Need a better way to do this.
*/
private static Boolean IsBlockSupportedCarpet(Block SchematicBlock){
if (SchematicBlock instanceof GlazedTerracottaBlock || SchematicBlock instanceof ObserverBlock || SchematicBlock instanceof RepeaterBlock || SchematicBlock instanceof TrapdoorBlock ||
SchematicBlock instanceof ComparatorBlock || SchematicBlock instanceof DispenserBlock || SchematicBlock instanceof PistonBlock || SchematicBlock instanceof StairsBlock)
{return true;}
return false;

}
private static Direction applyPlacementFacing(BlockState stateSchematic, Direction side, BlockState stateClient) {
Block blockSchematic = stateSchematic.getBlock();
Block blockClient = stateClient.getBlock();
Expand Down

0 comments on commit f3f09ed

Please sign in to comment.