Skip to content

Commit

Permalink
make hit detection rotate on correct axis, fix issues with inred block
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Jan 10, 2019
1 parent 639739b commit 20c7e6d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntit
blockCenteredHit = blockCenteredHit.subtract(0.5, 0.5, 0.5);
switch (state.get(AndGateBlock.FACING)) {
case SOUTH:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI);
break;
case EAST:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI/2);
break;
case WEST:
blockCenteredHit = blockCenteredHit.rotateX(3*(float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY(3*(float)Math.PI/2);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@ public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntit
blockCenteredHit = blockCenteredHit.subtract(0.5, 0.5, 0.5);
switch (state.get(DiodeBlock.FACING)) {
case SOUTH:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI);
break;
case EAST:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI/2);
break;
case WEST:
blockCenteredHit = blockCenteredHit.rotateX(3*(float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY(3*(float)Math.PI/2);
break;
default:
break;
}
blockCenteredHit = blockCenteredHit.add(0.5, 0.5, 0.5);
System.out.println(blockCenteredHit);
DiodeBlockEntity beDiode = (DiodeBlockEntity)be;
if (CLICK_BIT_0.getBoundingBox().contains(blockCenteredHit)) {
beDiode.setMask(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.block.BlockRenderLayer;
import net.minecraft.entity.VerticalEntityPosition;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.ViewableWorld;

Expand All @@ -25,4 +29,19 @@ public BlockEntity createBlockEntity(BlockView world) {
public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) {
return true;
}

@Override
public boolean isSimpleFullBlock(BlockState blockState, BlockView blockView, BlockPos blockPos) {
return true;
}

@Override
public VoxelShape getCollisionShape(BlockState blockState, BlockView blockView, BlockPos blockPos, VerticalEntityPosition verticalEntityPosition) {
return VoxelShapes.fullCube();
}

@Override
public VoxelShape getBoundingShape(BlockState state, BlockView view, BlockPos pos) {
return VoxelShapes.fullCube();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntit
blockCenteredHit = blockCenteredHit.subtract(0.5, 0.5, 0.5);
switch (state.get(NotGateBlock.FACING)) {
case SOUTH:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI);
break;
case EAST:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI/2);
break;
case WEST:
blockCenteredHit = blockCenteredHit.rotateX(3*(float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY(3*(float)Math.PI/2);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntit
blockCenteredHit = blockCenteredHit.subtract(0.5, 0.5, 0.5);
switch (state.get(XorGateBlock.FACING)) {
case SOUTH:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI);
break;
case EAST:
blockCenteredHit = blockCenteredHit.rotateX((float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY((float)Math.PI/2);
break;
case WEST:
blockCenteredHit = blockCenteredHit.rotateX(3*(float)Math.PI/2);
blockCenteredHit = blockCenteredHit.rotateY(3*(float)Math.PI/2);
break;
default:
break;
Expand Down

0 comments on commit 20c7e6d

Please sign in to comment.