mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 04:00:30 +00:00
Use vector helpers to convert BlockPos to Vector3d
A little shorter and more explicit than constructing the Vector3d manually. Fixes an issue where sounds were centered on the bottom left of speakers, not the middle (see cc-tweaked/cc-restitched#85).
This commit is contained in:
parent
e865d96f7b
commit
daf81b897a
@ -97,7 +97,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
return new CommandSource( receiver,
|
||||
new Vector3d( worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5 ), Vector2f.ZERO,
|
||||
Vector3d.atCenterOf( worldPosition ), Vector2f.ZERO,
|
||||
(ServerWorld) getLevel(), 2,
|
||||
name, new StringTextComponent( name ),
|
||||
getLevel().getServer(), null
|
||||
|
@ -60,8 +60,7 @@ public class TileCable extends TileGeneric
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos();
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return Vector3d.atCenterOf( getBlockPos() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,8 +105,7 @@ public class TileCable extends TileGeneric
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos().relative( modemDirection );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return Vector3d.atCenterOf( getBlockPos().relative( modemDirection ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -87,8 +87,7 @@ public class TileWiredModemFull extends TileGeneric
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = entity.getBlockPos();
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return Vector3d.atCenterOf( entity.getBlockPos() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,8 +417,7 @@ public class TileWiredModemFull extends TileGeneric
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos().relative( side );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return Vector3d.atCenterOf( getBlockPos().relative( side ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -14,7 +14,6 @@ import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@ -48,8 +47,7 @@ public class TileWirelessModem extends TileGeneric
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = entity.getBlockPos().relative( entity.modemDirection );
|
||||
return new Vector3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
return Vector3d.atLowerCornerOf( entity.getBlockPos().relative( entity.modemDirection ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,6 @@ import dan200.computercraft.shared.util.CapabilityUtil;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@ -90,8 +89,7 @@ public class TileSpeaker extends TileGeneric implements ITickableTileEntity
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = speaker.getBlockPos();
|
||||
return new Vector3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
return Vector3d.atCenterOf( speaker.getBlockPos() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,6 @@ import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@ -47,8 +46,7 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
@Override
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = turtle.getPosition();
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return Vector3d.atCenterOf( turtle.getPosition() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user